Debian Codegraph @

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