Debian Codegraph @

semconv/v1.32.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 LogRecord
47 // Processor.
48 ComponentTypeBatchingLogProcessor ComponentTypeAttr = "batching_log_processor"
49 // ComponentTypeSimpleLogProcessor is the builtin SDK Simple LogRecord
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 LogRecord exporter over gRPC
62 // with protobuf serialization.
63 ComponentTypeOtlpGRPCLogExporter ComponentTypeAttr = "otlp_grpc_log_exporter"
64 // ComponentTypeOtlpHTTPLogExporter is the OTLP LogRecord exporter over HTTP
65 // with protobuf serialization.
66 ComponentTypeOtlpHTTPLogExporter ComponentTypeAttr = "otlp_http_log_exporter"
67 // ComponentTypeOtlpHTTPJSONLogExporter is the OTLP LogRecord exporter over HTTP
68 // with JSON serialization.
69 ComponentTypeOtlpHTTPJSONLogExporter ComponentTypeAttr = "otlp_http_json_log_exporter"
70 )
71
72 // SpanSamplingResultAttr is an attribute conforming to the
73 // otel.span.sampling_result semantic conventions. It represents the result value
74 // of the sampler for this span.
75 type SpanSamplingResultAttr string
76
77 var (
78 // SpanSamplingResultDrop is the span is not sampled and not recording.
79 SpanSamplingResultDrop SpanSamplingResultAttr = "DROP"
80 // SpanSamplingResultRecordOnly is the span is not sampled, but recording.
81 SpanSamplingResultRecordOnly SpanSamplingResultAttr = "RECORD_ONLY"
82 // SpanSamplingResultRecordAndSample is the span is sampled and recording.
83 SpanSamplingResultRecordAndSample SpanSamplingResultAttr = "RECORD_AND_SAMPLE"
84 )
85
86 // SDKExporterLogExported is an instrument used to record metric values
87 // conforming to the "otel.sdk.exporter.log.exported" semantic conventions. It
88 // represents the number of log records for which the export has finished, either
89 // successful or failed.
90 type SDKExporterLogExported struct {
91 metric.Int64Counter
92 }
93
94 // NewSDKExporterLogExported returns a new SDKExporterLogExported instrument.
95 func NewSDKExporterLogExported(
96 m metric.Meter,
97 opt ...metric.Int64CounterOption,
98 ) (SDKExporterLogExported, error) {
99 // Check if the meter is nil.
100 if m == nil {
101 return SDKExporterLogExported{noop.Int64Counter{}}, nil
102 }
103
104 i, err := m.Int64Counter(
105 "otel.sdk.exporter.log.exported",
106 append([]metric.Int64CounterOption{
107 metric.WithDescription("The number of log records for which the export has finished, either successful or failed"),
108 metric.WithUnit("{log_record}"),
109 }, opt...)...,
110 )
111 if err != nil {
112 return SDKExporterLogExported{noop.Int64Counter{}}, err
113 }
114 return SDKExporterLogExported{i}, nil
115 }
116
117 // Inst returns the underlying metric instrument.
118 func (m SDKExporterLogExported) Inst() metric.Int64Counter {
119 return m.Int64Counter
120 }
121
122 // Name returns the semantic convention name of the instrument.
123 func (SDKExporterLogExported) Name() string {
124 return "otel.sdk.exporter.log.exported"
125 }
126
127 // Unit returns the semantic convention unit of the instrument
128 func (SDKExporterLogExported) Unit() string {
129 return "{log_record}"
130 }
131
132 // Description returns the semantic convention description of the instrument
133 func (SDKExporterLogExported) Description() string {
134 return "The number of log records for which the export has finished, either successful or failed"
135 }
136
137 // Add adds incr to the existing count.
138 //
139 // All additional attrs passed are included in the recorded value.
140 //
141 // For successful exports, `error.type` MUST NOT be set. For failed exports,
142 // `error.type` must contain the failure cause.
143 // For exporters with partial success semantics (e.g. OTLP with
144 // `rejected_log_records`), rejected log records must count as failed and only
145 // non-rejected log records count as success.
146 // If no rejection reason is available, `rejected` SHOULD be used as value for
147 // `error.type`.
148 func (m SDKExporterLogExported) Add(
149 ctx context.Context,
150 incr int64,
151 attrs ...attribute.KeyValue,
152 ) {
153 o := addOptPool.Get().(*[]metric.AddOption)
154 defer func() {
155 *o = (*o)[:0]
156 addOptPool.Put(o)
157 }()
158
159 *o = append(
160 *o,
161 metric.WithAttributes(
162 attrs...,
163 ),
164 )
165
166 m.Int64Counter.Add(ctx, incr, *o...)
167 }
168
169 // AttrErrorType returns an optional attribute for the "error.type" semantic
170 // convention. It represents the describes a class of error the operation ended
171 // with.
172 func (SDKExporterLogExported) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
173 return attribute.String("error.type", string(val))
174 }
175
176 // AttrComponentName returns an optional attribute for the "otel.component.name"
177 // semantic convention. It represents a name uniquely identifying the instance of
178 // the OpenTelemetry component within its containing SDK instance.
179 func (SDKExporterLogExported) AttrComponentName(val string) attribute.KeyValue {
180 return attribute.String("otel.component.name", val)
181 }
182
183 // AttrComponentType returns an optional attribute for the "otel.component.type"
184 // semantic convention. It represents a name identifying the type of the
185 // OpenTelemetry component.
186 func (SDKExporterLogExported) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
187 return attribute.String("otel.component.type", string(val))
188 }
189
190 // AttrServerAddress returns an optional attribute for the "server.address"
191 // semantic convention. It represents the server domain name if available without
192 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
193 func (SDKExporterLogExported) AttrServerAddress(val string) attribute.KeyValue {
194 return attribute.String("server.address", val)
195 }
196
197 // AttrServerPort returns an optional attribute for the "server.port" semantic
198 // convention. It represents the server port number.
199 func (SDKExporterLogExported) AttrServerPort(val int) attribute.KeyValue {
200 return attribute.Int("server.port", val)
201 }
202
203 // SDKExporterLogInflight is an instrument used to record metric values
204 // conforming to the "otel.sdk.exporter.log.inflight" semantic conventions. It
205 // represents the number of log records which were passed to the exporter, but
206 // that have not been exported yet (neither successful, nor failed).
207 type SDKExporterLogInflight struct {
208 metric.Int64UpDownCounter
209 }
210
211 // NewSDKExporterLogInflight returns a new SDKExporterLogInflight instrument.
212 func NewSDKExporterLogInflight(
213 m metric.Meter,
214 opt ...metric.Int64UpDownCounterOption,
215 ) (SDKExporterLogInflight, error) {
216 // Check if the meter is nil.
217 if m == nil {
218 return SDKExporterLogInflight{noop.Int64UpDownCounter{}}, nil
219 }
220
221 i, err := m.Int64UpDownCounter(
222 "otel.sdk.exporter.log.inflight",
223 append([]metric.Int64UpDownCounterOption{
224 metric.WithDescription("The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)"),
225 metric.WithUnit("{log_record}"),
226 }, opt...)...,
227 )
228 if err != nil {
229 return SDKExporterLogInflight{noop.Int64UpDownCounter{}}, err
230 }
231 return SDKExporterLogInflight{i}, nil
232 }
233
234 // Inst returns the underlying metric instrument.
235 func (m SDKExporterLogInflight) Inst() metric.Int64UpDownCounter {
236 return m.Int64UpDownCounter
237 }
238
239 // Name returns the semantic convention name of the instrument.
240 func (SDKExporterLogInflight) Name() string {
241 return "otel.sdk.exporter.log.inflight"
242 }
243
244 // Unit returns the semantic convention unit of the instrument
245 func (SDKExporterLogInflight) Unit() string {
246 return "{log_record}"
247 }
248
249 // Description returns the semantic convention description of the instrument
250 func (SDKExporterLogInflight) Description() string {
251 return "The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)"
252 }
253
254 // Add adds incr to the existing count.
255 //
256 // All additional attrs passed are included in the recorded value.
257 //
258 // For successful exports, `error.type` MUST NOT be set. For failed exports,
259 // `error.type` must contain the failure cause.
260 func (m SDKExporterLogInflight) Add(
261 ctx context.Context,
262 incr int64,
263 attrs ...attribute.KeyValue,
264 ) {
265 o := addOptPool.Get().(*[]metric.AddOption)
266 defer func() {
267 *o = (*o)[:0]
268 addOptPool.Put(o)
269 }()
270
271 *o = append(
272 *o,
273 metric.WithAttributes(
274 attrs...,
275 ),
276 )
277
278 m.Int64UpDownCounter.Add(ctx, incr, *o...)
279 }
280
281 // AttrComponentName returns an optional attribute for the "otel.component.name"
282 // semantic convention. It represents a name uniquely identifying the instance of
283 // the OpenTelemetry component within its containing SDK instance.
284 func (SDKExporterLogInflight) AttrComponentName(val string) attribute.KeyValue {
285 return attribute.String("otel.component.name", val)
286 }
287
288 // AttrComponentType returns an optional attribute for the "otel.component.type"
289 // semantic convention. It represents a name identifying the type of the
290 // OpenTelemetry component.
291 func (SDKExporterLogInflight) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
292 return attribute.String("otel.component.type", string(val))
293 }
294
295 // AttrServerAddress returns an optional attribute for the "server.address"
296 // semantic convention. It represents the server domain name if available without
297 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
298 func (SDKExporterLogInflight) AttrServerAddress(val string) attribute.KeyValue {
299 return attribute.String("server.address", val)
300 }
301
302 // AttrServerPort returns an optional attribute for the "server.port" semantic
303 // convention. It represents the server port number.
304 func (SDKExporterLogInflight) AttrServerPort(val int) attribute.KeyValue {
305 return attribute.Int("server.port", val)
306 }
307
308 // SDKExporterSpanExportedCount is an instrument used to record metric values
309 // conforming to the "otel.sdk.exporter.span.exported.count" semantic
310 // conventions. It represents the number of spans for which the export has
311 // finished, either successful or failed.
312 type SDKExporterSpanExportedCount struct {
313 metric.Int64Counter
314 }
315
316 // NewSDKExporterSpanExportedCount returns a new SDKExporterSpanExportedCount
317 // instrument.
318 func NewSDKExporterSpanExportedCount(
319 m metric.Meter,
320 opt ...metric.Int64CounterOption,
321 ) (SDKExporterSpanExportedCount, error) {
322 // Check if the meter is nil.
323 if m == nil {
324 return SDKExporterSpanExportedCount{noop.Int64Counter{}}, nil
325 }
326
327 i, err := m.Int64Counter(
328 "otel.sdk.exporter.span.exported.count",
329 append([]metric.Int64CounterOption{
330 metric.WithDescription("The number of spans for which the export has finished, either successful or failed"),
331 metric.WithUnit("{span}"),
332 }, opt...)...,
333 )
334 if err != nil {
335 return SDKExporterSpanExportedCount{noop.Int64Counter{}}, err
336 }
337 return SDKExporterSpanExportedCount{i}, nil
338 }
339
340 // Inst returns the underlying metric instrument.
341 func (m SDKExporterSpanExportedCount) Inst() metric.Int64Counter {
342 return m.Int64Counter
343 }
344
345 // Name returns the semantic convention name of the instrument.
346 func (SDKExporterSpanExportedCount) Name() string {
347 return "otel.sdk.exporter.span.exported.count"
348 }
349
350 // Unit returns the semantic convention unit of the instrument
351 func (SDKExporterSpanExportedCount) Unit() string {
352 return "{span}"
353 }
354
355 // Description returns the semantic convention description of the instrument
356 func (SDKExporterSpanExportedCount) Description() string {
357 return "The number of spans for which the export has finished, either successful or failed"
358 }
359
360 // Add adds incr to the existing count.
361 //
362 // All additional attrs passed are included in the recorded value.
363 //
364 // For successful exports, `error.type` MUST NOT be set. For failed exports,
365 // `error.type` must contain the failure cause.
366 // For exporters with partial success semantics (e.g. OTLP with `rejected_spans`
367 // ), rejected spans must count as failed and only non-rejected spans count as
368 // success.
369 // If no rejection reason is available, `rejected` SHOULD be used as value for
370 // `error.type`.
371 func (m SDKExporterSpanExportedCount) Add(
372 ctx context.Context,
373 incr int64,
374 attrs ...attribute.KeyValue,
375 ) {
376 o := addOptPool.Get().(*[]metric.AddOption)
377 defer func() {
378 *o = (*o)[:0]
379 addOptPool.Put(o)
380 }()
381
382 *o = append(
383 *o,
384 metric.WithAttributes(
385 attrs...,
386 ),
387 )
388
389 m.Int64Counter.Add(ctx, incr, *o...)
390 }
391
392 // AttrErrorType returns an optional attribute for the "error.type" semantic
393 // convention. It represents the describes a class of error the operation ended
394 // with.
395 func (SDKExporterSpanExportedCount) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
396 return attribute.String("error.type", string(val))
397 }
398
399 // AttrComponentName returns an optional attribute for the "otel.component.name"
400 // semantic convention. It represents a name uniquely identifying the instance of
401 // the OpenTelemetry component within its containing SDK instance.
402 func (SDKExporterSpanExportedCount) AttrComponentName(val string) attribute.KeyValue {
403 return attribute.String("otel.component.name", val)
404 }
405
406 // AttrComponentType returns an optional attribute for the "otel.component.type"
407 // semantic convention. It represents a name identifying the type of the
408 // OpenTelemetry component.
409 func (SDKExporterSpanExportedCount) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
410 return attribute.String("otel.component.type", string(val))
411 }
412
413 // AttrServerAddress returns an optional attribute for the "server.address"
414 // semantic convention. It represents the server domain name if available without
415 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
416 func (SDKExporterSpanExportedCount) AttrServerAddress(val string) attribute.KeyValue {
417 return attribute.String("server.address", val)
418 }
419
420 // AttrServerPort returns an optional attribute for the "server.port" semantic
421 // convention. It represents the server port number.
422 func (SDKExporterSpanExportedCount) AttrServerPort(val int) attribute.KeyValue {
423 return attribute.Int("server.port", val)
424 }
425
426 // SDKExporterSpanInflightCount is an instrument used to record metric values
427 // conforming to the "otel.sdk.exporter.span.inflight.count" semantic
428 // conventions. It represents the number of spans which were passed to the
429 // exporter, but that have not been exported yet (neither successful, nor
430 // failed).
431 type SDKExporterSpanInflightCount struct {
432 metric.Int64UpDownCounter
433 }
434
435 // NewSDKExporterSpanInflightCount returns a new SDKExporterSpanInflightCount
436 // instrument.
437 func NewSDKExporterSpanInflightCount(
438 m metric.Meter,
439 opt ...metric.Int64UpDownCounterOption,
440 ) (SDKExporterSpanInflightCount, error) {
441 // Check if the meter is nil.
442 if m == nil {
443 return SDKExporterSpanInflightCount{noop.Int64UpDownCounter{}}, nil
444 }
445
446 i, err := m.Int64UpDownCounter(
447 "otel.sdk.exporter.span.inflight.count",
448 append([]metric.Int64UpDownCounterOption{
449 metric.WithDescription("The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)"),
450 metric.WithUnit("{span}"),
451 }, opt...)...,
452 )
453 if err != nil {
454 return SDKExporterSpanInflightCount{noop.Int64UpDownCounter{}}, err
455 }
456 return SDKExporterSpanInflightCount{i}, nil
457 }
458
459 // Inst returns the underlying metric instrument.
460 func (m SDKExporterSpanInflightCount) Inst() metric.Int64UpDownCounter {
461 return m.Int64UpDownCounter
462 }
463
464 // Name returns the semantic convention name of the instrument.
465 func (SDKExporterSpanInflightCount) Name() string {
466 return "otel.sdk.exporter.span.inflight.count"
467 }
468
469 // Unit returns the semantic convention unit of the instrument
470 func (SDKExporterSpanInflightCount) Unit() string {
471 return "{span}"
472 }
473
474 // Description returns the semantic convention description of the instrument
475 func (SDKExporterSpanInflightCount) Description() string {
476 return "The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)"
477 }
478
479 // Add adds incr to the existing count.
480 //
481 // All additional attrs passed are included in the recorded value.
482 //
483 // For successful exports, `error.type` MUST NOT be set. For failed exports,
484 // `error.type` must contain the failure cause.
485 func (m SDKExporterSpanInflightCount) Add(
486 ctx context.Context,
487 incr int64,
488 attrs ...attribute.KeyValue,
489 ) {
490 o := addOptPool.Get().(*[]metric.AddOption)
491 defer func() {
492 *o = (*o)[:0]
493 addOptPool.Put(o)
494 }()
495
496 *o = append(
497 *o,
498 metric.WithAttributes(
499 attrs...,
500 ),
501 )
502
503 m.Int64UpDownCounter.Add(ctx, incr, *o...)
504 }
505
506 // AttrComponentName returns an optional attribute for the "otel.component.name"
507 // semantic convention. It represents a name uniquely identifying the instance of
508 // the OpenTelemetry component within its containing SDK instance.
509 func (SDKExporterSpanInflightCount) AttrComponentName(val string) attribute.KeyValue {
510 return attribute.String("otel.component.name", val)
511 }
512
513 // AttrComponentType returns an optional attribute for the "otel.component.type"
514 // semantic convention. It represents a name identifying the type of the
515 // OpenTelemetry component.
516 func (SDKExporterSpanInflightCount) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
517 return attribute.String("otel.component.type", string(val))
518 }
519
520 // AttrServerAddress returns an optional attribute for the "server.address"
521 // semantic convention. It represents the server domain name if available without
522 // reverse DNS lookup; otherwise, IP address or Unix domain socket name.
523 func (SDKExporterSpanInflightCount) AttrServerAddress(val string) attribute.KeyValue {
524 return attribute.String("server.address", val)
525 }
526
527 // AttrServerPort returns an optional attribute for the "server.port" semantic
528 // convention. It represents the server port number.
529 func (SDKExporterSpanInflightCount) AttrServerPort(val int) attribute.KeyValue {
530 return attribute.Int("server.port", val)
531 }
532
533 // SDKLogCreated is an instrument used to record metric values conforming to the
534 // "otel.sdk.log.created" semantic conventions. It represents the number of logs
535 // submitted to enabled SDK Loggers.
536 type SDKLogCreated struct {
537 metric.Int64Counter
538 }
539
540 // NewSDKLogCreated returns a new SDKLogCreated instrument.
541 func NewSDKLogCreated(
542 m metric.Meter,
543 opt ...metric.Int64CounterOption,
544 ) (SDKLogCreated, error) {
545 // Check if the meter is nil.
546 if m == nil {
547 return SDKLogCreated{noop.Int64Counter{}}, nil
548 }
549
550 i, err := m.Int64Counter(
551 "otel.sdk.log.created",
552 append([]metric.Int64CounterOption{
553 metric.WithDescription("The number of logs submitted to enabled SDK Loggers"),
554 metric.WithUnit("{log_record}"),
555 }, opt...)...,
556 )
557 if err != nil {
558 return SDKLogCreated{noop.Int64Counter{}}, err
559 }
560 return SDKLogCreated{i}, nil
561 }
562
563 // Inst returns the underlying metric instrument.
564 func (m SDKLogCreated) Inst() metric.Int64Counter {
565 return m.Int64Counter
566 }
567
568 // Name returns the semantic convention name of the instrument.
569 func (SDKLogCreated) Name() string {
570 return "otel.sdk.log.created"
571 }
572
573 // Unit returns the semantic convention unit of the instrument
574 func (SDKLogCreated) Unit() string {
575 return "{log_record}"
576 }
577
578 // Description returns the semantic convention description of the instrument
579 func (SDKLogCreated) Description() string {
580 return "The number of logs submitted to enabled SDK Loggers"
581 }
582
583 // Add adds incr to the existing count.
584 func (m SDKLogCreated) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
585 if len(attrs) == 0 {
586 m.Int64Counter.Add(ctx, incr)
587 return
588 }
589
590 o := addOptPool.Get().(*[]metric.AddOption)
591 defer func() {
592 *o = (*o)[:0]
593 addOptPool.Put(o)
594 }()
595
596 *o = append(*o, metric.WithAttributes(attrs...))
597 m.Int64Counter.Add(ctx, incr, *o...)
598 }
599
600 // SDKProcessorLogProcessed is an instrument used to record metric values
601 // conforming to the "otel.sdk.processor.log.processed" semantic conventions. It
602 // represents the number of log records for which the processing has finished,
603 // either successful or failed.
604 type SDKProcessorLogProcessed struct {
605 metric.Int64Counter
606 }
607
608 // NewSDKProcessorLogProcessed returns a new SDKProcessorLogProcessed instrument.
609 func NewSDKProcessorLogProcessed(
610 m metric.Meter,
611 opt ...metric.Int64CounterOption,
612 ) (SDKProcessorLogProcessed, error) {
613 // Check if the meter is nil.
614 if m == nil {
615 return SDKProcessorLogProcessed{noop.Int64Counter{}}, nil
616 }
617
618 i, err := m.Int64Counter(
619 "otel.sdk.processor.log.processed",
620 append([]metric.Int64CounterOption{
621 metric.WithDescription("The number of log records for which the processing has finished, either successful or failed"),
622 metric.WithUnit("{log_record}"),
623 }, opt...)...,
624 )
625 if err != nil {
626 return SDKProcessorLogProcessed{noop.Int64Counter{}}, err
627 }
628 return SDKProcessorLogProcessed{i}, nil
629 }
630
631 // Inst returns the underlying metric instrument.
632 func (m SDKProcessorLogProcessed) Inst() metric.Int64Counter {
633 return m.Int64Counter
634 }
635
636 // Name returns the semantic convention name of the instrument.
637 func (SDKProcessorLogProcessed) Name() string {
638 return "otel.sdk.processor.log.processed"
639 }
640
641 // Unit returns the semantic convention unit of the instrument
642 func (SDKProcessorLogProcessed) Unit() string {
643 return "{log_record}"
644 }
645
646 // Description returns the semantic convention description of the instrument
647 func (SDKProcessorLogProcessed) Description() string {
648 return "The number of log records for which the processing has finished, either successful or failed"
649 }
650
651 // Add adds incr to the existing count.
652 //
653 // All additional attrs passed are included in the recorded value.
654 //
655 // For successful processing, `error.type` MUST NOT be set. For failed
656 // processing, `error.type` must contain the failure cause.
657 // For the SDK Simple and Batching Log Record Processor a log record is
658 // considered to be processed already when it has been submitted to the exporter,
659 // not when the corresponding export call has finished.
660 func (m SDKProcessorLogProcessed) Add(
661 ctx context.Context,
662 incr int64,
663 attrs ...attribute.KeyValue,
664 ) {
665 o := addOptPool.Get().(*[]metric.AddOption)
666 defer func() {
667 *o = (*o)[:0]
668 addOptPool.Put(o)
669 }()
670
671 *o = append(
672 *o,
673 metric.WithAttributes(
674 attrs...,
675 ),
676 )
677
678 m.Int64Counter.Add(ctx, incr, *o...)
679 }
680
681 // AttrErrorType returns an optional attribute for the "error.type" semantic
682 // convention. It represents a low-cardinality description of the failure reason.
683 // SDK Batching Log Record Processors MUST use `queue_full` for log records
684 // dropped due to a full queue.
685 func (SDKProcessorLogProcessed) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
686 return attribute.String("error.type", string(val))
687 }
688
689 // AttrComponentName returns an optional attribute for the "otel.component.name"
690 // semantic convention. It represents a name uniquely identifying the instance of
691 // the OpenTelemetry component within its containing SDK instance.
692 func (SDKProcessorLogProcessed) AttrComponentName(val string) attribute.KeyValue {
693 return attribute.String("otel.component.name", val)
694 }
695
696 // AttrComponentType returns an optional attribute for the "otel.component.type"
697 // semantic convention. It represents a name identifying the type of the
698 // OpenTelemetry component.
699 func (SDKProcessorLogProcessed) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
700 return attribute.String("otel.component.type", string(val))
701 }
702
703 // SDKProcessorLogQueueCapacity is an instrument used to record metric values
704 // conforming to the "otel.sdk.processor.log.queue.capacity" semantic
705 // conventions. It represents the maximum number of log records the queue of a
706 // given instance of an SDK Log Record processor can hold.
707 type SDKProcessorLogQueueCapacity struct {
708 metric.Int64UpDownCounter
709 }
710
711 // NewSDKProcessorLogQueueCapacity returns a new SDKProcessorLogQueueCapacity
712 // instrument.
713 func NewSDKProcessorLogQueueCapacity(
714 m metric.Meter,
715 opt ...metric.Int64UpDownCounterOption,
716 ) (SDKProcessorLogQueueCapacity, error) {
717 // Check if the meter is nil.
718 if m == nil {
719 return SDKProcessorLogQueueCapacity{noop.Int64UpDownCounter{}}, nil
720 }
721
722 i, err := m.Int64UpDownCounter(
723 "otel.sdk.processor.log.queue.capacity",
724 append([]metric.Int64UpDownCounterOption{
725 metric.WithDescription("The maximum number of log records the queue of a given instance of an SDK Log Record processor can hold"),
726 metric.WithUnit("{log_record}"),
727 }, opt...)...,
728 )
729 if err != nil {
730 return SDKProcessorLogQueueCapacity{noop.Int64UpDownCounter{}}, err
731 }
732 return SDKProcessorLogQueueCapacity{i}, nil
733 }
734
735 // Inst returns the underlying metric instrument.
736 func (m SDKProcessorLogQueueCapacity) Inst() metric.Int64UpDownCounter {
737 return m.Int64UpDownCounter
738 }
739
740 // Name returns the semantic convention name of the instrument.
741 func (SDKProcessorLogQueueCapacity) Name() string {
742 return "otel.sdk.processor.log.queue.capacity"
743 }
744
745 // Unit returns the semantic convention unit of the instrument
746 func (SDKProcessorLogQueueCapacity) Unit() string {
747 return "{log_record}"
748 }
749
750 // Description returns the semantic convention description of the instrument
751 func (SDKProcessorLogQueueCapacity) Description() string {
752 return "The maximum number of log records the queue of a given instance of an SDK Log Record processor can hold"
753 }
754
755 // Add adds incr to the existing count.
756 //
757 // All additional attrs passed are included in the recorded value.
758 //
759 // Only applies to Log Record processors which use a queue, e.g. the SDK Batching
760 // Log Record Processor.
761 func (m SDKProcessorLogQueueCapacity) Add(
762 ctx context.Context,
763 incr int64,
764 attrs ...attribute.KeyValue,
765 ) {
766 o := addOptPool.Get().(*[]metric.AddOption)
767 defer func() {
768 *o = (*o)[:0]
769 addOptPool.Put(o)
770 }()
771
772 *o = append(
773 *o,
774 metric.WithAttributes(
775 attrs...,
776 ),
777 )
778
779 m.Int64UpDownCounter.Add(ctx, incr, *o...)
780 }
781
782 // AttrComponentName returns an optional attribute for the "otel.component.name"
783 // semantic convention. It represents a name uniquely identifying the instance of
784 // the OpenTelemetry component within its containing SDK instance.
785 func (SDKProcessorLogQueueCapacity) AttrComponentName(val string) attribute.KeyValue {
786 return attribute.String("otel.component.name", val)
787 }
788
789 // AttrComponentType returns an optional attribute for the "otel.component.type"
790 // semantic convention. It represents a name identifying the type of the
791 // OpenTelemetry component.
792 func (SDKProcessorLogQueueCapacity) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
793 return attribute.String("otel.component.type", string(val))
794 }
795
796 // SDKProcessorLogQueueSize is an instrument used to record metric values
797 // conforming to the "otel.sdk.processor.log.queue.size" semantic conventions. It
798 // represents the number of log records in the queue of a given instance of an
799 // SDK log processor.
800 type SDKProcessorLogQueueSize struct {
801 metric.Int64UpDownCounter
802 }
803
804 // NewSDKProcessorLogQueueSize returns a new SDKProcessorLogQueueSize instrument.
805 func NewSDKProcessorLogQueueSize(
806 m metric.Meter,
807 opt ...metric.Int64UpDownCounterOption,
808 ) (SDKProcessorLogQueueSize, error) {
809 // Check if the meter is nil.
810 if m == nil {
811 return SDKProcessorLogQueueSize{noop.Int64UpDownCounter{}}, nil
812 }
813
814 i, err := m.Int64UpDownCounter(
815 "otel.sdk.processor.log.queue.size",
816 append([]metric.Int64UpDownCounterOption{
817 metric.WithDescription("The number of log records in the queue of a given instance of an SDK log processor"),
818 metric.WithUnit("{log_record}"),
819 }, opt...)...,
820 )
821 if err != nil {
822 return SDKProcessorLogQueueSize{noop.Int64UpDownCounter{}}, err
823 }
824 return SDKProcessorLogQueueSize{i}, nil
825 }
826
827 // Inst returns the underlying metric instrument.
828 func (m SDKProcessorLogQueueSize) Inst() metric.Int64UpDownCounter {
829 return m.Int64UpDownCounter
830 }
831
832 // Name returns the semantic convention name of the instrument.
833 func (SDKProcessorLogQueueSize) Name() string {
834 return "otel.sdk.processor.log.queue.size"
835 }
836
837 // Unit returns the semantic convention unit of the instrument
838 func (SDKProcessorLogQueueSize) Unit() string {
839 return "{log_record}"
840 }
841
842 // Description returns the semantic convention description of the instrument
843 func (SDKProcessorLogQueueSize) Description() string {
844 return "The number of log records in the queue of a given instance of an SDK log processor"
845 }
846
847 // Add adds incr to the existing count.
848 //
849 // All additional attrs passed are included in the recorded value.
850 //
851 // Only applies to log record processors which use a queue, e.g. the SDK Batching
852 // Log Record Processor.
853 func (m SDKProcessorLogQueueSize) Add(
854 ctx context.Context,
855 incr int64,
856 attrs ...attribute.KeyValue,
857 ) {
858 o := addOptPool.Get().(*[]metric.AddOption)
859 defer func() {
860 *o = (*o)[:0]
861 addOptPool.Put(o)
862 }()
863
864 *o = append(
865 *o,
866 metric.WithAttributes(
867 attrs...,
868 ),
869 )
870
871 m.Int64UpDownCounter.Add(ctx, incr, *o...)
872 }
873
874 // AttrComponentName returns an optional attribute for the "otel.component.name"
875 // semantic convention. It represents a name uniquely identifying the instance of
876 // the OpenTelemetry component within its containing SDK instance.
877 func (SDKProcessorLogQueueSize) AttrComponentName(val string) attribute.KeyValue {
878 return attribute.String("otel.component.name", val)
879 }
880
881 // AttrComponentType returns an optional attribute for the "otel.component.type"
882 // semantic convention. It represents a name identifying the type of the
883 // OpenTelemetry component.
884 func (SDKProcessorLogQueueSize) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
885 return attribute.String("otel.component.type", string(val))
886 }
887
888 // SDKProcessorSpanProcessedCount is an instrument used to record metric values
889 // conforming to the "otel.sdk.processor.span.processed.count" semantic
890 // conventions. It represents the number of spans for which the processing has
891 // finished, either successful or failed.
892 type SDKProcessorSpanProcessedCount struct {
893 metric.Int64Counter
894 }
895
896 // NewSDKProcessorSpanProcessedCount returns a new SDKProcessorSpanProcessedCount
897 // instrument.
898 func NewSDKProcessorSpanProcessedCount(
899 m metric.Meter,
900 opt ...metric.Int64CounterOption,
901 ) (SDKProcessorSpanProcessedCount, error) {
902 // Check if the meter is nil.
903 if m == nil {
904 return SDKProcessorSpanProcessedCount{noop.Int64Counter{}}, nil
905 }
906
907 i, err := m.Int64Counter(
908 "otel.sdk.processor.span.processed.count",
909 append([]metric.Int64CounterOption{
910 metric.WithDescription("The number of spans for which the processing has finished, either successful or failed"),
911 metric.WithUnit("{span}"),
912 }, opt...)...,
913 )
914 if err != nil {
915 return SDKProcessorSpanProcessedCount{noop.Int64Counter{}}, err
916 }
917 return SDKProcessorSpanProcessedCount{i}, nil
918 }
919
920 // Inst returns the underlying metric instrument.
921 func (m SDKProcessorSpanProcessedCount) Inst() metric.Int64Counter {
922 return m.Int64Counter
923 }
924
925 // Name returns the semantic convention name of the instrument.
926 func (SDKProcessorSpanProcessedCount) Name() string {
927 return "otel.sdk.processor.span.processed.count"
928 }
929
930 // Unit returns the semantic convention unit of the instrument
931 func (SDKProcessorSpanProcessedCount) Unit() string {
932 return "{span}"
933 }
934
935 // Description returns the semantic convention description of the instrument
936 func (SDKProcessorSpanProcessedCount) Description() string {
937 return "The number of spans for which the processing has finished, either successful or failed"
938 }
939
940 // Add adds incr to the existing count.
941 //
942 // All additional attrs passed are included in the recorded value.
943 //
944 // For successful processing, `error.type` MUST NOT be set. For failed
945 // processing, `error.type` must contain the failure cause.
946 // For the SDK Simple and Batching Span Processor a span is considered to be
947 // processed already when it has been submitted to the exporter, not when the
948 // corresponding export call has finished.
949 func (m SDKProcessorSpanProcessedCount) Add(
950 ctx context.Context,
951 incr int64,
952 attrs ...attribute.KeyValue,
953 ) {
954 o := addOptPool.Get().(*[]metric.AddOption)
955 defer func() {
956 *o = (*o)[:0]
957 addOptPool.Put(o)
958 }()
959
960 *o = append(
961 *o,
962 metric.WithAttributes(
963 attrs...,
964 ),
965 )
966
967 m.Int64Counter.Add(ctx, incr, *o...)
968 }
969
970 // AttrErrorType returns an optional attribute for the "error.type" semantic
971 // convention. It represents a low-cardinality description of the failure reason.
972 // SDK Batching Span Processors MUST use `queue_full` for spans dropped due to a
973 // full queue.
974 func (SDKProcessorSpanProcessedCount) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
975 return attribute.String("error.type", string(val))
976 }
977
978 // AttrComponentName returns an optional attribute for the "otel.component.name"
979 // semantic convention. It represents a name uniquely identifying the instance of
980 // the OpenTelemetry component within its containing SDK instance.
981 func (SDKProcessorSpanProcessedCount) AttrComponentName(val string) attribute.KeyValue {
982 return attribute.String("otel.component.name", val)
983 }
984
985 // AttrComponentType returns an optional attribute for the "otel.component.type"
986 // semantic convention. It represents a name identifying the type of the
987 // OpenTelemetry component.
988 func (SDKProcessorSpanProcessedCount) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
989 return attribute.String("otel.component.type", string(val))
990 }
991
992 // SDKProcessorSpanQueueCapacity is an instrument used to record metric values
993 // conforming to the "otel.sdk.processor.span.queue.capacity" semantic
994 // conventions. It represents the maximum number of spans the queue of a given
995 // instance of an SDK span processor can hold.
996 type SDKProcessorSpanQueueCapacity struct {
997 metric.Int64UpDownCounter
998 }
999
1000 // NewSDKProcessorSpanQueueCapacity returns a new SDKProcessorSpanQueueCapacity
1001 // instrument.
1002 func NewSDKProcessorSpanQueueCapacity(
1003 m metric.Meter,
1004 opt ...metric.Int64UpDownCounterOption,
1005 ) (SDKProcessorSpanQueueCapacity, error) {
1006 // Check if the meter is nil.
1007 if m == nil {
1008 return SDKProcessorSpanQueueCapacity{noop.Int64UpDownCounter{}}, nil
1009 }
1010
1011 i, err := m.Int64UpDownCounter(
1012 "otel.sdk.processor.span.queue.capacity",
1013 append([]metric.Int64UpDownCounterOption{
1014 metric.WithDescription("The maximum number of spans the queue of a given instance of an SDK span processor can hold"),
1015 metric.WithUnit("{span}"),
1016 }, opt...)...,
1017 )
1018 if err != nil {
1019 return SDKProcessorSpanQueueCapacity{noop.Int64UpDownCounter{}}, err
1020 }
1021 return SDKProcessorSpanQueueCapacity{i}, nil
1022 }
1023
1024 // Inst returns the underlying metric instrument.
1025 func (m SDKProcessorSpanQueueCapacity) Inst() metric.Int64UpDownCounter {
1026 return m.Int64UpDownCounter
1027 }
1028
1029 // Name returns the semantic convention name of the instrument.
1030 func (SDKProcessorSpanQueueCapacity) Name() string {
1031 return "otel.sdk.processor.span.queue.capacity"
1032 }
1033
1034 // Unit returns the semantic convention unit of the instrument
1035 func (SDKProcessorSpanQueueCapacity) Unit() string {
1036 return "{span}"
1037 }
1038
1039 // Description returns the semantic convention description of the instrument
1040 func (SDKProcessorSpanQueueCapacity) Description() string {
1041 return "The maximum number of spans the queue of a given instance of an SDK span processor can hold"
1042 }
1043
1044 // Add adds incr to the existing count.
1045 //
1046 // All additional attrs passed are included in the recorded value.
1047 //
1048 // Only applies to span processors which use a queue, e.g. the SDK Batching Span
1049 // Processor.
1050 func (m SDKProcessorSpanQueueCapacity) Add(
1051 ctx context.Context,
1052 incr int64,
1053 attrs ...attribute.KeyValue,
1054 ) {
1055 o := addOptPool.Get().(*[]metric.AddOption)
1056 defer func() {
1057 *o = (*o)[:0]
1058 addOptPool.Put(o)
1059 }()
1060
1061 *o = append(
1062 *o,
1063 metric.WithAttributes(
1064 attrs...,
1065 ),
1066 )
1067
1068 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1069 }
1070
1071 // AttrComponentName returns an optional attribute for the "otel.component.name"
1072 // semantic convention. It represents a name uniquely identifying the instance of
1073 // the OpenTelemetry component within its containing SDK instance.
1074 func (SDKProcessorSpanQueueCapacity) AttrComponentName(val string) attribute.KeyValue {
1075 return attribute.String("otel.component.name", val)
1076 }
1077
1078 // AttrComponentType returns an optional attribute for the "otel.component.type"
1079 // semantic convention. It represents a name identifying the type of the
1080 // OpenTelemetry component.
1081 func (SDKProcessorSpanQueueCapacity) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1082 return attribute.String("otel.component.type", string(val))
1083 }
1084
1085 // SDKProcessorSpanQueueSize is an instrument used to record metric values
1086 // conforming to the "otel.sdk.processor.span.queue.size" semantic conventions.
1087 // It represents the number of spans in the queue of a given instance of an SDK
1088 // span processor.
1089 type SDKProcessorSpanQueueSize struct {
1090 metric.Int64UpDownCounter
1091 }
1092
1093 // NewSDKProcessorSpanQueueSize returns a new SDKProcessorSpanQueueSize
1094 // instrument.
1095 func NewSDKProcessorSpanQueueSize(
1096 m metric.Meter,
1097 opt ...metric.Int64UpDownCounterOption,
1098 ) (SDKProcessorSpanQueueSize, error) {
1099 // Check if the meter is nil.
1100 if m == nil {
1101 return SDKProcessorSpanQueueSize{noop.Int64UpDownCounter{}}, nil
1102 }
1103
1104 i, err := m.Int64UpDownCounter(
1105 "otel.sdk.processor.span.queue.size",
1106 append([]metric.Int64UpDownCounterOption{
1107 metric.WithDescription("The number of spans in the queue of a given instance of an SDK span processor"),
1108 metric.WithUnit("{span}"),
1109 }, opt...)...,
1110 )
1111 if err != nil {
1112 return SDKProcessorSpanQueueSize{noop.Int64UpDownCounter{}}, err
1113 }
1114 return SDKProcessorSpanQueueSize{i}, nil
1115 }
1116
1117 // Inst returns the underlying metric instrument.
1118 func (m SDKProcessorSpanQueueSize) Inst() metric.Int64UpDownCounter {
1119 return m.Int64UpDownCounter
1120 }
1121
1122 // Name returns the semantic convention name of the instrument.
1123 func (SDKProcessorSpanQueueSize) Name() string {
1124 return "otel.sdk.processor.span.queue.size"
1125 }
1126
1127 // Unit returns the semantic convention unit of the instrument
1128 func (SDKProcessorSpanQueueSize) Unit() string {
1129 return "{span}"
1130 }
1131
1132 // Description returns the semantic convention description of the instrument
1133 func (SDKProcessorSpanQueueSize) Description() string {
1134 return "The number of spans in the queue of a given instance of an SDK span processor"
1135 }
1136
1137 // Add adds incr to the existing count.
1138 //
1139 // All additional attrs passed are included in the recorded value.
1140 //
1141 // Only applies to span processors which use a queue, e.g. the SDK Batching Span
1142 // Processor.
1143 func (m SDKProcessorSpanQueueSize) Add(
1144 ctx context.Context,
1145 incr int64,
1146 attrs ...attribute.KeyValue,
1147 ) {
1148 o := addOptPool.Get().(*[]metric.AddOption)
1149 defer func() {
1150 *o = (*o)[:0]
1151 addOptPool.Put(o)
1152 }()
1153
1154 *o = append(
1155 *o,
1156 metric.WithAttributes(
1157 attrs...,
1158 ),
1159 )
1160
1161 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1162 }
1163
1164 // AttrComponentName returns an optional attribute for the "otel.component.name"
1165 // semantic convention. It represents a name uniquely identifying the instance of
1166 // the OpenTelemetry component within its containing SDK instance.
1167 func (SDKProcessorSpanQueueSize) AttrComponentName(val string) attribute.KeyValue {
1168 return attribute.String("otel.component.name", val)
1169 }
1170
1171 // AttrComponentType returns an optional attribute for the "otel.component.type"
1172 // semantic convention. It represents a name identifying the type of the
1173 // OpenTelemetry component.
1174 func (SDKProcessorSpanQueueSize) AttrComponentType(val ComponentTypeAttr) attribute.KeyValue {
1175 return attribute.String("otel.component.type", string(val))
1176 }
1177
1178 // SDKSpanEndedCount is an instrument used to record metric values conforming to
1179 // the "otel.sdk.span.ended.count" semantic conventions. It represents the number
1180 // of created spans for which the end operation was called.
1181 type SDKSpanEndedCount struct {
1182 metric.Int64Counter
1183 }
1184
1185 // NewSDKSpanEndedCount returns a new SDKSpanEndedCount instrument.
1186 func NewSDKSpanEndedCount(
1187 m metric.Meter,
1188 opt ...metric.Int64CounterOption,
1189 ) (SDKSpanEndedCount, error) {
1190 // Check if the meter is nil.
1191 if m == nil {
1192 return SDKSpanEndedCount{noop.Int64Counter{}}, nil
1193 }
1194
1195 i, err := m.Int64Counter(
1196 "otel.sdk.span.ended.count",
1197 append([]metric.Int64CounterOption{
1198 metric.WithDescription("The number of created spans for which the end operation was called"),
1199 metric.WithUnit("{span}"),
1200 }, opt...)...,
1201 )
1202 if err != nil {
1203 return SDKSpanEndedCount{noop.Int64Counter{}}, err
1204 }
1205 return SDKSpanEndedCount{i}, nil
1206 }
1207
1208 // Inst returns the underlying metric instrument.
1209 func (m SDKSpanEndedCount) Inst() metric.Int64Counter {
1210 return m.Int64Counter
1211 }
1212
1213 // Name returns the semantic convention name of the instrument.
1214 func (SDKSpanEndedCount) Name() string {
1215 return "otel.sdk.span.ended.count"
1216 }
1217
1218 // Unit returns the semantic convention unit of the instrument
1219 func (SDKSpanEndedCount) Unit() string {
1220 return "{span}"
1221 }
1222
1223 // Description returns the semantic convention description of the instrument
1224 func (SDKSpanEndedCount) Description() string {
1225 return "The number of created spans for which the end operation was called"
1226 }
1227
1228 // Add adds incr to the existing count.
1229 //
1230 // All additional attrs passed are included in the recorded value.
1231 //
1232 // For spans with `recording=true`: Implementations MUST record both
1233 // `otel.sdk.span.live.count` and `otel.sdk.span.ended.count`.
1234 // For spans with `recording=false`: If implementations decide to record this
1235 // metric, they MUST also record `otel.sdk.span.live.count`.
1236 func (m SDKSpanEndedCount) Add(
1237 ctx context.Context,
1238 incr int64,
1239 attrs ...attribute.KeyValue,
1240 ) {
1241 o := addOptPool.Get().(*[]metric.AddOption)
1242 defer func() {
1243 *o = (*o)[:0]
1244 addOptPool.Put(o)
1245 }()
1246
1247 *o = append(
1248 *o,
1249 metric.WithAttributes(
1250 attrs...,
1251 ),
1252 )
1253
1254 m.Int64Counter.Add(ctx, incr, *o...)
1255 }
1256
1257 // AttrSpanSamplingResult returns an optional attribute for the
1258 // "otel.span.sampling_result" semantic convention. It represents the result
1259 // value of the sampler for this span.
1260 func (SDKSpanEndedCount) AttrSpanSamplingResult(val SpanSamplingResultAttr) attribute.KeyValue {
1261 return attribute.String("otel.span.sampling_result", string(val))
1262 }
1263
1264 // SDKSpanLiveCount is an instrument used to record metric values conforming to
1265 // the "otel.sdk.span.live.count" semantic conventions. It represents the number
1266 // of created spans for which the end operation has not been called yet.
1267 type SDKSpanLiveCount struct {
1268 metric.Int64UpDownCounter
1269 }
1270
1271 // NewSDKSpanLiveCount returns a new SDKSpanLiveCount instrument.
1272 func NewSDKSpanLiveCount(
1273 m metric.Meter,
1274 opt ...metric.Int64UpDownCounterOption,
1275 ) (SDKSpanLiveCount, error) {
1276 // Check if the meter is nil.
1277 if m == nil {
1278 return SDKSpanLiveCount{noop.Int64UpDownCounter{}}, nil
1279 }
1280
1281 i, err := m.Int64UpDownCounter(
1282 "otel.sdk.span.live.count",
1283 append([]metric.Int64UpDownCounterOption{
1284 metric.WithDescription("The number of created spans for which the end operation has not been called yet"),
1285 metric.WithUnit("{span}"),
1286 }, opt...)...,
1287 )
1288 if err != nil {
1289 return SDKSpanLiveCount{noop.Int64UpDownCounter{}}, err
1290 }
1291 return SDKSpanLiveCount{i}, nil
1292 }
1293
1294 // Inst returns the underlying metric instrument.
1295 func (m SDKSpanLiveCount) Inst() metric.Int64UpDownCounter {
1296 return m.Int64UpDownCounter
1297 }
1298
1299 // Name returns the semantic convention name of the instrument.
1300 func (SDKSpanLiveCount) Name() string {
1301 return "otel.sdk.span.live.count"
1302 }
1303
1304 // Unit returns the semantic convention unit of the instrument
1305 func (SDKSpanLiveCount) Unit() string {
1306 return "{span}"
1307 }
1308
1309 // Description returns the semantic convention description of the instrument
1310 func (SDKSpanLiveCount) Description() string {
1311 return "The number of created spans for which the end operation has not been called yet"
1312 }
1313
1314 // Add adds incr to the existing count.
1315 //
1316 // All additional attrs passed are included in the recorded value.
1317 //
1318 // For spans with `recording=true`: Implementations MUST record both
1319 // `otel.sdk.span.live.count` and `otel.sdk.span.ended.count`.
1320 // For spans with `recording=false`: If implementations decide to record this
1321 // metric, they MUST also record `otel.sdk.span.ended.count`.
1322 func (m SDKSpanLiveCount) Add(
1323 ctx context.Context,
1324 incr int64,
1325 attrs ...attribute.KeyValue,
1326 ) {
1327 o := addOptPool.Get().(*[]metric.AddOption)
1328 defer func() {
1329 *o = (*o)[:0]
1330 addOptPool.Put(o)
1331 }()
1332
1333 *o = append(
1334 *o,
1335 metric.WithAttributes(
1336 attrs...,
1337 ),
1338 )
1339
1340 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1341 }
1342
1343 // AttrSpanSamplingResult returns an optional attribute for the
1344 // "otel.span.sampling_result" semantic convention. It represents the result
1345 // value of the sampler for this span.
1346 func (SDKSpanLiveCount) AttrSpanSamplingResult(val SpanSamplingResultAttr) attribute.KeyValue {
1347 return attribute.String("otel.span.sampling_result", string(val))
1348 }