Debian Codegraph @

semconv/v1.33.0/k8sconv/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 k8sconv provides types and functionality for OpenTelemetry semantic
7 // conventions in the "k8s" namespace.
8 package k8sconv
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 // NamespacePhaseAttr is an attribute conforming to the k8s.namespace.phase
25 // semantic conventions. It represents the phase of the K8s namespace.
26 type NamespacePhaseAttr string
27
28 var (
29 // NamespacePhaseActive is the active namespace phase as described by [K8s API]
30 // .
31 //
32 // [K8s API]: https://pkg.go.dev/k8s.io/[email protected]/core/v1#NamespacePhase
33 NamespacePhaseActive NamespacePhaseAttr = "active"
34 // NamespacePhaseTerminating is the terminating namespace phase as described by
35 // [K8s API].
36 //
37 // [K8s API]: https://pkg.go.dev/k8s.io/[email protected]/core/v1#NamespacePhase
38 NamespacePhaseTerminating NamespacePhaseAttr = "terminating"
39 )
40
41 // NetworkIODirectionAttr is an attribute conforming to the network.io.direction
42 // semantic conventions. It represents the network IO operation direction.
43 type NetworkIODirectionAttr string
44
45 var (
46 // NetworkIODirectionTransmit is the none.
47 NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit"
48 // NetworkIODirectionReceive is the none.
49 NetworkIODirectionReceive NetworkIODirectionAttr = "receive"
50 )
51
52 // CronJobActiveJobs is an instrument used to record metric values conforming to
53 // the "k8s.cronjob.active_jobs" semantic conventions. It represents the number
54 // of actively running jobs for a cronjob.
55 type CronJobActiveJobs struct {
56 metric.Int64UpDownCounter
57 }
58
59 // NewCronJobActiveJobs returns a new CronJobActiveJobs instrument.
60 func NewCronJobActiveJobs(
61 m metric.Meter,
62 opt ...metric.Int64UpDownCounterOption,
63 ) (CronJobActiveJobs, error) {
64 // Check if the meter is nil.
65 if m == nil {
66 return CronJobActiveJobs{noop.Int64UpDownCounter{}}, nil
67 }
68
69 i, err := m.Int64UpDownCounter(
70 "k8s.cronjob.active_jobs",
71 append([]metric.Int64UpDownCounterOption{
72 metric.WithDescription("The number of actively running jobs for a cronjob"),
73 metric.WithUnit("{job}"),
74 }, opt...)...,
75 )
76 if err != nil {
77 return CronJobActiveJobs{noop.Int64UpDownCounter{}}, err
78 }
79 return CronJobActiveJobs{i}, nil
80 }
81
82 // Inst returns the underlying metric instrument.
83 func (m CronJobActiveJobs) Inst() metric.Int64UpDownCounter {
84 return m.Int64UpDownCounter
85 }
86
87 // Name returns the semantic convention name of the instrument.
88 func (CronJobActiveJobs) Name() string {
89 return "k8s.cronjob.active_jobs"
90 }
91
92 // Unit returns the semantic convention unit of the instrument
93 func (CronJobActiveJobs) Unit() string {
94 return "{job}"
95 }
96
97 // Description returns the semantic convention description of the instrument
98 func (CronJobActiveJobs) Description() string {
99 return "The number of actively running jobs for a cronjob"
100 }
101
102 // Add adds incr to the existing count.
103 //
104 // This metric aligns with the `active` field of the
105 // [K8s CronJobStatus].
106 //
107 // This metric SHOULD, at a minimum, be reported against a
108 // [`k8s.cronjob`] resource.
109 //
110 // [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch
111 // [`k8s.cronjob`]: ../resource/k8s.md#cronjob
112 func (m CronJobActiveJobs) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
113 if len(attrs) == 0 {
114 m.Int64UpDownCounter.Add(ctx, incr)
115 return
116 }
117
118 o := addOptPool.Get().(*[]metric.AddOption)
119 defer func() {
120 *o = (*o)[:0]
121 addOptPool.Put(o)
122 }()
123
124 *o = append(*o, metric.WithAttributes(attrs...))
125 m.Int64UpDownCounter.Add(ctx, incr, *o...)
126 }
127
128 // DaemonSetCurrentScheduledNodes is an instrument used to record metric values
129 // conforming to the "k8s.daemonset.current_scheduled_nodes" semantic
130 // conventions. It represents the number of nodes that are running at least 1
131 // daemon pod and are supposed to run the daemon pod.
132 type DaemonSetCurrentScheduledNodes struct {
133 metric.Int64UpDownCounter
134 }
135
136 // NewDaemonSetCurrentScheduledNodes returns a new DaemonSetCurrentScheduledNodes
137 // instrument.
138 func NewDaemonSetCurrentScheduledNodes(
139 m metric.Meter,
140 opt ...metric.Int64UpDownCounterOption,
141 ) (DaemonSetCurrentScheduledNodes, error) {
142 // Check if the meter is nil.
143 if m == nil {
144 return DaemonSetCurrentScheduledNodes{noop.Int64UpDownCounter{}}, nil
145 }
146
147 i, err := m.Int64UpDownCounter(
148 "k8s.daemonset.current_scheduled_nodes",
149 append([]metric.Int64UpDownCounterOption{
150 metric.WithDescription("Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod"),
151 metric.WithUnit("{node}"),
152 }, opt...)...,
153 )
154 if err != nil {
155 return DaemonSetCurrentScheduledNodes{noop.Int64UpDownCounter{}}, err
156 }
157 return DaemonSetCurrentScheduledNodes{i}, nil
158 }
159
160 // Inst returns the underlying metric instrument.
161 func (m DaemonSetCurrentScheduledNodes) Inst() metric.Int64UpDownCounter {
162 return m.Int64UpDownCounter
163 }
164
165 // Name returns the semantic convention name of the instrument.
166 func (DaemonSetCurrentScheduledNodes) Name() string {
167 return "k8s.daemonset.current_scheduled_nodes"
168 }
169
170 // Unit returns the semantic convention unit of the instrument
171 func (DaemonSetCurrentScheduledNodes) Unit() string {
172 return "{node}"
173 }
174
175 // Description returns the semantic convention description of the instrument
176 func (DaemonSetCurrentScheduledNodes) Description() string {
177 return "Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod"
178 }
179
180 // Add adds incr to the existing count.
181 //
182 // This metric aligns with the `currentNumberScheduled` field of the
183 // [K8s DaemonSetStatus].
184 //
185 // This metric SHOULD, at a minimum, be reported against a
186 // [`k8s.daemonset`] resource.
187 //
188 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
189 // [`k8s.daemonset`]: ../resource/k8s.md#daemonset
190 func (m DaemonSetCurrentScheduledNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
191 if len(attrs) == 0 {
192 m.Int64UpDownCounter.Add(ctx, incr)
193 return
194 }
195
196 o := addOptPool.Get().(*[]metric.AddOption)
197 defer func() {
198 *o = (*o)[:0]
199 addOptPool.Put(o)
200 }()
201
202 *o = append(*o, metric.WithAttributes(attrs...))
203 m.Int64UpDownCounter.Add(ctx, incr, *o...)
204 }
205
206 // DaemonSetDesiredScheduledNodes is an instrument used to record metric values
207 // conforming to the "k8s.daemonset.desired_scheduled_nodes" semantic
208 // conventions. It represents the number of nodes that should be running the
209 // daemon pod (including nodes currently running the daemon pod).
210 type DaemonSetDesiredScheduledNodes struct {
211 metric.Int64UpDownCounter
212 }
213
214 // NewDaemonSetDesiredScheduledNodes returns a new DaemonSetDesiredScheduledNodes
215 // instrument.
216 func NewDaemonSetDesiredScheduledNodes(
217 m metric.Meter,
218 opt ...metric.Int64UpDownCounterOption,
219 ) (DaemonSetDesiredScheduledNodes, error) {
220 // Check if the meter is nil.
221 if m == nil {
222 return DaemonSetDesiredScheduledNodes{noop.Int64UpDownCounter{}}, nil
223 }
224
225 i, err := m.Int64UpDownCounter(
226 "k8s.daemonset.desired_scheduled_nodes",
227 append([]metric.Int64UpDownCounterOption{
228 metric.WithDescription("Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)"),
229 metric.WithUnit("{node}"),
230 }, opt...)...,
231 )
232 if err != nil {
233 return DaemonSetDesiredScheduledNodes{noop.Int64UpDownCounter{}}, err
234 }
235 return DaemonSetDesiredScheduledNodes{i}, nil
236 }
237
238 // Inst returns the underlying metric instrument.
239 func (m DaemonSetDesiredScheduledNodes) Inst() metric.Int64UpDownCounter {
240 return m.Int64UpDownCounter
241 }
242
243 // Name returns the semantic convention name of the instrument.
244 func (DaemonSetDesiredScheduledNodes) Name() string {
245 return "k8s.daemonset.desired_scheduled_nodes"
246 }
247
248 // Unit returns the semantic convention unit of the instrument
249 func (DaemonSetDesiredScheduledNodes) Unit() string {
250 return "{node}"
251 }
252
253 // Description returns the semantic convention description of the instrument
254 func (DaemonSetDesiredScheduledNodes) Description() string {
255 return "Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)"
256 }
257
258 // Add adds incr to the existing count.
259 //
260 // This metric aligns with the `desiredNumberScheduled` field of the
261 // [K8s DaemonSetStatus].
262 //
263 // This metric SHOULD, at a minimum, be reported against a
264 // [`k8s.daemonset`] resource.
265 //
266 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
267 // [`k8s.daemonset`]: ../resource/k8s.md#daemonset
268 func (m DaemonSetDesiredScheduledNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
269 if len(attrs) == 0 {
270 m.Int64UpDownCounter.Add(ctx, incr)
271 return
272 }
273
274 o := addOptPool.Get().(*[]metric.AddOption)
275 defer func() {
276 *o = (*o)[:0]
277 addOptPool.Put(o)
278 }()
279
280 *o = append(*o, metric.WithAttributes(attrs...))
281 m.Int64UpDownCounter.Add(ctx, incr, *o...)
282 }
283
284 // DaemonSetMisscheduledNodes is an instrument used to record metric values
285 // conforming to the "k8s.daemonset.misscheduled_nodes" semantic conventions. It
286 // represents the number of nodes that are running the daemon pod, but are not
287 // supposed to run the daemon pod.
288 type DaemonSetMisscheduledNodes struct {
289 metric.Int64UpDownCounter
290 }
291
292 // NewDaemonSetMisscheduledNodes returns a new DaemonSetMisscheduledNodes
293 // instrument.
294 func NewDaemonSetMisscheduledNodes(
295 m metric.Meter,
296 opt ...metric.Int64UpDownCounterOption,
297 ) (DaemonSetMisscheduledNodes, error) {
298 // Check if the meter is nil.
299 if m == nil {
300 return DaemonSetMisscheduledNodes{noop.Int64UpDownCounter{}}, nil
301 }
302
303 i, err := m.Int64UpDownCounter(
304 "k8s.daemonset.misscheduled_nodes",
305 append([]metric.Int64UpDownCounterOption{
306 metric.WithDescription("Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod"),
307 metric.WithUnit("{node}"),
308 }, opt...)...,
309 )
310 if err != nil {
311 return DaemonSetMisscheduledNodes{noop.Int64UpDownCounter{}}, err
312 }
313 return DaemonSetMisscheduledNodes{i}, nil
314 }
315
316 // Inst returns the underlying metric instrument.
317 func (m DaemonSetMisscheduledNodes) Inst() metric.Int64UpDownCounter {
318 return m.Int64UpDownCounter
319 }
320
321 // Name returns the semantic convention name of the instrument.
322 func (DaemonSetMisscheduledNodes) Name() string {
323 return "k8s.daemonset.misscheduled_nodes"
324 }
325
326 // Unit returns the semantic convention unit of the instrument
327 func (DaemonSetMisscheduledNodes) Unit() string {
328 return "{node}"
329 }
330
331 // Description returns the semantic convention description of the instrument
332 func (DaemonSetMisscheduledNodes) Description() string {
333 return "Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod"
334 }
335
336 // Add adds incr to the existing count.
337 //
338 // This metric aligns with the `numberMisscheduled` field of the
339 // [K8s DaemonSetStatus].
340 //
341 // This metric SHOULD, at a minimum, be reported against a
342 // [`k8s.daemonset`] resource.
343 //
344 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
345 // [`k8s.daemonset`]: ../resource/k8s.md#daemonset
346 func (m DaemonSetMisscheduledNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
347 if len(attrs) == 0 {
348 m.Int64UpDownCounter.Add(ctx, incr)
349 return
350 }
351
352 o := addOptPool.Get().(*[]metric.AddOption)
353 defer func() {
354 *o = (*o)[:0]
355 addOptPool.Put(o)
356 }()
357
358 *o = append(*o, metric.WithAttributes(attrs...))
359 m.Int64UpDownCounter.Add(ctx, incr, *o...)
360 }
361
362 // DaemonSetReadyNodes is an instrument used to record metric values conforming
363 // to the "k8s.daemonset.ready_nodes" semantic conventions. It represents the
364 // number of nodes that should be running the daemon pod and have one or more of
365 // the daemon pod running and ready.
366 type DaemonSetReadyNodes struct {
367 metric.Int64UpDownCounter
368 }
369
370 // NewDaemonSetReadyNodes returns a new DaemonSetReadyNodes instrument.
371 func NewDaemonSetReadyNodes(
372 m metric.Meter,
373 opt ...metric.Int64UpDownCounterOption,
374 ) (DaemonSetReadyNodes, error) {
375 // Check if the meter is nil.
376 if m == nil {
377 return DaemonSetReadyNodes{noop.Int64UpDownCounter{}}, nil
378 }
379
380 i, err := m.Int64UpDownCounter(
381 "k8s.daemonset.ready_nodes",
382 append([]metric.Int64UpDownCounterOption{
383 metric.WithDescription("Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready"),
384 metric.WithUnit("{node}"),
385 }, opt...)...,
386 )
387 if err != nil {
388 return DaemonSetReadyNodes{noop.Int64UpDownCounter{}}, err
389 }
390 return DaemonSetReadyNodes{i}, nil
391 }
392
393 // Inst returns the underlying metric instrument.
394 func (m DaemonSetReadyNodes) Inst() metric.Int64UpDownCounter {
395 return m.Int64UpDownCounter
396 }
397
398 // Name returns the semantic convention name of the instrument.
399 func (DaemonSetReadyNodes) Name() string {
400 return "k8s.daemonset.ready_nodes"
401 }
402
403 // Unit returns the semantic convention unit of the instrument
404 func (DaemonSetReadyNodes) Unit() string {
405 return "{node}"
406 }
407
408 // Description returns the semantic convention description of the instrument
409 func (DaemonSetReadyNodes) Description() string {
410 return "Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready"
411 }
412
413 // Add adds incr to the existing count.
414 //
415 // This metric aligns with the `numberReady` field of the
416 // [K8s DaemonSetStatus].
417 //
418 // This metric SHOULD, at a minimum, be reported against a
419 // [`k8s.daemonset`] resource.
420 //
421 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
422 // [`k8s.daemonset`]: ../resource/k8s.md#daemonset
423 func (m DaemonSetReadyNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
424 if len(attrs) == 0 {
425 m.Int64UpDownCounter.Add(ctx, incr)
426 return
427 }
428
429 o := addOptPool.Get().(*[]metric.AddOption)
430 defer func() {
431 *o = (*o)[:0]
432 addOptPool.Put(o)
433 }()
434
435 *o = append(*o, metric.WithAttributes(attrs...))
436 m.Int64UpDownCounter.Add(ctx, incr, *o...)
437 }
438
439 // DeploymentAvailablePods is an instrument used to record metric values
440 // conforming to the "k8s.deployment.available_pods" semantic conventions. It
441 // represents the total number of available replica pods (ready for at least
442 // minReadySeconds) targeted by this deployment.
443 type DeploymentAvailablePods struct {
444 metric.Int64UpDownCounter
445 }
446
447 // NewDeploymentAvailablePods returns a new DeploymentAvailablePods instrument.
448 func NewDeploymentAvailablePods(
449 m metric.Meter,
450 opt ...metric.Int64UpDownCounterOption,
451 ) (DeploymentAvailablePods, error) {
452 // Check if the meter is nil.
453 if m == nil {
454 return DeploymentAvailablePods{noop.Int64UpDownCounter{}}, nil
455 }
456
457 i, err := m.Int64UpDownCounter(
458 "k8s.deployment.available_pods",
459 append([]metric.Int64UpDownCounterOption{
460 metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment"),
461 metric.WithUnit("{pod}"),
462 }, opt...)...,
463 )
464 if err != nil {
465 return DeploymentAvailablePods{noop.Int64UpDownCounter{}}, err
466 }
467 return DeploymentAvailablePods{i}, nil
468 }
469
470 // Inst returns the underlying metric instrument.
471 func (m DeploymentAvailablePods) Inst() metric.Int64UpDownCounter {
472 return m.Int64UpDownCounter
473 }
474
475 // Name returns the semantic convention name of the instrument.
476 func (DeploymentAvailablePods) Name() string {
477 return "k8s.deployment.available_pods"
478 }
479
480 // Unit returns the semantic convention unit of the instrument
481 func (DeploymentAvailablePods) Unit() string {
482 return "{pod}"
483 }
484
485 // Description returns the semantic convention description of the instrument
486 func (DeploymentAvailablePods) Description() string {
487 return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment"
488 }
489
490 // Add adds incr to the existing count.
491 //
492 // This metric aligns with the `availableReplicas` field of the
493 // [K8s DeploymentStatus].
494 //
495 // This metric SHOULD, at a minimum, be reported against a
496 // [`k8s.deployment`] resource.
497 //
498 // [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps
499 // [`k8s.deployment`]: ../resource/k8s.md#deployment
500 func (m DeploymentAvailablePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
501 if len(attrs) == 0 {
502 m.Int64UpDownCounter.Add(ctx, incr)
503 return
504 }
505
506 o := addOptPool.Get().(*[]metric.AddOption)
507 defer func() {
508 *o = (*o)[:0]
509 addOptPool.Put(o)
510 }()
511
512 *o = append(*o, metric.WithAttributes(attrs...))
513 m.Int64UpDownCounter.Add(ctx, incr, *o...)
514 }
515
516 // DeploymentDesiredPods is an instrument used to record metric values conforming
517 // to the "k8s.deployment.desired_pods" semantic conventions. It represents the
518 // number of desired replica pods in this deployment.
519 type DeploymentDesiredPods struct {
520 metric.Int64UpDownCounter
521 }
522
523 // NewDeploymentDesiredPods returns a new DeploymentDesiredPods instrument.
524 func NewDeploymentDesiredPods(
525 m metric.Meter,
526 opt ...metric.Int64UpDownCounterOption,
527 ) (DeploymentDesiredPods, error) {
528 // Check if the meter is nil.
529 if m == nil {
530 return DeploymentDesiredPods{noop.Int64UpDownCounter{}}, nil
531 }
532
533 i, err := m.Int64UpDownCounter(
534 "k8s.deployment.desired_pods",
535 append([]metric.Int64UpDownCounterOption{
536 metric.WithDescription("Number of desired replica pods in this deployment"),
537 metric.WithUnit("{pod}"),
538 }, opt...)...,
539 )
540 if err != nil {
541 return DeploymentDesiredPods{noop.Int64UpDownCounter{}}, err
542 }
543 return DeploymentDesiredPods{i}, nil
544 }
545
546 // Inst returns the underlying metric instrument.
547 func (m DeploymentDesiredPods) Inst() metric.Int64UpDownCounter {
548 return m.Int64UpDownCounter
549 }
550
551 // Name returns the semantic convention name of the instrument.
552 func (DeploymentDesiredPods) Name() string {
553 return "k8s.deployment.desired_pods"
554 }
555
556 // Unit returns the semantic convention unit of the instrument
557 func (DeploymentDesiredPods) Unit() string {
558 return "{pod}"
559 }
560
561 // Description returns the semantic convention description of the instrument
562 func (DeploymentDesiredPods) Description() string {
563 return "Number of desired replica pods in this deployment"
564 }
565
566 // Add adds incr to the existing count.
567 //
568 // This metric aligns with the `replicas` field of the
569 // [K8s DeploymentSpec].
570 //
571 // This metric SHOULD, at a minimum, be reported against a
572 // [`k8s.deployment`] resource.
573 //
574 // [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps
575 // [`k8s.deployment`]: ../resource/k8s.md#deployment
576 func (m DeploymentDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
577 if len(attrs) == 0 {
578 m.Int64UpDownCounter.Add(ctx, incr)
579 return
580 }
581
582 o := addOptPool.Get().(*[]metric.AddOption)
583 defer func() {
584 *o = (*o)[:0]
585 addOptPool.Put(o)
586 }()
587
588 *o = append(*o, metric.WithAttributes(attrs...))
589 m.Int64UpDownCounter.Add(ctx, incr, *o...)
590 }
591
592 // HPACurrentPods is an instrument used to record metric values conforming to the
593 // "k8s.hpa.current_pods" semantic conventions. It represents the current number
594 // of replica pods managed by this horizontal pod autoscaler, as last seen by the
595 // autoscaler.
596 type HPACurrentPods struct {
597 metric.Int64UpDownCounter
598 }
599
600 // NewHPACurrentPods returns a new HPACurrentPods instrument.
601 func NewHPACurrentPods(
602 m metric.Meter,
603 opt ...metric.Int64UpDownCounterOption,
604 ) (HPACurrentPods, error) {
605 // Check if the meter is nil.
606 if m == nil {
607 return HPACurrentPods{noop.Int64UpDownCounter{}}, nil
608 }
609
610 i, err := m.Int64UpDownCounter(
611 "k8s.hpa.current_pods",
612 append([]metric.Int64UpDownCounterOption{
613 metric.WithDescription("Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler"),
614 metric.WithUnit("{pod}"),
615 }, opt...)...,
616 )
617 if err != nil {
618 return HPACurrentPods{noop.Int64UpDownCounter{}}, err
619 }
620 return HPACurrentPods{i}, nil
621 }
622
623 // Inst returns the underlying metric instrument.
624 func (m HPACurrentPods) Inst() metric.Int64UpDownCounter {
625 return m.Int64UpDownCounter
626 }
627
628 // Name returns the semantic convention name of the instrument.
629 func (HPACurrentPods) Name() string {
630 return "k8s.hpa.current_pods"
631 }
632
633 // Unit returns the semantic convention unit of the instrument
634 func (HPACurrentPods) Unit() string {
635 return "{pod}"
636 }
637
638 // Description returns the semantic convention description of the instrument
639 func (HPACurrentPods) Description() string {
640 return "Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler"
641 }
642
643 // Add adds incr to the existing count.
644 //
645 // This metric aligns with the `currentReplicas` field of the
646 // [K8s HorizontalPodAutoscalerStatus]
647 //
648 // This metric SHOULD, at a minimum, be reported against a
649 // [`k8s.hpa`] resource.
650 //
651 // [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling
652 // [`k8s.hpa`]: ../resource/k8s.md#horizontalpodautoscaler
653 func (m HPACurrentPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
654 if len(attrs) == 0 {
655 m.Int64UpDownCounter.Add(ctx, incr)
656 return
657 }
658
659 o := addOptPool.Get().(*[]metric.AddOption)
660 defer func() {
661 *o = (*o)[:0]
662 addOptPool.Put(o)
663 }()
664
665 *o = append(*o, metric.WithAttributes(attrs...))
666 m.Int64UpDownCounter.Add(ctx, incr, *o...)
667 }
668
669 // HPADesiredPods is an instrument used to record metric values conforming to the
670 // "k8s.hpa.desired_pods" semantic conventions. It represents the desired number
671 // of replica pods managed by this horizontal pod autoscaler, as last calculated
672 // by the autoscaler.
673 type HPADesiredPods struct {
674 metric.Int64UpDownCounter
675 }
676
677 // NewHPADesiredPods returns a new HPADesiredPods instrument.
678 func NewHPADesiredPods(
679 m metric.Meter,
680 opt ...metric.Int64UpDownCounterOption,
681 ) (HPADesiredPods, error) {
682 // Check if the meter is nil.
683 if m == nil {
684 return HPADesiredPods{noop.Int64UpDownCounter{}}, nil
685 }
686
687 i, err := m.Int64UpDownCounter(
688 "k8s.hpa.desired_pods",
689 append([]metric.Int64UpDownCounterOption{
690 metric.WithDescription("Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler"),
691 metric.WithUnit("{pod}"),
692 }, opt...)...,
693 )
694 if err != nil {
695 return HPADesiredPods{noop.Int64UpDownCounter{}}, err
696 }
697 return HPADesiredPods{i}, nil
698 }
699
700 // Inst returns the underlying metric instrument.
701 func (m HPADesiredPods) Inst() metric.Int64UpDownCounter {
702 return m.Int64UpDownCounter
703 }
704
705 // Name returns the semantic convention name of the instrument.
706 func (HPADesiredPods) Name() string {
707 return "k8s.hpa.desired_pods"
708 }
709
710 // Unit returns the semantic convention unit of the instrument
711 func (HPADesiredPods) Unit() string {
712 return "{pod}"
713 }
714
715 // Description returns the semantic convention description of the instrument
716 func (HPADesiredPods) Description() string {
717 return "Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler"
718 }
719
720 // Add adds incr to the existing count.
721 //
722 // This metric aligns with the `desiredReplicas` field of the
723 // [K8s HorizontalPodAutoscalerStatus]
724 //
725 // This metric SHOULD, at a minimum, be reported against a
726 // [`k8s.hpa`] resource.
727 //
728 // [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling
729 // [`k8s.hpa`]: ../resource/k8s.md#horizontalpodautoscaler
730 func (m HPADesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
731 if len(attrs) == 0 {
732 m.Int64UpDownCounter.Add(ctx, incr)
733 return
734 }
735
736 o := addOptPool.Get().(*[]metric.AddOption)
737 defer func() {
738 *o = (*o)[:0]
739 addOptPool.Put(o)
740 }()
741
742 *o = append(*o, metric.WithAttributes(attrs...))
743 m.Int64UpDownCounter.Add(ctx, incr, *o...)
744 }
745
746 // HPAMaxPods is an instrument used to record metric values conforming to the
747 // "k8s.hpa.max_pods" semantic conventions. It represents the upper limit for the
748 // number of replica pods to which the autoscaler can scale up.
749 type HPAMaxPods struct {
750 metric.Int64UpDownCounter
751 }
752
753 // NewHPAMaxPods returns a new HPAMaxPods instrument.
754 func NewHPAMaxPods(
755 m metric.Meter,
756 opt ...metric.Int64UpDownCounterOption,
757 ) (HPAMaxPods, error) {
758 // Check if the meter is nil.
759 if m == nil {
760 return HPAMaxPods{noop.Int64UpDownCounter{}}, nil
761 }
762
763 i, err := m.Int64UpDownCounter(
764 "k8s.hpa.max_pods",
765 append([]metric.Int64UpDownCounterOption{
766 metric.WithDescription("The upper limit for the number of replica pods to which the autoscaler can scale up"),
767 metric.WithUnit("{pod}"),
768 }, opt...)...,
769 )
770 if err != nil {
771 return HPAMaxPods{noop.Int64UpDownCounter{}}, err
772 }
773 return HPAMaxPods{i}, nil
774 }
775
776 // Inst returns the underlying metric instrument.
777 func (m HPAMaxPods) Inst() metric.Int64UpDownCounter {
778 return m.Int64UpDownCounter
779 }
780
781 // Name returns the semantic convention name of the instrument.
782 func (HPAMaxPods) Name() string {
783 return "k8s.hpa.max_pods"
784 }
785
786 // Unit returns the semantic convention unit of the instrument
787 func (HPAMaxPods) Unit() string {
788 return "{pod}"
789 }
790
791 // Description returns the semantic convention description of the instrument
792 func (HPAMaxPods) Description() string {
793 return "The upper limit for the number of replica pods to which the autoscaler can scale up"
794 }
795
796 // Add adds incr to the existing count.
797 //
798 // This metric aligns with the `maxReplicas` field of the
799 // [K8s HorizontalPodAutoscalerSpec]
800 //
801 // This metric SHOULD, at a minimum, be reported against a
802 // [`k8s.hpa`] resource.
803 //
804 // [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling
805 // [`k8s.hpa`]: ../resource/k8s.md#horizontalpodautoscaler
806 func (m HPAMaxPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
807 if len(attrs) == 0 {
808 m.Int64UpDownCounter.Add(ctx, incr)
809 return
810 }
811
812 o := addOptPool.Get().(*[]metric.AddOption)
813 defer func() {
814 *o = (*o)[:0]
815 addOptPool.Put(o)
816 }()
817
818 *o = append(*o, metric.WithAttributes(attrs...))
819 m.Int64UpDownCounter.Add(ctx, incr, *o...)
820 }
821
822 // HPAMinPods is an instrument used to record metric values conforming to the
823 // "k8s.hpa.min_pods" semantic conventions. It represents the lower limit for the
824 // number of replica pods to which the autoscaler can scale down.
825 type HPAMinPods struct {
826 metric.Int64UpDownCounter
827 }
828
829 // NewHPAMinPods returns a new HPAMinPods instrument.
830 func NewHPAMinPods(
831 m metric.Meter,
832 opt ...metric.Int64UpDownCounterOption,
833 ) (HPAMinPods, error) {
834 // Check if the meter is nil.
835 if m == nil {
836 return HPAMinPods{noop.Int64UpDownCounter{}}, nil
837 }
838
839 i, err := m.Int64UpDownCounter(
840 "k8s.hpa.min_pods",
841 append([]metric.Int64UpDownCounterOption{
842 metric.WithDescription("The lower limit for the number of replica pods to which the autoscaler can scale down"),
843 metric.WithUnit("{pod}"),
844 }, opt...)...,
845 )
846 if err != nil {
847 return HPAMinPods{noop.Int64UpDownCounter{}}, err
848 }
849 return HPAMinPods{i}, nil
850 }
851
852 // Inst returns the underlying metric instrument.
853 func (m HPAMinPods) Inst() metric.Int64UpDownCounter {
854 return m.Int64UpDownCounter
855 }
856
857 // Name returns the semantic convention name of the instrument.
858 func (HPAMinPods) Name() string {
859 return "k8s.hpa.min_pods"
860 }
861
862 // Unit returns the semantic convention unit of the instrument
863 func (HPAMinPods) Unit() string {
864 return "{pod}"
865 }
866
867 // Description returns the semantic convention description of the instrument
868 func (HPAMinPods) Description() string {
869 return "The lower limit for the number of replica pods to which the autoscaler can scale down"
870 }
871
872 // Add adds incr to the existing count.
873 //
874 // This metric aligns with the `minReplicas` field of the
875 // [K8s HorizontalPodAutoscalerSpec]
876 //
877 // This metric SHOULD, at a minimum, be reported against a
878 // [`k8s.hpa`] resource.
879 //
880 // [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling
881 // [`k8s.hpa`]: ../resource/k8s.md#horizontalpodautoscaler
882 func (m HPAMinPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
883 if len(attrs) == 0 {
884 m.Int64UpDownCounter.Add(ctx, incr)
885 return
886 }
887
888 o := addOptPool.Get().(*[]metric.AddOption)
889 defer func() {
890 *o = (*o)[:0]
891 addOptPool.Put(o)
892 }()
893
894 *o = append(*o, metric.WithAttributes(attrs...))
895 m.Int64UpDownCounter.Add(ctx, incr, *o...)
896 }
897
898 // JobActivePods is an instrument used to record metric values conforming to the
899 // "k8s.job.active_pods" semantic conventions. It represents the number of
900 // pending and actively running pods for a job.
901 type JobActivePods struct {
902 metric.Int64UpDownCounter
903 }
904
905 // NewJobActivePods returns a new JobActivePods instrument.
906 func NewJobActivePods(
907 m metric.Meter,
908 opt ...metric.Int64UpDownCounterOption,
909 ) (JobActivePods, error) {
910 // Check if the meter is nil.
911 if m == nil {
912 return JobActivePods{noop.Int64UpDownCounter{}}, nil
913 }
914
915 i, err := m.Int64UpDownCounter(
916 "k8s.job.active_pods",
917 append([]metric.Int64UpDownCounterOption{
918 metric.WithDescription("The number of pending and actively running pods for a job"),
919 metric.WithUnit("{pod}"),
920 }, opt...)...,
921 )
922 if err != nil {
923 return JobActivePods{noop.Int64UpDownCounter{}}, err
924 }
925 return JobActivePods{i}, nil
926 }
927
928 // Inst returns the underlying metric instrument.
929 func (m JobActivePods) Inst() metric.Int64UpDownCounter {
930 return m.Int64UpDownCounter
931 }
932
933 // Name returns the semantic convention name of the instrument.
934 func (JobActivePods) Name() string {
935 return "k8s.job.active_pods"
936 }
937
938 // Unit returns the semantic convention unit of the instrument
939 func (JobActivePods) Unit() string {
940 return "{pod}"
941 }
942
943 // Description returns the semantic convention description of the instrument
944 func (JobActivePods) Description() string {
945 return "The number of pending and actively running pods for a job"
946 }
947
948 // Add adds incr to the existing count.
949 //
950 // This metric aligns with the `active` field of the
951 // [K8s JobStatus].
952 //
953 // This metric SHOULD, at a minimum, be reported against a
954 // [`k8s.job`] resource.
955 //
956 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
957 // [`k8s.job`]: ../resource/k8s.md#job
958 func (m JobActivePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
959 if len(attrs) == 0 {
960 m.Int64UpDownCounter.Add(ctx, incr)
961 return
962 }
963
964 o := addOptPool.Get().(*[]metric.AddOption)
965 defer func() {
966 *o = (*o)[:0]
967 addOptPool.Put(o)
968 }()
969
970 *o = append(*o, metric.WithAttributes(attrs...))
971 m.Int64UpDownCounter.Add(ctx, incr, *o...)
972 }
973
974 // JobDesiredSuccessfulPods is an instrument used to record metric values
975 // conforming to the "k8s.job.desired_successful_pods" semantic conventions. It
976 // represents the desired number of successfully finished pods the job should be
977 // run with.
978 type JobDesiredSuccessfulPods struct {
979 metric.Int64UpDownCounter
980 }
981
982 // NewJobDesiredSuccessfulPods returns a new JobDesiredSuccessfulPods instrument.
983 func NewJobDesiredSuccessfulPods(
984 m metric.Meter,
985 opt ...metric.Int64UpDownCounterOption,
986 ) (JobDesiredSuccessfulPods, error) {
987 // Check if the meter is nil.
988 if m == nil {
989 return JobDesiredSuccessfulPods{noop.Int64UpDownCounter{}}, nil
990 }
991
992 i, err := m.Int64UpDownCounter(
993 "k8s.job.desired_successful_pods",
994 append([]metric.Int64UpDownCounterOption{
995 metric.WithDescription("The desired number of successfully finished pods the job should be run with"),
996 metric.WithUnit("{pod}"),
997 }, opt...)...,
998 )
999 if err != nil {
1000 return JobDesiredSuccessfulPods{noop.Int64UpDownCounter{}}, err
1001 }
1002 return JobDesiredSuccessfulPods{i}, nil
1003 }
1004
1005 // Inst returns the underlying metric instrument.
1006 func (m JobDesiredSuccessfulPods) Inst() metric.Int64UpDownCounter {
1007 return m.Int64UpDownCounter
1008 }
1009
1010 // Name returns the semantic convention name of the instrument.
1011 func (JobDesiredSuccessfulPods) Name() string {
1012 return "k8s.job.desired_successful_pods"
1013 }
1014
1015 // Unit returns the semantic convention unit of the instrument
1016 func (JobDesiredSuccessfulPods) Unit() string {
1017 return "{pod}"
1018 }
1019
1020 // Description returns the semantic convention description of the instrument
1021 func (JobDesiredSuccessfulPods) Description() string {
1022 return "The desired number of successfully finished pods the job should be run with"
1023 }
1024
1025 // Add adds incr to the existing count.
1026 //
1027 // This metric aligns with the `completions` field of the
1028 // [K8s JobSpec].
1029 //
1030 // This metric SHOULD, at a minimum, be reported against a
1031 // [`k8s.job`] resource.
1032 //
1033 // [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
1034 // [`k8s.job`]: ../resource/k8s.md#job
1035 func (m JobDesiredSuccessfulPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1036 if len(attrs) == 0 {
1037 m.Int64UpDownCounter.Add(ctx, incr)
1038 return
1039 }
1040
1041 o := addOptPool.Get().(*[]metric.AddOption)
1042 defer func() {
1043 *o = (*o)[:0]
1044 addOptPool.Put(o)
1045 }()
1046
1047 *o = append(*o, metric.WithAttributes(attrs...))
1048 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1049 }
1050
1051 // JobFailedPods is an instrument used to record metric values conforming to the
1052 // "k8s.job.failed_pods" semantic conventions. It represents the number of pods
1053 // which reached phase Failed for a job.
1054 type JobFailedPods struct {
1055 metric.Int64UpDownCounter
1056 }
1057
1058 // NewJobFailedPods returns a new JobFailedPods instrument.
1059 func NewJobFailedPods(
1060 m metric.Meter,
1061 opt ...metric.Int64UpDownCounterOption,
1062 ) (JobFailedPods, error) {
1063 // Check if the meter is nil.
1064 if m == nil {
1065 return JobFailedPods{noop.Int64UpDownCounter{}}, nil
1066 }
1067
1068 i, err := m.Int64UpDownCounter(
1069 "k8s.job.failed_pods",
1070 append([]metric.Int64UpDownCounterOption{
1071 metric.WithDescription("The number of pods which reached phase Failed for a job"),
1072 metric.WithUnit("{pod}"),
1073 }, opt...)...,
1074 )
1075 if err != nil {
1076 return JobFailedPods{noop.Int64UpDownCounter{}}, err
1077 }
1078 return JobFailedPods{i}, nil
1079 }
1080
1081 // Inst returns the underlying metric instrument.
1082 func (m JobFailedPods) Inst() metric.Int64UpDownCounter {
1083 return m.Int64UpDownCounter
1084 }
1085
1086 // Name returns the semantic convention name of the instrument.
1087 func (JobFailedPods) Name() string {
1088 return "k8s.job.failed_pods"
1089 }
1090
1091 // Unit returns the semantic convention unit of the instrument
1092 func (JobFailedPods) Unit() string {
1093 return "{pod}"
1094 }
1095
1096 // Description returns the semantic convention description of the instrument
1097 func (JobFailedPods) Description() string {
1098 return "The number of pods which reached phase Failed for a job"
1099 }
1100
1101 // Add adds incr to the existing count.
1102 //
1103 // This metric aligns with the `failed` field of the
1104 // [K8s JobStatus].
1105 //
1106 // This metric SHOULD, at a minimum, be reported against a
1107 // [`k8s.job`] resource.
1108 //
1109 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
1110 // [`k8s.job`]: ../resource/k8s.md#job
1111 func (m JobFailedPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1112 if len(attrs) == 0 {
1113 m.Int64UpDownCounter.Add(ctx, incr)
1114 return
1115 }
1116
1117 o := addOptPool.Get().(*[]metric.AddOption)
1118 defer func() {
1119 *o = (*o)[:0]
1120 addOptPool.Put(o)
1121 }()
1122
1123 *o = append(*o, metric.WithAttributes(attrs...))
1124 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1125 }
1126
1127 // JobMaxParallelPods is an instrument used to record metric values conforming to
1128 // the "k8s.job.max_parallel_pods" semantic conventions. It represents the max
1129 // desired number of pods the job should run at any given time.
1130 type JobMaxParallelPods struct {
1131 metric.Int64UpDownCounter
1132 }
1133
1134 // NewJobMaxParallelPods returns a new JobMaxParallelPods instrument.
1135 func NewJobMaxParallelPods(
1136 m metric.Meter,
1137 opt ...metric.Int64UpDownCounterOption,
1138 ) (JobMaxParallelPods, error) {
1139 // Check if the meter is nil.
1140 if m == nil {
1141 return JobMaxParallelPods{noop.Int64UpDownCounter{}}, nil
1142 }
1143
1144 i, err := m.Int64UpDownCounter(
1145 "k8s.job.max_parallel_pods",
1146 append([]metric.Int64UpDownCounterOption{
1147 metric.WithDescription("The max desired number of pods the job should run at any given time"),
1148 metric.WithUnit("{pod}"),
1149 }, opt...)...,
1150 )
1151 if err != nil {
1152 return JobMaxParallelPods{noop.Int64UpDownCounter{}}, err
1153 }
1154 return JobMaxParallelPods{i}, nil
1155 }
1156
1157 // Inst returns the underlying metric instrument.
1158 func (m JobMaxParallelPods) Inst() metric.Int64UpDownCounter {
1159 return m.Int64UpDownCounter
1160 }
1161
1162 // Name returns the semantic convention name of the instrument.
1163 func (JobMaxParallelPods) Name() string {
1164 return "k8s.job.max_parallel_pods"
1165 }
1166
1167 // Unit returns the semantic convention unit of the instrument
1168 func (JobMaxParallelPods) Unit() string {
1169 return "{pod}"
1170 }
1171
1172 // Description returns the semantic convention description of the instrument
1173 func (JobMaxParallelPods) Description() string {
1174 return "The max desired number of pods the job should run at any given time"
1175 }
1176
1177 // Add adds incr to the existing count.
1178 //
1179 // This metric aligns with the `parallelism` field of the
1180 // [K8s JobSpec].
1181 //
1182 // This metric SHOULD, at a minimum, be reported against a
1183 // [`k8s.job`] resource.
1184 //
1185 // [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
1186 // [`k8s.job`]: ../resource/k8s.md#job
1187 func (m JobMaxParallelPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1188 if len(attrs) == 0 {
1189 m.Int64UpDownCounter.Add(ctx, incr)
1190 return
1191 }
1192
1193 o := addOptPool.Get().(*[]metric.AddOption)
1194 defer func() {
1195 *o = (*o)[:0]
1196 addOptPool.Put(o)
1197 }()
1198
1199 *o = append(*o, metric.WithAttributes(attrs...))
1200 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1201 }
1202
1203 // JobSuccessfulPods is an instrument used to record metric values conforming to
1204 // the "k8s.job.successful_pods" semantic conventions. It represents the number
1205 // of pods which reached phase Succeeded for a job.
1206 type JobSuccessfulPods struct {
1207 metric.Int64UpDownCounter
1208 }
1209
1210 // NewJobSuccessfulPods returns a new JobSuccessfulPods instrument.
1211 func NewJobSuccessfulPods(
1212 m metric.Meter,
1213 opt ...metric.Int64UpDownCounterOption,
1214 ) (JobSuccessfulPods, error) {
1215 // Check if the meter is nil.
1216 if m == nil {
1217 return JobSuccessfulPods{noop.Int64UpDownCounter{}}, nil
1218 }
1219
1220 i, err := m.Int64UpDownCounter(
1221 "k8s.job.successful_pods",
1222 append([]metric.Int64UpDownCounterOption{
1223 metric.WithDescription("The number of pods which reached phase Succeeded for a job"),
1224 metric.WithUnit("{pod}"),
1225 }, opt...)...,
1226 )
1227 if err != nil {
1228 return JobSuccessfulPods{noop.Int64UpDownCounter{}}, err
1229 }
1230 return JobSuccessfulPods{i}, nil
1231 }
1232
1233 // Inst returns the underlying metric instrument.
1234 func (m JobSuccessfulPods) Inst() metric.Int64UpDownCounter {
1235 return m.Int64UpDownCounter
1236 }
1237
1238 // Name returns the semantic convention name of the instrument.
1239 func (JobSuccessfulPods) Name() string {
1240 return "k8s.job.successful_pods"
1241 }
1242
1243 // Unit returns the semantic convention unit of the instrument
1244 func (JobSuccessfulPods) Unit() string {
1245 return "{pod}"
1246 }
1247
1248 // Description returns the semantic convention description of the instrument
1249 func (JobSuccessfulPods) Description() string {
1250 return "The number of pods which reached phase Succeeded for a job"
1251 }
1252
1253 // Add adds incr to the existing count.
1254 //
1255 // This metric aligns with the `succeeded` field of the
1256 // [K8s JobStatus].
1257 //
1258 // This metric SHOULD, at a minimum, be reported against a
1259 // [`k8s.job`] resource.
1260 //
1261 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
1262 // [`k8s.job`]: ../resource/k8s.md#job
1263 func (m JobSuccessfulPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1264 if len(attrs) == 0 {
1265 m.Int64UpDownCounter.Add(ctx, incr)
1266 return
1267 }
1268
1269 o := addOptPool.Get().(*[]metric.AddOption)
1270 defer func() {
1271 *o = (*o)[:0]
1272 addOptPool.Put(o)
1273 }()
1274
1275 *o = append(*o, metric.WithAttributes(attrs...))
1276 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1277 }
1278
1279 // NamespacePhase is an instrument used to record metric values conforming to the
1280 // "k8s.namespace.phase" semantic conventions. It represents the describes number
1281 // of K8s namespaces that are currently in a given phase.
1282 type NamespacePhase struct {
1283 metric.Int64UpDownCounter
1284 }
1285
1286 // NewNamespacePhase returns a new NamespacePhase instrument.
1287 func NewNamespacePhase(
1288 m metric.Meter,
1289 opt ...metric.Int64UpDownCounterOption,
1290 ) (NamespacePhase, error) {
1291 // Check if the meter is nil.
1292 if m == nil {
1293 return NamespacePhase{noop.Int64UpDownCounter{}}, nil
1294 }
1295
1296 i, err := m.Int64UpDownCounter(
1297 "k8s.namespace.phase",
1298 append([]metric.Int64UpDownCounterOption{
1299 metric.WithDescription("Describes number of K8s namespaces that are currently in a given phase."),
1300 metric.WithUnit("{namespace}"),
1301 }, opt...)...,
1302 )
1303 if err != nil {
1304 return NamespacePhase{noop.Int64UpDownCounter{}}, err
1305 }
1306 return NamespacePhase{i}, nil
1307 }
1308
1309 // Inst returns the underlying metric instrument.
1310 func (m NamespacePhase) Inst() metric.Int64UpDownCounter {
1311 return m.Int64UpDownCounter
1312 }
1313
1314 // Name returns the semantic convention name of the instrument.
1315 func (NamespacePhase) Name() string {
1316 return "k8s.namespace.phase"
1317 }
1318
1319 // Unit returns the semantic convention unit of the instrument
1320 func (NamespacePhase) Unit() string {
1321 return "{namespace}"
1322 }
1323
1324 // Description returns the semantic convention description of the instrument
1325 func (NamespacePhase) Description() string {
1326 return "Describes number of K8s namespaces that are currently in a given phase."
1327 }
1328
1329 // Add adds incr to the existing count.
1330 //
1331 // The namespacePhase is the the phase of the K8s namespace.
1332 //
1333 // This metric SHOULD, at a minimum, be reported against a
1334 // [`k8s.namespace`] resource.
1335 //
1336 // [`k8s.namespace`]: ../resource/k8s.md#namespace
1337 func (m NamespacePhase) Add(
1338 ctx context.Context,
1339 incr int64,
1340 namespacePhase NamespacePhaseAttr,
1341 attrs ...attribute.KeyValue,
1342 ) {
1343 o := addOptPool.Get().(*[]metric.AddOption)
1344 defer func() {
1345 *o = (*o)[:0]
1346 addOptPool.Put(o)
1347 }()
1348
1349 *o = append(
1350 *o,
1351 metric.WithAttributes(
1352 append(
1353 attrs,
1354 attribute.String("k8s.namespace.phase", string(namespacePhase)),
1355 )...,
1356 ),
1357 )
1358
1359 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1360 }
1361
1362 // NodeCPUTime is an instrument used to record metric values conforming to the
1363 // "k8s.node.cpu.time" semantic conventions. It represents the total CPU time
1364 // consumed.
1365 type NodeCPUTime struct {
1366 metric.Float64Counter
1367 }
1368
1369 // NewNodeCPUTime returns a new NodeCPUTime instrument.
1370 func NewNodeCPUTime(
1371 m metric.Meter,
1372 opt ...metric.Float64CounterOption,
1373 ) (NodeCPUTime, error) {
1374 // Check if the meter is nil.
1375 if m == nil {
1376 return NodeCPUTime{noop.Float64Counter{}}, nil
1377 }
1378
1379 i, err := m.Float64Counter(
1380 "k8s.node.cpu.time",
1381 append([]metric.Float64CounterOption{
1382 metric.WithDescription("Total CPU time consumed"),
1383 metric.WithUnit("s"),
1384 }, opt...)...,
1385 )
1386 if err != nil {
1387 return NodeCPUTime{noop.Float64Counter{}}, err
1388 }
1389 return NodeCPUTime{i}, nil
1390 }
1391
1392 // Inst returns the underlying metric instrument.
1393 func (m NodeCPUTime) Inst() metric.Float64Counter {
1394 return m.Float64Counter
1395 }
1396
1397 // Name returns the semantic convention name of the instrument.
1398 func (NodeCPUTime) Name() string {
1399 return "k8s.node.cpu.time"
1400 }
1401
1402 // Unit returns the semantic convention unit of the instrument
1403 func (NodeCPUTime) Unit() string {
1404 return "s"
1405 }
1406
1407 // Description returns the semantic convention description of the instrument
1408 func (NodeCPUTime) Description() string {
1409 return "Total CPU time consumed"
1410 }
1411
1412 // Add adds incr to the existing count.
1413 //
1414 // Total CPU time consumed by the specific Node on all available CPU cores
1415 func (m NodeCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
1416 if len(attrs) == 0 {
1417 m.Float64Counter.Add(ctx, incr)
1418 return
1419 }
1420
1421 o := addOptPool.Get().(*[]metric.AddOption)
1422 defer func() {
1423 *o = (*o)[:0]
1424 addOptPool.Put(o)
1425 }()
1426
1427 *o = append(*o, metric.WithAttributes(attrs...))
1428 m.Float64Counter.Add(ctx, incr, *o...)
1429 }
1430
1431 // NodeCPUUsage is an instrument used to record metric values conforming to the
1432 // "k8s.node.cpu.usage" semantic conventions. It represents the node's CPU usage,
1433 // measured in cpus. Range from 0 to the number of allocatable CPUs.
1434 type NodeCPUUsage struct {
1435 metric.Int64Gauge
1436 }
1437
1438 // NewNodeCPUUsage returns a new NodeCPUUsage instrument.
1439 func NewNodeCPUUsage(
1440 m metric.Meter,
1441 opt ...metric.Int64GaugeOption,
1442 ) (NodeCPUUsage, error) {
1443 // Check if the meter is nil.
1444 if m == nil {
1445 return NodeCPUUsage{noop.Int64Gauge{}}, nil
1446 }
1447
1448 i, err := m.Int64Gauge(
1449 "k8s.node.cpu.usage",
1450 append([]metric.Int64GaugeOption{
1451 metric.WithDescription("Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"),
1452 metric.WithUnit("{cpu}"),
1453 }, opt...)...,
1454 )
1455 if err != nil {
1456 return NodeCPUUsage{noop.Int64Gauge{}}, err
1457 }
1458 return NodeCPUUsage{i}, nil
1459 }
1460
1461 // Inst returns the underlying metric instrument.
1462 func (m NodeCPUUsage) Inst() metric.Int64Gauge {
1463 return m.Int64Gauge
1464 }
1465
1466 // Name returns the semantic convention name of the instrument.
1467 func (NodeCPUUsage) Name() string {
1468 return "k8s.node.cpu.usage"
1469 }
1470
1471 // Unit returns the semantic convention unit of the instrument
1472 func (NodeCPUUsage) Unit() string {
1473 return "{cpu}"
1474 }
1475
1476 // Description returns the semantic convention description of the instrument
1477 func (NodeCPUUsage) Description() string {
1478 return "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"
1479 }
1480
1481 // Record records val to the current distribution.
1482 //
1483 // CPU usage of the specific Node on all available CPU cores, averaged over the
1484 // sample window
1485 func (m NodeCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
1486 if len(attrs) == 0 {
1487 m.Int64Gauge.Record(ctx, val)
1488 }
1489
1490 o := recOptPool.Get().(*[]metric.RecordOption)
1491 defer func() {
1492 *o = (*o)[:0]
1493 recOptPool.Put(o)
1494 }()
1495
1496 *o = append(*o, metric.WithAttributes(attrs...))
1497 m.Int64Gauge.Record(ctx, val, *o...)
1498 }
1499
1500 // NodeMemoryUsage is an instrument used to record metric values conforming to
1501 // the "k8s.node.memory.usage" semantic conventions. It represents the memory
1502 // usage of the Node.
1503 type NodeMemoryUsage struct {
1504 metric.Int64Gauge
1505 }
1506
1507 // NewNodeMemoryUsage returns a new NodeMemoryUsage instrument.
1508 func NewNodeMemoryUsage(
1509 m metric.Meter,
1510 opt ...metric.Int64GaugeOption,
1511 ) (NodeMemoryUsage, error) {
1512 // Check if the meter is nil.
1513 if m == nil {
1514 return NodeMemoryUsage{noop.Int64Gauge{}}, nil
1515 }
1516
1517 i, err := m.Int64Gauge(
1518 "k8s.node.memory.usage",
1519 append([]metric.Int64GaugeOption{
1520 metric.WithDescription("Memory usage of the Node"),
1521 metric.WithUnit("By"),
1522 }, opt...)...,
1523 )
1524 if err != nil {
1525 return NodeMemoryUsage{noop.Int64Gauge{}}, err
1526 }
1527 return NodeMemoryUsage{i}, nil
1528 }
1529
1530 // Inst returns the underlying metric instrument.
1531 func (m NodeMemoryUsage) Inst() metric.Int64Gauge {
1532 return m.Int64Gauge
1533 }
1534
1535 // Name returns the semantic convention name of the instrument.
1536 func (NodeMemoryUsage) Name() string {
1537 return "k8s.node.memory.usage"
1538 }
1539
1540 // Unit returns the semantic convention unit of the instrument
1541 func (NodeMemoryUsage) Unit() string {
1542 return "By"
1543 }
1544
1545 // Description returns the semantic convention description of the instrument
1546 func (NodeMemoryUsage) Description() string {
1547 return "Memory usage of the Node"
1548 }
1549
1550 // Record records val to the current distribution.
1551 //
1552 // Total memory usage of the Node
1553 func (m NodeMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
1554 if len(attrs) == 0 {
1555 m.Int64Gauge.Record(ctx, val)
1556 }
1557
1558 o := recOptPool.Get().(*[]metric.RecordOption)
1559 defer func() {
1560 *o = (*o)[:0]
1561 recOptPool.Put(o)
1562 }()
1563
1564 *o = append(*o, metric.WithAttributes(attrs...))
1565 m.Int64Gauge.Record(ctx, val, *o...)
1566 }
1567
1568 // NodeNetworkErrors is an instrument used to record metric values conforming to
1569 // the "k8s.node.network.errors" semantic conventions. It represents the node
1570 // network errors.
1571 type NodeNetworkErrors struct {
1572 metric.Int64Counter
1573 }
1574
1575 // NewNodeNetworkErrors returns a new NodeNetworkErrors instrument.
1576 func NewNodeNetworkErrors(
1577 m metric.Meter,
1578 opt ...metric.Int64CounterOption,
1579 ) (NodeNetworkErrors, error) {
1580 // Check if the meter is nil.
1581 if m == nil {
1582 return NodeNetworkErrors{noop.Int64Counter{}}, nil
1583 }
1584
1585 i, err := m.Int64Counter(
1586 "k8s.node.network.errors",
1587 append([]metric.Int64CounterOption{
1588 metric.WithDescription("Node network errors"),
1589 metric.WithUnit("{error}"),
1590 }, opt...)...,
1591 )
1592 if err != nil {
1593 return NodeNetworkErrors{noop.Int64Counter{}}, err
1594 }
1595 return NodeNetworkErrors{i}, nil
1596 }
1597
1598 // Inst returns the underlying metric instrument.
1599 func (m NodeNetworkErrors) Inst() metric.Int64Counter {
1600 return m.Int64Counter
1601 }
1602
1603 // Name returns the semantic convention name of the instrument.
1604 func (NodeNetworkErrors) Name() string {
1605 return "k8s.node.network.errors"
1606 }
1607
1608 // Unit returns the semantic convention unit of the instrument
1609 func (NodeNetworkErrors) Unit() string {
1610 return "{error}"
1611 }
1612
1613 // Description returns the semantic convention description of the instrument
1614 func (NodeNetworkErrors) Description() string {
1615 return "Node network errors"
1616 }
1617
1618 // Add adds incr to the existing count.
1619 //
1620 // All additional attrs passed are included in the recorded value.
1621 func (m NodeNetworkErrors) Add(
1622 ctx context.Context,
1623 incr int64,
1624 attrs ...attribute.KeyValue,
1625 ) {
1626 o := addOptPool.Get().(*[]metric.AddOption)
1627 defer func() {
1628 *o = (*o)[:0]
1629 addOptPool.Put(o)
1630 }()
1631
1632 *o = append(
1633 *o,
1634 metric.WithAttributes(
1635 attrs...,
1636 ),
1637 )
1638
1639 m.Int64Counter.Add(ctx, incr, *o...)
1640 }
1641
1642 // AttrNetworkInterfaceName returns an optional attribute for the
1643 // "network.interface.name" semantic convention. It represents the network
1644 // interface name.
1645 func (NodeNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue {
1646 return attribute.String("network.interface.name", val)
1647 }
1648
1649 // AttrNetworkIODirection returns an optional attribute for the
1650 // "network.io.direction" semantic convention. It represents the network IO
1651 // operation direction.
1652 func (NodeNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
1653 return attribute.String("network.io.direction", string(val))
1654 }
1655
1656 // NodeNetworkIO is an instrument used to record metric values conforming to the
1657 // "k8s.node.network.io" semantic conventions. It represents the network bytes
1658 // for the Node.
1659 type NodeNetworkIO struct {
1660 metric.Int64Counter
1661 }
1662
1663 // NewNodeNetworkIO returns a new NodeNetworkIO instrument.
1664 func NewNodeNetworkIO(
1665 m metric.Meter,
1666 opt ...metric.Int64CounterOption,
1667 ) (NodeNetworkIO, error) {
1668 // Check if the meter is nil.
1669 if m == nil {
1670 return NodeNetworkIO{noop.Int64Counter{}}, nil
1671 }
1672
1673 i, err := m.Int64Counter(
1674 "k8s.node.network.io",
1675 append([]metric.Int64CounterOption{
1676 metric.WithDescription("Network bytes for the Node"),
1677 metric.WithUnit("By"),
1678 }, opt...)...,
1679 )
1680 if err != nil {
1681 return NodeNetworkIO{noop.Int64Counter{}}, err
1682 }
1683 return NodeNetworkIO{i}, nil
1684 }
1685
1686 // Inst returns the underlying metric instrument.
1687 func (m NodeNetworkIO) Inst() metric.Int64Counter {
1688 return m.Int64Counter
1689 }
1690
1691 // Name returns the semantic convention name of the instrument.
1692 func (NodeNetworkIO) Name() string {
1693 return "k8s.node.network.io"
1694 }
1695
1696 // Unit returns the semantic convention unit of the instrument
1697 func (NodeNetworkIO) Unit() string {
1698 return "By"
1699 }
1700
1701 // Description returns the semantic convention description of the instrument
1702 func (NodeNetworkIO) Description() string {
1703 return "Network bytes for the Node"
1704 }
1705
1706 // Add adds incr to the existing count.
1707 //
1708 // All additional attrs passed are included in the recorded value.
1709 func (m NodeNetworkIO) Add(
1710 ctx context.Context,
1711 incr int64,
1712 attrs ...attribute.KeyValue,
1713 ) {
1714 o := addOptPool.Get().(*[]metric.AddOption)
1715 defer func() {
1716 *o = (*o)[:0]
1717 addOptPool.Put(o)
1718 }()
1719
1720 *o = append(
1721 *o,
1722 metric.WithAttributes(
1723 attrs...,
1724 ),
1725 )
1726
1727 m.Int64Counter.Add(ctx, incr, *o...)
1728 }
1729
1730 // AttrNetworkInterfaceName returns an optional attribute for the
1731 // "network.interface.name" semantic convention. It represents the network
1732 // interface name.
1733 func (NodeNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue {
1734 return attribute.String("network.interface.name", val)
1735 }
1736
1737 // AttrNetworkIODirection returns an optional attribute for the
1738 // "network.io.direction" semantic convention. It represents the network IO
1739 // operation direction.
1740 func (NodeNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
1741 return attribute.String("network.io.direction", string(val))
1742 }
1743
1744 // NodeUptime is an instrument used to record metric values conforming to the
1745 // "k8s.node.uptime" semantic conventions. It represents the time the Node has
1746 // been running.
1747 type NodeUptime struct {
1748 metric.Float64Gauge
1749 }
1750
1751 // NewNodeUptime returns a new NodeUptime instrument.
1752 func NewNodeUptime(
1753 m metric.Meter,
1754 opt ...metric.Float64GaugeOption,
1755 ) (NodeUptime, error) {
1756 // Check if the meter is nil.
1757 if m == nil {
1758 return NodeUptime{noop.Float64Gauge{}}, nil
1759 }
1760
1761 i, err := m.Float64Gauge(
1762 "k8s.node.uptime",
1763 append([]metric.Float64GaugeOption{
1764 metric.WithDescription("The time the Node has been running"),
1765 metric.WithUnit("s"),
1766 }, opt...)...,
1767 )
1768 if err != nil {
1769 return NodeUptime{noop.Float64Gauge{}}, err
1770 }
1771 return NodeUptime{i}, nil
1772 }
1773
1774 // Inst returns the underlying metric instrument.
1775 func (m NodeUptime) Inst() metric.Float64Gauge {
1776 return m.Float64Gauge
1777 }
1778
1779 // Name returns the semantic convention name of the instrument.
1780 func (NodeUptime) Name() string {
1781 return "k8s.node.uptime"
1782 }
1783
1784 // Unit returns the semantic convention unit of the instrument
1785 func (NodeUptime) Unit() string {
1786 return "s"
1787 }
1788
1789 // Description returns the semantic convention description of the instrument
1790 func (NodeUptime) Description() string {
1791 return "The time the Node has been running"
1792 }
1793
1794 // Record records val to the current distribution.
1795 //
1796 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
1797 // seconds as a floating point number with the highest precision available.
1798 // The actual accuracy would depend on the instrumentation and operating system.
1799 func (m NodeUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
1800 if len(attrs) == 0 {
1801 m.Float64Gauge.Record(ctx, val)
1802 }
1803
1804 o := recOptPool.Get().(*[]metric.RecordOption)
1805 defer func() {
1806 *o = (*o)[:0]
1807 recOptPool.Put(o)
1808 }()
1809
1810 *o = append(*o, metric.WithAttributes(attrs...))
1811 m.Float64Gauge.Record(ctx, val, *o...)
1812 }
1813
1814 // PodCPUTime is an instrument used to record metric values conforming to the
1815 // "k8s.pod.cpu.time" semantic conventions. It represents the total CPU time
1816 // consumed.
1817 type PodCPUTime struct {
1818 metric.Float64Counter
1819 }
1820
1821 // NewPodCPUTime returns a new PodCPUTime instrument.
1822 func NewPodCPUTime(
1823 m metric.Meter,
1824 opt ...metric.Float64CounterOption,
1825 ) (PodCPUTime, error) {
1826 // Check if the meter is nil.
1827 if m == nil {
1828 return PodCPUTime{noop.Float64Counter{}}, nil
1829 }
1830
1831 i, err := m.Float64Counter(
1832 "k8s.pod.cpu.time",
1833 append([]metric.Float64CounterOption{
1834 metric.WithDescription("Total CPU time consumed"),
1835 metric.WithUnit("s"),
1836 }, opt...)...,
1837 )
1838 if err != nil {
1839 return PodCPUTime{noop.Float64Counter{}}, err
1840 }
1841 return PodCPUTime{i}, nil
1842 }
1843
1844 // Inst returns the underlying metric instrument.
1845 func (m PodCPUTime) Inst() metric.Float64Counter {
1846 return m.Float64Counter
1847 }
1848
1849 // Name returns the semantic convention name of the instrument.
1850 func (PodCPUTime) Name() string {
1851 return "k8s.pod.cpu.time"
1852 }
1853
1854 // Unit returns the semantic convention unit of the instrument
1855 func (PodCPUTime) Unit() string {
1856 return "s"
1857 }
1858
1859 // Description returns the semantic convention description of the instrument
1860 func (PodCPUTime) Description() string {
1861 return "Total CPU time consumed"
1862 }
1863
1864 // Add adds incr to the existing count.
1865 //
1866 // Total CPU time consumed by the specific Pod on all available CPU cores
1867 func (m PodCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
1868 if len(attrs) == 0 {
1869 m.Float64Counter.Add(ctx, incr)
1870 return
1871 }
1872
1873 o := addOptPool.Get().(*[]metric.AddOption)
1874 defer func() {
1875 *o = (*o)[:0]
1876 addOptPool.Put(o)
1877 }()
1878
1879 *o = append(*o, metric.WithAttributes(attrs...))
1880 m.Float64Counter.Add(ctx, incr, *o...)
1881 }
1882
1883 // PodCPUUsage is an instrument used to record metric values conforming to the
1884 // "k8s.pod.cpu.usage" semantic conventions. It represents the pod's CPU usage,
1885 // measured in cpus. Range from 0 to the number of allocatable CPUs.
1886 type PodCPUUsage struct {
1887 metric.Int64Gauge
1888 }
1889
1890 // NewPodCPUUsage returns a new PodCPUUsage instrument.
1891 func NewPodCPUUsage(
1892 m metric.Meter,
1893 opt ...metric.Int64GaugeOption,
1894 ) (PodCPUUsage, error) {
1895 // Check if the meter is nil.
1896 if m == nil {
1897 return PodCPUUsage{noop.Int64Gauge{}}, nil
1898 }
1899
1900 i, err := m.Int64Gauge(
1901 "k8s.pod.cpu.usage",
1902 append([]metric.Int64GaugeOption{
1903 metric.WithDescription("Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"),
1904 metric.WithUnit("{cpu}"),
1905 }, opt...)...,
1906 )
1907 if err != nil {
1908 return PodCPUUsage{noop.Int64Gauge{}}, err
1909 }
1910 return PodCPUUsage{i}, nil
1911 }
1912
1913 // Inst returns the underlying metric instrument.
1914 func (m PodCPUUsage) Inst() metric.Int64Gauge {
1915 return m.Int64Gauge
1916 }
1917
1918 // Name returns the semantic convention name of the instrument.
1919 func (PodCPUUsage) Name() string {
1920 return "k8s.pod.cpu.usage"
1921 }
1922
1923 // Unit returns the semantic convention unit of the instrument
1924 func (PodCPUUsage) Unit() string {
1925 return "{cpu}"
1926 }
1927
1928 // Description returns the semantic convention description of the instrument
1929 func (PodCPUUsage) Description() string {
1930 return "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"
1931 }
1932
1933 // Record records val to the current distribution.
1934 //
1935 // CPU usage of the specific Pod on all available CPU cores, averaged over the
1936 // sample window
1937 func (m PodCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
1938 if len(attrs) == 0 {
1939 m.Int64Gauge.Record(ctx, val)
1940 }
1941
1942 o := recOptPool.Get().(*[]metric.RecordOption)
1943 defer func() {
1944 *o = (*o)[:0]
1945 recOptPool.Put(o)
1946 }()
1947
1948 *o = append(*o, metric.WithAttributes(attrs...))
1949 m.Int64Gauge.Record(ctx, val, *o...)
1950 }
1951
1952 // PodMemoryUsage is an instrument used to record metric values conforming to the
1953 // "k8s.pod.memory.usage" semantic conventions. It represents the memory usage of
1954 // the Pod.
1955 type PodMemoryUsage struct {
1956 metric.Int64Gauge
1957 }
1958
1959 // NewPodMemoryUsage returns a new PodMemoryUsage instrument.
1960 func NewPodMemoryUsage(
1961 m metric.Meter,
1962 opt ...metric.Int64GaugeOption,
1963 ) (PodMemoryUsage, error) {
1964 // Check if the meter is nil.
1965 if m == nil {
1966 return PodMemoryUsage{noop.Int64Gauge{}}, nil
1967 }
1968
1969 i, err := m.Int64Gauge(
1970 "k8s.pod.memory.usage",
1971 append([]metric.Int64GaugeOption{
1972 metric.WithDescription("Memory usage of the Pod"),
1973 metric.WithUnit("By"),
1974 }, opt...)...,
1975 )
1976 if err != nil {
1977 return PodMemoryUsage{noop.Int64Gauge{}}, err
1978 }
1979 return PodMemoryUsage{i}, nil
1980 }
1981
1982 // Inst returns the underlying metric instrument.
1983 func (m PodMemoryUsage) Inst() metric.Int64Gauge {
1984 return m.Int64Gauge
1985 }
1986
1987 // Name returns the semantic convention name of the instrument.
1988 func (PodMemoryUsage) Name() string {
1989 return "k8s.pod.memory.usage"
1990 }
1991
1992 // Unit returns the semantic convention unit of the instrument
1993 func (PodMemoryUsage) Unit() string {
1994 return "By"
1995 }
1996
1997 // Description returns the semantic convention description of the instrument
1998 func (PodMemoryUsage) Description() string {
1999 return "Memory usage of the Pod"
2000 }
2001
2002 // Record records val to the current distribution.
2003 //
2004 // Total memory usage of the Pod
2005 func (m PodMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
2006 if len(attrs) == 0 {
2007 m.Int64Gauge.Record(ctx, val)
2008 }
2009
2010 o := recOptPool.Get().(*[]metric.RecordOption)
2011 defer func() {
2012 *o = (*o)[:0]
2013 recOptPool.Put(o)
2014 }()
2015
2016 *o = append(*o, metric.WithAttributes(attrs...))
2017 m.Int64Gauge.Record(ctx, val, *o...)
2018 }
2019
2020 // PodNetworkErrors is an instrument used to record metric values conforming to
2021 // the "k8s.pod.network.errors" semantic conventions. It represents the pod
2022 // network errors.
2023 type PodNetworkErrors struct {
2024 metric.Int64Counter
2025 }
2026
2027 // NewPodNetworkErrors returns a new PodNetworkErrors instrument.
2028 func NewPodNetworkErrors(
2029 m metric.Meter,
2030 opt ...metric.Int64CounterOption,
2031 ) (PodNetworkErrors, error) {
2032 // Check if the meter is nil.
2033 if m == nil {
2034 return PodNetworkErrors{noop.Int64Counter{}}, nil
2035 }
2036
2037 i, err := m.Int64Counter(
2038 "k8s.pod.network.errors",
2039 append([]metric.Int64CounterOption{
2040 metric.WithDescription("Pod network errors"),
2041 metric.WithUnit("{error}"),
2042 }, opt...)...,
2043 )
2044 if err != nil {
2045 return PodNetworkErrors{noop.Int64Counter{}}, err
2046 }
2047 return PodNetworkErrors{i}, nil
2048 }
2049
2050 // Inst returns the underlying metric instrument.
2051 func (m PodNetworkErrors) Inst() metric.Int64Counter {
2052 return m.Int64Counter
2053 }
2054
2055 // Name returns the semantic convention name of the instrument.
2056 func (PodNetworkErrors) Name() string {
2057 return "k8s.pod.network.errors"
2058 }
2059
2060 // Unit returns the semantic convention unit of the instrument
2061 func (PodNetworkErrors) Unit() string {
2062 return "{error}"
2063 }
2064
2065 // Description returns the semantic convention description of the instrument
2066 func (PodNetworkErrors) Description() string {
2067 return "Pod network errors"
2068 }
2069
2070 // Add adds incr to the existing count.
2071 //
2072 // All additional attrs passed are included in the recorded value.
2073 func (m PodNetworkErrors) Add(
2074 ctx context.Context,
2075 incr int64,
2076 attrs ...attribute.KeyValue,
2077 ) {
2078 o := addOptPool.Get().(*[]metric.AddOption)
2079 defer func() {
2080 *o = (*o)[:0]
2081 addOptPool.Put(o)
2082 }()
2083
2084 *o = append(
2085 *o,
2086 metric.WithAttributes(
2087 attrs...,
2088 ),
2089 )
2090
2091 m.Int64Counter.Add(ctx, incr, *o...)
2092 }
2093
2094 // AttrNetworkInterfaceName returns an optional attribute for the
2095 // "network.interface.name" semantic convention. It represents the network
2096 // interface name.
2097 func (PodNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue {
2098 return attribute.String("network.interface.name", val)
2099 }
2100
2101 // AttrNetworkIODirection returns an optional attribute for the
2102 // "network.io.direction" semantic convention. It represents the network IO
2103 // operation direction.
2104 func (PodNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
2105 return attribute.String("network.io.direction", string(val))
2106 }
2107
2108 // PodNetworkIO is an instrument used to record metric values conforming to the
2109 // "k8s.pod.network.io" semantic conventions. It represents the network bytes for
2110 // the Pod.
2111 type PodNetworkIO struct {
2112 metric.Int64Counter
2113 }
2114
2115 // NewPodNetworkIO returns a new PodNetworkIO instrument.
2116 func NewPodNetworkIO(
2117 m metric.Meter,
2118 opt ...metric.Int64CounterOption,
2119 ) (PodNetworkIO, error) {
2120 // Check if the meter is nil.
2121 if m == nil {
2122 return PodNetworkIO{noop.Int64Counter{}}, nil
2123 }
2124
2125 i, err := m.Int64Counter(
2126 "k8s.pod.network.io",
2127 append([]metric.Int64CounterOption{
2128 metric.WithDescription("Network bytes for the Pod"),
2129 metric.WithUnit("By"),
2130 }, opt...)...,
2131 )
2132 if err != nil {
2133 return PodNetworkIO{noop.Int64Counter{}}, err
2134 }
2135 return PodNetworkIO{i}, nil
2136 }
2137
2138 // Inst returns the underlying metric instrument.
2139 func (m PodNetworkIO) Inst() metric.Int64Counter {
2140 return m.Int64Counter
2141 }
2142
2143 // Name returns the semantic convention name of the instrument.
2144 func (PodNetworkIO) Name() string {
2145 return "k8s.pod.network.io"
2146 }
2147
2148 // Unit returns the semantic convention unit of the instrument
2149 func (PodNetworkIO) Unit() string {
2150 return "By"
2151 }
2152
2153 // Description returns the semantic convention description of the instrument
2154 func (PodNetworkIO) Description() string {
2155 return "Network bytes for the Pod"
2156 }
2157
2158 // Add adds incr to the existing count.
2159 //
2160 // All additional attrs passed are included in the recorded value.
2161 func (m PodNetworkIO) Add(
2162 ctx context.Context,
2163 incr int64,
2164 attrs ...attribute.KeyValue,
2165 ) {
2166 o := addOptPool.Get().(*[]metric.AddOption)
2167 defer func() {
2168 *o = (*o)[:0]
2169 addOptPool.Put(o)
2170 }()
2171
2172 *o = append(
2173 *o,
2174 metric.WithAttributes(
2175 attrs...,
2176 ),
2177 )
2178
2179 m.Int64Counter.Add(ctx, incr, *o...)
2180 }
2181
2182 // AttrNetworkInterfaceName returns an optional attribute for the
2183 // "network.interface.name" semantic convention. It represents the network
2184 // interface name.
2185 func (PodNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue {
2186 return attribute.String("network.interface.name", val)
2187 }
2188
2189 // AttrNetworkIODirection returns an optional attribute for the
2190 // "network.io.direction" semantic convention. It represents the network IO
2191 // operation direction.
2192 func (PodNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
2193 return attribute.String("network.io.direction", string(val))
2194 }
2195
2196 // PodUptime is an instrument used to record metric values conforming to the
2197 // "k8s.pod.uptime" semantic conventions. It represents the time the Pod has been
2198 // running.
2199 type PodUptime struct {
2200 metric.Float64Gauge
2201 }
2202
2203 // NewPodUptime returns a new PodUptime instrument.
2204 func NewPodUptime(
2205 m metric.Meter,
2206 opt ...metric.Float64GaugeOption,
2207 ) (PodUptime, error) {
2208 // Check if the meter is nil.
2209 if m == nil {
2210 return PodUptime{noop.Float64Gauge{}}, nil
2211 }
2212
2213 i, err := m.Float64Gauge(
2214 "k8s.pod.uptime",
2215 append([]metric.Float64GaugeOption{
2216 metric.WithDescription("The time the Pod has been running"),
2217 metric.WithUnit("s"),
2218 }, opt...)...,
2219 )
2220 if err != nil {
2221 return PodUptime{noop.Float64Gauge{}}, err
2222 }
2223 return PodUptime{i}, nil
2224 }
2225
2226 // Inst returns the underlying metric instrument.
2227 func (m PodUptime) Inst() metric.Float64Gauge {
2228 return m.Float64Gauge
2229 }
2230
2231 // Name returns the semantic convention name of the instrument.
2232 func (PodUptime) Name() string {
2233 return "k8s.pod.uptime"
2234 }
2235
2236 // Unit returns the semantic convention unit of the instrument
2237 func (PodUptime) Unit() string {
2238 return "s"
2239 }
2240
2241 // Description returns the semantic convention description of the instrument
2242 func (PodUptime) Description() string {
2243 return "The time the Pod has been running"
2244 }
2245
2246 // Record records val to the current distribution.
2247 //
2248 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
2249 // seconds as a floating point number with the highest precision available.
2250 // The actual accuracy would depend on the instrumentation and operating system.
2251 func (m PodUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
2252 if len(attrs) == 0 {
2253 m.Float64Gauge.Record(ctx, val)
2254 }
2255
2256 o := recOptPool.Get().(*[]metric.RecordOption)
2257 defer func() {
2258 *o = (*o)[:0]
2259 recOptPool.Put(o)
2260 }()
2261
2262 *o = append(*o, metric.WithAttributes(attrs...))
2263 m.Float64Gauge.Record(ctx, val, *o...)
2264 }
2265
2266 // ReplicaSetAvailablePods is an instrument used to record metric values
2267 // conforming to the "k8s.replicaset.available_pods" semantic conventions. It
2268 // represents the total number of available replica pods (ready for at least
2269 // minReadySeconds) targeted by this replicaset.
2270 type ReplicaSetAvailablePods struct {
2271 metric.Int64UpDownCounter
2272 }
2273
2274 // NewReplicaSetAvailablePods returns a new ReplicaSetAvailablePods instrument.
2275 func NewReplicaSetAvailablePods(
2276 m metric.Meter,
2277 opt ...metric.Int64UpDownCounterOption,
2278 ) (ReplicaSetAvailablePods, error) {
2279 // Check if the meter is nil.
2280 if m == nil {
2281 return ReplicaSetAvailablePods{noop.Int64UpDownCounter{}}, nil
2282 }
2283
2284 i, err := m.Int64UpDownCounter(
2285 "k8s.replicaset.available_pods",
2286 append([]metric.Int64UpDownCounterOption{
2287 metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset"),
2288 metric.WithUnit("{pod}"),
2289 }, opt...)...,
2290 )
2291 if err != nil {
2292 return ReplicaSetAvailablePods{noop.Int64UpDownCounter{}}, err
2293 }
2294 return ReplicaSetAvailablePods{i}, nil
2295 }
2296
2297 // Inst returns the underlying metric instrument.
2298 func (m ReplicaSetAvailablePods) Inst() metric.Int64UpDownCounter {
2299 return m.Int64UpDownCounter
2300 }
2301
2302 // Name returns the semantic convention name of the instrument.
2303 func (ReplicaSetAvailablePods) Name() string {
2304 return "k8s.replicaset.available_pods"
2305 }
2306
2307 // Unit returns the semantic convention unit of the instrument
2308 func (ReplicaSetAvailablePods) Unit() string {
2309 return "{pod}"
2310 }
2311
2312 // Description returns the semantic convention description of the instrument
2313 func (ReplicaSetAvailablePods) Description() string {
2314 return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset"
2315 }
2316
2317 // Add adds incr to the existing count.
2318 //
2319 // This metric aligns with the `availableReplicas` field of the
2320 // [K8s ReplicaSetStatus].
2321 //
2322 // This metric SHOULD, at a minimum, be reported against a
2323 // [`k8s.replicaset`] resource.
2324 //
2325 // [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps
2326 // [`k8s.replicaset`]: ../resource/k8s.md#replicaset
2327 func (m ReplicaSetAvailablePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2328 if len(attrs) == 0 {
2329 m.Int64UpDownCounter.Add(ctx, incr)
2330 return
2331 }
2332
2333 o := addOptPool.Get().(*[]metric.AddOption)
2334 defer func() {
2335 *o = (*o)[:0]
2336 addOptPool.Put(o)
2337 }()
2338
2339 *o = append(*o, metric.WithAttributes(attrs...))
2340 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2341 }
2342
2343 // ReplicaSetDesiredPods is an instrument used to record metric values conforming
2344 // to the "k8s.replicaset.desired_pods" semantic conventions. It represents the
2345 // number of desired replica pods in this replicaset.
2346 type ReplicaSetDesiredPods struct {
2347 metric.Int64UpDownCounter
2348 }
2349
2350 // NewReplicaSetDesiredPods returns a new ReplicaSetDesiredPods instrument.
2351 func NewReplicaSetDesiredPods(
2352 m metric.Meter,
2353 opt ...metric.Int64UpDownCounterOption,
2354 ) (ReplicaSetDesiredPods, error) {
2355 // Check if the meter is nil.
2356 if m == nil {
2357 return ReplicaSetDesiredPods{noop.Int64UpDownCounter{}}, nil
2358 }
2359
2360 i, err := m.Int64UpDownCounter(
2361 "k8s.replicaset.desired_pods",
2362 append([]metric.Int64UpDownCounterOption{
2363 metric.WithDescription("Number of desired replica pods in this replicaset"),
2364 metric.WithUnit("{pod}"),
2365 }, opt...)...,
2366 )
2367 if err != nil {
2368 return ReplicaSetDesiredPods{noop.Int64UpDownCounter{}}, err
2369 }
2370 return ReplicaSetDesiredPods{i}, nil
2371 }
2372
2373 // Inst returns the underlying metric instrument.
2374 func (m ReplicaSetDesiredPods) Inst() metric.Int64UpDownCounter {
2375 return m.Int64UpDownCounter
2376 }
2377
2378 // Name returns the semantic convention name of the instrument.
2379 func (ReplicaSetDesiredPods) Name() string {
2380 return "k8s.replicaset.desired_pods"
2381 }
2382
2383 // Unit returns the semantic convention unit of the instrument
2384 func (ReplicaSetDesiredPods) Unit() string {
2385 return "{pod}"
2386 }
2387
2388 // Description returns the semantic convention description of the instrument
2389 func (ReplicaSetDesiredPods) Description() string {
2390 return "Number of desired replica pods in this replicaset"
2391 }
2392
2393 // Add adds incr to the existing count.
2394 //
2395 // This metric aligns with the `replicas` field of the
2396 // [K8s ReplicaSetSpec].
2397 //
2398 // This metric SHOULD, at a minimum, be reported against a
2399 // [`k8s.replicaset`] resource.
2400 //
2401 // [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps
2402 // [`k8s.replicaset`]: ../resource/k8s.md#replicaset
2403 func (m ReplicaSetDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2404 if len(attrs) == 0 {
2405 m.Int64UpDownCounter.Add(ctx, incr)
2406 return
2407 }
2408
2409 o := addOptPool.Get().(*[]metric.AddOption)
2410 defer func() {
2411 *o = (*o)[:0]
2412 addOptPool.Put(o)
2413 }()
2414
2415 *o = append(*o, metric.WithAttributes(attrs...))
2416 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2417 }
2418
2419 // ReplicationControllerAvailablePods is an instrument used to record metric
2420 // values conforming to the "k8s.replicationcontroller.available_pods" semantic
2421 // conventions. It represents the total number of available replica pods (ready
2422 // for at least minReadySeconds) targeted by this replication controller.
2423 type ReplicationControllerAvailablePods struct {
2424 metric.Int64UpDownCounter
2425 }
2426
2427 // NewReplicationControllerAvailablePods returns a new
2428 // ReplicationControllerAvailablePods instrument.
2429 func NewReplicationControllerAvailablePods(
2430 m metric.Meter,
2431 opt ...metric.Int64UpDownCounterOption,
2432 ) (ReplicationControllerAvailablePods, error) {
2433 // Check if the meter is nil.
2434 if m == nil {
2435 return ReplicationControllerAvailablePods{noop.Int64UpDownCounter{}}, nil
2436 }
2437
2438 i, err := m.Int64UpDownCounter(
2439 "k8s.replicationcontroller.available_pods",
2440 append([]metric.Int64UpDownCounterOption{
2441 metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller"),
2442 metric.WithUnit("{pod}"),
2443 }, opt...)...,
2444 )
2445 if err != nil {
2446 return ReplicationControllerAvailablePods{noop.Int64UpDownCounter{}}, err
2447 }
2448 return ReplicationControllerAvailablePods{i}, nil
2449 }
2450
2451 // Inst returns the underlying metric instrument.
2452 func (m ReplicationControllerAvailablePods) Inst() metric.Int64UpDownCounter {
2453 return m.Int64UpDownCounter
2454 }
2455
2456 // Name returns the semantic convention name of the instrument.
2457 func (ReplicationControllerAvailablePods) Name() string {
2458 return "k8s.replicationcontroller.available_pods"
2459 }
2460
2461 // Unit returns the semantic convention unit of the instrument
2462 func (ReplicationControllerAvailablePods) Unit() string {
2463 return "{pod}"
2464 }
2465
2466 // Description returns the semantic convention description of the instrument
2467 func (ReplicationControllerAvailablePods) Description() string {
2468 return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller"
2469 }
2470
2471 // Add adds incr to the existing count.
2472 //
2473 // This metric aligns with the `availableReplicas` field of the
2474 // [K8s ReplicationControllerStatus]
2475 //
2476 // This metric SHOULD, at a minimum, be reported against a
2477 // [`k8s.replicationcontroller`] resource.
2478 //
2479 // [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core
2480 // [`k8s.replicationcontroller`]: ../resource/k8s.md#replicationcontroller
2481 func (m ReplicationControllerAvailablePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2482 if len(attrs) == 0 {
2483 m.Int64UpDownCounter.Add(ctx, incr)
2484 return
2485 }
2486
2487 o := addOptPool.Get().(*[]metric.AddOption)
2488 defer func() {
2489 *o = (*o)[:0]
2490 addOptPool.Put(o)
2491 }()
2492
2493 *o = append(*o, metric.WithAttributes(attrs...))
2494 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2495 }
2496
2497 // ReplicationControllerDesiredPods is an instrument used to record metric values
2498 // conforming to the "k8s.replicationcontroller.desired_pods" semantic
2499 // conventions. It represents the number of desired replica pods in this
2500 // replication controller.
2501 type ReplicationControllerDesiredPods struct {
2502 metric.Int64UpDownCounter
2503 }
2504
2505 // NewReplicationControllerDesiredPods returns a new
2506 // ReplicationControllerDesiredPods instrument.
2507 func NewReplicationControllerDesiredPods(
2508 m metric.Meter,
2509 opt ...metric.Int64UpDownCounterOption,
2510 ) (ReplicationControllerDesiredPods, error) {
2511 // Check if the meter is nil.
2512 if m == nil {
2513 return ReplicationControllerDesiredPods{noop.Int64UpDownCounter{}}, nil
2514 }
2515
2516 i, err := m.Int64UpDownCounter(
2517 "k8s.replicationcontroller.desired_pods",
2518 append([]metric.Int64UpDownCounterOption{
2519 metric.WithDescription("Number of desired replica pods in this replication controller"),
2520 metric.WithUnit("{pod}"),
2521 }, opt...)...,
2522 )
2523 if err != nil {
2524 return ReplicationControllerDesiredPods{noop.Int64UpDownCounter{}}, err
2525 }
2526 return ReplicationControllerDesiredPods{i}, nil
2527 }
2528
2529 // Inst returns the underlying metric instrument.
2530 func (m ReplicationControllerDesiredPods) Inst() metric.Int64UpDownCounter {
2531 return m.Int64UpDownCounter
2532 }
2533
2534 // Name returns the semantic convention name of the instrument.
2535 func (ReplicationControllerDesiredPods) Name() string {
2536 return "k8s.replicationcontroller.desired_pods"
2537 }
2538
2539 // Unit returns the semantic convention unit of the instrument
2540 func (ReplicationControllerDesiredPods) Unit() string {
2541 return "{pod}"
2542 }
2543
2544 // Description returns the semantic convention description of the instrument
2545 func (ReplicationControllerDesiredPods) Description() string {
2546 return "Number of desired replica pods in this replication controller"
2547 }
2548
2549 // Add adds incr to the existing count.
2550 //
2551 // This metric aligns with the `replicas` field of the
2552 // [K8s ReplicationControllerSpec]
2553 //
2554 // This metric SHOULD, at a minimum, be reported against a
2555 // [`k8s.replicationcontroller`] resource.
2556 //
2557 // [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core
2558 // [`k8s.replicationcontroller`]: ../resource/k8s.md#replicationcontroller
2559 func (m ReplicationControllerDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2560 if len(attrs) == 0 {
2561 m.Int64UpDownCounter.Add(ctx, incr)
2562 return
2563 }
2564
2565 o := addOptPool.Get().(*[]metric.AddOption)
2566 defer func() {
2567 *o = (*o)[:0]
2568 addOptPool.Put(o)
2569 }()
2570
2571 *o = append(*o, metric.WithAttributes(attrs...))
2572 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2573 }
2574
2575 // StatefulSetCurrentPods is an instrument used to record metric values
2576 // conforming to the "k8s.statefulset.current_pods" semantic conventions. It
2577 // represents the number of replica pods created by the statefulset controller
2578 // from the statefulset version indicated by currentRevision.
2579 type StatefulSetCurrentPods struct {
2580 metric.Int64UpDownCounter
2581 }
2582
2583 // NewStatefulSetCurrentPods returns a new StatefulSetCurrentPods instrument.
2584 func NewStatefulSetCurrentPods(
2585 m metric.Meter,
2586 opt ...metric.Int64UpDownCounterOption,
2587 ) (StatefulSetCurrentPods, error) {
2588 // Check if the meter is nil.
2589 if m == nil {
2590 return StatefulSetCurrentPods{noop.Int64UpDownCounter{}}, nil
2591 }
2592
2593 i, err := m.Int64UpDownCounter(
2594 "k8s.statefulset.current_pods",
2595 append([]metric.Int64UpDownCounterOption{
2596 metric.WithDescription("The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision"),
2597 metric.WithUnit("{pod}"),
2598 }, opt...)...,
2599 )
2600 if err != nil {
2601 return StatefulSetCurrentPods{noop.Int64UpDownCounter{}}, err
2602 }
2603 return StatefulSetCurrentPods{i}, nil
2604 }
2605
2606 // Inst returns the underlying metric instrument.
2607 func (m StatefulSetCurrentPods) Inst() metric.Int64UpDownCounter {
2608 return m.Int64UpDownCounter
2609 }
2610
2611 // Name returns the semantic convention name of the instrument.
2612 func (StatefulSetCurrentPods) Name() string {
2613 return "k8s.statefulset.current_pods"
2614 }
2615
2616 // Unit returns the semantic convention unit of the instrument
2617 func (StatefulSetCurrentPods) Unit() string {
2618 return "{pod}"
2619 }
2620
2621 // Description returns the semantic convention description of the instrument
2622 func (StatefulSetCurrentPods) Description() string {
2623 return "The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision"
2624 }
2625
2626 // Add adds incr to the existing count.
2627 //
2628 // This metric aligns with the `currentReplicas` field of the
2629 // [K8s StatefulSetStatus].
2630 //
2631 // This metric SHOULD, at a minimum, be reported against a
2632 // [`k8s.statefulset`] resource.
2633 //
2634 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
2635 // [`k8s.statefulset`]: ../resource/k8s.md#statefulset
2636 func (m StatefulSetCurrentPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2637 if len(attrs) == 0 {
2638 m.Int64UpDownCounter.Add(ctx, incr)
2639 return
2640 }
2641
2642 o := addOptPool.Get().(*[]metric.AddOption)
2643 defer func() {
2644 *o = (*o)[:0]
2645 addOptPool.Put(o)
2646 }()
2647
2648 *o = append(*o, metric.WithAttributes(attrs...))
2649 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2650 }
2651
2652 // StatefulSetDesiredPods is an instrument used to record metric values
2653 // conforming to the "k8s.statefulset.desired_pods" semantic conventions. It
2654 // represents the number of desired replica pods in this statefulset.
2655 type StatefulSetDesiredPods struct {
2656 metric.Int64UpDownCounter
2657 }
2658
2659 // NewStatefulSetDesiredPods returns a new StatefulSetDesiredPods instrument.
2660 func NewStatefulSetDesiredPods(
2661 m metric.Meter,
2662 opt ...metric.Int64UpDownCounterOption,
2663 ) (StatefulSetDesiredPods, error) {
2664 // Check if the meter is nil.
2665 if m == nil {
2666 return StatefulSetDesiredPods{noop.Int64UpDownCounter{}}, nil
2667 }
2668
2669 i, err := m.Int64UpDownCounter(
2670 "k8s.statefulset.desired_pods",
2671 append([]metric.Int64UpDownCounterOption{
2672 metric.WithDescription("Number of desired replica pods in this statefulset"),
2673 metric.WithUnit("{pod}"),
2674 }, opt...)...,
2675 )
2676 if err != nil {
2677 return StatefulSetDesiredPods{noop.Int64UpDownCounter{}}, err
2678 }
2679 return StatefulSetDesiredPods{i}, nil
2680 }
2681
2682 // Inst returns the underlying metric instrument.
2683 func (m StatefulSetDesiredPods) Inst() metric.Int64UpDownCounter {
2684 return m.Int64UpDownCounter
2685 }
2686
2687 // Name returns the semantic convention name of the instrument.
2688 func (StatefulSetDesiredPods) Name() string {
2689 return "k8s.statefulset.desired_pods"
2690 }
2691
2692 // Unit returns the semantic convention unit of the instrument
2693 func (StatefulSetDesiredPods) Unit() string {
2694 return "{pod}"
2695 }
2696
2697 // Description returns the semantic convention description of the instrument
2698 func (StatefulSetDesiredPods) Description() string {
2699 return "Number of desired replica pods in this statefulset"
2700 }
2701
2702 // Add adds incr to the existing count.
2703 //
2704 // This metric aligns with the `replicas` field of the
2705 // [K8s StatefulSetSpec].
2706 //
2707 // This metric SHOULD, at a minimum, be reported against a
2708 // [`k8s.statefulset`] resource.
2709 //
2710 // [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps
2711 // [`k8s.statefulset`]: ../resource/k8s.md#statefulset
2712 func (m StatefulSetDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2713 if len(attrs) == 0 {
2714 m.Int64UpDownCounter.Add(ctx, incr)
2715 return
2716 }
2717
2718 o := addOptPool.Get().(*[]metric.AddOption)
2719 defer func() {
2720 *o = (*o)[:0]
2721 addOptPool.Put(o)
2722 }()
2723
2724 *o = append(*o, metric.WithAttributes(attrs...))
2725 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2726 }
2727
2728 // StatefulSetReadyPods is an instrument used to record metric values conforming
2729 // to the "k8s.statefulset.ready_pods" semantic conventions. It represents the
2730 // number of replica pods created for this statefulset with a Ready Condition.
2731 type StatefulSetReadyPods struct {
2732 metric.Int64UpDownCounter
2733 }
2734
2735 // NewStatefulSetReadyPods returns a new StatefulSetReadyPods instrument.
2736 func NewStatefulSetReadyPods(
2737 m metric.Meter,
2738 opt ...metric.Int64UpDownCounterOption,
2739 ) (StatefulSetReadyPods, error) {
2740 // Check if the meter is nil.
2741 if m == nil {
2742 return StatefulSetReadyPods{noop.Int64UpDownCounter{}}, nil
2743 }
2744
2745 i, err := m.Int64UpDownCounter(
2746 "k8s.statefulset.ready_pods",
2747 append([]metric.Int64UpDownCounterOption{
2748 metric.WithDescription("The number of replica pods created for this statefulset with a Ready Condition"),
2749 metric.WithUnit("{pod}"),
2750 }, opt...)...,
2751 )
2752 if err != nil {
2753 return StatefulSetReadyPods{noop.Int64UpDownCounter{}}, err
2754 }
2755 return StatefulSetReadyPods{i}, nil
2756 }
2757
2758 // Inst returns the underlying metric instrument.
2759 func (m StatefulSetReadyPods) Inst() metric.Int64UpDownCounter {
2760 return m.Int64UpDownCounter
2761 }
2762
2763 // Name returns the semantic convention name of the instrument.
2764 func (StatefulSetReadyPods) Name() string {
2765 return "k8s.statefulset.ready_pods"
2766 }
2767
2768 // Unit returns the semantic convention unit of the instrument
2769 func (StatefulSetReadyPods) Unit() string {
2770 return "{pod}"
2771 }
2772
2773 // Description returns the semantic convention description of the instrument
2774 func (StatefulSetReadyPods) Description() string {
2775 return "The number of replica pods created for this statefulset with a Ready Condition"
2776 }
2777
2778 // Add adds incr to the existing count.
2779 //
2780 // This metric aligns with the `readyReplicas` field of the
2781 // [K8s StatefulSetStatus].
2782 //
2783 // This metric SHOULD, at a minimum, be reported against a
2784 // [`k8s.statefulset`] resource.
2785 //
2786 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
2787 // [`k8s.statefulset`]: ../resource/k8s.md#statefulset
2788 func (m StatefulSetReadyPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2789 if len(attrs) == 0 {
2790 m.Int64UpDownCounter.Add(ctx, incr)
2791 return
2792 }
2793
2794 o := addOptPool.Get().(*[]metric.AddOption)
2795 defer func() {
2796 *o = (*o)[:0]
2797 addOptPool.Put(o)
2798 }()
2799
2800 *o = append(*o, metric.WithAttributes(attrs...))
2801 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2802 }
2803
2804 // StatefulSetUpdatedPods is an instrument used to record metric values
2805 // conforming to the "k8s.statefulset.updated_pods" semantic conventions. It
2806 // represents the number of replica pods created by the statefulset controller
2807 // from the statefulset version indicated by updateRevision.
2808 type StatefulSetUpdatedPods struct {
2809 metric.Int64UpDownCounter
2810 }
2811
2812 // NewStatefulSetUpdatedPods returns a new StatefulSetUpdatedPods instrument.
2813 func NewStatefulSetUpdatedPods(
2814 m metric.Meter,
2815 opt ...metric.Int64UpDownCounterOption,
2816 ) (StatefulSetUpdatedPods, error) {
2817 // Check if the meter is nil.
2818 if m == nil {
2819 return StatefulSetUpdatedPods{noop.Int64UpDownCounter{}}, nil
2820 }
2821
2822 i, err := m.Int64UpDownCounter(
2823 "k8s.statefulset.updated_pods",
2824 append([]metric.Int64UpDownCounterOption{
2825 metric.WithDescription("Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision"),
2826 metric.WithUnit("{pod}"),
2827 }, opt...)...,
2828 )
2829 if err != nil {
2830 return StatefulSetUpdatedPods{noop.Int64UpDownCounter{}}, err
2831 }
2832 return StatefulSetUpdatedPods{i}, nil
2833 }
2834
2835 // Inst returns the underlying metric instrument.
2836 func (m StatefulSetUpdatedPods) Inst() metric.Int64UpDownCounter {
2837 return m.Int64UpDownCounter
2838 }
2839
2840 // Name returns the semantic convention name of the instrument.
2841 func (StatefulSetUpdatedPods) Name() string {
2842 return "k8s.statefulset.updated_pods"
2843 }
2844
2845 // Unit returns the semantic convention unit of the instrument
2846 func (StatefulSetUpdatedPods) Unit() string {
2847 return "{pod}"
2848 }
2849
2850 // Description returns the semantic convention description of the instrument
2851 func (StatefulSetUpdatedPods) Description() string {
2852 return "Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision"
2853 }
2854
2855 // Add adds incr to the existing count.
2856 //
2857 // This metric aligns with the `updatedReplicas` field of the
2858 // [K8s StatefulSetStatus].
2859 //
2860 // This metric SHOULD, at a minimum, be reported against a
2861 // [`k8s.statefulset`] resource.
2862 //
2863 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
2864 // [`k8s.statefulset`]: ../resource/k8s.md#statefulset
2865 func (m StatefulSetUpdatedPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2866 if len(attrs) == 0 {
2867 m.Int64UpDownCounter.Add(ctx, incr)
2868 return
2869 }
2870
2871 o := addOptPool.Get().(*[]metric.AddOption)
2872 defer func() {
2873 *o = (*o)[:0]
2874 addOptPool.Put(o)
2875 }()
2876
2877 *o = append(*o, metric.WithAttributes(attrs...))
2878 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2879 }