Debian Codegraph @

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