Debian Codegraph @

semconv/v1.40.0/otelconv/metric.go

raw
1 // Code generated from semantic convention specification. DO NOT EDIT.
2
3 // Copyright The OpenTelemetry Authors
4 // SPDX-License-Identifier: Apache-2.0
5
6 // Package otelconv provides types and functionality for OpenTelemetry semantic
7 // conventions in the "otel" namespace.
8 package otelconv
9
10 import (
11 "context"
12 "sync"
13
14 "go.opentelemetry.io/otel/attribute"
15 "go.opentelemetry.io/otel/metric"
16 "go.opentelemetry.io/otel/metric/noop"
17 )
18
19 var (
20 addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
21 recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
22 )
23
24 // ErrorTypeAttr is an attribute conforming to the error.type semantic
25 // conventions. It represents the describes a class of error the operation ended
26 // with.
27 type ErrorTypeAttr string
28
29 var (
30 // ErrorTypeOther is a fallback error value to be used when the instrumentation
31 // doesn't define a custom value.
32 ErrorTypeOther ErrorTypeAttr = "_OTHER"
33 )
34
35 // ComponentTypeAttr is an attribute conforming to the otel.component.type
36 // semantic conventions. It represents a name identifying the type of the
37 // OpenTelemetry component.
38 type ComponentTypeAttr string
39
40 var (
41 // ComponentTypeBatchingSpanProcessor is the builtin SDK batching span
42 // processor.
43 ComponentTypeBatchingSpanProcessor ComponentTypeAttr = "batching_span_processor"
44 // ComponentTypeSimpleSpanProcessor is the builtin SDK simple span processor.
45 ComponentTypeSimpleSpanProcessor ComponentTypeAttr = "simple_span_processor"
46 // ComponentTypeBatchingLogProcessor is the builtin SDK batching log record
47 // processor.
48 ComponentTypeBatchingLogProcessor ComponentTypeAttr = "batching_log_processor"
49 // ComponentTypeSimpleLogProcessor is the builtin SDK simple log record
50 // processor.
51 ComponentTypeSimpleLogProcessor ComponentTypeAttr = "simple_log_processor"
52 // ComponentTypeOtlpGRPCSpanExporter is the OTLP span exporter over gRPC with
53 // protobuf serialization.
54 ComponentTypeOtlpGRPCSpanExporter ComponentTypeAttr = "otlp_grpc_span_exporter"
55 // ComponentTypeOtlpHTTPSpanExporter is the OTLP span exporter over HTTP with
56 // protobuf serialization.
57 ComponentTypeOtlpHTTPSpanExporter ComponentTypeAttr = "otlp_http_span_exporter"
58 // ComponentTypeOtlpHTTPJSONSpanExporter is the OTLP span exporter over HTTP
59 // with JSON serialization.
60 ComponentTypeOtlpHTTPJSONSpanExporter ComponentTypeAttr = "otlp_http_json_span_exporter"
61 // ComponentTypeZipkinHTTPSpanExporter is the zipkin span exporter over HTTP.
62 ComponentTypeZipkinHTTPSpanExporter ComponentTypeAttr = "zipkin_http_span_exporter"
63 // ComponentTypeOtlpGRPCLogExporter is the OTLP log record exporter over gRPC
64 // with protobuf serialization.
65 ComponentTypeOtlpGRPCLogExporter ComponentTypeAttr = "otlp_grpc_log_exporter"
66 // ComponentTypeOtlpHTTPLogExporter is the OTLP log record exporter over HTTP
67 // with protobuf serialization.
68 ComponentTypeOtlpHTTPLogExporter ComponentTypeAttr = "otlp_http_log_exporter"
69 // ComponentTypeOtlpHTTPJSONLogExporter is the OTLP log record exporter over
70 // HTTP with JSON serialization.
71 ComponentTypeOtlpHTTPJSONLogExporter ComponentTypeAttr = "otlp_http_json_log_exporter"
72 // ComponentTypePeriodicMetricReader is the builtin SDK periodically exporting
73 // metric reader.
74 ComponentTypePeriodicMetricReader ComponentTypeAttr = "periodic_metric_reader"
75 // ComponentTypeOtlpGRPCMetricExporter is the OTLP metric exporter over gRPC
76 // with protobuf serialization.
77 ComponentTypeOtlpGRPCMetricExporter ComponentTypeAttr = "otlp_grpc_metric_exporter"
78 // ComponentTypeOtlpHTTPMetricExporter is the OTLP metric exporter over HTTP
79 // with protobuf serialization.
80 ComponentTypeOtlpHTTPMetricExporter ComponentTypeAttr = "otlp_http_metric_exporter"
81 // ComponentTypeOtlpHTTPJSONMetricExporter is the OTLP metric exporter over HTTP
82 // with JSON serialization.
83 ComponentTypeOtlpHTTPJSONMetricExporter ComponentTypeAttr = "otlp_http_json_metric_exporter"
84 // ComponentTypePrometheusHTTPTextMetricExporter is the prometheus metric
85 // exporter over HTTP with the default text-based format.
86 ComponentTypePrometheusHTTPTextMetricExporter ComponentTypeAttr = "prometheus_http_text_metric_exporter"
87 )
88
89 // SpanParentOriginAttr is an attribute conforming to the otel.span.parent.origin
90 // semantic conventions. It represents the determines whether the span has a
91 // parent span, and if so, [whether it is a remote parent].
92 //
93 // [whether it is a remote parent]: https://opentelemetry.io/docs/specs/otel/trace/api/#isremote
94 type SpanParentOriginAttr string
95
96 var (
97 // SpanParentOriginNone is the span does not have a parent, it is a root span.
98 SpanParentOriginNone SpanParentOriginAttr = "none"
99 // SpanParentOriginLocal is the span has a parent and the parent's span context
100 // [isRemote()] is false.
101 //
102 // [isRemote()]: https://opentelemetry.io/docs/specs/otel/trace/api/#isremote
103 SpanParentOriginLocal SpanParentOriginAttr = "local"
104 // SpanParentOriginRemote is the span has a parent and the parent's span context
105 // [isRemote()] is true.
106 //
107 // [isRemote()]: https://opentelemetry.io/docs/specs/otel/trace/api/#isremote
108 SpanParentOriginRemote SpanParentOriginAttr = "remote"
109 )
110
111 // SpanSamplingResultAttr is an attribute conforming to the
112 // otel.span.sampling_result semantic conventions. It represents the result value
113 // of the sampler for this span.
114 type SpanSamplingResultAttr string
115
116 var (
117 // SpanSamplingResultDrop is the span is not sampled and not recording.
118 SpanSamplingResultDrop SpanSamplingResultAttr = "DROP"
119 // SpanSamplingResultRecordOnly is the span is not sampled, but recording.
120 SpanSamplingResultRecordOnly SpanSamplingResultAttr = "RECORD_ONLY"
121 // SpanSamplingResultRecordAndSample is the span is sampled and recording.
122 SpanSamplingResultRecordAndSample SpanSamplingResultAttr = "RECORD_AND_SAMPLE"
123 )
124
125 // SDKExporterLogExported is an instrument used to record metric values
126 // conforming to the "otel.sdk.exporter.log.exported" semantic conventions. It
127 // represents the number of log records for which the export has finished, either
128 // successful or failed.
129 type SDKExporterLogExported struct {
130 metric.Int64Counter
131 }
132
133 var newSDKExporterLogExportedOpts = []metric.Int64CounterOption{
134 metric.WithDescription("The number of log records for which the export has finished, either successful or failed."),
135 metric.WithUnit("{log_record}"),
136 }
137
138 // NewSDKExporterLogExported returns a new SDKExporterLogExported instrument.
139 func NewSDKExporterLogExported(
140 m metric.Meter,
141 opt ...metric.Int64CounterOption,
142 ) (SDKExporterLogExported, error) {
143 // Check if the meter is nil.
144 if m == nil {
145 return SDKExporterLogExported{noop.Int64Counter{}}, nil
146 }
147
148 if len(opt) == 0 {
149 opt = newSDKExporterLogExportedOpts
150 } else {
151 opt = append(opt, newSDKExporterLogExportedOpts...)
152 }
153
154 i, err := m.Int64Counter(
155 "otel.sdk.exporter.log.exported",
156 opt...,
157 )
158 if err != nil {
159 return SDKExporterLogExported{noop.Int64Counter{}}, err
160 }
161 return SDKExporterLogExported{i}, nil
162 }
163
164 // Inst returns the underlying metric instrument.
165 func (m SDKExporterLogExported) Inst() metric.Int64Counter {
166 return m.Int64Counter
167 }
168
169 // Name returns the semantic convention name of the instrument.
170 func (SDKExporterLogExported) Name() string {
171 return "otel.sdk.exporter.log.exported"
172 }
173
174 // Unit returns the semantic convention unit of the instrument
175 func (SDKExporterLogExported) Unit() string {
176 return "{log_record}"
177 }
178
179 // Description returns the semantic convention description of the instrument
180 func (SDKExporterLogExported) Description() string {
181 return "The number of log records for which the export has finished, either successful or failed."
182 }
183
184 // Add adds incr to the existing count for attrs.
185 //
186 // All additional attrs passed are included in the recorded value.
187 //
188 // For successful exports, `error.type` MUST NOT be set. For failed exports,
189 // `error.type` MUST contain the failure cause.
190 // For exporters with partial success semantics (e.g. OTLP with
191 // `rejected_log_records`), rejected log records MUST count as failed and only
192 // non-rejected log records count as success.
193 // If no rejection reason is available, `rejected` SHOULD be used as value for
194 // `error.type`.
195 func (m SDKExporterLogExported) Add(
196 ctx context.Context,
197 incr int64,
198 attrs ...attribute.KeyValue,
199 ) {
200 if len(attrs) == 0 {
201 m.Int64Counter.Add(ctx, incr)
202 return
203 }
204
205 o := addOptPool.Get().(*[]metric.AddOption)
206 defer func() {
207 *o = (*o)[:0]
208 addOptPool.Put(o)
209 }()
210
211 *o = append(
212 *o,
213 metric.WithAttributes(
214 attrs...,
215 ),
216 )
217
218 m.Int64Counter.Add(ctx, incr, *o...)
219 }
220
221 // AddSet adds incr to the existing count for set.
222 //
223 // For successful exports, `error.type` MUST NOT be set. For failed exports,
224 // `error.type` MUST contain the failure cause.
225 // For exporters with partial success semantics (e.g. OTLP with
226 // `rejected_log_records`), rejected log records MUST count as failed and only
227 // non-rejected log records count as success.
228 // If no rejection reason is available, `rejected` SHOULD be used as value for
229 // `error.type`.
230 func (m SDKExporterLogExported) AddSet(ctx context.Context, incr int64, set attribute.Set) {
231 if set.Len() == 0 {
232 m.Int64Counter.Add(ctx, incr)
233 return
234 }
235
236 o := addOptPool.Get().(*[]metric.AddOption)
237 defer func() {
238 *o = (*o)[:0]
239 addOptPool.Put(o)
240 }()
241
242 *o = append(*o, metric.WithAttributeSet(set))
243 m.Int64Counter.Add(ctx, incr, *o...)
244 }
245
246 // AttrErrorType returns an optional attribute for the "error.type" semantic
247 // convention. It represents the describes a class of error the operation ended
248 // with.
249 func (SDKExporterLogExported) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
250 return attribute.String("error.type", string(val))
251 }
252
253 // AttrComponentName returns an optional attribute for the "otel.component.name"
254 // semantic convention. It represents a name uniquely identifying the instance of
255 // the OpenTelemetry component within its containing SDK instance.
256 func (SDKExporterLogExported) AttrComponentName(val string) attribute.KeyValue {
257 return attribute.String("otel.component.name", val)
258 }
259
260 // AttrComponentType returns an optional attribute for the "otel.component.type"
261 // semantic convention. It represents a name identifying the type of the
262 // OpenTelemetry component.
263 func (SDKExporterLogExported) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
264 return attribute.String("otel.component.type", string(val))
265 }
266
267 // AttrServerAddress returns an optional attribute for the "server.address"
268 // semantic convention. It represents the server domain name if available without
269 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
270 func (SDKExporterLogExported) AttrServerAddress(val string) attribute.KeyValue {
271 return attribute.String("server.address", val)
272 }
273
274 // AttrServerPort returns an optional attribute for the "server.port" semantic
275 // convention. It represents the server port number.
276 func (SDKExporterLogExported) AttrServerPort(val int) attribute.KeyValue {
277 return attribute.Int("server.port", val)
278 }
279
280 // SDKExporterLogInflight is an instrument used to record metric values
281 // conforming to the "otel.sdk.exporter.log.inflight" semantic conventions. It
282 // represents the number of log records which were passed to the exporter, but
283 // that have not been exported yet (neither successful, nor failed).
284 type SDKExporterLogInflight struct {
285 metric.Int64UpDownCounter
286 }
287
288 var newSDKExporterLogInflightOpts = []metric.Int64UpDownCounterOption{
289 metric.WithDescription("The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)."),
290 metric.WithUnit("{log_record}"),
291 }
292
293 // NewSDKExporterLogInflight returns a new SDKExporterLogInflight instrument.
294 func NewSDKExporterLogInflight(
295 m metric.Meter,
296 opt ...metric.Int64UpDownCounterOption,
297 ) (SDKExporterLogInflight, error) {
298 // Check if the meter is nil.
299 if m == nil {
300 return SDKExporterLogInflight{noop.Int64UpDownCounter{}}, nil
301 }
302
303 if len(opt) == 0 {
304 opt = newSDKExporterLogInflightOpts
305 } else {
306 opt = append(opt, newSDKExporterLogInflightOpts...)
307 }
308
309 i, err := m.Int64UpDownCounter(
310 "otel.sdk.exporter.log.inflight",
311 opt...,
312 )
313 if err != nil {
314 return SDKExporterLogInflight{noop.Int64UpDownCounter{}}, err
315 }
316 return SDKExporterLogInflight{i}, nil
317 }
318
319 // Inst returns the underlying metric instrument.
320 func (m SDKExporterLogInflight) Inst() metric.Int64UpDownCounter {
321 return m.Int64UpDownCounter
322 }
323
324 // Name returns the semantic convention name of the instrument.
325 func (SDKExporterLogInflight) Name() string {
326 return "otel.sdk.exporter.log.inflight"
327 }
328
329 // Unit returns the semantic convention unit of the instrument
330 func (SDKExporterLogInflight) Unit() string {
331 return "{log_record}"
332 }
333
334 // Description returns the semantic convention description of the instrument
335 func (SDKExporterLogInflight) Description() string {
336 return "The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)."
337 }
338
339 // Add adds incr to the existing count for attrs.
340 //
341 // All additional attrs passed are included in the recorded value.
342 //
343 // For successful exports, `error.type` MUST NOT be set. For failed exports,
344 // `error.type` MUST contain the failure cause.
345 func (m SDKExporterLogInflight) Add(
346 ctx context.Context,
347 incr int64,
348 attrs ...attribute.KeyValue,
349 ) {
350 if len(attrs) == 0 {
351 m.Int64UpDownCounter.Add(ctx, incr)
352 return
353 }
354
355 o := addOptPool.Get().(*[]metric.AddOption)
356 defer func() {
357 *o = (*o)[:0]
358 addOptPool.Put(o)
359 }()
360
361 *o = append(
362 *o,
363 metric.WithAttributes(
364 attrs...,
365 ),
366 )
367
368 m.Int64UpDownCounter.Add(ctx, incr, *o...)
369 }
370
371 // AddSet adds incr to the existing count for set.
372 //
373 // For successful exports, `error.type` MUST NOT be set. For failed exports,
374 // `error.type` MUST contain the failure cause.
375 func (m SDKExporterLogInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) {
376 if set.Len() == 0 {
377 m.Int64UpDownCounter.Add(ctx, incr)
378 return
379 }
380
381 o := addOptPool.Get().(*[]metric.AddOption)
382 defer func() {
383 *o = (*o)[:0]
384 addOptPool.Put(o)
385 }()
386
387 *o = append(*o, metric.WithAttributeSet(set))
388 m.Int64UpDownCounter.Add(ctx, incr, *o...)
389 }
390
391 // AttrComponentName returns an optional attribute for the "otel.component.name"
392 // semantic convention. It represents a name uniquely identifying the instance of
393 // the OpenTelemetry component within its containing SDK instance.
394 func (SDKExporterLogInflight) AttrComponentName(val string) attribute.KeyValue {
395 return attribute.String("otel.component.name", val)
396 }
397
398 // AttrComponentType returns an optional attribute for the "otel.component.type"
399 // semantic convention. It represents a name identifying the type of the
400 // OpenTelemetry component.
401 func (SDKExporterLogInflight) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
402 return attribute.String("otel.component.type", string(val))
403 }
404
405 // AttrServerAddress returns an optional attribute for the "server.address"
406 // semantic convention. It represents the server domain name if available without
407 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
408 func (SDKExporterLogInflight) AttrServerAddress(val string) attribute.KeyValue {
409 return attribute.String("server.address", val)
410 }
411
412 // AttrServerPort returns an optional attribute for the "server.port" semantic
413 // convention. It represents the server port number.
414 func (SDKExporterLogInflight) AttrServerPort(val int) attribute.KeyValue {
415 return attribute.Int("server.port", val)
416 }
417
418 // SDKExporterMetricDataPointExported is an instrument used to record metric
419 // values conforming to the "otel.sdk.exporter.metric_data_point.exported"
420 // semantic conventions. It represents the number of metric data points for which
421 // the export has finished, either successful or failed.
422 type SDKExporterMetricDataPointExported struct {
423 metric.Int64Counter
424 }
425
426 var newSDKExporterMetricDataPointExportedOpts = []metric.Int64CounterOption{
427 metric.WithDescription("The number of metric data points for which the export has finished, either successful or failed."),
428 metric.WithUnit("{data_point}"),
429 }
430
431 // NewSDKExporterMetricDataPointExported returns a new
432 // SDKExporterMetricDataPointExported instrument.
433 func NewSDKExporterMetricDataPointExported(
434 m metric.Meter,
435 opt ...metric.Int64CounterOption,
436 ) (SDKExporterMetricDataPointExported, error) {
437 // Check if the meter is nil.
438 if m == nil {
439 return SDKExporterMetricDataPointExported{noop.Int64Counter{}}, nil
440 }
441
442 if len(opt) == 0 {
443 opt = newSDKExporterMetricDataPointExportedOpts
444 } else {
445 opt = append(opt, newSDKExporterMetricDataPointExportedOpts...)
446 }
447
448 i, err := m.Int64Counter(
449 "otel.sdk.exporter.metric_data_point.exported",
450 opt...,
451 )
452 if err != nil {
453 return SDKExporterMetricDataPointExported{noop.Int64Counter{}}, err
454 }
455 return SDKExporterMetricDataPointExported{i}, nil
456 }
457
458 // Inst returns the underlying metric instrument.
459 func (m SDKExporterMetricDataPointExported) Inst() metric.Int64Counter {
460 return m.Int64Counter
461 }
462
463 // Name returns the semantic convention name of the instrument.
464 func (SDKExporterMetricDataPointExported) Name() string {
465 return "otel.sdk.exporter.metric_data_point.exported"
466 }
467
468 // Unit returns the semantic convention unit of the instrument
469 func (SDKExporterMetricDataPointExported) Unit() string {
470 return "{data_point}"
471 }
472
473 // Description returns the semantic convention description of the instrument
474 func (SDKExporterMetricDataPointExported) Description() string {
475 return "The number of metric data points for which the export has finished, either successful or failed."
476 }
477
478 // Add adds incr to the existing count for attrs.
479 //
480 // All additional attrs passed are included in the recorded value.
481 //
482 // For successful exports, `error.type` MUST NOT be set. For failed exports,
483 // `error.type` MUST contain the failure cause.
484 // For exporters with partial success semantics (e.g. OTLP with
485 // `rejected_data_points`), rejected data points MUST count as failed and only
486 // non-rejected data points count as success.
487 // If no rejection reason is available, `rejected` SHOULD be used as value for
488 // `error.type`.
489 func (m SDKExporterMetricDataPointExported) Add(
490 ctx context.Context,
491 incr int64,
492 attrs ...attribute.KeyValue,
493 ) {
494 if len(attrs) == 0 {
495 m.Int64Counter.Add(ctx, incr)
496 return
497 }
498
499 o := addOptPool.Get().(*[]metric.AddOption)
500 defer func() {
501 *o = (*o)[:0]
502 addOptPool.Put(o)
503 }()
504
505 *o = append(
506 *o,
507 metric.WithAttributes(
508 attrs...,
509 ),
510 )
511
512 m.Int64Counter.Add(ctx, incr, *o...)
513 }
514
515 // AddSet adds incr to the existing count for set.
516 //
517 // For successful exports, `error.type` MUST NOT be set. For failed exports,
518 // `error.type` MUST contain the failure cause.
519 // For exporters with partial success semantics (e.g. OTLP with
520 // `rejected_data_points`), rejected data points MUST count as failed and only
521 // non-rejected data points count as success.
522 // If no rejection reason is available, `rejected` SHOULD be used as value for
523 // `error.type`.
524 func (m SDKExporterMetricDataPointExported) AddSet(ctx context.Context, incr int64, set attribute.Set) {
525 if set.Len() == 0 {
526 m.Int64Counter.Add(ctx, incr)
527 return
528 }
529
530 o := addOptPool.Get().(*[]metric.AddOption)
531 defer func() {
532 *o = (*o)[:0]
533 addOptPool.Put(o)
534 }()
535
536 *o = append(*o, metric.WithAttributeSet(set))
537 m.Int64Counter.Add(ctx, incr, *o...)
538 }
539
540 // AttrErrorType returns an optional attribute for the "error.type" semantic
541 // convention. It represents the describes a class of error the operation ended
542 // with.
543 func (SDKExporterMetricDataPointExported) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
544 return attribute.String("error.type", string(val))
545 }
546
547 // AttrComponentName returns an optional attribute for the "otel.component.name"
548 // semantic convention. It represents a name uniquely identifying the instance of
549 // the OpenTelemetry component within its containing SDK instance.
550 func (SDKExporterMetricDataPointExported) AttrComponentName(val string) attribute.KeyValue {
551 return attribute.String("otel.component.name", val)
552 }
553
554 // AttrComponentType returns an optional attribute for the "otel.component.type"
555 // semantic convention. It represents a name identifying the type of the
556 // OpenTelemetry component.
557 func (SDKExporterMetricDataPointExported) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
558 return attribute.String("otel.component.type", string(val))
559 }
560
561 // AttrServerAddress returns an optional attribute for the "server.address"
562 // semantic convention. It represents the server domain name if available without
563 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
564 func (SDKExporterMetricDataPointExported) AttrServerAddress(val string) attribute.KeyValue {
565 return attribute.String("server.address", val)
566 }
567
568 // AttrServerPort returns an optional attribute for the "server.port" semantic
569 // convention. It represents the server port number.
570 func (SDKExporterMetricDataPointExported) AttrServerPort(val int) attribute.KeyValue {
571 return attribute.Int("server.port", val)
572 }
573
574 // SDKExporterMetricDataPointInflight is an instrument used to record metric
575 // values conforming to the "otel.sdk.exporter.metric_data_point.inflight"
576 // semantic conventions. It represents the number of metric data points which
577 // were passed to the exporter, but that have not been exported yet (neither
578 // successful, nor failed).
579 type SDKExporterMetricDataPointInflight struct {
580 metric.Int64UpDownCounter
581 }
582
583 var newSDKExporterMetricDataPointInflightOpts = []metric.Int64UpDownCounterOption{
584 metric.WithDescription("The number of metric data points which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)."),
585 metric.WithUnit("{data_point}"),
586 }
587
588 // NewSDKExporterMetricDataPointInflight returns a new
589 // SDKExporterMetricDataPointInflight instrument.
590 func NewSDKExporterMetricDataPointInflight(
591 m metric.Meter,
592 opt ...metric.Int64UpDownCounterOption,
593 ) (SDKExporterMetricDataPointInflight, error) {
594 // Check if the meter is nil.
595 if m == nil {
596 return SDKExporterMetricDataPointInflight{noop.Int64UpDownCounter{}}, nil
597 }
598
599 if len(opt) == 0 {
600 opt = newSDKExporterMetricDataPointInflightOpts
601 } else {
602 opt = append(opt, newSDKExporterMetricDataPointInflightOpts...)
603 }
604
605 i, err := m.Int64UpDownCounter(
606 "otel.sdk.exporter.metric_data_point.inflight",
607 opt...,
608 )
609 if err != nil {
610 return SDKExporterMetricDataPointInflight{noop.Int64UpDownCounter{}}, err
611 }
612 return SDKExporterMetricDataPointInflight{i}, nil
613 }
614
615 // Inst returns the underlying metric instrument.
616 func (m SDKExporterMetricDataPointInflight) Inst() metric.Int64UpDownCounter {
617 return m.Int64UpDownCounter
618 }
619
620 // Name returns the semantic convention name of the instrument.
621 func (SDKExporterMetricDataPointInflight) Name() string {
622 return "otel.sdk.exporter.metric_data_point.inflight"
623 }
624
625 // Unit returns the semantic convention unit of the instrument
626 func (SDKExporterMetricDataPointInflight) Unit() string {
627 return "{data_point}"
628 }
629
630 // Description returns the semantic convention description of the instrument
631 func (SDKExporterMetricDataPointInflight) Description() string {
632 return "The number of metric data points which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)."
633 }
634
635 // Add adds incr to the existing count for attrs.
636 //
637 // All additional attrs passed are included in the recorded value.
638 //
639 // For successful exports, `error.type` MUST NOT be set. For failed exports,
640 // `error.type` MUST contain the failure cause.
641 func (m SDKExporterMetricDataPointInflight) Add(
642 ctx context.Context,
643 incr int64,
644 attrs ...attribute.KeyValue,
645 ) {
646 if len(attrs) == 0 {
647 m.Int64UpDownCounter.Add(ctx, incr)
648 return
649 }
650
651 o := addOptPool.Get().(*[]metric.AddOption)
652 defer func() {
653 *o = (*o)[:0]
654 addOptPool.Put(o)
655 }()
656
657 *o = append(
658 *o,
659 metric.WithAttributes(
660 attrs...,
661 ),
662 )
663
664 m.Int64UpDownCounter.Add(ctx, incr, *o...)
665 }
666
667 // AddSet adds incr to the existing count for set.
668 //
669 // For successful exports, `error.type` MUST NOT be set. For failed exports,
670 // `error.type` MUST contain the failure cause.
671 func (m SDKExporterMetricDataPointInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) {
672 if set.Len() == 0 {
673 m.Int64UpDownCounter.Add(ctx, incr)
674 return
675 }
676
677 o := addOptPool.Get().(*[]metric.AddOption)
678 defer func() {
679 *o = (*o)[:0]
680 addOptPool.Put(o)
681 }()
682
683 *o = append(*o, metric.WithAttributeSet(set))
684 m.Int64UpDownCounter.Add(ctx, incr, *o...)
685 }
686
687 // AttrComponentName returns an optional attribute for the "otel.component.name"
688 // semantic convention. It represents a name uniquely identifying the instance of
689 // the OpenTelemetry component within its containing SDK instance.
690 func (SDKExporterMetricDataPointInflight) AttrComponentName(val string) attribute.KeyValue {
691 return attribute.String("otel.component.name", val)
692 }
693
694 // AttrComponentType returns an optional attribute for the "otel.component.type"
695 // semantic convention. It represents a name identifying the type of the
696 // OpenTelemetry component.
697 func (SDKExporterMetricDataPointInflight) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
698 return attribute.String("otel.component.type", string(val))
699 }
700
701 // AttrServerAddress returns an optional attribute for the "server.address"
702 // semantic convention. It represents the server domain name if available without
703 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
704 func (SDKExporterMetricDataPointInflight) AttrServerAddress(val string) attribute.KeyValue {
705 return attribute.String("server.address", val)
706 }
707
708 // AttrServerPort returns an optional attribute for the "server.port" semantic
709 // convention. It represents the server port number.
710 func (SDKExporterMetricDataPointInflight) AttrServerPort(val int) attribute.KeyValue {
711 return attribute.Int("server.port", val)
712 }
713
714 // SDKExporterOperationDuration is an instrument used to record metric values
715 // conforming to the "otel.sdk.exporter.operation.duration" semantic conventions.
716 // It represents the duration of exporting a batch of telemetry records.
717 type SDKExporterOperationDuration struct {
718 metric.Float64Histogram
719 }
720
721 var newSDKExporterOperationDurationOpts = []metric.Float64HistogramOption{
722 metric.WithDescription("The duration of exporting a batch of telemetry records."),
723 metric.WithUnit("s"),
724 }
725
726 // NewSDKExporterOperationDuration returns a new SDKExporterOperationDuration
727 // instrument.
728 func NewSDKExporterOperationDuration(
729 m metric.Meter,
730 opt ...metric.Float64HistogramOption,
731 ) (SDKExporterOperationDuration, error) {
732 // Check if the meter is nil.
733 if m == nil {
734 return SDKExporterOperationDuration{noop.Float64Histogram{}}, nil
735 }
736
737 if len(opt) == 0 {
738 opt = newSDKExporterOperationDurationOpts
739 } else {
740 opt = append(opt, newSDKExporterOperationDurationOpts...)
741 }
742
743 i, err := m.Float64Histogram(
744 "otel.sdk.exporter.operation.duration",
745 opt...,
746 )
747 if err != nil {
748 return SDKExporterOperationDuration{noop.Float64Histogram{}}, err
749 }
750 return SDKExporterOperationDuration{i}, nil
751 }
752
753 // Inst returns the underlying metric instrument.
754 func (m SDKExporterOperationDuration) Inst() metric.Float64Histogram {
755 return m.Float64Histogram
756 }
757
758 // Name returns the semantic convention name of the instrument.
759 func (SDKExporterOperationDuration) Name() string {
760 return "otel.sdk.exporter.operation.duration"
761 }
762
763 // Unit returns the semantic convention unit of the instrument
764 func (SDKExporterOperationDuration) Unit() string {
765 return "s"
766 }
767
768 // Description returns the semantic convention description of the instrument
769 func (SDKExporterOperationDuration) Description() string {
770 return "The duration of exporting a batch of telemetry records."
771 }
772
773 // Record records val to the current distribution for attrs.
774 //
775 // All additional attrs passed are included in the recorded value.
776 //
777 // This metric defines successful operations using the full success definitions
778 // for [http]
779 // and [grpc]. Anything else is defined as an unsuccessful operation. For
780 // successful
781 // operations, `error.type` MUST NOT be set. For unsuccessful export operations,
782 // `error.type` MUST contain a relevant failure cause.
783 //
784 // [http]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success-1
785 // [grpc]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success
786 func (m SDKExporterOperationDuration) Record(
787 ctx context.Context,
788 val float64,
789 attrs ...attribute.KeyValue,
790 ) {
791 if len(attrs) == 0 {
792 m.Float64Histogram.Record(ctx, val)
793 return
794 }
795
796 o := recOptPool.Get().(*[]metric.RecordOption)
797 defer func() {
798 *o = (*o)[:0]
799 recOptPool.Put(o)
800 }()
801
802 *o = append(
803 *o,
804 metric.WithAttributes(
805 attrs...,
806 ),
807 )
808
809 m.Float64Histogram.Record(ctx, val, *o...)
810 }
811
812 // RecordSet records val to the current distribution for set.
813 //
814 // This metric defines successful operations using the full success definitions
815 // for [http]
816 // and [grpc]. Anything else is defined as an unsuccessful operation. For
817 // successful
818 // operations, `error.type` MUST NOT be set. For unsuccessful export operations,
819 // `error.type` MUST contain a relevant failure cause.
820 //
821 // [http]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success-1
822 // [grpc]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success
823 func (m SDKExporterOperationDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
824 if set.Len() == 0 {
825 m.Float64Histogram.Record(ctx, val)
826 return
827 }
828
829 o := recOptPool.Get().(*[]metric.RecordOption)
830 defer func() {
831 *o = (*o)[:0]
832 recOptPool.Put(o)
833 }()
834
835 *o = append(*o, metric.WithAttributeSet(set))
836 m.Float64Histogram.Record(ctx, val, *o...)
837 }
838
839 // AttrErrorType returns an optional attribute for the "error.type" semantic
840 // convention. It represents the describes a class of error the operation ended
841 // with.
842 func (SDKExporterOperationDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
843 return attribute.String("error.type", string(val))
844 }
845
846 // AttrHTTPResponseStatusCode returns an optional attribute for the
847 // "http.response.status_code" semantic convention. It represents the HTTP status
848 // code of the last HTTP request performed in scope of this export call.
849 func (SDKExporterOperationDuration) AttrHTTPResponseStatusCode(val int) attribute.KeyValue {
850 return attribute.Int("http.response.status_code", val)
851 }
852
853 // AttrComponentName returns an optional attribute for the "otel.component.name"
854 // semantic convention. It represents a name uniquely identifying the instance of
855 // the OpenTelemetry component within its containing SDK instance.
856 func (SDKExporterOperationDuration) AttrComponentName(val string) attribute.KeyValue {
857 return attribute.String("otel.component.name", val)
858 }
859
860 // AttrComponentType returns an optional attribute for the "otel.component.type"
861 // semantic convention. It represents a name identifying the type of the
862 // OpenTelemetry component.
863 func (SDKExporterOperationDuration) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
864 return attribute.String("otel.component.type", string(val))
865 }
866
867 // AttrRPCResponseStatusCode returns an optional attribute for the
868 // "rpc.response.status_code" semantic convention. It represents the gRPC status
869 // code of the last gRPC request performed in scope of this export call.
870 func (SDKExporterOperationDuration) AttrRPCResponseStatusCode(val string) attribute.KeyValue {
871 return attribute.String("rpc.response.status_code", val)
872 }
873
874 // AttrServerAddress returns an optional attribute for the "server.address"
875 // semantic convention. It represents the server domain name if available without
876 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
877 func (SDKExporterOperationDuration) AttrServerAddress(val string) attribute.KeyValue {
878 return attribute.String("server.address", val)
879 }
880
881 // AttrServerPort returns an optional attribute for the "server.port" semantic
882 // convention. It represents the server port number.
883 func (SDKExporterOperationDuration) AttrServerPort(val int) attribute.KeyValue {
884 return attribute.Int("server.port", val)
885 }
886
887 // SDKExporterSpanExported is an instrument used to record metric values
888 // conforming to the "otel.sdk.exporter.span.exported" semantic conventions. It
889 // represents the number of spans for which the export has finished, either
890 // successful or failed.
891 type SDKExporterSpanExported struct {
892 metric.Int64Counter
893 }
894
895 var newSDKExporterSpanExportedOpts = []metric.Int64CounterOption{
896 metric.WithDescription("The number of spans for which the export has finished, either successful or failed."),
897 metric.WithUnit("{span}"),
898 }
899
900 // NewSDKExporterSpanExported returns a new SDKExporterSpanExported instrument.
901 func NewSDKExporterSpanExported(
902 m metric.Meter,
903 opt ...metric.Int64CounterOption,
904 ) (SDKExporterSpanExported, error) {
905 // Check if the meter is nil.
906 if m == nil {
907 return SDKExporterSpanExported{noop.Int64Counter{}}, nil
908 }
909
910 if len(opt) == 0 {
911 opt = newSDKExporterSpanExportedOpts
912 } else {
913 opt = append(opt, newSDKExporterSpanExportedOpts...)
914 }
915
916 i, err := m.Int64Counter(
917 "otel.sdk.exporter.span.exported",
918 opt...,
919 )
920 if err != nil {
921 return SDKExporterSpanExported{noop.Int64Counter{}}, err
922 }
923 return SDKExporterSpanExported{i}, nil
924 }
925
926 // Inst returns the underlying metric instrument.
927 func (m SDKExporterSpanExported) Inst() metric.Int64Counter {
928 return m.Int64Counter
929 }
930
931 // Name returns the semantic convention name of the instrument.
932 func (SDKExporterSpanExported) Name() string {
933 return "otel.sdk.exporter.span.exported"
934 }
935
936 // Unit returns the semantic convention unit of the instrument
937 func (SDKExporterSpanExported) Unit() string {
938 return "{span}"
939 }
940
941 // Description returns the semantic convention description of the instrument
942 func (SDKExporterSpanExported) Description() string {
943 return "The number of spans for which the export has finished, either successful or failed."
944 }
945
946 // Add adds incr to the existing count for attrs.
947 //
948 // All additional attrs passed are included in the recorded value.
949 //
950 // For successful exports, `error.type` MUST NOT be set. For failed exports,
951 // `error.type` MUST contain the failure cause.
952 // For exporters with partial success semantics (e.g. OTLP with `rejected_spans`
953 // ), rejected spans MUST count as failed and only non-rejected spans count as
954 // success.
955 // If no rejection reason is available, `rejected` SHOULD be used as value for
956 // `error.type`.
957 func (m SDKExporterSpanExported) Add(
958 ctx context.Context,
959 incr int64,
960 attrs ...attribute.KeyValue,
961 ) {
962 if len(attrs) == 0 {
963 m.Int64Counter.Add(ctx, incr)
964 return
965 }
966
967 o := addOptPool.Get().(*[]metric.AddOption)
968 defer func() {
969 *o = (*o)[:0]
970 addOptPool.Put(o)
971 }()
972
973 *o = append(
974 *o,
975 metric.WithAttributes(
976 attrs...,
977 ),
978 )
979
980 m.Int64Counter.Add(ctx, incr, *o...)
981 }
982
983 // AddSet adds incr to the existing count for set.
984 //
985 // For successful exports, `error.type` MUST NOT be set. For failed exports,
986 // `error.type` MUST contain the failure cause.
987 // For exporters with partial success semantics (e.g. OTLP with `rejected_spans`
988 // ), rejected spans MUST count as failed and only non-rejected spans count as
989 // success.
990 // If no rejection reason is available, `rejected` SHOULD be used as value for
991 // `error.type`.
992 func (m SDKExporterSpanExported) AddSet(ctx context.Context, incr int64, set attribute.Set) {
993 if set.Len() == 0 {
994 m.Int64Counter.Add(ctx, incr)
995 return
996 }
997
998 o := addOptPool.Get().(*[]metric.AddOption)
999 defer func() {
1000 *o = (*o)[:0]
1001 addOptPool.Put(o)
1002 }()
1003
1004 *o = append(*o, metric.WithAttributeSet(set))
1005 m.Int64Counter.Add(ctx, incr, *o...)
1006 }
1007
1008 // AttrErrorType returns an optional attribute for the "error.type" semantic
1009 // convention. It represents the describes a class of error the operation ended
1010 // with.
1011 func (SDKExporterSpanExported) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
1012 return attribute.String("error.type", string(val))
1013 }
1014
1015 // AttrComponentName returns an optional attribute for the "otel.component.name"
1016 // semantic convention. It represents a name uniquely identifying the instance of
1017 // the OpenTelemetry component within its containing SDK instance.
1018 func (SDKExporterSpanExported) AttrComponentName(val string) attribute.KeyValue {
1019 return attribute.String("otel.component.name", val)
1020 }
1021
1022 // AttrComponentType returns an optional attribute for the "otel.component.type"
1023 // semantic convention. It represents a name identifying the type of the
1024 // OpenTelemetry component.
1025 func (SDKExporterSpanExported) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1026 return attribute.String("otel.component.type", string(val))
1027 }
1028
1029 // AttrServerAddress returns an optional attribute for the "server.address"
1030 // semantic convention. It represents the server domain name if available without
1031 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
1032 func (SDKExporterSpanExported) AttrServerAddress(val string) attribute.KeyValue {
1033 return attribute.String("server.address", val)
1034 }
1035
1036 // AttrServerPort returns an optional attribute for the "server.port" semantic
1037 // convention. It represents the server port number.
1038 func (SDKExporterSpanExported) AttrServerPort(val int) attribute.KeyValue {
1039 return attribute.Int("server.port", val)
1040 }
1041
1042 // SDKExporterSpanInflight is an instrument used to record metric values
1043 // conforming to the "otel.sdk.exporter.span.inflight" semantic conventions. It
1044 // represents the number of spans which were passed to the exporter, but that
1045 // have not been exported yet (neither successful, nor failed).
1046 type SDKExporterSpanInflight struct {
1047 metric.Int64UpDownCounter
1048 }
1049
1050 var newSDKExporterSpanInflightOpts = []metric.Int64UpDownCounterOption{
1051 metric.WithDescription("The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)."),
1052 metric.WithUnit("{span}"),
1053 }
1054
1055 // NewSDKExporterSpanInflight returns a new SDKExporterSpanInflight instrument.
1056 func NewSDKExporterSpanInflight(
1057 m metric.Meter,
1058 opt ...metric.Int64UpDownCounterOption,
1059 ) (SDKExporterSpanInflight, error) {
1060 // Check if the meter is nil.
1061 if m == nil {
1062 return SDKExporterSpanInflight{noop.Int64UpDownCounter{}}, nil
1063 }
1064
1065 if len(opt) == 0 {
1066 opt = newSDKExporterSpanInflightOpts
1067 } else {
1068 opt = append(opt, newSDKExporterSpanInflightOpts...)
1069 }
1070
1071 i, err := m.Int64UpDownCounter(
1072 "otel.sdk.exporter.span.inflight",
1073 opt...,
1074 )
1075 if err != nil {
1076 return SDKExporterSpanInflight{noop.Int64UpDownCounter{}}, err
1077 }
1078 return SDKExporterSpanInflight{i}, nil
1079 }
1080
1081 // Inst returns the underlying metric instrument.
1082 func (m SDKExporterSpanInflight) Inst() metric.Int64UpDownCounter {
1083 return m.Int64UpDownCounter
1084 }
1085
1086 // Name returns the semantic convention name of the instrument.
1087 func (SDKExporterSpanInflight) Name() string {
1088 return "otel.sdk.exporter.span.inflight"
1089 }
1090
1091 // Unit returns the semantic convention unit of the instrument
1092 func (SDKExporterSpanInflight) Unit() string {
1093 return "{span}"
1094 }
1095
1096 // Description returns the semantic convention description of the instrument
1097 func (SDKExporterSpanInflight) Description() string {
1098 return "The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)."
1099 }
1100
1101 // Add adds incr to the existing count for attrs.
1102 //
1103 // All additional attrs passed are included in the recorded value.
1104 //
1105 // For successful exports, `error.type` MUST NOT be set. For failed exports,
1106 // `error.type` MUST contain the failure cause.
1107 func (m SDKExporterSpanInflight) Add(
1108 ctx context.Context,
1109 incr int64,
1110 attrs ...attribute.KeyValue,
1111 ) {
1112 if len(attrs) == 0 {
1113 m.Int64UpDownCounter.Add(ctx, incr)
1114 return
1115 }
1116
1117 o := addOptPool.Get().(*[]metric.AddOption)
1118 defer func() {
1119 *o = (*o)[:0]
1120 addOptPool.Put(o)
1121 }()
1122
1123 *o = append(
1124 *o,
1125 metric.WithAttributes(
1126 attrs...,
1127 ),
1128 )
1129
1130 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1131 }
1132
1133 // AddSet adds incr to the existing count for set.
1134 //
1135 // For successful exports, `error.type` MUST NOT be set. For failed exports,
1136 // `error.type` MUST contain the failure cause.
1137 func (m SDKExporterSpanInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1138 if set.Len() == 0 {
1139 m.Int64UpDownCounter.Add(ctx, incr)
1140 return
1141 }
1142
1143 o := addOptPool.Get().(*[]metric.AddOption)
1144 defer func() {
1145 *o = (*o)[:0]
1146 addOptPool.Put(o)
1147 }()
1148
1149 *o = append(*o, metric.WithAttributeSet(set))
1150 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1151 }
1152
1153 // AttrComponentName returns an optional attribute for the "otel.component.name"
1154 // semantic convention. It represents a name uniquely identifying the instance of
1155 // the OpenTelemetry component within its containing SDK instance.
1156 func (SDKExporterSpanInflight) AttrComponentName(val string) attribute.KeyValue {
1157 return attribute.String("otel.component.name", val)
1158 }
1159
1160 // AttrComponentType returns an optional attribute for the "otel.component.type"
1161 // semantic convention. It represents a name identifying the type of the
1162 // OpenTelemetry component.
1163 func (SDKExporterSpanInflight) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1164 return attribute.String("otel.component.type", string(val))
1165 }
1166
1167 // AttrServerAddress returns an optional attribute for the "server.address"
1168 // semantic convention. It represents the server domain name if available without
1169 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
1170 func (SDKExporterSpanInflight) AttrServerAddress(val string) attribute.KeyValue {
1171 return attribute.String("server.address", val)
1172 }
1173
1174 // AttrServerPort returns an optional attribute for the "server.port" semantic
1175 // convention. It represents the server port number.
1176 func (SDKExporterSpanInflight) AttrServerPort(val int) attribute.KeyValue {
1177 return attribute.Int("server.port", val)
1178 }
1179
1180 // SDKLogCreated is an instrument used to record metric values conforming to the
1181 // "otel.sdk.log.created" semantic conventions. It represents the number of logs
1182 // submitted to enabled SDK Loggers.
1183 type SDKLogCreated struct {
1184 metric.Int64Counter
1185 }
1186
1187 var newSDKLogCreatedOpts = []metric.Int64CounterOption{
1188 metric.WithDescription("The number of logs submitted to enabled SDK Loggers."),
1189 metric.WithUnit("{log_record}"),
1190 }
1191
1192 // NewSDKLogCreated returns a new SDKLogCreated instrument.
1193 func NewSDKLogCreated(
1194 m metric.Meter,
1195 opt ...metric.Int64CounterOption,
1196 ) (SDKLogCreated, error) {
1197 // Check if the meter is nil.
1198 if m == nil {
1199 return SDKLogCreated{noop.Int64Counter{}}, nil
1200 }
1201
1202 if len(opt) == 0 {
1203 opt = newSDKLogCreatedOpts
1204 } else {
1205 opt = append(opt, newSDKLogCreatedOpts...)
1206 }
1207
1208 i, err := m.Int64Counter(
1209 "otel.sdk.log.created",
1210 opt...,
1211 )
1212 if err != nil {
1213 return SDKLogCreated{noop.Int64Counter{}}, err
1214 }
1215 return SDKLogCreated{i}, nil
1216 }
1217
1218 // Inst returns the underlying metric instrument.
1219 func (m SDKLogCreated) Inst() metric.Int64Counter {
1220 return m.Int64Counter
1221 }
1222
1223 // Name returns the semantic convention name of the instrument.
1224 func (SDKLogCreated) Name() string {
1225 return "otel.sdk.log.created"
1226 }
1227
1228 // Unit returns the semantic convention unit of the instrument
1229 func (SDKLogCreated) Unit() string {
1230 return "{log_record}"
1231 }
1232
1233 // Description returns the semantic convention description of the instrument
1234 func (SDKLogCreated) Description() string {
1235 return "The number of logs submitted to enabled SDK Loggers."
1236 }
1237
1238 // Add adds incr to the existing count for attrs.
1239 func (m SDKLogCreated) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1240 if len(attrs) == 0 {
1241 m.Int64Counter.Add(ctx, incr)
1242 return
1243 }
1244
1245 o := addOptPool.Get().(*[]metric.AddOption)
1246 defer func() {
1247 *o = (*o)[:0]
1248 addOptPool.Put(o)
1249 }()
1250
1251 *o = append(*o, metric.WithAttributes(attrs...))
1252 m.Int64Counter.Add(ctx, incr, *o...)
1253 }
1254
1255 // AddSet adds incr to the existing count for set.
1256 func (m SDKLogCreated) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1257 if set.Len() == 0 {
1258 m.Int64Counter.Add(ctx, incr)
1259 return
1260 }
1261
1262 o := addOptPool.Get().(*[]metric.AddOption)
1263 defer func() {
1264 *o = (*o)[:0]
1265 addOptPool.Put(o)
1266 }()
1267
1268 *o = append(*o, metric.WithAttributeSet(set))
1269 m.Int64Counter.Add(ctx, incr, *o...)
1270 }
1271
1272 // SDKMetricReaderCollectionDuration is an instrument used to record metric
1273 // values conforming to the "otel.sdk.metric_reader.collection.duration" semantic
1274 // conventions. It represents the duration of the collect operation of the metric
1275 // reader.
1276 type SDKMetricReaderCollectionDuration struct {
1277 metric.Float64Histogram
1278 }
1279
1280 var newSDKMetricReaderCollectionDurationOpts = []metric.Float64HistogramOption{
1281 metric.WithDescription("The duration of the collect operation of the metric reader."),
1282 metric.WithUnit("s"),
1283 }
1284
1285 // NewSDKMetricReaderCollectionDuration returns a new
1286 // SDKMetricReaderCollectionDuration instrument.
1287 func NewSDKMetricReaderCollectionDuration(
1288 m metric.Meter,
1289 opt ...metric.Float64HistogramOption,
1290 ) (SDKMetricReaderCollectionDuration, error) {
1291 // Check if the meter is nil.
1292 if m == nil {
1293 return SDKMetricReaderCollectionDuration{noop.Float64Histogram{}}, nil
1294 }
1295
1296 if len(opt) == 0 {
1297 opt = newSDKMetricReaderCollectionDurationOpts
1298 } else {
1299 opt = append(opt, newSDKMetricReaderCollectionDurationOpts...)
1300 }
1301
1302 i, err := m.Float64Histogram(
1303 "otel.sdk.metric_reader.collection.duration",
1304 opt...,
1305 )
1306 if err != nil {
1307 return SDKMetricReaderCollectionDuration{noop.Float64Histogram{}}, err
1308 }
1309 return SDKMetricReaderCollectionDuration{i}, nil
1310 }
1311
1312 // Inst returns the underlying metric instrument.
1313 func (m SDKMetricReaderCollectionDuration) Inst() metric.Float64Histogram {
1314 return m.Float64Histogram
1315 }
1316
1317 // Name returns the semantic convention name of the instrument.
1318 func (SDKMetricReaderCollectionDuration) Name() string {
1319 return "otel.sdk.metric_reader.collection.duration"
1320 }
1321
1322 // Unit returns the semantic convention unit of the instrument
1323 func (SDKMetricReaderCollectionDuration) Unit() string {
1324 return "s"
1325 }
1326
1327 // Description returns the semantic convention description of the instrument
1328 func (SDKMetricReaderCollectionDuration) Description() string {
1329 return "The duration of the collect operation of the metric reader."
1330 }
1331
1332 // Record records val to the current distribution for attrs.
1333 //
1334 // All additional attrs passed are included in the recorded value.
1335 //
1336 // For successful collections, `error.type` MUST NOT be set. For failed
1337 // collections, `error.type` SHOULD contain the failure cause.
1338 // It can happen that metrics collection is successful for some MetricProducers,
1339 // while others fail. In that case `error.type` SHOULD be set to any of the
1340 // failure causes.
1341 func (m SDKMetricReaderCollectionDuration) Record(
1342 ctx context.Context,
1343 val float64,
1344 attrs ...attribute.KeyValue,
1345 ) {
1346 if len(attrs) == 0 {
1347 m.Float64Histogram.Record(ctx, val)
1348 return
1349 }
1350
1351 o := recOptPool.Get().(*[]metric.RecordOption)
1352 defer func() {
1353 *o = (*o)[:0]
1354 recOptPool.Put(o)
1355 }()
1356
1357 *o = append(
1358 *o,
1359 metric.WithAttributes(
1360 attrs...,
1361 ),
1362 )
1363
1364 m.Float64Histogram.Record(ctx, val, *o...)
1365 }
1366
1367 // RecordSet records val to the current distribution for set.
1368 //
1369 // For successful collections, `error.type` MUST NOT be set. For failed
1370 // collections, `error.type` SHOULD contain the failure cause.
1371 // It can happen that metrics collection is successful for some MetricProducers,
1372 // while others fail. In that case `error.type` SHOULD be set to any of the
1373 // failure causes.
1374 func (m SDKMetricReaderCollectionDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
1375 if set.Len() == 0 {
1376 m.Float64Histogram.Record(ctx, val)
1377 return
1378 }
1379
1380 o := recOptPool.Get().(*[]metric.RecordOption)
1381 defer func() {
1382 *o = (*o)[:0]
1383 recOptPool.Put(o)
1384 }()
1385
1386 *o = append(*o, metric.WithAttributeSet(set))
1387 m.Float64Histogram.Record(ctx, val, *o...)
1388 }
1389
1390 // AttrErrorType returns an optional attribute for the "error.type" semantic
1391 // convention. It represents the describes a class of error the operation ended
1392 // with.
1393 func (SDKMetricReaderCollectionDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
1394 return attribute.String("error.type", string(val))
1395 }
1396
1397 // AttrComponentName returns an optional attribute for the "otel.component.name"
1398 // semantic convention. It represents a name uniquely identifying the instance of
1399 // the OpenTelemetry component within its containing SDK instance.
1400 func (SDKMetricReaderCollectionDuration) AttrComponentName(val string) attribute.KeyValue {
1401 return attribute.String("otel.component.name", val)
1402 }
1403
1404 // AttrComponentType returns an optional attribute for the "otel.component.type"
1405 // semantic convention. It represents a name identifying the type of the
1406 // OpenTelemetry component.
1407 func (SDKMetricReaderCollectionDuration) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1408 return attribute.String("otel.component.type", string(val))
1409 }
1410
1411 // SDKProcessorLogProcessed is an instrument used to record metric values
1412 // conforming to the "otel.sdk.processor.log.processed" semantic conventions. It
1413 // represents the number of log records for which the processing has finished,
1414 // either successful or failed.
1415 type SDKProcessorLogProcessed struct {
1416 metric.Int64Counter
1417 }
1418
1419 var newSDKProcessorLogProcessedOpts = []metric.Int64CounterOption{
1420 metric.WithDescription("The number of log records for which the processing has finished, either successful or failed."),
1421 metric.WithUnit("{log_record}"),
1422 }
1423
1424 // NewSDKProcessorLogProcessed returns a new SDKProcessorLogProcessed instrument.
1425 func NewSDKProcessorLogProcessed(
1426 m metric.Meter,
1427 opt ...metric.Int64CounterOption,
1428 ) (SDKProcessorLogProcessed, error) {
1429 // Check if the meter is nil.
1430 if m == nil {
1431 return SDKProcessorLogProcessed{noop.Int64Counter{}}, nil
1432 }
1433
1434 if len(opt) == 0 {
1435 opt = newSDKProcessorLogProcessedOpts
1436 } else {
1437 opt = append(opt, newSDKProcessorLogProcessedOpts...)
1438 }
1439
1440 i, err := m.Int64Counter(
1441 "otel.sdk.processor.log.processed",
1442 opt...,
1443 )
1444 if err != nil {
1445 return SDKProcessorLogProcessed{noop.Int64Counter{}}, err
1446 }
1447 return SDKProcessorLogProcessed{i}, nil
1448 }
1449
1450 // Inst returns the underlying metric instrument.
1451 func (m SDKProcessorLogProcessed) Inst() metric.Int64Counter {
1452 return m.Int64Counter
1453 }
1454
1455 // Name returns the semantic convention name of the instrument.
1456 func (SDKProcessorLogProcessed) Name() string {
1457 return "otel.sdk.processor.log.processed"
1458 }
1459
1460 // Unit returns the semantic convention unit of the instrument
1461 func (SDKProcessorLogProcessed) Unit() string {
1462 return "{log_record}"
1463 }
1464
1465 // Description returns the semantic convention description of the instrument
1466 func (SDKProcessorLogProcessed) Description() string {
1467 return "The number of log records for which the processing has finished, either successful or failed."
1468 }
1469
1470 // Add adds incr to the existing count for attrs.
1471 //
1472 // All additional attrs passed are included in the recorded value.
1473 //
1474 // For successful processing, `error.type` MUST NOT be set. For failed
1475 // processing, `error.type` MUST contain the failure cause.
1476 // For the SDK Simple and Batching Log Record Processor a log record is
1477 // considered to be processed already when it has been submitted to the exporter,
1478 // not when the corresponding export call has finished.
1479 func (m SDKProcessorLogProcessed) Add(
1480 ctx context.Context,
1481 incr int64,
1482 attrs ...attribute.KeyValue,
1483 ) {
1484 if len(attrs) == 0 {
1485 m.Int64Counter.Add(ctx, incr)
1486 return
1487 }
1488
1489 o := addOptPool.Get().(*[]metric.AddOption)
1490 defer func() {
1491 *o = (*o)[:0]
1492 addOptPool.Put(o)
1493 }()
1494
1495 *o = append(
1496 *o,
1497 metric.WithAttributes(
1498 attrs...,
1499 ),
1500 )
1501
1502 m.Int64Counter.Add(ctx, incr, *o...)
1503 }
1504
1505 // AddSet adds incr to the existing count for set.
1506 //
1507 // For successful processing, `error.type` MUST NOT be set. For failed
1508 // processing, `error.type` MUST contain the failure cause.
1509 // For the SDK Simple and Batching Log Record Processor a log record is
1510 // considered to be processed already when it has been submitted to the exporter,
1511 // not when the corresponding export call has finished.
1512 func (m SDKProcessorLogProcessed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1513 if set.Len() == 0 {
1514 m.Int64Counter.Add(ctx, incr)
1515 return
1516 }
1517
1518 o := addOptPool.Get().(*[]metric.AddOption)
1519 defer func() {
1520 *o = (*o)[:0]
1521 addOptPool.Put(o)
1522 }()
1523
1524 *o = append(*o, metric.WithAttributeSet(set))
1525 m.Int64Counter.Add(ctx, incr, *o...)
1526 }
1527
1528 // AttrErrorType returns an optional attribute for the "error.type" semantic
1529 // convention. It represents a low-cardinality description of the failure reason.
1530 // SDK Batching Log Record Processors MUST use `queue_full` for log records
1531 // dropped due to a full queue.
1532 func (SDKProcessorLogProcessed) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
1533 return attribute.String("error.type", string(val))
1534 }
1535
1536 // AttrComponentName returns an optional attribute for the "otel.component.name"
1537 // semantic convention. It represents a name uniquely identifying the instance of
1538 // the OpenTelemetry component within its containing SDK instance.
1539 func (SDKProcessorLogProcessed) AttrComponentName(val string) attribute.KeyValue {
1540 return attribute.String("otel.component.name", val)
1541 }
1542
1543 // AttrComponentType returns an optional attribute for the "otel.component.type"
1544 // semantic convention. It represents a name identifying the type of the
1545 // OpenTelemetry component.
1546 func (SDKProcessorLogProcessed) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1547 return attribute.String("otel.component.type", string(val))
1548 }
1549
1550 // SDKProcessorLogQueueCapacity is an instrument used to record metric values
1551 // conforming to the "otel.sdk.processor.log.queue.capacity" semantic
1552 // conventions. It represents the maximum number of log records the queue of a
1553 // given instance of an SDK Log Record processor can hold.
1554 type SDKProcessorLogQueueCapacity struct {
1555 metric.Int64ObservableUpDownCounter
1556 }
1557
1558 var newSDKProcessorLogQueueCapacityOpts = []metric.Int64ObservableUpDownCounterOption{
1559 metric.WithDescription("The maximum number of log records the queue of a given instance of an SDK Log Record processor can hold."),
1560 metric.WithUnit("{log_record}"),
1561 }
1562
1563 // NewSDKProcessorLogQueueCapacity returns a new SDKProcessorLogQueueCapacity
1564 // instrument.
1565 func NewSDKProcessorLogQueueCapacity(
1566 m metric.Meter,
1567 opt ...metric.Int64ObservableUpDownCounterOption,
1568 ) (SDKProcessorLogQueueCapacity, error) {
1569 // Check if the meter is nil.
1570 if m == nil {
1571 return SDKProcessorLogQueueCapacity{noop.Int64ObservableUpDownCounter{}}, nil
1572 }
1573
1574 if len(opt) == 0 {
1575 opt = newSDKProcessorLogQueueCapacityOpts
1576 } else {
1577 opt = append(opt, newSDKProcessorLogQueueCapacityOpts...)
1578 }
1579
1580 i, err := m.Int64ObservableUpDownCounter(
1581 "otel.sdk.processor.log.queue.capacity",
1582 opt...,
1583 )
1584 if err != nil {
1585 return SDKProcessorLogQueueCapacity{noop.Int64ObservableUpDownCounter{}}, err
1586 }
1587 return SDKProcessorLogQueueCapacity{i}, nil
1588 }
1589
1590 // Inst returns the underlying metric instrument.
1591 func (m SDKProcessorLogQueueCapacity) Inst() metric.Int64ObservableUpDownCounter {
1592 return m.Int64ObservableUpDownCounter
1593 }
1594
1595 // Name returns the semantic convention name of the instrument.
1596 func (SDKProcessorLogQueueCapacity) Name() string {
1597 return "otel.sdk.processor.log.queue.capacity"
1598 }
1599
1600 // Unit returns the semantic convention unit of the instrument
1601 func (SDKProcessorLogQueueCapacity) Unit() string {
1602 return "{log_record}"
1603 }
1604
1605 // Description returns the semantic convention description of the instrument
1606 func (SDKProcessorLogQueueCapacity) Description() string {
1607 return "The maximum number of log records the queue of a given instance of an SDK Log Record processor can hold."
1608 }
1609
1610 // AttrComponentName returns an optional attribute for the "otel.component.name"
1611 // semantic convention. It represents a name uniquely identifying the instance of
1612 // the OpenTelemetry component within its containing SDK instance.
1613 func (SDKProcessorLogQueueCapacity) AttrComponentName(val string) attribute.KeyValue {
1614 return attribute.String("otel.component.name", val)
1615 }
1616
1617 // AttrComponentType returns an optional attribute for the "otel.component.type"
1618 // semantic convention. It represents a name identifying the type of the
1619 // OpenTelemetry component.
1620 func (SDKProcessorLogQueueCapacity) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1621 return attribute.String("otel.component.type", string(val))
1622 }
1623
1624 // SDKProcessorLogQueueSize is an instrument used to record metric values
1625 // conforming to the "otel.sdk.processor.log.queue.size" semantic conventions. It
1626 // represents the number of log records in the queue of a given instance of an
1627 // SDK log processor.
1628 type SDKProcessorLogQueueSize struct {
1629 metric.Int64ObservableUpDownCounter
1630 }
1631
1632 var newSDKProcessorLogQueueSizeOpts = []metric.Int64ObservableUpDownCounterOption{
1633 metric.WithDescription("The number of log records in the queue of a given instance of an SDK log processor."),
1634 metric.WithUnit("{log_record}"),
1635 }
1636
1637 // NewSDKProcessorLogQueueSize returns a new SDKProcessorLogQueueSize instrument.
1638 func NewSDKProcessorLogQueueSize(
1639 m metric.Meter,
1640 opt ...metric.Int64ObservableUpDownCounterOption,
1641 ) (SDKProcessorLogQueueSize, error) {
1642 // Check if the meter is nil.
1643 if m == nil {
1644 return SDKProcessorLogQueueSize{noop.Int64ObservableUpDownCounter{}}, nil
1645 }
1646
1647 if len(opt) == 0 {
1648 opt = newSDKProcessorLogQueueSizeOpts
1649 } else {
1650 opt = append(opt, newSDKProcessorLogQueueSizeOpts...)
1651 }
1652
1653 i, err := m.Int64ObservableUpDownCounter(
1654 "otel.sdk.processor.log.queue.size",
1655 opt...,
1656 )
1657 if err != nil {
1658 return SDKProcessorLogQueueSize{noop.Int64ObservableUpDownCounter{}}, err
1659 }
1660 return SDKProcessorLogQueueSize{i}, nil
1661 }
1662
1663 // Inst returns the underlying metric instrument.
1664 func (m SDKProcessorLogQueueSize) Inst() metric.Int64ObservableUpDownCounter {
1665 return m.Int64ObservableUpDownCounter
1666 }
1667
1668 // Name returns the semantic convention name of the instrument.
1669 func (SDKProcessorLogQueueSize) Name() string {
1670 return "otel.sdk.processor.log.queue.size"
1671 }
1672
1673 // Unit returns the semantic convention unit of the instrument
1674 func (SDKProcessorLogQueueSize) Unit() string {
1675 return "{log_record}"
1676 }
1677
1678 // Description returns the semantic convention description of the instrument
1679 func (SDKProcessorLogQueueSize) Description() string {
1680 return "The number of log records in the queue of a given instance of an SDK log processor."
1681 }
1682
1683 // AttrComponentName returns an optional attribute for the "otel.component.name"
1684 // semantic convention. It represents a name uniquely identifying the instance of
1685 // the OpenTelemetry component within its containing SDK instance.
1686 func (SDKProcessorLogQueueSize) AttrComponentName(val string) attribute.KeyValue {
1687 return attribute.String("otel.component.name", val)
1688 }
1689
1690 // AttrComponentType returns an optional attribute for the "otel.component.type"
1691 // semantic convention. It represents a name identifying the type of the
1692 // OpenTelemetry component.
1693 func (SDKProcessorLogQueueSize) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1694 return attribute.String("otel.component.type", string(val))
1695 }
1696
1697 // SDKProcessorSpanProcessed is an instrument used to record metric values
1698 // conforming to the "otel.sdk.processor.span.processed" semantic conventions. It
1699 // represents the number of spans for which the processing has finished, either
1700 // successful or failed.
1701 type SDKProcessorSpanProcessed struct {
1702 metric.Int64Counter
1703 }
1704
1705 var newSDKProcessorSpanProcessedOpts = []metric.Int64CounterOption{
1706 metric.WithDescription("The number of spans for which the processing has finished, either successful or failed."),
1707 metric.WithUnit("{span}"),
1708 }
1709
1710 // NewSDKProcessorSpanProcessed returns a new SDKProcessorSpanProcessed
1711 // instrument.
1712 func NewSDKProcessorSpanProcessed(
1713 m metric.Meter,
1714 opt ...metric.Int64CounterOption,
1715 ) (SDKProcessorSpanProcessed, error) {
1716 // Check if the meter is nil.
1717 if m == nil {
1718 return SDKProcessorSpanProcessed{noop.Int64Counter{}}, nil
1719 }
1720
1721 if len(opt) == 0 {
1722 opt = newSDKProcessorSpanProcessedOpts
1723 } else {
1724 opt = append(opt, newSDKProcessorSpanProcessedOpts...)
1725 }
1726
1727 i, err := m.Int64Counter(
1728 "otel.sdk.processor.span.processed",
1729 opt...,
1730 )
1731 if err != nil {
1732 return SDKProcessorSpanProcessed{noop.Int64Counter{}}, err
1733 }
1734 return SDKProcessorSpanProcessed{i}, nil
1735 }
1736
1737 // Inst returns the underlying metric instrument.
1738 func (m SDKProcessorSpanProcessed) Inst() metric.Int64Counter {
1739 return m.Int64Counter
1740 }
1741
1742 // Name returns the semantic convention name of the instrument.
1743 func (SDKProcessorSpanProcessed) Name() string {
1744 return "otel.sdk.processor.span.processed"
1745 }
1746
1747 // Unit returns the semantic convention unit of the instrument
1748 func (SDKProcessorSpanProcessed) Unit() string {
1749 return "{span}"
1750 }
1751
1752 // Description returns the semantic convention description of the instrument
1753 func (SDKProcessorSpanProcessed) Description() string {
1754 return "The number of spans for which the processing has finished, either successful or failed."
1755 }
1756
1757 // Add adds incr to the existing count for attrs.
1758 //
1759 // All additional attrs passed are included in the recorded value.
1760 //
1761 // For successful processing, `error.type` MUST NOT be set. For failed
1762 // processing, `error.type` MUST contain the failure cause.
1763 // For the SDK Simple and Batching Span Processor a span is considered to be
1764 // processed already when it has been submitted to the exporter, not when the
1765 // corresponding export call has finished.
1766 func (m SDKProcessorSpanProcessed) Add(
1767 ctx context.Context,
1768 incr int64,
1769 attrs ...attribute.KeyValue,
1770 ) {
1771 if len(attrs) == 0 {
1772 m.Int64Counter.Add(ctx, incr)
1773 return
1774 }
1775
1776 o := addOptPool.Get().(*[]metric.AddOption)
1777 defer func() {
1778 *o = (*o)[:0]
1779 addOptPool.Put(o)
1780 }()
1781
1782 *o = append(
1783 *o,
1784 metric.WithAttributes(
1785 attrs...,
1786 ),
1787 )
1788
1789 m.Int64Counter.Add(ctx, incr, *o...)
1790 }
1791
1792 // AddSet adds incr to the existing count for set.
1793 //
1794 // For successful processing, `error.type` MUST NOT be set. For failed
1795 // processing, `error.type` MUST contain the failure cause.
1796 // For the SDK Simple and Batching Span Processor a span is considered to be
1797 // processed already when it has been submitted to the exporter, not when the
1798 // corresponding export call has finished.
1799 func (m SDKProcessorSpanProcessed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1800 if set.Len() == 0 {
1801 m.Int64Counter.Add(ctx, incr)
1802 return
1803 }
1804
1805 o := addOptPool.Get().(*[]metric.AddOption)
1806 defer func() {
1807 *o = (*o)[:0]
1808 addOptPool.Put(o)
1809 }()
1810
1811 *o = append(*o, metric.WithAttributeSet(set))
1812 m.Int64Counter.Add(ctx, incr, *o...)
1813 }
1814
1815 // AttrErrorType returns an optional attribute for the "error.type" semantic
1816 // convention. It represents a low-cardinality description of the failure reason.
1817 // SDK Batching Span Processors MUST use `queue_full` for spans dropped due to a
1818 // full queue.
1819 func (SDKProcessorSpanProcessed) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
1820 return attribute.String("error.type", string(val))
1821 }
1822
1823 // AttrComponentName returns an optional attribute for the "otel.component.name"
1824 // semantic convention. It represents a name uniquely identifying the instance of
1825 // the OpenTelemetry component within its containing SDK instance.
1826 func (SDKProcessorSpanProcessed) AttrComponentName(val string) attribute.KeyValue {
1827 return attribute.String("otel.component.name", val)
1828 }
1829
1830 // AttrComponentType returns an optional attribute for the "otel.component.type"
1831 // semantic convention. It represents a name identifying the type of the
1832 // OpenTelemetry component.
1833 func (SDKProcessorSpanProcessed) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1834 return attribute.String("otel.component.type", string(val))
1835 }
1836
1837 // SDKProcessorSpanQueueCapacity is an instrument used to record metric values
1838 // conforming to the "otel.sdk.processor.span.queue.capacity" semantic
1839 // conventions. It represents the maximum number of spans the queue of a given
1840 // instance of an SDK span processor can hold.
1841 type SDKProcessorSpanQueueCapacity struct {
1842 metric.Int64ObservableUpDownCounter
1843 }
1844
1845 var newSDKProcessorSpanQueueCapacityOpts = []metric.Int64ObservableUpDownCounterOption{
1846 metric.WithDescription("The maximum number of spans the queue of a given instance of an SDK span processor can hold."),
1847 metric.WithUnit("{span}"),
1848 }
1849
1850 // NewSDKProcessorSpanQueueCapacity returns a new SDKProcessorSpanQueueCapacity
1851 // instrument.
1852 func NewSDKProcessorSpanQueueCapacity(
1853 m metric.Meter,
1854 opt ...metric.Int64ObservableUpDownCounterOption,
1855 ) (SDKProcessorSpanQueueCapacity, error) {
1856 // Check if the meter is nil.
1857 if m == nil {
1858 return SDKProcessorSpanQueueCapacity{noop.Int64ObservableUpDownCounter{}}, nil
1859 }
1860
1861 if len(opt) == 0 {
1862 opt = newSDKProcessorSpanQueueCapacityOpts
1863 } else {
1864 opt = append(opt, newSDKProcessorSpanQueueCapacityOpts...)
1865 }
1866
1867 i, err := m.Int64ObservableUpDownCounter(
1868 "otel.sdk.processor.span.queue.capacity",
1869 opt...,
1870 )
1871 if err != nil {
1872 return SDKProcessorSpanQueueCapacity{noop.Int64ObservableUpDownCounter{}}, err
1873 }
1874 return SDKProcessorSpanQueueCapacity{i}, nil
1875 }
1876
1877 // Inst returns the underlying metric instrument.
1878 func (m SDKProcessorSpanQueueCapacity) Inst() metric.Int64ObservableUpDownCounter {
1879 return m.Int64ObservableUpDownCounter
1880 }
1881
1882 // Name returns the semantic convention name of the instrument.
1883 func (SDKProcessorSpanQueueCapacity) Name() string {
1884 return "otel.sdk.processor.span.queue.capacity"
1885 }
1886
1887 // Unit returns the semantic convention unit of the instrument
1888 func (SDKProcessorSpanQueueCapacity) Unit() string {
1889 return "{span}"
1890 }
1891
1892 // Description returns the semantic convention description of the instrument
1893 func (SDKProcessorSpanQueueCapacity) Description() string {
1894 return "The maximum number of spans the queue of a given instance of an SDK span processor can hold."
1895 }
1896
1897 // AttrComponentName returns an optional attribute for the "otel.component.name"
1898 // semantic convention. It represents a name uniquely identifying the instance of
1899 // the OpenTelemetry component within its containing SDK instance.
1900 func (SDKProcessorSpanQueueCapacity) AttrComponentName(val string) attribute.KeyValue {
1901 return attribute.String("otel.component.name", val)
1902 }
1903
1904 // AttrComponentType returns an optional attribute for the "otel.component.type"
1905 // semantic convention. It represents a name identifying the type of the
1906 // OpenTelemetry component.
1907 func (SDKProcessorSpanQueueCapacity) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1908 return attribute.String("otel.component.type", string(val))
1909 }
1910
1911 // SDKProcessorSpanQueueSize is an instrument used to record metric values
1912 // conforming to the "otel.sdk.processor.span.queue.size" semantic conventions.
1913 // It represents the number of spans in the queue of a given instance of an SDK
1914 // span processor.
1915 type SDKProcessorSpanQueueSize struct {
1916 metric.Int64ObservableUpDownCounter
1917 }
1918
1919 var newSDKProcessorSpanQueueSizeOpts = []metric.Int64ObservableUpDownCounterOption{
1920 metric.WithDescription("The number of spans in the queue of a given instance of an SDK span processor."),
1921 metric.WithUnit("{span}"),
1922 }
1923
1924 // NewSDKProcessorSpanQueueSize returns a new SDKProcessorSpanQueueSize
1925 // instrument.
1926 func NewSDKProcessorSpanQueueSize(
1927 m metric.Meter,
1928 opt ...metric.Int64ObservableUpDownCounterOption,
1929 ) (SDKProcessorSpanQueueSize, error) {
1930 // Check if the meter is nil.
1931 if m == nil {
1932 return SDKProcessorSpanQueueSize{noop.Int64ObservableUpDownCounter{}}, nil
1933 }
1934
1935 if len(opt) == 0 {
1936 opt = newSDKProcessorSpanQueueSizeOpts
1937 } else {
1938 opt = append(opt, newSDKProcessorSpanQueueSizeOpts...)
1939 }
1940
1941 i, err := m.Int64ObservableUpDownCounter(
1942 "otel.sdk.processor.span.queue.size",
1943 opt...,
1944 )
1945 if err != nil {
1946 return SDKProcessorSpanQueueSize{noop.Int64ObservableUpDownCounter{}}, err
1947 }
1948 return SDKProcessorSpanQueueSize{i}, nil
1949 }
1950
1951 // Inst returns the underlying metric instrument.
1952 func (m SDKProcessorSpanQueueSize) Inst() metric.Int64ObservableUpDownCounter {
1953 return m.Int64ObservableUpDownCounter
1954 }
1955
1956 // Name returns the semantic convention name of the instrument.
1957 func (SDKProcessorSpanQueueSize) Name() string {
1958 return "otel.sdk.processor.span.queue.size"
1959 }
1960
1961 // Unit returns the semantic convention unit of the instrument
1962 func (SDKProcessorSpanQueueSize) Unit() string {
1963 return "{span}"
1964 }
1965
1966 // Description returns the semantic convention description of the instrument
1967 func (SDKProcessorSpanQueueSize) Description() string {
1968 return "The number of spans in the queue of a given instance of an SDK span processor."
1969 }
1970
1971 // AttrComponentName returns an optional attribute for the "otel.component.name"
1972 // semantic convention. It represents a name uniquely identifying the instance of
1973 // the OpenTelemetry component within its containing SDK instance.
1974 func (SDKProcessorSpanQueueSize) AttrComponentName(val string) attribute.KeyValue {
1975 return attribute.String("otel.component.name", val)
1976 }
1977
1978 // AttrComponentType returns an optional attribute for the "otel.component.type"
1979 // semantic convention. It represents a name identifying the type of the
1980 // OpenTelemetry component.
1981 func (SDKProcessorSpanQueueSize) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1982 return attribute.String("otel.component.type", string(val))
1983 }
1984
1985 // SDKSpanLive is an instrument used to record metric values conforming to the
1986 // "otel.sdk.span.live" semantic conventions. It represents the number of created
1987 // spans with `recording=true` for which the end operation has not been called
1988 // yet.
1989 type SDKSpanLive struct {
1990 metric.Int64UpDownCounter
1991 }
1992
1993 var newSDKSpanLiveOpts = []metric.Int64UpDownCounterOption{
1994 metric.WithDescription("The number of created spans with `recording=true` for which the end operation has not been called yet."),
1995 metric.WithUnit("{span}"),
1996 }
1997
1998 // NewSDKSpanLive returns a new SDKSpanLive instrument.
1999 func NewSDKSpanLive(
2000 m metric.Meter,
2001 opt ...metric.Int64UpDownCounterOption,
2002 ) (SDKSpanLive, error) {
2003 // Check if the meter is nil.
2004 if m == nil {
2005 return SDKSpanLive{noop.Int64UpDownCounter{}}, nil
2006 }
2007
2008 if len(opt) == 0 {
2009 opt = newSDKSpanLiveOpts
2010 } else {
2011 opt = append(opt, newSDKSpanLiveOpts...)
2012 }
2013
2014 i, err := m.Int64UpDownCounter(
2015 "otel.sdk.span.live",
2016 opt...,
2017 )
2018 if err != nil {
2019 return SDKSpanLive{noop.Int64UpDownCounter{}}, err
2020 }
2021 return SDKSpanLive{i}, nil
2022 }
2023
2024 // Inst returns the underlying metric instrument.
2025 func (m SDKSpanLive) Inst() metric.Int64UpDownCounter {
2026 return m.Int64UpDownCounter
2027 }
2028
2029 // Name returns the semantic convention name of the instrument.
2030 func (SDKSpanLive) Name() string {
2031 return "otel.sdk.span.live"
2032 }
2033
2034 // Unit returns the semantic convention unit of the instrument
2035 func (SDKSpanLive) Unit() string {
2036 return "{span}"
2037 }
2038
2039 // Description returns the semantic convention description of the instrument
2040 func (SDKSpanLive) Description() string {
2041 return "The number of created spans with `recording=true` for which the end operation has not been called yet."
2042 }
2043
2044 // Add adds incr to the existing count for attrs.
2045 //
2046 // All additional attrs passed are included in the recorded value.
2047 func (m SDKSpanLive) Add(
2048 ctx context.Context,
2049 incr int64,
2050 attrs ...attribute.KeyValue,
2051 ) {
2052 if len(attrs) == 0 {
2053 m.Int64UpDownCounter.Add(ctx, incr)
2054 return
2055 }
2056
2057 o := addOptPool.Get().(*[]metric.AddOption)
2058 defer func() {
2059 *o = (*o)[:0]
2060 addOptPool.Put(o)
2061 }()
2062
2063 *o = append(
2064 *o,
2065 metric.WithAttributes(
2066 attrs...,
2067 ),
2068 )
2069
2070 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2071 }
2072
2073 // AddSet adds incr to the existing count for set.
2074 func (m SDKSpanLive) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2075 if set.Len() == 0 {
2076 m.Int64UpDownCounter.Add(ctx, incr)
2077 return
2078 }
2079
2080 o := addOptPool.Get().(*[]metric.AddOption)
2081 defer func() {
2082 *o = (*o)[:0]
2083 addOptPool.Put(o)
2084 }()
2085
2086 *o = append(*o, metric.WithAttributeSet(set))
2087 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2088 }
2089
2090 // AttrSpanSamplingResult returns an optional attribute for the
2091 // "otel.span.sampling_result" semantic convention. It represents the result
2092 // value of the sampler for this span.
2093 func (SDKSpanLive) AttrSpanSamplingResult(val SpanSamplingResultAttr) attribute.KeyValue {
2094 return attribute.String("otel.span.sampling_result", string(val))
2095 }
2096
2097 // SDKSpanStarted is an instrument used to record metric values conforming to the
2098 // "otel.sdk.span.started" semantic conventions. It represents the number of
2099 // created spans.
2100 type SDKSpanStarted struct {
2101 metric.Int64Counter
2102 }
2103
2104 var newSDKSpanStartedOpts = []metric.Int64CounterOption{
2105 metric.WithDescription("The number of created spans."),
2106 metric.WithUnit("{span}"),
2107 }
2108
2109 // NewSDKSpanStarted returns a new SDKSpanStarted instrument.
2110 func NewSDKSpanStarted(
2111 m metric.Meter,
2112 opt ...metric.Int64CounterOption,
2113 ) (SDKSpanStarted, error) {
2114 // Check if the meter is nil.
2115 if m == nil {
2116 return SDKSpanStarted{noop.Int64Counter{}}, nil
2117 }
2118
2119 if len(opt) == 0 {
2120 opt = newSDKSpanStartedOpts
2121 } else {
2122 opt = append(opt, newSDKSpanStartedOpts...)
2123 }
2124
2125 i, err := m.Int64Counter(
2126 "otel.sdk.span.started",
2127 opt...,
2128 )
2129 if err != nil {
2130 return SDKSpanStarted{noop.Int64Counter{}}, err
2131 }
2132 return SDKSpanStarted{i}, nil
2133 }
2134
2135 // Inst returns the underlying metric instrument.
2136 func (m SDKSpanStarted) Inst() metric.Int64Counter {
2137 return m.Int64Counter
2138 }
2139
2140 // Name returns the semantic convention name of the instrument.
2141 func (SDKSpanStarted) Name() string {
2142 return "otel.sdk.span.started"
2143 }
2144
2145 // Unit returns the semantic convention unit of the instrument
2146 func (SDKSpanStarted) Unit() string {
2147 return "{span}"
2148 }
2149
2150 // Description returns the semantic convention description of the instrument
2151 func (SDKSpanStarted) Description() string {
2152 return "The number of created spans."
2153 }
2154
2155 // Add adds incr to the existing count for attrs.
2156 //
2157 // All additional attrs passed are included in the recorded value.
2158 //
2159 // Implementations MUST record this metric for all spans, even for non-recording
2160 // ones.
2161 func (m SDKSpanStarted) Add(
2162 ctx context.Context,
2163 incr int64,
2164 attrs ...attribute.KeyValue,
2165 ) {
2166 if len(attrs) == 0 {
2167 m.Int64Counter.Add(ctx, incr)
2168 return
2169 }
2170
2171 o := addOptPool.Get().(*[]metric.AddOption)
2172 defer func() {
2173 *o = (*o)[:0]
2174 addOptPool.Put(o)
2175 }()
2176
2177 *o = append(
2178 *o,
2179 metric.WithAttributes(
2180 attrs...,
2181 ),
2182 )
2183
2184 m.Int64Counter.Add(ctx, incr, *o...)
2185 }
2186
2187 // AddSet adds incr to the existing count for set.
2188 //
2189 // Implementations MUST record this metric for all spans, even for non-recording
2190 // ones.
2191 func (m SDKSpanStarted) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2192 if set.Len() == 0 {
2193 m.Int64Counter.Add(ctx, incr)
2194 return
2195 }
2196
2197 o := addOptPool.Get().(*[]metric.AddOption)
2198 defer func() {
2199 *o = (*o)[:0]
2200 addOptPool.Put(o)
2201 }()
2202
2203 *o = append(*o, metric.WithAttributeSet(set))
2204 m.Int64Counter.Add(ctx, incr, *o...)
2205 }
2206
2207 // AttrSpanParentOrigin returns an optional attribute for the
2208 // "otel.span.parent.origin" semantic convention. It represents the determines
2209 // whether the span has a parent span, and if so, [whether it is a remote parent]
2210 // .
2211 //
2212 // [whether it is a remote parent]: https://opentelemetry.io/docs/specs/otel/trace/api/#isremote
2213 func (SDKSpanStarted) AttrSpanParentOrigin(val SpanParentOriginAttr) attribute.KeyValue {
2214 return attribute.String("otel.span.parent.origin", string(val))
2215 }
2216
2217 // AttrSpanSamplingResult returns an optional attribute for the
2218 // "otel.span.sampling_result" semantic convention. It represents the result
2219 // value of the sampler for this span.
2220 func (SDKSpanStarted) AttrSpanSamplingResult(val SpanSamplingResultAttr) attribute.KeyValue {
2221 return attribute.String("otel.span.sampling_result", string(val))
2222 }