Debian Codegraph @

semconv/v1.40.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 // ContainerStatusReasonAttr is an attribute conforming to the
25 // k8s.container.status.reason semantic conventions. It represents the reason for
26 // the container state. Corresponds to the `reason` field of the:
27 // [K8s ContainerStateWaiting] or [K8s ContainerStateTerminated].
28 //
29 // [K8s ContainerStateWaiting]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatewaiting-v1-core
30 // [K8s ContainerStateTerminated]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstateterminated-v1-core
31 type ContainerStatusReasonAttr string
32
33 var (
34 // ContainerStatusReasonContainerCreating is the container is being created.
35 ContainerStatusReasonContainerCreating ContainerStatusReasonAttr = "ContainerCreating"
36 // ContainerStatusReasonCrashLoopBackOff is the container is in a crash loop
37 // back off state.
38 ContainerStatusReasonCrashLoopBackOff ContainerStatusReasonAttr = "CrashLoopBackOff"
39 // ContainerStatusReasonCreateContainerConfigError is the there was an error
40 // creating the container configuration.
41 ContainerStatusReasonCreateContainerConfigError ContainerStatusReasonAttr = "CreateContainerConfigError"
42 // ContainerStatusReasonErrImagePull is the there was an error pulling the
43 // container image.
44 ContainerStatusReasonErrImagePull ContainerStatusReasonAttr = "ErrImagePull"
45 // ContainerStatusReasonImagePullBackOff is the container image pull is in back
46 // off state.
47 ContainerStatusReasonImagePullBackOff ContainerStatusReasonAttr = "ImagePullBackOff"
48 // ContainerStatusReasonOomKilled is the container was killed due to out of
49 // memory.
50 ContainerStatusReasonOomKilled ContainerStatusReasonAttr = "OOMKilled"
51 // ContainerStatusReasonCompleted is the container has completed execution.
52 ContainerStatusReasonCompleted ContainerStatusReasonAttr = "Completed"
53 // ContainerStatusReasonError is the there was an error with the container.
54 ContainerStatusReasonError ContainerStatusReasonAttr = "Error"
55 // ContainerStatusReasonContainerCannotRun is the container cannot run.
56 ContainerStatusReasonContainerCannotRun ContainerStatusReasonAttr = "ContainerCannotRun"
57 )
58
59 // ContainerStatusStateAttr is an attribute conforming to the
60 // k8s.container.status.state semantic conventions. It represents the state of
61 // the container. [K8s ContainerState].
62 //
63 // [K8s ContainerState]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstate-v1-core
64 type ContainerStatusStateAttr string
65
66 var (
67 // ContainerStatusStateTerminated is the container has terminated.
68 ContainerStatusStateTerminated ContainerStatusStateAttr = "terminated"
69 // ContainerStatusStateRunning is the container is running.
70 ContainerStatusStateRunning ContainerStatusStateAttr = "running"
71 // ContainerStatusStateWaiting is the container is waiting.
72 ContainerStatusStateWaiting ContainerStatusStateAttr = "waiting"
73 )
74
75 // NamespacePhaseAttr is an attribute conforming to the k8s.namespace.phase
76 // semantic conventions. It represents the phase of the K8s namespace.
77 type NamespacePhaseAttr string
78
79 var (
80 // NamespacePhaseActive is the active namespace phase as described by [K8s API]
81 // .
82 //
83 // [K8s API]: https://pkg.go.dev/k8s.io/[email protected]/core/v1#NamespacePhase
84 NamespacePhaseActive NamespacePhaseAttr = "active"
85 // NamespacePhaseTerminating is the terminating namespace phase as described by
86 // [K8s API].
87 //
88 // [K8s API]: https://pkg.go.dev/k8s.io/[email protected]/core/v1#NamespacePhase
89 NamespacePhaseTerminating NamespacePhaseAttr = "terminating"
90 )
91
92 // NodeConditionStatusAttr is an attribute conforming to the
93 // k8s.node.condition.status semantic conventions. It represents the status of
94 // the condition, one of True, False, Unknown.
95 type NodeConditionStatusAttr string
96
97 var (
98 // NodeConditionStatusConditionTrue is the standardized value "true" of
99 // NodeConditionStatusAttr.
100 NodeConditionStatusConditionTrue NodeConditionStatusAttr = "true"
101 // NodeConditionStatusConditionFalse is the standardized value "false" of
102 // NodeConditionStatusAttr.
103 NodeConditionStatusConditionFalse NodeConditionStatusAttr = "false"
104 // NodeConditionStatusConditionUnknown is the standardized value "unknown" of
105 // NodeConditionStatusAttr.
106 NodeConditionStatusConditionUnknown NodeConditionStatusAttr = "unknown"
107 )
108
109 // NodeConditionTypeAttr is an attribute conforming to the
110 // k8s.node.condition.type semantic conventions. It represents the condition type
111 // of a K8s Node.
112 type NodeConditionTypeAttr string
113
114 var (
115 // NodeConditionTypeReady is the node is healthy and ready to accept pods.
116 NodeConditionTypeReady NodeConditionTypeAttr = "Ready"
117 // NodeConditionTypeDiskPressure is the pressure exists on the disk size—that
118 // is, if the disk capacity is low.
119 NodeConditionTypeDiskPressure NodeConditionTypeAttr = "DiskPressure"
120 // NodeConditionTypeMemoryPressure is the pressure exists on the node
121 // memory—that is, if the node memory is low.
122 NodeConditionTypeMemoryPressure NodeConditionTypeAttr = "MemoryPressure"
123 // NodeConditionTypePIDPressure is the pressure exists on the processes—that
124 // is, if there are too many processes on the node.
125 NodeConditionTypePIDPressure NodeConditionTypeAttr = "PIDPressure"
126 // NodeConditionTypeNetworkUnavailable is the network for the node is not
127 // correctly configured.
128 NodeConditionTypeNetworkUnavailable NodeConditionTypeAttr = "NetworkUnavailable"
129 )
130
131 // PodStatusPhaseAttr is an attribute conforming to the k8s.pod.status.phase
132 // semantic conventions. It represents the phase for the pod. Corresponds to the
133 // `phase` field of the: [K8s PodStatus].
134 //
135 // [K8s PodStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.33/#podstatus-v1-core
136 type PodStatusPhaseAttr string
137
138 var (
139 // PodStatusPhasePending is the pod has been accepted by the system, but one or
140 // more of the containers has not been started. This includes time before being
141 // bound to a node, as well as time spent pulling images onto the host.
142 PodStatusPhasePending PodStatusPhaseAttr = "Pending"
143 // PodStatusPhaseRunning is the pod has been bound to a node and all of the
144 // containers have been started. At least one container is still running or is
145 // in the process of being restarted.
146 PodStatusPhaseRunning PodStatusPhaseAttr = "Running"
147 // PodStatusPhaseSucceeded is the all containers in the pod have voluntarily
148 // terminated with a container exit code of 0, and the system is not going to
149 // restart any of these containers.
150 PodStatusPhaseSucceeded PodStatusPhaseAttr = "Succeeded"
151 // PodStatusPhaseFailed is the all containers in the pod have terminated, and at
152 // least one container has terminated in a failure (exited with a non-zero exit
153 // code or was stopped by the system).
154 PodStatusPhaseFailed PodStatusPhaseAttr = "Failed"
155 // PodStatusPhaseUnknown is the for some reason the state of the pod could not
156 // be obtained, typically due to an error in communicating with the host of the
157 // pod.
158 PodStatusPhaseUnknown PodStatusPhaseAttr = "Unknown"
159 )
160
161 // PodStatusReasonAttr is an attribute conforming to the k8s.pod.status.reason
162 // semantic conventions. It represents the reason for the pod state. Corresponds
163 // to the `reason` field of the: [K8s PodStatus].
164 //
165 // [K8s PodStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.33/#podstatus-v1-core
166 type PodStatusReasonAttr string
167
168 var (
169 // PodStatusReasonEvicted is the pod is evicted.
170 PodStatusReasonEvicted PodStatusReasonAttr = "Evicted"
171 // PodStatusReasonNodeAffinity is the pod is in a status because of its node
172 // affinity.
173 PodStatusReasonNodeAffinity PodStatusReasonAttr = "NodeAffinity"
174 // PodStatusReasonNodeLost is the reason on a pod when its state cannot be
175 // confirmed as kubelet is unresponsive on the node it is (was) running.
176 PodStatusReasonNodeLost PodStatusReasonAttr = "NodeLost"
177 // PodStatusReasonShutdown is the node is shutdown.
178 PodStatusReasonShutdown PodStatusReasonAttr = "Shutdown"
179 // PodStatusReasonUnexpectedAdmissionError is the pod was rejected admission to
180 // the node because of an error during admission that could not be categorized.
181 PodStatusReasonUnexpectedAdmissionError PodStatusReasonAttr = "UnexpectedAdmissionError"
182 )
183
184 // ServiceEndpointAddressTypeAttr is an attribute conforming to the
185 // k8s.service.endpoint.address_type semantic conventions. It represents the
186 // address type of the service endpoint.
187 type ServiceEndpointAddressTypeAttr string
188
189 var (
190 // ServiceEndpointAddressTypeIPv4 is the IPv4 address type.
191 ServiceEndpointAddressTypeIPv4 ServiceEndpointAddressTypeAttr = "IPv4"
192 // ServiceEndpointAddressTypeIPv6 is the IPv6 address type.
193 ServiceEndpointAddressTypeIPv6 ServiceEndpointAddressTypeAttr = "IPv6"
194 // ServiceEndpointAddressTypeFqdn is the FQDN address type.
195 ServiceEndpointAddressTypeFqdn ServiceEndpointAddressTypeAttr = "FQDN"
196 )
197
198 // ServiceEndpointConditionAttr is an attribute conforming to the
199 // k8s.service.endpoint.condition semantic conventions. It represents the
200 // condition of the service endpoint.
201 type ServiceEndpointConditionAttr string
202
203 var (
204 // ServiceEndpointConditionReady is the endpoint is ready to receive new
205 // connections.
206 ServiceEndpointConditionReady ServiceEndpointConditionAttr = "ready"
207 // ServiceEndpointConditionServing is the endpoint is currently handling
208 // traffic.
209 ServiceEndpointConditionServing ServiceEndpointConditionAttr = "serving"
210 // ServiceEndpointConditionTerminating is the endpoint is in the process of
211 // shutting down.
212 ServiceEndpointConditionTerminating ServiceEndpointConditionAttr = "terminating"
213 )
214
215 // VolumeTypeAttr is an attribute conforming to the k8s.volume.type semantic
216 // conventions. It represents the type of the K8s volume.
217 type VolumeTypeAttr string
218
219 var (
220 // VolumeTypePersistentVolumeClaim is a [persistentVolumeClaim] volume.
221 //
222 // [persistentVolumeClaim]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim
223 VolumeTypePersistentVolumeClaim VolumeTypeAttr = "persistentVolumeClaim"
224 // VolumeTypeConfigMap is a [configMap] volume.
225 //
226 // [configMap]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#configmap
227 VolumeTypeConfigMap VolumeTypeAttr = "configMap"
228 // VolumeTypeDownwardAPI is a [downwardAPI] volume.
229 //
230 // [downwardAPI]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#downwardapi
231 VolumeTypeDownwardAPI VolumeTypeAttr = "downwardAPI"
232 // VolumeTypeEmptyDir is an [emptyDir] volume.
233 //
234 // [emptyDir]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#emptydir
235 VolumeTypeEmptyDir VolumeTypeAttr = "emptyDir"
236 // VolumeTypeSecret is a [secret] volume.
237 //
238 // [secret]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#secret
239 VolumeTypeSecret VolumeTypeAttr = "secret"
240 // VolumeTypeLocal is a [local] volume.
241 //
242 // [local]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#local
243 VolumeTypeLocal VolumeTypeAttr = "local"
244 )
245
246 // NetworkIODirectionAttr is an attribute conforming to the network.io.direction
247 // semantic conventions. It represents the network IO operation direction.
248 type NetworkIODirectionAttr string
249
250 var (
251 // NetworkIODirectionTransmit is the standardized value "transmit" of
252 // NetworkIODirectionAttr.
253 NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit"
254 // NetworkIODirectionReceive is the standardized value "receive" of
255 // NetworkIODirectionAttr.
256 NetworkIODirectionReceive NetworkIODirectionAttr = "receive"
257 )
258
259 // SystemPagingFaultTypeAttr is an attribute conforming to the
260 // system.paging.fault.type semantic conventions. It represents the paging fault
261 // type.
262 type SystemPagingFaultTypeAttr string
263
264 var (
265 // SystemPagingFaultTypeMajor is the standardized value "major" of
266 // SystemPagingFaultTypeAttr.
267 SystemPagingFaultTypeMajor SystemPagingFaultTypeAttr = "major"
268 // SystemPagingFaultTypeMinor is the standardized value "minor" of
269 // SystemPagingFaultTypeAttr.
270 SystemPagingFaultTypeMinor SystemPagingFaultTypeAttr = "minor"
271 )
272
273 // ContainerCPULimit is an instrument used to record metric values conforming to
274 // the "k8s.container.cpu.limit" semantic conventions. It represents the maximum
275 // CPU resource limit set for the container.
276 type ContainerCPULimit struct {
277 metric.Int64UpDownCounter
278 }
279
280 var newContainerCPULimitOpts = []metric.Int64UpDownCounterOption{
281 metric.WithDescription("Maximum CPU resource limit set for the container."),
282 metric.WithUnit("{cpu}"),
283 }
284
285 // NewContainerCPULimit returns a new ContainerCPULimit instrument.
286 func NewContainerCPULimit(
287 m metric.Meter,
288 opt ...metric.Int64UpDownCounterOption,
289 ) (ContainerCPULimit, error) {
290 // Check if the meter is nil.
291 if m == nil {
292 return ContainerCPULimit{noop.Int64UpDownCounter{}}, nil
293 }
294
295 if len(opt) == 0 {
296 opt = newContainerCPULimitOpts
297 } else {
298 opt = append(opt, newContainerCPULimitOpts...)
299 }
300
301 i, err := m.Int64UpDownCounter(
302 "k8s.container.cpu.limit",
303 opt...,
304 )
305 if err != nil {
306 return ContainerCPULimit{noop.Int64UpDownCounter{}}, err
307 }
308 return ContainerCPULimit{i}, nil
309 }
310
311 // Inst returns the underlying metric instrument.
312 func (m ContainerCPULimit) Inst() metric.Int64UpDownCounter {
313 return m.Int64UpDownCounter
314 }
315
316 // Name returns the semantic convention name of the instrument.
317 func (ContainerCPULimit) Name() string {
318 return "k8s.container.cpu.limit"
319 }
320
321 // Unit returns the semantic convention unit of the instrument
322 func (ContainerCPULimit) Unit() string {
323 return "{cpu}"
324 }
325
326 // Description returns the semantic convention description of the instrument
327 func (ContainerCPULimit) Description() string {
328 return "Maximum CPU resource limit set for the container."
329 }
330
331 // Add adds incr to the existing count for attrs.
332 //
333 // See
334 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
335 // for details.
336 func (m ContainerCPULimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
337 if len(attrs) == 0 {
338 m.Int64UpDownCounter.Add(ctx, incr)
339 return
340 }
341
342 o := addOptPool.Get().(*[]metric.AddOption)
343 defer func() {
344 *o = (*o)[:0]
345 addOptPool.Put(o)
346 }()
347
348 *o = append(*o, metric.WithAttributes(attrs...))
349 m.Int64UpDownCounter.Add(ctx, incr, *o...)
350 }
351
352 // AddSet adds incr to the existing count for set.
353 //
354 // See
355 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
356 // for details.
357 func (m ContainerCPULimit) AddSet(ctx context.Context, incr int64, set attribute.Set) {
358 if set.Len() == 0 {
359 m.Int64UpDownCounter.Add(ctx, incr)
360 return
361 }
362
363 o := addOptPool.Get().(*[]metric.AddOption)
364 defer func() {
365 *o = (*o)[:0]
366 addOptPool.Put(o)
367 }()
368
369 *o = append(*o, metric.WithAttributeSet(set))
370 m.Int64UpDownCounter.Add(ctx, incr, *o...)
371 }
372
373 // ContainerCPULimitUtilization is an instrument used to record metric values
374 // conforming to the "k8s.container.cpu.limit_utilization" semantic conventions.
375 // It represents the ratio of container CPU usage to its CPU limit.
376 type ContainerCPULimitUtilization struct {
377 metric.Int64Gauge
378 }
379
380 var newContainerCPULimitUtilizationOpts = []metric.Int64GaugeOption{
381 metric.WithDescription("The ratio of container CPU usage to its CPU limit."),
382 metric.WithUnit("1"),
383 }
384
385 // NewContainerCPULimitUtilization returns a new ContainerCPULimitUtilization
386 // instrument.
387 func NewContainerCPULimitUtilization(
388 m metric.Meter,
389 opt ...metric.Int64GaugeOption,
390 ) (ContainerCPULimitUtilization, error) {
391 // Check if the meter is nil.
392 if m == nil {
393 return ContainerCPULimitUtilization{noop.Int64Gauge{}}, nil
394 }
395
396 if len(opt) == 0 {
397 opt = newContainerCPULimitUtilizationOpts
398 } else {
399 opt = append(opt, newContainerCPULimitUtilizationOpts...)
400 }
401
402 i, err := m.Int64Gauge(
403 "k8s.container.cpu.limit_utilization",
404 opt...,
405 )
406 if err != nil {
407 return ContainerCPULimitUtilization{noop.Int64Gauge{}}, err
408 }
409 return ContainerCPULimitUtilization{i}, nil
410 }
411
412 // Inst returns the underlying metric instrument.
413 func (m ContainerCPULimitUtilization) Inst() metric.Int64Gauge {
414 return m.Int64Gauge
415 }
416
417 // Name returns the semantic convention name of the instrument.
418 func (ContainerCPULimitUtilization) Name() string {
419 return "k8s.container.cpu.limit_utilization"
420 }
421
422 // Unit returns the semantic convention unit of the instrument
423 func (ContainerCPULimitUtilization) Unit() string {
424 return "1"
425 }
426
427 // Description returns the semantic convention description of the instrument
428 func (ContainerCPULimitUtilization) Description() string {
429 return "The ratio of container CPU usage to its CPU limit."
430 }
431
432 // Record records val to the current distribution for attrs.
433 //
434 // The value range is [0.0,1.0]. A value of 1.0 means the container is using 100%
435 // of its CPU limit. If the CPU limit is not set, this metric SHOULD NOT be
436 // emitted for that container.
437 func (m ContainerCPULimitUtilization) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
438 if len(attrs) == 0 {
439 m.Int64Gauge.Record(ctx, val)
440 return
441 }
442
443 o := recOptPool.Get().(*[]metric.RecordOption)
444 defer func() {
445 *o = (*o)[:0]
446 recOptPool.Put(o)
447 }()
448
449 *o = append(*o, metric.WithAttributes(attrs...))
450 m.Int64Gauge.Record(ctx, val, *o...)
451 }
452
453 // RecordSet records val to the current distribution for set.
454 //
455 // The value range is [0.0,1.0]. A value of 1.0 means the container is using 100%
456 // of its CPU limit. If the CPU limit is not set, this metric SHOULD NOT be
457 // emitted for that container.
458 func (m ContainerCPULimitUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) {
459 if set.Len() == 0 {
460 m.Int64Gauge.Record(ctx, val)
461 return
462 }
463
464 o := recOptPool.Get().(*[]metric.RecordOption)
465 defer func() {
466 *o = (*o)[:0]
467 recOptPool.Put(o)
468 }()
469
470 *o = append(*o, metric.WithAttributeSet(set))
471 m.Int64Gauge.Record(ctx, val, *o...)
472 }
473
474 // ContainerCPURequest is an instrument used to record metric values conforming
475 // to the "k8s.container.cpu.request" semantic conventions. It represents the CPU
476 // resource requested for the container.
477 type ContainerCPURequest struct {
478 metric.Int64UpDownCounter
479 }
480
481 var newContainerCPURequestOpts = []metric.Int64UpDownCounterOption{
482 metric.WithDescription("CPU resource requested for the container."),
483 metric.WithUnit("{cpu}"),
484 }
485
486 // NewContainerCPURequest returns a new ContainerCPURequest instrument.
487 func NewContainerCPURequest(
488 m metric.Meter,
489 opt ...metric.Int64UpDownCounterOption,
490 ) (ContainerCPURequest, error) {
491 // Check if the meter is nil.
492 if m == nil {
493 return ContainerCPURequest{noop.Int64UpDownCounter{}}, nil
494 }
495
496 if len(opt) == 0 {
497 opt = newContainerCPURequestOpts
498 } else {
499 opt = append(opt, newContainerCPURequestOpts...)
500 }
501
502 i, err := m.Int64UpDownCounter(
503 "k8s.container.cpu.request",
504 opt...,
505 )
506 if err != nil {
507 return ContainerCPURequest{noop.Int64UpDownCounter{}}, err
508 }
509 return ContainerCPURequest{i}, nil
510 }
511
512 // Inst returns the underlying metric instrument.
513 func (m ContainerCPURequest) Inst() metric.Int64UpDownCounter {
514 return m.Int64UpDownCounter
515 }
516
517 // Name returns the semantic convention name of the instrument.
518 func (ContainerCPURequest) Name() string {
519 return "k8s.container.cpu.request"
520 }
521
522 // Unit returns the semantic convention unit of the instrument
523 func (ContainerCPURequest) Unit() string {
524 return "{cpu}"
525 }
526
527 // Description returns the semantic convention description of the instrument
528 func (ContainerCPURequest) Description() string {
529 return "CPU resource requested for the container."
530 }
531
532 // Add adds incr to the existing count for attrs.
533 //
534 // See
535 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
536 // for details.
537 func (m ContainerCPURequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
538 if len(attrs) == 0 {
539 m.Int64UpDownCounter.Add(ctx, incr)
540 return
541 }
542
543 o := addOptPool.Get().(*[]metric.AddOption)
544 defer func() {
545 *o = (*o)[:0]
546 addOptPool.Put(o)
547 }()
548
549 *o = append(*o, metric.WithAttributes(attrs...))
550 m.Int64UpDownCounter.Add(ctx, incr, *o...)
551 }
552
553 // AddSet adds incr to the existing count for set.
554 //
555 // See
556 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
557 // for details.
558 func (m ContainerCPURequest) AddSet(ctx context.Context, incr int64, set attribute.Set) {
559 if set.Len() == 0 {
560 m.Int64UpDownCounter.Add(ctx, incr)
561 return
562 }
563
564 o := addOptPool.Get().(*[]metric.AddOption)
565 defer func() {
566 *o = (*o)[:0]
567 addOptPool.Put(o)
568 }()
569
570 *o = append(*o, metric.WithAttributeSet(set))
571 m.Int64UpDownCounter.Add(ctx, incr, *o...)
572 }
573
574 // ContainerCPURequestUtilization is an instrument used to record metric values
575 // conforming to the "k8s.container.cpu.request_utilization" semantic
576 // conventions. It represents the ratio of container CPU usage to its CPU
577 // request.
578 type ContainerCPURequestUtilization struct {
579 metric.Int64Gauge
580 }
581
582 var newContainerCPURequestUtilizationOpts = []metric.Int64GaugeOption{
583 metric.WithDescription("The ratio of container CPU usage to its CPU request."),
584 metric.WithUnit("1"),
585 }
586
587 // NewContainerCPURequestUtilization returns a new ContainerCPURequestUtilization
588 // instrument.
589 func NewContainerCPURequestUtilization(
590 m metric.Meter,
591 opt ...metric.Int64GaugeOption,
592 ) (ContainerCPURequestUtilization, error) {
593 // Check if the meter is nil.
594 if m == nil {
595 return ContainerCPURequestUtilization{noop.Int64Gauge{}}, nil
596 }
597
598 if len(opt) == 0 {
599 opt = newContainerCPURequestUtilizationOpts
600 } else {
601 opt = append(opt, newContainerCPURequestUtilizationOpts...)
602 }
603
604 i, err := m.Int64Gauge(
605 "k8s.container.cpu.request_utilization",
606 opt...,
607 )
608 if err != nil {
609 return ContainerCPURequestUtilization{noop.Int64Gauge{}}, err
610 }
611 return ContainerCPURequestUtilization{i}, nil
612 }
613
614 // Inst returns the underlying metric instrument.
615 func (m ContainerCPURequestUtilization) Inst() metric.Int64Gauge {
616 return m.Int64Gauge
617 }
618
619 // Name returns the semantic convention name of the instrument.
620 func (ContainerCPURequestUtilization) Name() string {
621 return "k8s.container.cpu.request_utilization"
622 }
623
624 // Unit returns the semantic convention unit of the instrument
625 func (ContainerCPURequestUtilization) Unit() string {
626 return "1"
627 }
628
629 // Description returns the semantic convention description of the instrument
630 func (ContainerCPURequestUtilization) Description() string {
631 return "The ratio of container CPU usage to its CPU request."
632 }
633
634 // Record records val to the current distribution for attrs.
635 func (m ContainerCPURequestUtilization) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
636 if len(attrs) == 0 {
637 m.Int64Gauge.Record(ctx, val)
638 return
639 }
640
641 o := recOptPool.Get().(*[]metric.RecordOption)
642 defer func() {
643 *o = (*o)[:0]
644 recOptPool.Put(o)
645 }()
646
647 *o = append(*o, metric.WithAttributes(attrs...))
648 m.Int64Gauge.Record(ctx, val, *o...)
649 }
650
651 // RecordSet records val to the current distribution for set.
652 func (m ContainerCPURequestUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) {
653 if set.Len() == 0 {
654 m.Int64Gauge.Record(ctx, val)
655 return
656 }
657
658 o := recOptPool.Get().(*[]metric.RecordOption)
659 defer func() {
660 *o = (*o)[:0]
661 recOptPool.Put(o)
662 }()
663
664 *o = append(*o, metric.WithAttributeSet(set))
665 m.Int64Gauge.Record(ctx, val, *o...)
666 }
667
668 // ContainerEphemeralStorageLimit is an instrument used to record metric values
669 // conforming to the "k8s.container.ephemeral_storage.limit" semantic
670 // conventions. It represents the maximum ephemeral storage resource limit set
671 // for the container.
672 type ContainerEphemeralStorageLimit struct {
673 metric.Int64UpDownCounter
674 }
675
676 var newContainerEphemeralStorageLimitOpts = []metric.Int64UpDownCounterOption{
677 metric.WithDescription("Maximum ephemeral storage resource limit set for the container."),
678 metric.WithUnit("By"),
679 }
680
681 // NewContainerEphemeralStorageLimit returns a new ContainerEphemeralStorageLimit
682 // instrument.
683 func NewContainerEphemeralStorageLimit(
684 m metric.Meter,
685 opt ...metric.Int64UpDownCounterOption,
686 ) (ContainerEphemeralStorageLimit, error) {
687 // Check if the meter is nil.
688 if m == nil {
689 return ContainerEphemeralStorageLimit{noop.Int64UpDownCounter{}}, nil
690 }
691
692 if len(opt) == 0 {
693 opt = newContainerEphemeralStorageLimitOpts
694 } else {
695 opt = append(opt, newContainerEphemeralStorageLimitOpts...)
696 }
697
698 i, err := m.Int64UpDownCounter(
699 "k8s.container.ephemeral_storage.limit",
700 opt...,
701 )
702 if err != nil {
703 return ContainerEphemeralStorageLimit{noop.Int64UpDownCounter{}}, err
704 }
705 return ContainerEphemeralStorageLimit{i}, nil
706 }
707
708 // Inst returns the underlying metric instrument.
709 func (m ContainerEphemeralStorageLimit) Inst() metric.Int64UpDownCounter {
710 return m.Int64UpDownCounter
711 }
712
713 // Name returns the semantic convention name of the instrument.
714 func (ContainerEphemeralStorageLimit) Name() string {
715 return "k8s.container.ephemeral_storage.limit"
716 }
717
718 // Unit returns the semantic convention unit of the instrument
719 func (ContainerEphemeralStorageLimit) Unit() string {
720 return "By"
721 }
722
723 // Description returns the semantic convention description of the instrument
724 func (ContainerEphemeralStorageLimit) Description() string {
725 return "Maximum ephemeral storage resource limit set for the container."
726 }
727
728 // Add adds incr to the existing count for attrs.
729 //
730 // See
731 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
732 // for details.
733 func (m ContainerEphemeralStorageLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
734 if len(attrs) == 0 {
735 m.Int64UpDownCounter.Add(ctx, incr)
736 return
737 }
738
739 o := addOptPool.Get().(*[]metric.AddOption)
740 defer func() {
741 *o = (*o)[:0]
742 addOptPool.Put(o)
743 }()
744
745 *o = append(*o, metric.WithAttributes(attrs...))
746 m.Int64UpDownCounter.Add(ctx, incr, *o...)
747 }
748
749 // AddSet adds incr to the existing count for set.
750 //
751 // See
752 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
753 // for details.
754 func (m ContainerEphemeralStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) {
755 if set.Len() == 0 {
756 m.Int64UpDownCounter.Add(ctx, incr)
757 return
758 }
759
760 o := addOptPool.Get().(*[]metric.AddOption)
761 defer func() {
762 *o = (*o)[:0]
763 addOptPool.Put(o)
764 }()
765
766 *o = append(*o, metric.WithAttributeSet(set))
767 m.Int64UpDownCounter.Add(ctx, incr, *o...)
768 }
769
770 // ContainerEphemeralStorageRequest is an instrument used to record metric values
771 // conforming to the "k8s.container.ephemeral_storage.request" semantic
772 // conventions. It represents the ephemeral storage resource requested for the
773 // container.
774 type ContainerEphemeralStorageRequest struct {
775 metric.Int64UpDownCounter
776 }
777
778 var newContainerEphemeralStorageRequestOpts = []metric.Int64UpDownCounterOption{
779 metric.WithDescription("Ephemeral storage resource requested for the container."),
780 metric.WithUnit("By"),
781 }
782
783 // NewContainerEphemeralStorageRequest returns a new
784 // ContainerEphemeralStorageRequest instrument.
785 func NewContainerEphemeralStorageRequest(
786 m metric.Meter,
787 opt ...metric.Int64UpDownCounterOption,
788 ) (ContainerEphemeralStorageRequest, error) {
789 // Check if the meter is nil.
790 if m == nil {
791 return ContainerEphemeralStorageRequest{noop.Int64UpDownCounter{}}, nil
792 }
793
794 if len(opt) == 0 {
795 opt = newContainerEphemeralStorageRequestOpts
796 } else {
797 opt = append(opt, newContainerEphemeralStorageRequestOpts...)
798 }
799
800 i, err := m.Int64UpDownCounter(
801 "k8s.container.ephemeral_storage.request",
802 opt...,
803 )
804 if err != nil {
805 return ContainerEphemeralStorageRequest{noop.Int64UpDownCounter{}}, err
806 }
807 return ContainerEphemeralStorageRequest{i}, nil
808 }
809
810 // Inst returns the underlying metric instrument.
811 func (m ContainerEphemeralStorageRequest) Inst() metric.Int64UpDownCounter {
812 return m.Int64UpDownCounter
813 }
814
815 // Name returns the semantic convention name of the instrument.
816 func (ContainerEphemeralStorageRequest) Name() string {
817 return "k8s.container.ephemeral_storage.request"
818 }
819
820 // Unit returns the semantic convention unit of the instrument
821 func (ContainerEphemeralStorageRequest) Unit() string {
822 return "By"
823 }
824
825 // Description returns the semantic convention description of the instrument
826 func (ContainerEphemeralStorageRequest) Description() string {
827 return "Ephemeral storage resource requested for the container."
828 }
829
830 // Add adds incr to the existing count for attrs.
831 //
832 // See
833 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
834 // for details.
835 func (m ContainerEphemeralStorageRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
836 if len(attrs) == 0 {
837 m.Int64UpDownCounter.Add(ctx, incr)
838 return
839 }
840
841 o := addOptPool.Get().(*[]metric.AddOption)
842 defer func() {
843 *o = (*o)[:0]
844 addOptPool.Put(o)
845 }()
846
847 *o = append(*o, metric.WithAttributes(attrs...))
848 m.Int64UpDownCounter.Add(ctx, incr, *o...)
849 }
850
851 // AddSet adds incr to the existing count for set.
852 //
853 // See
854 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
855 // for details.
856 func (m ContainerEphemeralStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) {
857 if set.Len() == 0 {
858 m.Int64UpDownCounter.Add(ctx, incr)
859 return
860 }
861
862 o := addOptPool.Get().(*[]metric.AddOption)
863 defer func() {
864 *o = (*o)[:0]
865 addOptPool.Put(o)
866 }()
867
868 *o = append(*o, metric.WithAttributeSet(set))
869 m.Int64UpDownCounter.Add(ctx, incr, *o...)
870 }
871
872 // ContainerMemoryLimit is an instrument used to record metric values conforming
873 // to the "k8s.container.memory.limit" semantic conventions. It represents the
874 // maximum memory resource limit set for the container.
875 type ContainerMemoryLimit struct {
876 metric.Int64UpDownCounter
877 }
878
879 var newContainerMemoryLimitOpts = []metric.Int64UpDownCounterOption{
880 metric.WithDescription("Maximum memory resource limit set for the container."),
881 metric.WithUnit("By"),
882 }
883
884 // NewContainerMemoryLimit returns a new ContainerMemoryLimit instrument.
885 func NewContainerMemoryLimit(
886 m metric.Meter,
887 opt ...metric.Int64UpDownCounterOption,
888 ) (ContainerMemoryLimit, error) {
889 // Check if the meter is nil.
890 if m == nil {
891 return ContainerMemoryLimit{noop.Int64UpDownCounter{}}, nil
892 }
893
894 if len(opt) == 0 {
895 opt = newContainerMemoryLimitOpts
896 } else {
897 opt = append(opt, newContainerMemoryLimitOpts...)
898 }
899
900 i, err := m.Int64UpDownCounter(
901 "k8s.container.memory.limit",
902 opt...,
903 )
904 if err != nil {
905 return ContainerMemoryLimit{noop.Int64UpDownCounter{}}, err
906 }
907 return ContainerMemoryLimit{i}, nil
908 }
909
910 // Inst returns the underlying metric instrument.
911 func (m ContainerMemoryLimit) Inst() metric.Int64UpDownCounter {
912 return m.Int64UpDownCounter
913 }
914
915 // Name returns the semantic convention name of the instrument.
916 func (ContainerMemoryLimit) Name() string {
917 return "k8s.container.memory.limit"
918 }
919
920 // Unit returns the semantic convention unit of the instrument
921 func (ContainerMemoryLimit) Unit() string {
922 return "By"
923 }
924
925 // Description returns the semantic convention description of the instrument
926 func (ContainerMemoryLimit) Description() string {
927 return "Maximum memory resource limit set for the container."
928 }
929
930 // Add adds incr to the existing count for attrs.
931 //
932 // See
933 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
934 // for details.
935 func (m ContainerMemoryLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
936 if len(attrs) == 0 {
937 m.Int64UpDownCounter.Add(ctx, incr)
938 return
939 }
940
941 o := addOptPool.Get().(*[]metric.AddOption)
942 defer func() {
943 *o = (*o)[:0]
944 addOptPool.Put(o)
945 }()
946
947 *o = append(*o, metric.WithAttributes(attrs...))
948 m.Int64UpDownCounter.Add(ctx, incr, *o...)
949 }
950
951 // AddSet adds incr to the existing count for set.
952 //
953 // See
954 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
955 // for details.
956 func (m ContainerMemoryLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) {
957 if set.Len() == 0 {
958 m.Int64UpDownCounter.Add(ctx, incr)
959 return
960 }
961
962 o := addOptPool.Get().(*[]metric.AddOption)
963 defer func() {
964 *o = (*o)[:0]
965 addOptPool.Put(o)
966 }()
967
968 *o = append(*o, metric.WithAttributeSet(set))
969 m.Int64UpDownCounter.Add(ctx, incr, *o...)
970 }
971
972 // ContainerMemoryRequest is an instrument used to record metric values
973 // conforming to the "k8s.container.memory.request" semantic conventions. It
974 // represents the memory resource requested for the container.
975 type ContainerMemoryRequest struct {
976 metric.Int64UpDownCounter
977 }
978
979 var newContainerMemoryRequestOpts = []metric.Int64UpDownCounterOption{
980 metric.WithDescription("Memory resource requested for the container."),
981 metric.WithUnit("By"),
982 }
983
984 // NewContainerMemoryRequest returns a new ContainerMemoryRequest instrument.
985 func NewContainerMemoryRequest(
986 m metric.Meter,
987 opt ...metric.Int64UpDownCounterOption,
988 ) (ContainerMemoryRequest, error) {
989 // Check if the meter is nil.
990 if m == nil {
991 return ContainerMemoryRequest{noop.Int64UpDownCounter{}}, nil
992 }
993
994 if len(opt) == 0 {
995 opt = newContainerMemoryRequestOpts
996 } else {
997 opt = append(opt, newContainerMemoryRequestOpts...)
998 }
999
1000 i, err := m.Int64UpDownCounter(
1001 "k8s.container.memory.request",
1002 opt...,
1003 )
1004 if err != nil {
1005 return ContainerMemoryRequest{noop.Int64UpDownCounter{}}, err
1006 }
1007 return ContainerMemoryRequest{i}, nil
1008 }
1009
1010 // Inst returns the underlying metric instrument.
1011 func (m ContainerMemoryRequest) Inst() metric.Int64UpDownCounter {
1012 return m.Int64UpDownCounter
1013 }
1014
1015 // Name returns the semantic convention name of the instrument.
1016 func (ContainerMemoryRequest) Name() string {
1017 return "k8s.container.memory.request"
1018 }
1019
1020 // Unit returns the semantic convention unit of the instrument
1021 func (ContainerMemoryRequest) Unit() string {
1022 return "By"
1023 }
1024
1025 // Description returns the semantic convention description of the instrument
1026 func (ContainerMemoryRequest) Description() string {
1027 return "Memory resource requested for the container."
1028 }
1029
1030 // Add adds incr to the existing count for attrs.
1031 //
1032 // See
1033 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
1034 // for details.
1035 func (m ContainerMemoryRequest) 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 // AddSet adds incr to the existing count for set.
1052 //
1053 // See
1054 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
1055 // for details.
1056 func (m ContainerMemoryRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1057 if set.Len() == 0 {
1058 m.Int64UpDownCounter.Add(ctx, incr)
1059 return
1060 }
1061
1062 o := addOptPool.Get().(*[]metric.AddOption)
1063 defer func() {
1064 *o = (*o)[:0]
1065 addOptPool.Put(o)
1066 }()
1067
1068 *o = append(*o, metric.WithAttributeSet(set))
1069 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1070 }
1071
1072 // ContainerReady is an instrument used to record metric values conforming to the
1073 // "k8s.container.ready" semantic conventions. It represents the indicates
1074 // whether the container is currently marked as ready to accept traffic, based on
1075 // its readiness probe (1 = ready, 0 = not ready).
1076 type ContainerReady struct {
1077 metric.Int64UpDownCounter
1078 }
1079
1080 var newContainerReadyOpts = []metric.Int64UpDownCounterOption{
1081 metric.WithDescription("Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready)."),
1082 metric.WithUnit("{container}"),
1083 }
1084
1085 // NewContainerReady returns a new ContainerReady instrument.
1086 func NewContainerReady(
1087 m metric.Meter,
1088 opt ...metric.Int64UpDownCounterOption,
1089 ) (ContainerReady, error) {
1090 // Check if the meter is nil.
1091 if m == nil {
1092 return ContainerReady{noop.Int64UpDownCounter{}}, nil
1093 }
1094
1095 if len(opt) == 0 {
1096 opt = newContainerReadyOpts
1097 } else {
1098 opt = append(opt, newContainerReadyOpts...)
1099 }
1100
1101 i, err := m.Int64UpDownCounter(
1102 "k8s.container.ready",
1103 opt...,
1104 )
1105 if err != nil {
1106 return ContainerReady{noop.Int64UpDownCounter{}}, err
1107 }
1108 return ContainerReady{i}, nil
1109 }
1110
1111 // Inst returns the underlying metric instrument.
1112 func (m ContainerReady) Inst() metric.Int64UpDownCounter {
1113 return m.Int64UpDownCounter
1114 }
1115
1116 // Name returns the semantic convention name of the instrument.
1117 func (ContainerReady) Name() string {
1118 return "k8s.container.ready"
1119 }
1120
1121 // Unit returns the semantic convention unit of the instrument
1122 func (ContainerReady) Unit() string {
1123 return "{container}"
1124 }
1125
1126 // Description returns the semantic convention description of the instrument
1127 func (ContainerReady) Description() string {
1128 return "Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready)."
1129 }
1130
1131 // Add adds incr to the existing count for attrs.
1132 //
1133 // This metric SHOULD reflect the value of the `ready` field in the
1134 // [K8s ContainerStatus].
1135 //
1136 // [K8s ContainerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core
1137 func (m ContainerReady) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1138 if len(attrs) == 0 {
1139 m.Int64UpDownCounter.Add(ctx, incr)
1140 return
1141 }
1142
1143 o := addOptPool.Get().(*[]metric.AddOption)
1144 defer func() {
1145 *o = (*o)[:0]
1146 addOptPool.Put(o)
1147 }()
1148
1149 *o = append(*o, metric.WithAttributes(attrs...))
1150 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1151 }
1152
1153 // AddSet adds incr to the existing count for set.
1154 //
1155 // This metric SHOULD reflect the value of the `ready` field in the
1156 // [K8s ContainerStatus].
1157 //
1158 // [K8s ContainerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core
1159 func (m ContainerReady) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1160 if set.Len() == 0 {
1161 m.Int64UpDownCounter.Add(ctx, incr)
1162 return
1163 }
1164
1165 o := addOptPool.Get().(*[]metric.AddOption)
1166 defer func() {
1167 *o = (*o)[:0]
1168 addOptPool.Put(o)
1169 }()
1170
1171 *o = append(*o, metric.WithAttributeSet(set))
1172 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1173 }
1174
1175 // ContainerRestartCount is an instrument used to record metric values conforming
1176 // to the "k8s.container.restart.count" semantic conventions. It represents the
1177 // describes how many times the container has restarted (since the last counter
1178 // reset).
1179 type ContainerRestartCount struct {
1180 metric.Int64UpDownCounter
1181 }
1182
1183 var newContainerRestartCountOpts = []metric.Int64UpDownCounterOption{
1184 metric.WithDescription("Describes how many times the container has restarted (since the last counter reset)."),
1185 metric.WithUnit("{restart}"),
1186 }
1187
1188 // NewContainerRestartCount returns a new ContainerRestartCount instrument.
1189 func NewContainerRestartCount(
1190 m metric.Meter,
1191 opt ...metric.Int64UpDownCounterOption,
1192 ) (ContainerRestartCount, error) {
1193 // Check if the meter is nil.
1194 if m == nil {
1195 return ContainerRestartCount{noop.Int64UpDownCounter{}}, nil
1196 }
1197
1198 if len(opt) == 0 {
1199 opt = newContainerRestartCountOpts
1200 } else {
1201 opt = append(opt, newContainerRestartCountOpts...)
1202 }
1203
1204 i, err := m.Int64UpDownCounter(
1205 "k8s.container.restart.count",
1206 opt...,
1207 )
1208 if err != nil {
1209 return ContainerRestartCount{noop.Int64UpDownCounter{}}, err
1210 }
1211 return ContainerRestartCount{i}, nil
1212 }
1213
1214 // Inst returns the underlying metric instrument.
1215 func (m ContainerRestartCount) Inst() metric.Int64UpDownCounter {
1216 return m.Int64UpDownCounter
1217 }
1218
1219 // Name returns the semantic convention name of the instrument.
1220 func (ContainerRestartCount) Name() string {
1221 return "k8s.container.restart.count"
1222 }
1223
1224 // Unit returns the semantic convention unit of the instrument
1225 func (ContainerRestartCount) Unit() string {
1226 return "{restart}"
1227 }
1228
1229 // Description returns the semantic convention description of the instrument
1230 func (ContainerRestartCount) Description() string {
1231 return "Describes how many times the container has restarted (since the last counter reset)."
1232 }
1233
1234 // Add adds incr to the existing count for attrs.
1235 //
1236 // This value is pulled directly from the K8s API and the value can go
1237 // indefinitely high and be reset to 0
1238 // at any time depending on how your kubelet is configured to prune dead
1239 // containers.
1240 // It is best to not depend too much on the exact value but rather look at it as
1241 // either == 0, in which case you can conclude there were no restarts in the
1242 // recent past, or > 0, in which case
1243 // you can conclude there were restarts in the recent past, and not try and
1244 // analyze the value beyond that.
1245 func (m ContainerRestartCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1246 if len(attrs) == 0 {
1247 m.Int64UpDownCounter.Add(ctx, incr)
1248 return
1249 }
1250
1251 o := addOptPool.Get().(*[]metric.AddOption)
1252 defer func() {
1253 *o = (*o)[:0]
1254 addOptPool.Put(o)
1255 }()
1256
1257 *o = append(*o, metric.WithAttributes(attrs...))
1258 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1259 }
1260
1261 // AddSet adds incr to the existing count for set.
1262 //
1263 // This value is pulled directly from the K8s API and the value can go
1264 // indefinitely high and be reset to 0
1265 // at any time depending on how your kubelet is configured to prune dead
1266 // containers.
1267 // It is best to not depend too much on the exact value but rather look at it as
1268 // either == 0, in which case you can conclude there were no restarts in the
1269 // recent past, or > 0, in which case
1270 // you can conclude there were restarts in the recent past, and not try and
1271 // analyze the value beyond that.
1272 func (m ContainerRestartCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1273 if set.Len() == 0 {
1274 m.Int64UpDownCounter.Add(ctx, incr)
1275 return
1276 }
1277
1278 o := addOptPool.Get().(*[]metric.AddOption)
1279 defer func() {
1280 *o = (*o)[:0]
1281 addOptPool.Put(o)
1282 }()
1283
1284 *o = append(*o, metric.WithAttributeSet(set))
1285 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1286 }
1287
1288 // ContainerStatusReason is an instrument used to record metric values conforming
1289 // to the "k8s.container.status.reason" semantic conventions. It represents the
1290 // describes the number of K8s containers that are currently in a state for a
1291 // given reason.
1292 type ContainerStatusReason struct {
1293 metric.Int64UpDownCounter
1294 }
1295
1296 var newContainerStatusReasonOpts = []metric.Int64UpDownCounterOption{
1297 metric.WithDescription("Describes the number of K8s containers that are currently in a state for a given reason."),
1298 metric.WithUnit("{container}"),
1299 }
1300
1301 // NewContainerStatusReason returns a new ContainerStatusReason instrument.
1302 func NewContainerStatusReason(
1303 m metric.Meter,
1304 opt ...metric.Int64UpDownCounterOption,
1305 ) (ContainerStatusReason, error) {
1306 // Check if the meter is nil.
1307 if m == nil {
1308 return ContainerStatusReason{noop.Int64UpDownCounter{}}, nil
1309 }
1310
1311 if len(opt) == 0 {
1312 opt = newContainerStatusReasonOpts
1313 } else {
1314 opt = append(opt, newContainerStatusReasonOpts...)
1315 }
1316
1317 i, err := m.Int64UpDownCounter(
1318 "k8s.container.status.reason",
1319 opt...,
1320 )
1321 if err != nil {
1322 return ContainerStatusReason{noop.Int64UpDownCounter{}}, err
1323 }
1324 return ContainerStatusReason{i}, nil
1325 }
1326
1327 // Inst returns the underlying metric instrument.
1328 func (m ContainerStatusReason) Inst() metric.Int64UpDownCounter {
1329 return m.Int64UpDownCounter
1330 }
1331
1332 // Name returns the semantic convention name of the instrument.
1333 func (ContainerStatusReason) Name() string {
1334 return "k8s.container.status.reason"
1335 }
1336
1337 // Unit returns the semantic convention unit of the instrument
1338 func (ContainerStatusReason) Unit() string {
1339 return "{container}"
1340 }
1341
1342 // Description returns the semantic convention description of the instrument
1343 func (ContainerStatusReason) Description() string {
1344 return "Describes the number of K8s containers that are currently in a state for a given reason."
1345 }
1346
1347 // Add adds incr to the existing count for attrs.
1348 //
1349 // The containerStatusReason is the the reason for the container state.
1350 // Corresponds to the `reason` field of the: [K8s ContainerStateWaiting] or
1351 // [K8s ContainerStateTerminated]
1352 //
1353 // [K8s ContainerStateWaiting]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatewaiting-v1-core
1354 // [K8s ContainerStateTerminated]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstateterminated-v1-core
1355 //
1356 // All possible container state reasons will be reported at each time interval to
1357 // avoid missing metrics.
1358 // Only the value corresponding to the current state reason will be non-zero.
1359 func (m ContainerStatusReason) Add(
1360 ctx context.Context,
1361 incr int64,
1362 containerStatusReason ContainerStatusReasonAttr,
1363 attrs ...attribute.KeyValue,
1364 ) {
1365 if len(attrs) == 0 {
1366 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
1367 attribute.String("k8s.container.status.reason", string(containerStatusReason)),
1368 ))
1369 return
1370 }
1371
1372 o := addOptPool.Get().(*[]metric.AddOption)
1373 defer func() {
1374 *o = (*o)[:0]
1375 addOptPool.Put(o)
1376 }()
1377
1378 *o = append(
1379 *o,
1380 metric.WithAttributes(
1381 append(
1382 attrs[:len(attrs):len(attrs)],
1383 attribute.String("k8s.container.status.reason", string(containerStatusReason)),
1384 )...,
1385 ),
1386 )
1387
1388 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1389 }
1390
1391 // AddSet adds incr to the existing count for set.
1392 //
1393 // All possible container state reasons will be reported at each time interval to
1394 // avoid missing metrics.
1395 // Only the value corresponding to the current state reason will be non-zero.
1396 func (m ContainerStatusReason) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1397 if set.Len() == 0 {
1398 m.Int64UpDownCounter.Add(ctx, incr)
1399 return
1400 }
1401
1402 o := addOptPool.Get().(*[]metric.AddOption)
1403 defer func() {
1404 *o = (*o)[:0]
1405 addOptPool.Put(o)
1406 }()
1407
1408 *o = append(*o, metric.WithAttributeSet(set))
1409 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1410 }
1411
1412 // ContainerStatusState is an instrument used to record metric values conforming
1413 // to the "k8s.container.status.state" semantic conventions. It represents the
1414 // describes the number of K8s containers that are currently in a given state.
1415 type ContainerStatusState struct {
1416 metric.Int64UpDownCounter
1417 }
1418
1419 var newContainerStatusStateOpts = []metric.Int64UpDownCounterOption{
1420 metric.WithDescription("Describes the number of K8s containers that are currently in a given state."),
1421 metric.WithUnit("{container}"),
1422 }
1423
1424 // NewContainerStatusState returns a new ContainerStatusState instrument.
1425 func NewContainerStatusState(
1426 m metric.Meter,
1427 opt ...metric.Int64UpDownCounterOption,
1428 ) (ContainerStatusState, error) {
1429 // Check if the meter is nil.
1430 if m == nil {
1431 return ContainerStatusState{noop.Int64UpDownCounter{}}, nil
1432 }
1433
1434 if len(opt) == 0 {
1435 opt = newContainerStatusStateOpts
1436 } else {
1437 opt = append(opt, newContainerStatusStateOpts...)
1438 }
1439
1440 i, err := m.Int64UpDownCounter(
1441 "k8s.container.status.state",
1442 opt...,
1443 )
1444 if err != nil {
1445 return ContainerStatusState{noop.Int64UpDownCounter{}}, err
1446 }
1447 return ContainerStatusState{i}, nil
1448 }
1449
1450 // Inst returns the underlying metric instrument.
1451 func (m ContainerStatusState) Inst() metric.Int64UpDownCounter {
1452 return m.Int64UpDownCounter
1453 }
1454
1455 // Name returns the semantic convention name of the instrument.
1456 func (ContainerStatusState) Name() string {
1457 return "k8s.container.status.state"
1458 }
1459
1460 // Unit returns the semantic convention unit of the instrument
1461 func (ContainerStatusState) Unit() string {
1462 return "{container}"
1463 }
1464
1465 // Description returns the semantic convention description of the instrument
1466 func (ContainerStatusState) Description() string {
1467 return "Describes the number of K8s containers that are currently in a given state."
1468 }
1469
1470 // Add adds incr to the existing count for attrs.
1471 //
1472 // The containerStatusState is the the state of the container.
1473 // [K8s ContainerState]
1474 //
1475 // [K8s ContainerState]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstate-v1-core
1476 //
1477 // All possible container states will be reported at each time interval to avoid
1478 // missing metrics.
1479 // Only the value corresponding to the current state will be non-zero.
1480 func (m ContainerStatusState) Add(
1481 ctx context.Context,
1482 incr int64,
1483 containerStatusState ContainerStatusStateAttr,
1484 attrs ...attribute.KeyValue,
1485 ) {
1486 if len(attrs) == 0 {
1487 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
1488 attribute.String("k8s.container.status.state", string(containerStatusState)),
1489 ))
1490 return
1491 }
1492
1493 o := addOptPool.Get().(*[]metric.AddOption)
1494 defer func() {
1495 *o = (*o)[:0]
1496 addOptPool.Put(o)
1497 }()
1498
1499 *o = append(
1500 *o,
1501 metric.WithAttributes(
1502 append(
1503 attrs[:len(attrs):len(attrs)],
1504 attribute.String("k8s.container.status.state", string(containerStatusState)),
1505 )...,
1506 ),
1507 )
1508
1509 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1510 }
1511
1512 // AddSet adds incr to the existing count for set.
1513 //
1514 // All possible container states will be reported at each time interval to avoid
1515 // missing metrics.
1516 // Only the value corresponding to the current state will be non-zero.
1517 func (m ContainerStatusState) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1518 if set.Len() == 0 {
1519 m.Int64UpDownCounter.Add(ctx, incr)
1520 return
1521 }
1522
1523 o := addOptPool.Get().(*[]metric.AddOption)
1524 defer func() {
1525 *o = (*o)[:0]
1526 addOptPool.Put(o)
1527 }()
1528
1529 *o = append(*o, metric.WithAttributeSet(set))
1530 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1531 }
1532
1533 // ContainerStorageLimit is an instrument used to record metric values conforming
1534 // to the "k8s.container.storage.limit" semantic conventions. It represents the
1535 // maximum storage resource limit set for the container.
1536 type ContainerStorageLimit struct {
1537 metric.Int64UpDownCounter
1538 }
1539
1540 var newContainerStorageLimitOpts = []metric.Int64UpDownCounterOption{
1541 metric.WithDescription("Maximum storage resource limit set for the container."),
1542 metric.WithUnit("By"),
1543 }
1544
1545 // NewContainerStorageLimit returns a new ContainerStorageLimit instrument.
1546 func NewContainerStorageLimit(
1547 m metric.Meter,
1548 opt ...metric.Int64UpDownCounterOption,
1549 ) (ContainerStorageLimit, error) {
1550 // Check if the meter is nil.
1551 if m == nil {
1552 return ContainerStorageLimit{noop.Int64UpDownCounter{}}, nil
1553 }
1554
1555 if len(opt) == 0 {
1556 opt = newContainerStorageLimitOpts
1557 } else {
1558 opt = append(opt, newContainerStorageLimitOpts...)
1559 }
1560
1561 i, err := m.Int64UpDownCounter(
1562 "k8s.container.storage.limit",
1563 opt...,
1564 )
1565 if err != nil {
1566 return ContainerStorageLimit{noop.Int64UpDownCounter{}}, err
1567 }
1568 return ContainerStorageLimit{i}, nil
1569 }
1570
1571 // Inst returns the underlying metric instrument.
1572 func (m ContainerStorageLimit) Inst() metric.Int64UpDownCounter {
1573 return m.Int64UpDownCounter
1574 }
1575
1576 // Name returns the semantic convention name of the instrument.
1577 func (ContainerStorageLimit) Name() string {
1578 return "k8s.container.storage.limit"
1579 }
1580
1581 // Unit returns the semantic convention unit of the instrument
1582 func (ContainerStorageLimit) Unit() string {
1583 return "By"
1584 }
1585
1586 // Description returns the semantic convention description of the instrument
1587 func (ContainerStorageLimit) Description() string {
1588 return "Maximum storage resource limit set for the container."
1589 }
1590
1591 // Add adds incr to the existing count for attrs.
1592 //
1593 // See
1594 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
1595 // for details.
1596 func (m ContainerStorageLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1597 if len(attrs) == 0 {
1598 m.Int64UpDownCounter.Add(ctx, incr)
1599 return
1600 }
1601
1602 o := addOptPool.Get().(*[]metric.AddOption)
1603 defer func() {
1604 *o = (*o)[:0]
1605 addOptPool.Put(o)
1606 }()
1607
1608 *o = append(*o, metric.WithAttributes(attrs...))
1609 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1610 }
1611
1612 // AddSet adds incr to the existing count for set.
1613 //
1614 // See
1615 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
1616 // for details.
1617 func (m ContainerStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1618 if set.Len() == 0 {
1619 m.Int64UpDownCounter.Add(ctx, incr)
1620 return
1621 }
1622
1623 o := addOptPool.Get().(*[]metric.AddOption)
1624 defer func() {
1625 *o = (*o)[:0]
1626 addOptPool.Put(o)
1627 }()
1628
1629 *o = append(*o, metric.WithAttributeSet(set))
1630 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1631 }
1632
1633 // ContainerStorageRequest is an instrument used to record metric values
1634 // conforming to the "k8s.container.storage.request" semantic conventions. It
1635 // represents the storage resource requested for the container.
1636 type ContainerStorageRequest struct {
1637 metric.Int64UpDownCounter
1638 }
1639
1640 var newContainerStorageRequestOpts = []metric.Int64UpDownCounterOption{
1641 metric.WithDescription("Storage resource requested for the container."),
1642 metric.WithUnit("By"),
1643 }
1644
1645 // NewContainerStorageRequest returns a new ContainerStorageRequest instrument.
1646 func NewContainerStorageRequest(
1647 m metric.Meter,
1648 opt ...metric.Int64UpDownCounterOption,
1649 ) (ContainerStorageRequest, error) {
1650 // Check if the meter is nil.
1651 if m == nil {
1652 return ContainerStorageRequest{noop.Int64UpDownCounter{}}, nil
1653 }
1654
1655 if len(opt) == 0 {
1656 opt = newContainerStorageRequestOpts
1657 } else {
1658 opt = append(opt, newContainerStorageRequestOpts...)
1659 }
1660
1661 i, err := m.Int64UpDownCounter(
1662 "k8s.container.storage.request",
1663 opt...,
1664 )
1665 if err != nil {
1666 return ContainerStorageRequest{noop.Int64UpDownCounter{}}, err
1667 }
1668 return ContainerStorageRequest{i}, nil
1669 }
1670
1671 // Inst returns the underlying metric instrument.
1672 func (m ContainerStorageRequest) Inst() metric.Int64UpDownCounter {
1673 return m.Int64UpDownCounter
1674 }
1675
1676 // Name returns the semantic convention name of the instrument.
1677 func (ContainerStorageRequest) Name() string {
1678 return "k8s.container.storage.request"
1679 }
1680
1681 // Unit returns the semantic convention unit of the instrument
1682 func (ContainerStorageRequest) Unit() string {
1683 return "By"
1684 }
1685
1686 // Description returns the semantic convention description of the instrument
1687 func (ContainerStorageRequest) Description() string {
1688 return "Storage resource requested for the container."
1689 }
1690
1691 // Add adds incr to the existing count for attrs.
1692 //
1693 // See
1694 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
1695 // for details.
1696 func (m ContainerStorageRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1697 if len(attrs) == 0 {
1698 m.Int64UpDownCounter.Add(ctx, incr)
1699 return
1700 }
1701
1702 o := addOptPool.Get().(*[]metric.AddOption)
1703 defer func() {
1704 *o = (*o)[:0]
1705 addOptPool.Put(o)
1706 }()
1707
1708 *o = append(*o, metric.WithAttributes(attrs...))
1709 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1710 }
1711
1712 // AddSet adds incr to the existing count for set.
1713 //
1714 // See
1715 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core
1716 // for details.
1717 func (m ContainerStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1718 if set.Len() == 0 {
1719 m.Int64UpDownCounter.Add(ctx, incr)
1720 return
1721 }
1722
1723 o := addOptPool.Get().(*[]metric.AddOption)
1724 defer func() {
1725 *o = (*o)[:0]
1726 addOptPool.Put(o)
1727 }()
1728
1729 *o = append(*o, metric.WithAttributeSet(set))
1730 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1731 }
1732
1733 // CronJobJobActive is an instrument used to record metric values conforming to
1734 // the "k8s.cronjob.job.active" semantic conventions. It represents the number of
1735 // actively running jobs for a cronjob.
1736 type CronJobJobActive struct {
1737 metric.Int64UpDownCounter
1738 }
1739
1740 var newCronJobJobActiveOpts = []metric.Int64UpDownCounterOption{
1741 metric.WithDescription("The number of actively running jobs for a cronjob."),
1742 metric.WithUnit("{job}"),
1743 }
1744
1745 // NewCronJobJobActive returns a new CronJobJobActive instrument.
1746 func NewCronJobJobActive(
1747 m metric.Meter,
1748 opt ...metric.Int64UpDownCounterOption,
1749 ) (CronJobJobActive, error) {
1750 // Check if the meter is nil.
1751 if m == nil {
1752 return CronJobJobActive{noop.Int64UpDownCounter{}}, nil
1753 }
1754
1755 if len(opt) == 0 {
1756 opt = newCronJobJobActiveOpts
1757 } else {
1758 opt = append(opt, newCronJobJobActiveOpts...)
1759 }
1760
1761 i, err := m.Int64UpDownCounter(
1762 "k8s.cronjob.job.active",
1763 opt...,
1764 )
1765 if err != nil {
1766 return CronJobJobActive{noop.Int64UpDownCounter{}}, err
1767 }
1768 return CronJobJobActive{i}, nil
1769 }
1770
1771 // Inst returns the underlying metric instrument.
1772 func (m CronJobJobActive) Inst() metric.Int64UpDownCounter {
1773 return m.Int64UpDownCounter
1774 }
1775
1776 // Name returns the semantic convention name of the instrument.
1777 func (CronJobJobActive) Name() string {
1778 return "k8s.cronjob.job.active"
1779 }
1780
1781 // Unit returns the semantic convention unit of the instrument
1782 func (CronJobJobActive) Unit() string {
1783 return "{job}"
1784 }
1785
1786 // Description returns the semantic convention description of the instrument
1787 func (CronJobJobActive) Description() string {
1788 return "The number of actively running jobs for a cronjob."
1789 }
1790
1791 // Add adds incr to the existing count for attrs.
1792 //
1793 // This metric aligns with the `active` field of the
1794 // [K8s CronJobStatus].
1795 //
1796 // [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch
1797 func (m CronJobJobActive) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1798 if len(attrs) == 0 {
1799 m.Int64UpDownCounter.Add(ctx, incr)
1800 return
1801 }
1802
1803 o := addOptPool.Get().(*[]metric.AddOption)
1804 defer func() {
1805 *o = (*o)[:0]
1806 addOptPool.Put(o)
1807 }()
1808
1809 *o = append(*o, metric.WithAttributes(attrs...))
1810 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1811 }
1812
1813 // AddSet adds incr to the existing count for set.
1814 //
1815 // This metric aligns with the `active` field of the
1816 // [K8s CronJobStatus].
1817 //
1818 // [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch
1819 func (m CronJobJobActive) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1820 if set.Len() == 0 {
1821 m.Int64UpDownCounter.Add(ctx, incr)
1822 return
1823 }
1824
1825 o := addOptPool.Get().(*[]metric.AddOption)
1826 defer func() {
1827 *o = (*o)[:0]
1828 addOptPool.Put(o)
1829 }()
1830
1831 *o = append(*o, metric.WithAttributeSet(set))
1832 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1833 }
1834
1835 // DaemonSetNodeCurrentScheduled is an instrument used to record metric values
1836 // conforming to the "k8s.daemonset.node.current_scheduled" semantic conventions.
1837 // It represents the number of nodes that are running at least 1 daemon pod and
1838 // are supposed to run the daemon pod.
1839 type DaemonSetNodeCurrentScheduled struct {
1840 metric.Int64UpDownCounter
1841 }
1842
1843 var newDaemonSetNodeCurrentScheduledOpts = []metric.Int64UpDownCounterOption{
1844 metric.WithDescription("Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod."),
1845 metric.WithUnit("{node}"),
1846 }
1847
1848 // NewDaemonSetNodeCurrentScheduled returns a new DaemonSetNodeCurrentScheduled
1849 // instrument.
1850 func NewDaemonSetNodeCurrentScheduled(
1851 m metric.Meter,
1852 opt ...metric.Int64UpDownCounterOption,
1853 ) (DaemonSetNodeCurrentScheduled, error) {
1854 // Check if the meter is nil.
1855 if m == nil {
1856 return DaemonSetNodeCurrentScheduled{noop.Int64UpDownCounter{}}, nil
1857 }
1858
1859 if len(opt) == 0 {
1860 opt = newDaemonSetNodeCurrentScheduledOpts
1861 } else {
1862 opt = append(opt, newDaemonSetNodeCurrentScheduledOpts...)
1863 }
1864
1865 i, err := m.Int64UpDownCounter(
1866 "k8s.daemonset.node.current_scheduled",
1867 opt...,
1868 )
1869 if err != nil {
1870 return DaemonSetNodeCurrentScheduled{noop.Int64UpDownCounter{}}, err
1871 }
1872 return DaemonSetNodeCurrentScheduled{i}, nil
1873 }
1874
1875 // Inst returns the underlying metric instrument.
1876 func (m DaemonSetNodeCurrentScheduled) Inst() metric.Int64UpDownCounter {
1877 return m.Int64UpDownCounter
1878 }
1879
1880 // Name returns the semantic convention name of the instrument.
1881 func (DaemonSetNodeCurrentScheduled) Name() string {
1882 return "k8s.daemonset.node.current_scheduled"
1883 }
1884
1885 // Unit returns the semantic convention unit of the instrument
1886 func (DaemonSetNodeCurrentScheduled) Unit() string {
1887 return "{node}"
1888 }
1889
1890 // Description returns the semantic convention description of the instrument
1891 func (DaemonSetNodeCurrentScheduled) Description() string {
1892 return "Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod."
1893 }
1894
1895 // Add adds incr to the existing count for attrs.
1896 //
1897 // This metric aligns with the `currentNumberScheduled` field of the
1898 // [K8s DaemonSetStatus].
1899 //
1900 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
1901 func (m DaemonSetNodeCurrentScheduled) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1902 if len(attrs) == 0 {
1903 m.Int64UpDownCounter.Add(ctx, incr)
1904 return
1905 }
1906
1907 o := addOptPool.Get().(*[]metric.AddOption)
1908 defer func() {
1909 *o = (*o)[:0]
1910 addOptPool.Put(o)
1911 }()
1912
1913 *o = append(*o, metric.WithAttributes(attrs...))
1914 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1915 }
1916
1917 // AddSet adds incr to the existing count for set.
1918 //
1919 // This metric aligns with the `currentNumberScheduled` field of the
1920 // [K8s DaemonSetStatus].
1921 //
1922 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
1923 func (m DaemonSetNodeCurrentScheduled) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1924 if set.Len() == 0 {
1925 m.Int64UpDownCounter.Add(ctx, incr)
1926 return
1927 }
1928
1929 o := addOptPool.Get().(*[]metric.AddOption)
1930 defer func() {
1931 *o = (*o)[:0]
1932 addOptPool.Put(o)
1933 }()
1934
1935 *o = append(*o, metric.WithAttributeSet(set))
1936 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1937 }
1938
1939 // DaemonSetNodeDesiredScheduled is an instrument used to record metric values
1940 // conforming to the "k8s.daemonset.node.desired_scheduled" semantic conventions.
1941 // It represents the number of nodes that should be running the daemon pod
1942 // (including nodes currently running the daemon pod).
1943 type DaemonSetNodeDesiredScheduled struct {
1944 metric.Int64UpDownCounter
1945 }
1946
1947 var newDaemonSetNodeDesiredScheduledOpts = []metric.Int64UpDownCounterOption{
1948 metric.WithDescription("Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)."),
1949 metric.WithUnit("{node}"),
1950 }
1951
1952 // NewDaemonSetNodeDesiredScheduled returns a new DaemonSetNodeDesiredScheduled
1953 // instrument.
1954 func NewDaemonSetNodeDesiredScheduled(
1955 m metric.Meter,
1956 opt ...metric.Int64UpDownCounterOption,
1957 ) (DaemonSetNodeDesiredScheduled, error) {
1958 // Check if the meter is nil.
1959 if m == nil {
1960 return DaemonSetNodeDesiredScheduled{noop.Int64UpDownCounter{}}, nil
1961 }
1962
1963 if len(opt) == 0 {
1964 opt = newDaemonSetNodeDesiredScheduledOpts
1965 } else {
1966 opt = append(opt, newDaemonSetNodeDesiredScheduledOpts...)
1967 }
1968
1969 i, err := m.Int64UpDownCounter(
1970 "k8s.daemonset.node.desired_scheduled",
1971 opt...,
1972 )
1973 if err != nil {
1974 return DaemonSetNodeDesiredScheduled{noop.Int64UpDownCounter{}}, err
1975 }
1976 return DaemonSetNodeDesiredScheduled{i}, nil
1977 }
1978
1979 // Inst returns the underlying metric instrument.
1980 func (m DaemonSetNodeDesiredScheduled) Inst() metric.Int64UpDownCounter {
1981 return m.Int64UpDownCounter
1982 }
1983
1984 // Name returns the semantic convention name of the instrument.
1985 func (DaemonSetNodeDesiredScheduled) Name() string {
1986 return "k8s.daemonset.node.desired_scheduled"
1987 }
1988
1989 // Unit returns the semantic convention unit of the instrument
1990 func (DaemonSetNodeDesiredScheduled) Unit() string {
1991 return "{node}"
1992 }
1993
1994 // Description returns the semantic convention description of the instrument
1995 func (DaemonSetNodeDesiredScheduled) Description() string {
1996 return "Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)."
1997 }
1998
1999 // Add adds incr to the existing count for attrs.
2000 //
2001 // This metric aligns with the `desiredNumberScheduled` field of the
2002 // [K8s DaemonSetStatus].
2003 //
2004 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
2005 func (m DaemonSetNodeDesiredScheduled) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2006 if len(attrs) == 0 {
2007 m.Int64UpDownCounter.Add(ctx, incr)
2008 return
2009 }
2010
2011 o := addOptPool.Get().(*[]metric.AddOption)
2012 defer func() {
2013 *o = (*o)[:0]
2014 addOptPool.Put(o)
2015 }()
2016
2017 *o = append(*o, metric.WithAttributes(attrs...))
2018 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2019 }
2020
2021 // AddSet adds incr to the existing count for set.
2022 //
2023 // This metric aligns with the `desiredNumberScheduled` field of the
2024 // [K8s DaemonSetStatus].
2025 //
2026 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
2027 func (m DaemonSetNodeDesiredScheduled) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2028 if set.Len() == 0 {
2029 m.Int64UpDownCounter.Add(ctx, incr)
2030 return
2031 }
2032
2033 o := addOptPool.Get().(*[]metric.AddOption)
2034 defer func() {
2035 *o = (*o)[:0]
2036 addOptPool.Put(o)
2037 }()
2038
2039 *o = append(*o, metric.WithAttributeSet(set))
2040 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2041 }
2042
2043 // DaemonSetNodeMisscheduled is an instrument used to record metric values
2044 // conforming to the "k8s.daemonset.node.misscheduled" semantic conventions. It
2045 // represents the number of nodes that are running the daemon pod, but are not
2046 // supposed to run the daemon pod.
2047 type DaemonSetNodeMisscheduled struct {
2048 metric.Int64UpDownCounter
2049 }
2050
2051 var newDaemonSetNodeMisscheduledOpts = []metric.Int64UpDownCounterOption{
2052 metric.WithDescription("Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod."),
2053 metric.WithUnit("{node}"),
2054 }
2055
2056 // NewDaemonSetNodeMisscheduled returns a new DaemonSetNodeMisscheduled
2057 // instrument.
2058 func NewDaemonSetNodeMisscheduled(
2059 m metric.Meter,
2060 opt ...metric.Int64UpDownCounterOption,
2061 ) (DaemonSetNodeMisscheduled, error) {
2062 // Check if the meter is nil.
2063 if m == nil {
2064 return DaemonSetNodeMisscheduled{noop.Int64UpDownCounter{}}, nil
2065 }
2066
2067 if len(opt) == 0 {
2068 opt = newDaemonSetNodeMisscheduledOpts
2069 } else {
2070 opt = append(opt, newDaemonSetNodeMisscheduledOpts...)
2071 }
2072
2073 i, err := m.Int64UpDownCounter(
2074 "k8s.daemonset.node.misscheduled",
2075 opt...,
2076 )
2077 if err != nil {
2078 return DaemonSetNodeMisscheduled{noop.Int64UpDownCounter{}}, err
2079 }
2080 return DaemonSetNodeMisscheduled{i}, nil
2081 }
2082
2083 // Inst returns the underlying metric instrument.
2084 func (m DaemonSetNodeMisscheduled) Inst() metric.Int64UpDownCounter {
2085 return m.Int64UpDownCounter
2086 }
2087
2088 // Name returns the semantic convention name of the instrument.
2089 func (DaemonSetNodeMisscheduled) Name() string {
2090 return "k8s.daemonset.node.misscheduled"
2091 }
2092
2093 // Unit returns the semantic convention unit of the instrument
2094 func (DaemonSetNodeMisscheduled) Unit() string {
2095 return "{node}"
2096 }
2097
2098 // Description returns the semantic convention description of the instrument
2099 func (DaemonSetNodeMisscheduled) Description() string {
2100 return "Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod."
2101 }
2102
2103 // Add adds incr to the existing count for attrs.
2104 //
2105 // This metric aligns with the `numberMisscheduled` field of the
2106 // [K8s DaemonSetStatus].
2107 //
2108 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
2109 func (m DaemonSetNodeMisscheduled) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2110 if len(attrs) == 0 {
2111 m.Int64UpDownCounter.Add(ctx, incr)
2112 return
2113 }
2114
2115 o := addOptPool.Get().(*[]metric.AddOption)
2116 defer func() {
2117 *o = (*o)[:0]
2118 addOptPool.Put(o)
2119 }()
2120
2121 *o = append(*o, metric.WithAttributes(attrs...))
2122 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2123 }
2124
2125 // AddSet adds incr to the existing count for set.
2126 //
2127 // This metric aligns with the `numberMisscheduled` field of the
2128 // [K8s DaemonSetStatus].
2129 //
2130 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
2131 func (m DaemonSetNodeMisscheduled) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2132 if set.Len() == 0 {
2133 m.Int64UpDownCounter.Add(ctx, incr)
2134 return
2135 }
2136
2137 o := addOptPool.Get().(*[]metric.AddOption)
2138 defer func() {
2139 *o = (*o)[:0]
2140 addOptPool.Put(o)
2141 }()
2142
2143 *o = append(*o, metric.WithAttributeSet(set))
2144 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2145 }
2146
2147 // DaemonSetNodeReady is an instrument used to record metric values conforming to
2148 // the "k8s.daemonset.node.ready" semantic conventions. It represents the number
2149 // of nodes that should be running the daemon pod and have one or more of the
2150 // daemon pod running and ready.
2151 type DaemonSetNodeReady struct {
2152 metric.Int64UpDownCounter
2153 }
2154
2155 var newDaemonSetNodeReadyOpts = []metric.Int64UpDownCounterOption{
2156 metric.WithDescription("Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready."),
2157 metric.WithUnit("{node}"),
2158 }
2159
2160 // NewDaemonSetNodeReady returns a new DaemonSetNodeReady instrument.
2161 func NewDaemonSetNodeReady(
2162 m metric.Meter,
2163 opt ...metric.Int64UpDownCounterOption,
2164 ) (DaemonSetNodeReady, error) {
2165 // Check if the meter is nil.
2166 if m == nil {
2167 return DaemonSetNodeReady{noop.Int64UpDownCounter{}}, nil
2168 }
2169
2170 if len(opt) == 0 {
2171 opt = newDaemonSetNodeReadyOpts
2172 } else {
2173 opt = append(opt, newDaemonSetNodeReadyOpts...)
2174 }
2175
2176 i, err := m.Int64UpDownCounter(
2177 "k8s.daemonset.node.ready",
2178 opt...,
2179 )
2180 if err != nil {
2181 return DaemonSetNodeReady{noop.Int64UpDownCounter{}}, err
2182 }
2183 return DaemonSetNodeReady{i}, nil
2184 }
2185
2186 // Inst returns the underlying metric instrument.
2187 func (m DaemonSetNodeReady) Inst() metric.Int64UpDownCounter {
2188 return m.Int64UpDownCounter
2189 }
2190
2191 // Name returns the semantic convention name of the instrument.
2192 func (DaemonSetNodeReady) Name() string {
2193 return "k8s.daemonset.node.ready"
2194 }
2195
2196 // Unit returns the semantic convention unit of the instrument
2197 func (DaemonSetNodeReady) Unit() string {
2198 return "{node}"
2199 }
2200
2201 // Description returns the semantic convention description of the instrument
2202 func (DaemonSetNodeReady) Description() string {
2203 return "Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready."
2204 }
2205
2206 // Add adds incr to the existing count for attrs.
2207 //
2208 // This metric aligns with the `numberReady` field of the
2209 // [K8s DaemonSetStatus].
2210 //
2211 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
2212 func (m DaemonSetNodeReady) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2213 if len(attrs) == 0 {
2214 m.Int64UpDownCounter.Add(ctx, incr)
2215 return
2216 }
2217
2218 o := addOptPool.Get().(*[]metric.AddOption)
2219 defer func() {
2220 *o = (*o)[:0]
2221 addOptPool.Put(o)
2222 }()
2223
2224 *o = append(*o, metric.WithAttributes(attrs...))
2225 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2226 }
2227
2228 // AddSet adds incr to the existing count for set.
2229 //
2230 // This metric aligns with the `numberReady` field of the
2231 // [K8s DaemonSetStatus].
2232 //
2233 // [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps
2234 func (m DaemonSetNodeReady) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2235 if set.Len() == 0 {
2236 m.Int64UpDownCounter.Add(ctx, incr)
2237 return
2238 }
2239
2240 o := addOptPool.Get().(*[]metric.AddOption)
2241 defer func() {
2242 *o = (*o)[:0]
2243 addOptPool.Put(o)
2244 }()
2245
2246 *o = append(*o, metric.WithAttributeSet(set))
2247 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2248 }
2249
2250 // DeploymentPodAvailable is an instrument used to record metric values
2251 // conforming to the "k8s.deployment.pod.available" semantic conventions. It
2252 // represents the total number of available replica pods (ready for at least
2253 // minReadySeconds) targeted by this deployment.
2254 type DeploymentPodAvailable struct {
2255 metric.Int64UpDownCounter
2256 }
2257
2258 var newDeploymentPodAvailableOpts = []metric.Int64UpDownCounterOption{
2259 metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment."),
2260 metric.WithUnit("{pod}"),
2261 }
2262
2263 // NewDeploymentPodAvailable returns a new DeploymentPodAvailable instrument.
2264 func NewDeploymentPodAvailable(
2265 m metric.Meter,
2266 opt ...metric.Int64UpDownCounterOption,
2267 ) (DeploymentPodAvailable, error) {
2268 // Check if the meter is nil.
2269 if m == nil {
2270 return DeploymentPodAvailable{noop.Int64UpDownCounter{}}, nil
2271 }
2272
2273 if len(opt) == 0 {
2274 opt = newDeploymentPodAvailableOpts
2275 } else {
2276 opt = append(opt, newDeploymentPodAvailableOpts...)
2277 }
2278
2279 i, err := m.Int64UpDownCounter(
2280 "k8s.deployment.pod.available",
2281 opt...,
2282 )
2283 if err != nil {
2284 return DeploymentPodAvailable{noop.Int64UpDownCounter{}}, err
2285 }
2286 return DeploymentPodAvailable{i}, nil
2287 }
2288
2289 // Inst returns the underlying metric instrument.
2290 func (m DeploymentPodAvailable) Inst() metric.Int64UpDownCounter {
2291 return m.Int64UpDownCounter
2292 }
2293
2294 // Name returns the semantic convention name of the instrument.
2295 func (DeploymentPodAvailable) Name() string {
2296 return "k8s.deployment.pod.available"
2297 }
2298
2299 // Unit returns the semantic convention unit of the instrument
2300 func (DeploymentPodAvailable) Unit() string {
2301 return "{pod}"
2302 }
2303
2304 // Description returns the semantic convention description of the instrument
2305 func (DeploymentPodAvailable) Description() string {
2306 return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment."
2307 }
2308
2309 // Add adds incr to the existing count for attrs.
2310 //
2311 // This metric aligns with the `availableReplicas` field of the
2312 // [K8s DeploymentStatus].
2313 //
2314 // [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps
2315 func (m DeploymentPodAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2316 if len(attrs) == 0 {
2317 m.Int64UpDownCounter.Add(ctx, incr)
2318 return
2319 }
2320
2321 o := addOptPool.Get().(*[]metric.AddOption)
2322 defer func() {
2323 *o = (*o)[:0]
2324 addOptPool.Put(o)
2325 }()
2326
2327 *o = append(*o, metric.WithAttributes(attrs...))
2328 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2329 }
2330
2331 // AddSet adds incr to the existing count for set.
2332 //
2333 // This metric aligns with the `availableReplicas` field of the
2334 // [K8s DeploymentStatus].
2335 //
2336 // [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps
2337 func (m DeploymentPodAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2338 if set.Len() == 0 {
2339 m.Int64UpDownCounter.Add(ctx, incr)
2340 return
2341 }
2342
2343 o := addOptPool.Get().(*[]metric.AddOption)
2344 defer func() {
2345 *o = (*o)[:0]
2346 addOptPool.Put(o)
2347 }()
2348
2349 *o = append(*o, metric.WithAttributeSet(set))
2350 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2351 }
2352
2353 // DeploymentPodDesired is an instrument used to record metric values conforming
2354 // to the "k8s.deployment.pod.desired" semantic conventions. It represents the
2355 // number of desired replica pods in this deployment.
2356 type DeploymentPodDesired struct {
2357 metric.Int64UpDownCounter
2358 }
2359
2360 var newDeploymentPodDesiredOpts = []metric.Int64UpDownCounterOption{
2361 metric.WithDescription("Number of desired replica pods in this deployment."),
2362 metric.WithUnit("{pod}"),
2363 }
2364
2365 // NewDeploymentPodDesired returns a new DeploymentPodDesired instrument.
2366 func NewDeploymentPodDesired(
2367 m metric.Meter,
2368 opt ...metric.Int64UpDownCounterOption,
2369 ) (DeploymentPodDesired, error) {
2370 // Check if the meter is nil.
2371 if m == nil {
2372 return DeploymentPodDesired{noop.Int64UpDownCounter{}}, nil
2373 }
2374
2375 if len(opt) == 0 {
2376 opt = newDeploymentPodDesiredOpts
2377 } else {
2378 opt = append(opt, newDeploymentPodDesiredOpts...)
2379 }
2380
2381 i, err := m.Int64UpDownCounter(
2382 "k8s.deployment.pod.desired",
2383 opt...,
2384 )
2385 if err != nil {
2386 return DeploymentPodDesired{noop.Int64UpDownCounter{}}, err
2387 }
2388 return DeploymentPodDesired{i}, nil
2389 }
2390
2391 // Inst returns the underlying metric instrument.
2392 func (m DeploymentPodDesired) Inst() metric.Int64UpDownCounter {
2393 return m.Int64UpDownCounter
2394 }
2395
2396 // Name returns the semantic convention name of the instrument.
2397 func (DeploymentPodDesired) Name() string {
2398 return "k8s.deployment.pod.desired"
2399 }
2400
2401 // Unit returns the semantic convention unit of the instrument
2402 func (DeploymentPodDesired) Unit() string {
2403 return "{pod}"
2404 }
2405
2406 // Description returns the semantic convention description of the instrument
2407 func (DeploymentPodDesired) Description() string {
2408 return "Number of desired replica pods in this deployment."
2409 }
2410
2411 // Add adds incr to the existing count for attrs.
2412 //
2413 // This metric aligns with the `replicas` field of the
2414 // [K8s DeploymentSpec].
2415 //
2416 // [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps
2417 func (m DeploymentPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2418 if len(attrs) == 0 {
2419 m.Int64UpDownCounter.Add(ctx, incr)
2420 return
2421 }
2422
2423 o := addOptPool.Get().(*[]metric.AddOption)
2424 defer func() {
2425 *o = (*o)[:0]
2426 addOptPool.Put(o)
2427 }()
2428
2429 *o = append(*o, metric.WithAttributes(attrs...))
2430 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2431 }
2432
2433 // AddSet adds incr to the existing count for set.
2434 //
2435 // This metric aligns with the `replicas` field of the
2436 // [K8s DeploymentSpec].
2437 //
2438 // [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps
2439 func (m DeploymentPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2440 if set.Len() == 0 {
2441 m.Int64UpDownCounter.Add(ctx, incr)
2442 return
2443 }
2444
2445 o := addOptPool.Get().(*[]metric.AddOption)
2446 defer func() {
2447 *o = (*o)[:0]
2448 addOptPool.Put(o)
2449 }()
2450
2451 *o = append(*o, metric.WithAttributeSet(set))
2452 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2453 }
2454
2455 // HPAMetricTargetCPUAverageUtilization is an instrument used to record metric
2456 // values conforming to the "k8s.hpa.metric.target.cpu.average_utilization"
2457 // semantic conventions. It represents the target average utilization, in
2458 // percentage, for CPU resource in HPA config.
2459 type HPAMetricTargetCPUAverageUtilization struct {
2460 metric.Int64Gauge
2461 }
2462
2463 var newHPAMetricTargetCPUAverageUtilizationOpts = []metric.Int64GaugeOption{
2464 metric.WithDescription("Target average utilization, in percentage, for CPU resource in HPA config."),
2465 metric.WithUnit("1"),
2466 }
2467
2468 // NewHPAMetricTargetCPUAverageUtilization returns a new
2469 // HPAMetricTargetCPUAverageUtilization instrument.
2470 func NewHPAMetricTargetCPUAverageUtilization(
2471 m metric.Meter,
2472 opt ...metric.Int64GaugeOption,
2473 ) (HPAMetricTargetCPUAverageUtilization, error) {
2474 // Check if the meter is nil.
2475 if m == nil {
2476 return HPAMetricTargetCPUAverageUtilization{noop.Int64Gauge{}}, nil
2477 }
2478
2479 if len(opt) == 0 {
2480 opt = newHPAMetricTargetCPUAverageUtilizationOpts
2481 } else {
2482 opt = append(opt, newHPAMetricTargetCPUAverageUtilizationOpts...)
2483 }
2484
2485 i, err := m.Int64Gauge(
2486 "k8s.hpa.metric.target.cpu.average_utilization",
2487 opt...,
2488 )
2489 if err != nil {
2490 return HPAMetricTargetCPUAverageUtilization{noop.Int64Gauge{}}, err
2491 }
2492 return HPAMetricTargetCPUAverageUtilization{i}, nil
2493 }
2494
2495 // Inst returns the underlying metric instrument.
2496 func (m HPAMetricTargetCPUAverageUtilization) Inst() metric.Int64Gauge {
2497 return m.Int64Gauge
2498 }
2499
2500 // Name returns the semantic convention name of the instrument.
2501 func (HPAMetricTargetCPUAverageUtilization) Name() string {
2502 return "k8s.hpa.metric.target.cpu.average_utilization"
2503 }
2504
2505 // Unit returns the semantic convention unit of the instrument
2506 func (HPAMetricTargetCPUAverageUtilization) Unit() string {
2507 return "1"
2508 }
2509
2510 // Description returns the semantic convention description of the instrument
2511 func (HPAMetricTargetCPUAverageUtilization) Description() string {
2512 return "Target average utilization, in percentage, for CPU resource in HPA config."
2513 }
2514
2515 // Record records val to the current distribution for attrs.
2516 //
2517 // All additional attrs passed are included in the recorded value.
2518 //
2519 // This metric aligns with the `averageUtilization` field of the
2520 // [K8s HPA MetricTarget].
2521 // If the type of the metric is [`ContainerResource`],
2522 // the `k8s.container.name` attribute MUST be set to identify the specific
2523 // container within the pod to which the metric applies.
2524 //
2525 // [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling
2526 // [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis
2527 func (m HPAMetricTargetCPUAverageUtilization) Record(
2528 ctx context.Context,
2529 val int64,
2530 attrs ...attribute.KeyValue,
2531 ) {
2532 if len(attrs) == 0 {
2533 m.Int64Gauge.Record(ctx, val)
2534 return
2535 }
2536
2537 o := recOptPool.Get().(*[]metric.RecordOption)
2538 defer func() {
2539 *o = (*o)[:0]
2540 recOptPool.Put(o)
2541 }()
2542
2543 *o = append(
2544 *o,
2545 metric.WithAttributes(
2546 attrs...,
2547 ),
2548 )
2549
2550 m.Int64Gauge.Record(ctx, val, *o...)
2551 }
2552
2553 // RecordSet records val to the current distribution for set.
2554 //
2555 // This metric aligns with the `averageUtilization` field of the
2556 // [K8s HPA MetricTarget].
2557 // If the type of the metric is [`ContainerResource`],
2558 // the `k8s.container.name` attribute MUST be set to identify the specific
2559 // container within the pod to which the metric applies.
2560 //
2561 // [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling
2562 // [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis
2563 func (m HPAMetricTargetCPUAverageUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) {
2564 if set.Len() == 0 {
2565 m.Int64Gauge.Record(ctx, val)
2566 return
2567 }
2568
2569 o := recOptPool.Get().(*[]metric.RecordOption)
2570 defer func() {
2571 *o = (*o)[:0]
2572 recOptPool.Put(o)
2573 }()
2574
2575 *o = append(*o, metric.WithAttributeSet(set))
2576 m.Int64Gauge.Record(ctx, val, *o...)
2577 }
2578
2579 // AttrContainerName returns an optional attribute for the "k8s.container.name"
2580 // semantic convention. It represents the name of the Container from Pod
2581 // specification, must be unique within a Pod. Container runtime usually uses
2582 // different globally unique name (`container.name`).
2583 func (HPAMetricTargetCPUAverageUtilization) AttrContainerName(val string) attribute.KeyValue {
2584 return attribute.String("k8s.container.name", val)
2585 }
2586
2587 // AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type"
2588 // semantic convention. It represents the type of metric source for the
2589 // horizontal pod autoscaler.
2590 func (HPAMetricTargetCPUAverageUtilization) AttrHPAMetricType(val string) attribute.KeyValue {
2591 return attribute.String("k8s.hpa.metric.type", val)
2592 }
2593
2594 // HPAMetricTargetCPUAverageValue is an instrument used to record metric values
2595 // conforming to the "k8s.hpa.metric.target.cpu.average_value" semantic
2596 // conventions. It represents the target average value for CPU resource in HPA
2597 // config.
2598 type HPAMetricTargetCPUAverageValue struct {
2599 metric.Int64Gauge
2600 }
2601
2602 var newHPAMetricTargetCPUAverageValueOpts = []metric.Int64GaugeOption{
2603 metric.WithDescription("Target average value for CPU resource in HPA config."),
2604 metric.WithUnit("{cpu}"),
2605 }
2606
2607 // NewHPAMetricTargetCPUAverageValue returns a new HPAMetricTargetCPUAverageValue
2608 // instrument.
2609 func NewHPAMetricTargetCPUAverageValue(
2610 m metric.Meter,
2611 opt ...metric.Int64GaugeOption,
2612 ) (HPAMetricTargetCPUAverageValue, error) {
2613 // Check if the meter is nil.
2614 if m == nil {
2615 return HPAMetricTargetCPUAverageValue{noop.Int64Gauge{}}, nil
2616 }
2617
2618 if len(opt) == 0 {
2619 opt = newHPAMetricTargetCPUAverageValueOpts
2620 } else {
2621 opt = append(opt, newHPAMetricTargetCPUAverageValueOpts...)
2622 }
2623
2624 i, err := m.Int64Gauge(
2625 "k8s.hpa.metric.target.cpu.average_value",
2626 opt...,
2627 )
2628 if err != nil {
2629 return HPAMetricTargetCPUAverageValue{noop.Int64Gauge{}}, err
2630 }
2631 return HPAMetricTargetCPUAverageValue{i}, nil
2632 }
2633
2634 // Inst returns the underlying metric instrument.
2635 func (m HPAMetricTargetCPUAverageValue) Inst() metric.Int64Gauge {
2636 return m.Int64Gauge
2637 }
2638
2639 // Name returns the semantic convention name of the instrument.
2640 func (HPAMetricTargetCPUAverageValue) Name() string {
2641 return "k8s.hpa.metric.target.cpu.average_value"
2642 }
2643
2644 // Unit returns the semantic convention unit of the instrument
2645 func (HPAMetricTargetCPUAverageValue) Unit() string {
2646 return "{cpu}"
2647 }
2648
2649 // Description returns the semantic convention description of the instrument
2650 func (HPAMetricTargetCPUAverageValue) Description() string {
2651 return "Target average value for CPU resource in HPA config."
2652 }
2653
2654 // Record records val to the current distribution for attrs.
2655 //
2656 // All additional attrs passed are included in the recorded value.
2657 //
2658 // This metric aligns with the `averageValue` field of the
2659 // [K8s HPA MetricTarget].
2660 // If the type of the metric is [`ContainerResource`],
2661 // the `k8s.container.name` attribute MUST be set to identify the specific
2662 // container within the pod to which the metric applies.
2663 //
2664 // [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling
2665 // [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis
2666 func (m HPAMetricTargetCPUAverageValue) Record(
2667 ctx context.Context,
2668 val int64,
2669 attrs ...attribute.KeyValue,
2670 ) {
2671 if len(attrs) == 0 {
2672 m.Int64Gauge.Record(ctx, val)
2673 return
2674 }
2675
2676 o := recOptPool.Get().(*[]metric.RecordOption)
2677 defer func() {
2678 *o = (*o)[:0]
2679 recOptPool.Put(o)
2680 }()
2681
2682 *o = append(
2683 *o,
2684 metric.WithAttributes(
2685 attrs...,
2686 ),
2687 )
2688
2689 m.Int64Gauge.Record(ctx, val, *o...)
2690 }
2691
2692 // RecordSet records val to the current distribution for set.
2693 //
2694 // This metric aligns with the `averageValue` field of the
2695 // [K8s HPA MetricTarget].
2696 // If the type of the metric is [`ContainerResource`],
2697 // the `k8s.container.name` attribute MUST be set to identify the specific
2698 // container within the pod to which the metric applies.
2699 //
2700 // [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling
2701 // [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis
2702 func (m HPAMetricTargetCPUAverageValue) RecordSet(ctx context.Context, val int64, set attribute.Set) {
2703 if set.Len() == 0 {
2704 m.Int64Gauge.Record(ctx, val)
2705 return
2706 }
2707
2708 o := recOptPool.Get().(*[]metric.RecordOption)
2709 defer func() {
2710 *o = (*o)[:0]
2711 recOptPool.Put(o)
2712 }()
2713
2714 *o = append(*o, metric.WithAttributeSet(set))
2715 m.Int64Gauge.Record(ctx, val, *o...)
2716 }
2717
2718 // AttrContainerName returns an optional attribute for the "k8s.container.name"
2719 // semantic convention. It represents the name of the Container from Pod
2720 // specification, must be unique within a Pod. Container runtime usually uses
2721 // different globally unique name (`container.name`).
2722 func (HPAMetricTargetCPUAverageValue) AttrContainerName(val string) attribute.KeyValue {
2723 return attribute.String("k8s.container.name", val)
2724 }
2725
2726 // AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type"
2727 // semantic convention. It represents the type of metric source for the
2728 // horizontal pod autoscaler.
2729 func (HPAMetricTargetCPUAverageValue) AttrHPAMetricType(val string) attribute.KeyValue {
2730 return attribute.String("k8s.hpa.metric.type", val)
2731 }
2732
2733 // HPAMetricTargetCPUValue is an instrument used to record metric values
2734 // conforming to the "k8s.hpa.metric.target.cpu.value" semantic conventions. It
2735 // represents the target value for CPU resource in HPA config.
2736 type HPAMetricTargetCPUValue struct {
2737 metric.Int64Gauge
2738 }
2739
2740 var newHPAMetricTargetCPUValueOpts = []metric.Int64GaugeOption{
2741 metric.WithDescription("Target value for CPU resource in HPA config."),
2742 metric.WithUnit("{cpu}"),
2743 }
2744
2745 // NewHPAMetricTargetCPUValue returns a new HPAMetricTargetCPUValue instrument.
2746 func NewHPAMetricTargetCPUValue(
2747 m metric.Meter,
2748 opt ...metric.Int64GaugeOption,
2749 ) (HPAMetricTargetCPUValue, error) {
2750 // Check if the meter is nil.
2751 if m == nil {
2752 return HPAMetricTargetCPUValue{noop.Int64Gauge{}}, nil
2753 }
2754
2755 if len(opt) == 0 {
2756 opt = newHPAMetricTargetCPUValueOpts
2757 } else {
2758 opt = append(opt, newHPAMetricTargetCPUValueOpts...)
2759 }
2760
2761 i, err := m.Int64Gauge(
2762 "k8s.hpa.metric.target.cpu.value",
2763 opt...,
2764 )
2765 if err != nil {
2766 return HPAMetricTargetCPUValue{noop.Int64Gauge{}}, err
2767 }
2768 return HPAMetricTargetCPUValue{i}, nil
2769 }
2770
2771 // Inst returns the underlying metric instrument.
2772 func (m HPAMetricTargetCPUValue) Inst() metric.Int64Gauge {
2773 return m.Int64Gauge
2774 }
2775
2776 // Name returns the semantic convention name of the instrument.
2777 func (HPAMetricTargetCPUValue) Name() string {
2778 return "k8s.hpa.metric.target.cpu.value"
2779 }
2780
2781 // Unit returns the semantic convention unit of the instrument
2782 func (HPAMetricTargetCPUValue) Unit() string {
2783 return "{cpu}"
2784 }
2785
2786 // Description returns the semantic convention description of the instrument
2787 func (HPAMetricTargetCPUValue) Description() string {
2788 return "Target value for CPU resource in HPA config."
2789 }
2790
2791 // Record records val to the current distribution for attrs.
2792 //
2793 // All additional attrs passed are included in the recorded value.
2794 //
2795 // This metric aligns with the `value` field of the
2796 // [K8s HPA MetricTarget].
2797 // If the type of the metric is [`ContainerResource`],
2798 // the `k8s.container.name` attribute MUST be set to identify the specific
2799 // container within the pod to which the metric applies.
2800 //
2801 // [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling
2802 // [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis
2803 func (m HPAMetricTargetCPUValue) Record(
2804 ctx context.Context,
2805 val int64,
2806 attrs ...attribute.KeyValue,
2807 ) {
2808 if len(attrs) == 0 {
2809 m.Int64Gauge.Record(ctx, val)
2810 return
2811 }
2812
2813 o := recOptPool.Get().(*[]metric.RecordOption)
2814 defer func() {
2815 *o = (*o)[:0]
2816 recOptPool.Put(o)
2817 }()
2818
2819 *o = append(
2820 *o,
2821 metric.WithAttributes(
2822 attrs...,
2823 ),
2824 )
2825
2826 m.Int64Gauge.Record(ctx, val, *o...)
2827 }
2828
2829 // RecordSet records val to the current distribution for set.
2830 //
2831 // This metric aligns with the `value` field of the
2832 // [K8s HPA MetricTarget].
2833 // If the type of the metric is [`ContainerResource`],
2834 // the `k8s.container.name` attribute MUST be set to identify the specific
2835 // container within the pod to which the metric applies.
2836 //
2837 // [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling
2838 // [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis
2839 func (m HPAMetricTargetCPUValue) RecordSet(ctx context.Context, val int64, set attribute.Set) {
2840 if set.Len() == 0 {
2841 m.Int64Gauge.Record(ctx, val)
2842 return
2843 }
2844
2845 o := recOptPool.Get().(*[]metric.RecordOption)
2846 defer func() {
2847 *o = (*o)[:0]
2848 recOptPool.Put(o)
2849 }()
2850
2851 *o = append(*o, metric.WithAttributeSet(set))
2852 m.Int64Gauge.Record(ctx, val, *o...)
2853 }
2854
2855 // AttrContainerName returns an optional attribute for the "k8s.container.name"
2856 // semantic convention. It represents the name of the Container from Pod
2857 // specification, must be unique within a Pod. Container runtime usually uses
2858 // different globally unique name (`container.name`).
2859 func (HPAMetricTargetCPUValue) AttrContainerName(val string) attribute.KeyValue {
2860 return attribute.String("k8s.container.name", val)
2861 }
2862
2863 // AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type"
2864 // semantic convention. It represents the type of metric source for the
2865 // horizontal pod autoscaler.
2866 func (HPAMetricTargetCPUValue) AttrHPAMetricType(val string) attribute.KeyValue {
2867 return attribute.String("k8s.hpa.metric.type", val)
2868 }
2869
2870 // HPAPodCurrent is an instrument used to record metric values conforming to the
2871 // "k8s.hpa.pod.current" semantic conventions. It represents the current number
2872 // of replica pods managed by this horizontal pod autoscaler, as last seen by the
2873 // autoscaler.
2874 type HPAPodCurrent struct {
2875 metric.Int64UpDownCounter
2876 }
2877
2878 var newHPAPodCurrentOpts = []metric.Int64UpDownCounterOption{
2879 metric.WithDescription("Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler."),
2880 metric.WithUnit("{pod}"),
2881 }
2882
2883 // NewHPAPodCurrent returns a new HPAPodCurrent instrument.
2884 func NewHPAPodCurrent(
2885 m metric.Meter,
2886 opt ...metric.Int64UpDownCounterOption,
2887 ) (HPAPodCurrent, error) {
2888 // Check if the meter is nil.
2889 if m == nil {
2890 return HPAPodCurrent{noop.Int64UpDownCounter{}}, nil
2891 }
2892
2893 if len(opt) == 0 {
2894 opt = newHPAPodCurrentOpts
2895 } else {
2896 opt = append(opt, newHPAPodCurrentOpts...)
2897 }
2898
2899 i, err := m.Int64UpDownCounter(
2900 "k8s.hpa.pod.current",
2901 opt...,
2902 )
2903 if err != nil {
2904 return HPAPodCurrent{noop.Int64UpDownCounter{}}, err
2905 }
2906 return HPAPodCurrent{i}, nil
2907 }
2908
2909 // Inst returns the underlying metric instrument.
2910 func (m HPAPodCurrent) Inst() metric.Int64UpDownCounter {
2911 return m.Int64UpDownCounter
2912 }
2913
2914 // Name returns the semantic convention name of the instrument.
2915 func (HPAPodCurrent) Name() string {
2916 return "k8s.hpa.pod.current"
2917 }
2918
2919 // Unit returns the semantic convention unit of the instrument
2920 func (HPAPodCurrent) Unit() string {
2921 return "{pod}"
2922 }
2923
2924 // Description returns the semantic convention description of the instrument
2925 func (HPAPodCurrent) Description() string {
2926 return "Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler."
2927 }
2928
2929 // Add adds incr to the existing count for attrs.
2930 //
2931 // This metric aligns with the `currentReplicas` field of the
2932 // [K8s HorizontalPodAutoscalerStatus]
2933 //
2934 // [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling
2935 func (m HPAPodCurrent) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2936 if len(attrs) == 0 {
2937 m.Int64UpDownCounter.Add(ctx, incr)
2938 return
2939 }
2940
2941 o := addOptPool.Get().(*[]metric.AddOption)
2942 defer func() {
2943 *o = (*o)[:0]
2944 addOptPool.Put(o)
2945 }()
2946
2947 *o = append(*o, metric.WithAttributes(attrs...))
2948 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2949 }
2950
2951 // AddSet adds incr to the existing count for set.
2952 //
2953 // This metric aligns with the `currentReplicas` field of the
2954 // [K8s HorizontalPodAutoscalerStatus]
2955 //
2956 // [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling
2957 func (m HPAPodCurrent) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2958 if set.Len() == 0 {
2959 m.Int64UpDownCounter.Add(ctx, incr)
2960 return
2961 }
2962
2963 o := addOptPool.Get().(*[]metric.AddOption)
2964 defer func() {
2965 *o = (*o)[:0]
2966 addOptPool.Put(o)
2967 }()
2968
2969 *o = append(*o, metric.WithAttributeSet(set))
2970 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2971 }
2972
2973 // HPAPodDesired is an instrument used to record metric values conforming to the
2974 // "k8s.hpa.pod.desired" semantic conventions. It represents the desired number
2975 // of replica pods managed by this horizontal pod autoscaler, as last calculated
2976 // by the autoscaler.
2977 type HPAPodDesired struct {
2978 metric.Int64UpDownCounter
2979 }
2980
2981 var newHPAPodDesiredOpts = []metric.Int64UpDownCounterOption{
2982 metric.WithDescription("Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler."),
2983 metric.WithUnit("{pod}"),
2984 }
2985
2986 // NewHPAPodDesired returns a new HPAPodDesired instrument.
2987 func NewHPAPodDesired(
2988 m metric.Meter,
2989 opt ...metric.Int64UpDownCounterOption,
2990 ) (HPAPodDesired, error) {
2991 // Check if the meter is nil.
2992 if m == nil {
2993 return HPAPodDesired{noop.Int64UpDownCounter{}}, nil
2994 }
2995
2996 if len(opt) == 0 {
2997 opt = newHPAPodDesiredOpts
2998 } else {
2999 opt = append(opt, newHPAPodDesiredOpts...)
3000 }
3001
3002 i, err := m.Int64UpDownCounter(
3003 "k8s.hpa.pod.desired",
3004 opt...,
3005 )
3006 if err != nil {
3007 return HPAPodDesired{noop.Int64UpDownCounter{}}, err
3008 }
3009 return HPAPodDesired{i}, nil
3010 }
3011
3012 // Inst returns the underlying metric instrument.
3013 func (m HPAPodDesired) Inst() metric.Int64UpDownCounter {
3014 return m.Int64UpDownCounter
3015 }
3016
3017 // Name returns the semantic convention name of the instrument.
3018 func (HPAPodDesired) Name() string {
3019 return "k8s.hpa.pod.desired"
3020 }
3021
3022 // Unit returns the semantic convention unit of the instrument
3023 func (HPAPodDesired) Unit() string {
3024 return "{pod}"
3025 }
3026
3027 // Description returns the semantic convention description of the instrument
3028 func (HPAPodDesired) Description() string {
3029 return "Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler."
3030 }
3031
3032 // Add adds incr to the existing count for attrs.
3033 //
3034 // This metric aligns with the `desiredReplicas` field of the
3035 // [K8s HorizontalPodAutoscalerStatus]
3036 //
3037 // [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling
3038 func (m HPAPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3039 if len(attrs) == 0 {
3040 m.Int64UpDownCounter.Add(ctx, incr)
3041 return
3042 }
3043
3044 o := addOptPool.Get().(*[]metric.AddOption)
3045 defer func() {
3046 *o = (*o)[:0]
3047 addOptPool.Put(o)
3048 }()
3049
3050 *o = append(*o, metric.WithAttributes(attrs...))
3051 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3052 }
3053
3054 // AddSet adds incr to the existing count for set.
3055 //
3056 // This metric aligns with the `desiredReplicas` field of the
3057 // [K8s HorizontalPodAutoscalerStatus]
3058 //
3059 // [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling
3060 func (m HPAPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3061 if set.Len() == 0 {
3062 m.Int64UpDownCounter.Add(ctx, incr)
3063 return
3064 }
3065
3066 o := addOptPool.Get().(*[]metric.AddOption)
3067 defer func() {
3068 *o = (*o)[:0]
3069 addOptPool.Put(o)
3070 }()
3071
3072 *o = append(*o, metric.WithAttributeSet(set))
3073 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3074 }
3075
3076 // HPAPodMax is an instrument used to record metric values conforming to the
3077 // "k8s.hpa.pod.max" semantic conventions. It represents the upper limit for the
3078 // number of replica pods to which the autoscaler can scale up.
3079 type HPAPodMax struct {
3080 metric.Int64UpDownCounter
3081 }
3082
3083 var newHPAPodMaxOpts = []metric.Int64UpDownCounterOption{
3084 metric.WithDescription("The upper limit for the number of replica pods to which the autoscaler can scale up."),
3085 metric.WithUnit("{pod}"),
3086 }
3087
3088 // NewHPAPodMax returns a new HPAPodMax instrument.
3089 func NewHPAPodMax(
3090 m metric.Meter,
3091 opt ...metric.Int64UpDownCounterOption,
3092 ) (HPAPodMax, error) {
3093 // Check if the meter is nil.
3094 if m == nil {
3095 return HPAPodMax{noop.Int64UpDownCounter{}}, nil
3096 }
3097
3098 if len(opt) == 0 {
3099 opt = newHPAPodMaxOpts
3100 } else {
3101 opt = append(opt, newHPAPodMaxOpts...)
3102 }
3103
3104 i, err := m.Int64UpDownCounter(
3105 "k8s.hpa.pod.max",
3106 opt...,
3107 )
3108 if err != nil {
3109 return HPAPodMax{noop.Int64UpDownCounter{}}, err
3110 }
3111 return HPAPodMax{i}, nil
3112 }
3113
3114 // Inst returns the underlying metric instrument.
3115 func (m HPAPodMax) Inst() metric.Int64UpDownCounter {
3116 return m.Int64UpDownCounter
3117 }
3118
3119 // Name returns the semantic convention name of the instrument.
3120 func (HPAPodMax) Name() string {
3121 return "k8s.hpa.pod.max"
3122 }
3123
3124 // Unit returns the semantic convention unit of the instrument
3125 func (HPAPodMax) Unit() string {
3126 return "{pod}"
3127 }
3128
3129 // Description returns the semantic convention description of the instrument
3130 func (HPAPodMax) Description() string {
3131 return "The upper limit for the number of replica pods to which the autoscaler can scale up."
3132 }
3133
3134 // Add adds incr to the existing count for attrs.
3135 //
3136 // This metric aligns with the `maxReplicas` field of the
3137 // [K8s HorizontalPodAutoscalerSpec]
3138 //
3139 // [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling
3140 func (m HPAPodMax) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3141 if len(attrs) == 0 {
3142 m.Int64UpDownCounter.Add(ctx, incr)
3143 return
3144 }
3145
3146 o := addOptPool.Get().(*[]metric.AddOption)
3147 defer func() {
3148 *o = (*o)[:0]
3149 addOptPool.Put(o)
3150 }()
3151
3152 *o = append(*o, metric.WithAttributes(attrs...))
3153 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3154 }
3155
3156 // AddSet adds incr to the existing count for set.
3157 //
3158 // This metric aligns with the `maxReplicas` field of the
3159 // [K8s HorizontalPodAutoscalerSpec]
3160 //
3161 // [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling
3162 func (m HPAPodMax) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3163 if set.Len() == 0 {
3164 m.Int64UpDownCounter.Add(ctx, incr)
3165 return
3166 }
3167
3168 o := addOptPool.Get().(*[]metric.AddOption)
3169 defer func() {
3170 *o = (*o)[:0]
3171 addOptPool.Put(o)
3172 }()
3173
3174 *o = append(*o, metric.WithAttributeSet(set))
3175 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3176 }
3177
3178 // HPAPodMin is an instrument used to record metric values conforming to the
3179 // "k8s.hpa.pod.min" semantic conventions. It represents the lower limit for the
3180 // number of replica pods to which the autoscaler can scale down.
3181 type HPAPodMin struct {
3182 metric.Int64UpDownCounter
3183 }
3184
3185 var newHPAPodMinOpts = []metric.Int64UpDownCounterOption{
3186 metric.WithDescription("The lower limit for the number of replica pods to which the autoscaler can scale down."),
3187 metric.WithUnit("{pod}"),
3188 }
3189
3190 // NewHPAPodMin returns a new HPAPodMin instrument.
3191 func NewHPAPodMin(
3192 m metric.Meter,
3193 opt ...metric.Int64UpDownCounterOption,
3194 ) (HPAPodMin, error) {
3195 // Check if the meter is nil.
3196 if m == nil {
3197 return HPAPodMin{noop.Int64UpDownCounter{}}, nil
3198 }
3199
3200 if len(opt) == 0 {
3201 opt = newHPAPodMinOpts
3202 } else {
3203 opt = append(opt, newHPAPodMinOpts...)
3204 }
3205
3206 i, err := m.Int64UpDownCounter(
3207 "k8s.hpa.pod.min",
3208 opt...,
3209 )
3210 if err != nil {
3211 return HPAPodMin{noop.Int64UpDownCounter{}}, err
3212 }
3213 return HPAPodMin{i}, nil
3214 }
3215
3216 // Inst returns the underlying metric instrument.
3217 func (m HPAPodMin) Inst() metric.Int64UpDownCounter {
3218 return m.Int64UpDownCounter
3219 }
3220
3221 // Name returns the semantic convention name of the instrument.
3222 func (HPAPodMin) Name() string {
3223 return "k8s.hpa.pod.min"
3224 }
3225
3226 // Unit returns the semantic convention unit of the instrument
3227 func (HPAPodMin) Unit() string {
3228 return "{pod}"
3229 }
3230
3231 // Description returns the semantic convention description of the instrument
3232 func (HPAPodMin) Description() string {
3233 return "The lower limit for the number of replica pods to which the autoscaler can scale down."
3234 }
3235
3236 // Add adds incr to the existing count for attrs.
3237 //
3238 // This metric aligns with the `minReplicas` field of the
3239 // [K8s HorizontalPodAutoscalerSpec]
3240 //
3241 // [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling
3242 func (m HPAPodMin) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3243 if len(attrs) == 0 {
3244 m.Int64UpDownCounter.Add(ctx, incr)
3245 return
3246 }
3247
3248 o := addOptPool.Get().(*[]metric.AddOption)
3249 defer func() {
3250 *o = (*o)[:0]
3251 addOptPool.Put(o)
3252 }()
3253
3254 *o = append(*o, metric.WithAttributes(attrs...))
3255 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3256 }
3257
3258 // AddSet adds incr to the existing count for set.
3259 //
3260 // This metric aligns with the `minReplicas` field of the
3261 // [K8s HorizontalPodAutoscalerSpec]
3262 //
3263 // [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling
3264 func (m HPAPodMin) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3265 if set.Len() == 0 {
3266 m.Int64UpDownCounter.Add(ctx, incr)
3267 return
3268 }
3269
3270 o := addOptPool.Get().(*[]metric.AddOption)
3271 defer func() {
3272 *o = (*o)[:0]
3273 addOptPool.Put(o)
3274 }()
3275
3276 *o = append(*o, metric.WithAttributeSet(set))
3277 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3278 }
3279
3280 // JobPodActive is an instrument used to record metric values conforming to the
3281 // "k8s.job.pod.active" semantic conventions. It represents the number of pending
3282 // and actively running pods for a job.
3283 type JobPodActive struct {
3284 metric.Int64UpDownCounter
3285 }
3286
3287 var newJobPodActiveOpts = []metric.Int64UpDownCounterOption{
3288 metric.WithDescription("The number of pending and actively running pods for a job."),
3289 metric.WithUnit("{pod}"),
3290 }
3291
3292 // NewJobPodActive returns a new JobPodActive instrument.
3293 func NewJobPodActive(
3294 m metric.Meter,
3295 opt ...metric.Int64UpDownCounterOption,
3296 ) (JobPodActive, error) {
3297 // Check if the meter is nil.
3298 if m == nil {
3299 return JobPodActive{noop.Int64UpDownCounter{}}, nil
3300 }
3301
3302 if len(opt) == 0 {
3303 opt = newJobPodActiveOpts
3304 } else {
3305 opt = append(opt, newJobPodActiveOpts...)
3306 }
3307
3308 i, err := m.Int64UpDownCounter(
3309 "k8s.job.pod.active",
3310 opt...,
3311 )
3312 if err != nil {
3313 return JobPodActive{noop.Int64UpDownCounter{}}, err
3314 }
3315 return JobPodActive{i}, nil
3316 }
3317
3318 // Inst returns the underlying metric instrument.
3319 func (m JobPodActive) Inst() metric.Int64UpDownCounter {
3320 return m.Int64UpDownCounter
3321 }
3322
3323 // Name returns the semantic convention name of the instrument.
3324 func (JobPodActive) Name() string {
3325 return "k8s.job.pod.active"
3326 }
3327
3328 // Unit returns the semantic convention unit of the instrument
3329 func (JobPodActive) Unit() string {
3330 return "{pod}"
3331 }
3332
3333 // Description returns the semantic convention description of the instrument
3334 func (JobPodActive) Description() string {
3335 return "The number of pending and actively running pods for a job."
3336 }
3337
3338 // Add adds incr to the existing count for attrs.
3339 //
3340 // This metric aligns with the `active` field of the
3341 // [K8s JobStatus].
3342 //
3343 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
3344 func (m JobPodActive) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3345 if len(attrs) == 0 {
3346 m.Int64UpDownCounter.Add(ctx, incr)
3347 return
3348 }
3349
3350 o := addOptPool.Get().(*[]metric.AddOption)
3351 defer func() {
3352 *o = (*o)[:0]
3353 addOptPool.Put(o)
3354 }()
3355
3356 *o = append(*o, metric.WithAttributes(attrs...))
3357 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3358 }
3359
3360 // AddSet adds incr to the existing count for set.
3361 //
3362 // This metric aligns with the `active` field of the
3363 // [K8s JobStatus].
3364 //
3365 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
3366 func (m JobPodActive) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3367 if set.Len() == 0 {
3368 m.Int64UpDownCounter.Add(ctx, incr)
3369 return
3370 }
3371
3372 o := addOptPool.Get().(*[]metric.AddOption)
3373 defer func() {
3374 *o = (*o)[:0]
3375 addOptPool.Put(o)
3376 }()
3377
3378 *o = append(*o, metric.WithAttributeSet(set))
3379 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3380 }
3381
3382 // JobPodDesiredSuccessful is an instrument used to record metric values
3383 // conforming to the "k8s.job.pod.desired_successful" semantic conventions. It
3384 // represents the desired number of successfully finished pods the job should be
3385 // run with.
3386 type JobPodDesiredSuccessful struct {
3387 metric.Int64UpDownCounter
3388 }
3389
3390 var newJobPodDesiredSuccessfulOpts = []metric.Int64UpDownCounterOption{
3391 metric.WithDescription("The desired number of successfully finished pods the job should be run with."),
3392 metric.WithUnit("{pod}"),
3393 }
3394
3395 // NewJobPodDesiredSuccessful returns a new JobPodDesiredSuccessful instrument.
3396 func NewJobPodDesiredSuccessful(
3397 m metric.Meter,
3398 opt ...metric.Int64UpDownCounterOption,
3399 ) (JobPodDesiredSuccessful, error) {
3400 // Check if the meter is nil.
3401 if m == nil {
3402 return JobPodDesiredSuccessful{noop.Int64UpDownCounter{}}, nil
3403 }
3404
3405 if len(opt) == 0 {
3406 opt = newJobPodDesiredSuccessfulOpts
3407 } else {
3408 opt = append(opt, newJobPodDesiredSuccessfulOpts...)
3409 }
3410
3411 i, err := m.Int64UpDownCounter(
3412 "k8s.job.pod.desired_successful",
3413 opt...,
3414 )
3415 if err != nil {
3416 return JobPodDesiredSuccessful{noop.Int64UpDownCounter{}}, err
3417 }
3418 return JobPodDesiredSuccessful{i}, nil
3419 }
3420
3421 // Inst returns the underlying metric instrument.
3422 func (m JobPodDesiredSuccessful) Inst() metric.Int64UpDownCounter {
3423 return m.Int64UpDownCounter
3424 }
3425
3426 // Name returns the semantic convention name of the instrument.
3427 func (JobPodDesiredSuccessful) Name() string {
3428 return "k8s.job.pod.desired_successful"
3429 }
3430
3431 // Unit returns the semantic convention unit of the instrument
3432 func (JobPodDesiredSuccessful) Unit() string {
3433 return "{pod}"
3434 }
3435
3436 // Description returns the semantic convention description of the instrument
3437 func (JobPodDesiredSuccessful) Description() string {
3438 return "The desired number of successfully finished pods the job should be run with."
3439 }
3440
3441 // Add adds incr to the existing count for attrs.
3442 //
3443 // This metric aligns with the `completions` field of the
3444 // [K8s JobSpec]..
3445 //
3446 // [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
3447 func (m JobPodDesiredSuccessful) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3448 if len(attrs) == 0 {
3449 m.Int64UpDownCounter.Add(ctx, incr)
3450 return
3451 }
3452
3453 o := addOptPool.Get().(*[]metric.AddOption)
3454 defer func() {
3455 *o = (*o)[:0]
3456 addOptPool.Put(o)
3457 }()
3458
3459 *o = append(*o, metric.WithAttributes(attrs...))
3460 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3461 }
3462
3463 // AddSet adds incr to the existing count for set.
3464 //
3465 // This metric aligns with the `completions` field of the
3466 // [K8s JobSpec]..
3467 //
3468 // [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
3469 func (m JobPodDesiredSuccessful) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3470 if set.Len() == 0 {
3471 m.Int64UpDownCounter.Add(ctx, incr)
3472 return
3473 }
3474
3475 o := addOptPool.Get().(*[]metric.AddOption)
3476 defer func() {
3477 *o = (*o)[:0]
3478 addOptPool.Put(o)
3479 }()
3480
3481 *o = append(*o, metric.WithAttributeSet(set))
3482 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3483 }
3484
3485 // JobPodFailed is an instrument used to record metric values conforming to the
3486 // "k8s.job.pod.failed" semantic conventions. It represents the number of pods
3487 // which reached phase Failed for a job.
3488 type JobPodFailed struct {
3489 metric.Int64UpDownCounter
3490 }
3491
3492 var newJobPodFailedOpts = []metric.Int64UpDownCounterOption{
3493 metric.WithDescription("The number of pods which reached phase Failed for a job."),
3494 metric.WithUnit("{pod}"),
3495 }
3496
3497 // NewJobPodFailed returns a new JobPodFailed instrument.
3498 func NewJobPodFailed(
3499 m metric.Meter,
3500 opt ...metric.Int64UpDownCounterOption,
3501 ) (JobPodFailed, error) {
3502 // Check if the meter is nil.
3503 if m == nil {
3504 return JobPodFailed{noop.Int64UpDownCounter{}}, nil
3505 }
3506
3507 if len(opt) == 0 {
3508 opt = newJobPodFailedOpts
3509 } else {
3510 opt = append(opt, newJobPodFailedOpts...)
3511 }
3512
3513 i, err := m.Int64UpDownCounter(
3514 "k8s.job.pod.failed",
3515 opt...,
3516 )
3517 if err != nil {
3518 return JobPodFailed{noop.Int64UpDownCounter{}}, err
3519 }
3520 return JobPodFailed{i}, nil
3521 }
3522
3523 // Inst returns the underlying metric instrument.
3524 func (m JobPodFailed) Inst() metric.Int64UpDownCounter {
3525 return m.Int64UpDownCounter
3526 }
3527
3528 // Name returns the semantic convention name of the instrument.
3529 func (JobPodFailed) Name() string {
3530 return "k8s.job.pod.failed"
3531 }
3532
3533 // Unit returns the semantic convention unit of the instrument
3534 func (JobPodFailed) Unit() string {
3535 return "{pod}"
3536 }
3537
3538 // Description returns the semantic convention description of the instrument
3539 func (JobPodFailed) Description() string {
3540 return "The number of pods which reached phase Failed for a job."
3541 }
3542
3543 // Add adds incr to the existing count for attrs.
3544 //
3545 // This metric aligns with the `failed` field of the
3546 // [K8s JobStatus].
3547 //
3548 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
3549 func (m JobPodFailed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3550 if len(attrs) == 0 {
3551 m.Int64UpDownCounter.Add(ctx, incr)
3552 return
3553 }
3554
3555 o := addOptPool.Get().(*[]metric.AddOption)
3556 defer func() {
3557 *o = (*o)[:0]
3558 addOptPool.Put(o)
3559 }()
3560
3561 *o = append(*o, metric.WithAttributes(attrs...))
3562 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3563 }
3564
3565 // AddSet adds incr to the existing count for set.
3566 //
3567 // This metric aligns with the `failed` field of the
3568 // [K8s JobStatus].
3569 //
3570 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
3571 func (m JobPodFailed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3572 if set.Len() == 0 {
3573 m.Int64UpDownCounter.Add(ctx, incr)
3574 return
3575 }
3576
3577 o := addOptPool.Get().(*[]metric.AddOption)
3578 defer func() {
3579 *o = (*o)[:0]
3580 addOptPool.Put(o)
3581 }()
3582
3583 *o = append(*o, metric.WithAttributeSet(set))
3584 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3585 }
3586
3587 // JobPodMaxParallel is an instrument used to record metric values conforming to
3588 // the "k8s.job.pod.max_parallel" semantic conventions. It represents the max
3589 // desired number of pods the job should run at any given time.
3590 type JobPodMaxParallel struct {
3591 metric.Int64UpDownCounter
3592 }
3593
3594 var newJobPodMaxParallelOpts = []metric.Int64UpDownCounterOption{
3595 metric.WithDescription("The max desired number of pods the job should run at any given time."),
3596 metric.WithUnit("{pod}"),
3597 }
3598
3599 // NewJobPodMaxParallel returns a new JobPodMaxParallel instrument.
3600 func NewJobPodMaxParallel(
3601 m metric.Meter,
3602 opt ...metric.Int64UpDownCounterOption,
3603 ) (JobPodMaxParallel, error) {
3604 // Check if the meter is nil.
3605 if m == nil {
3606 return JobPodMaxParallel{noop.Int64UpDownCounter{}}, nil
3607 }
3608
3609 if len(opt) == 0 {
3610 opt = newJobPodMaxParallelOpts
3611 } else {
3612 opt = append(opt, newJobPodMaxParallelOpts...)
3613 }
3614
3615 i, err := m.Int64UpDownCounter(
3616 "k8s.job.pod.max_parallel",
3617 opt...,
3618 )
3619 if err != nil {
3620 return JobPodMaxParallel{noop.Int64UpDownCounter{}}, err
3621 }
3622 return JobPodMaxParallel{i}, nil
3623 }
3624
3625 // Inst returns the underlying metric instrument.
3626 func (m JobPodMaxParallel) Inst() metric.Int64UpDownCounter {
3627 return m.Int64UpDownCounter
3628 }
3629
3630 // Name returns the semantic convention name of the instrument.
3631 func (JobPodMaxParallel) Name() string {
3632 return "k8s.job.pod.max_parallel"
3633 }
3634
3635 // Unit returns the semantic convention unit of the instrument
3636 func (JobPodMaxParallel) Unit() string {
3637 return "{pod}"
3638 }
3639
3640 // Description returns the semantic convention description of the instrument
3641 func (JobPodMaxParallel) Description() string {
3642 return "The max desired number of pods the job should run at any given time."
3643 }
3644
3645 // Add adds incr to the existing count for attrs.
3646 //
3647 // This metric aligns with the `parallelism` field of the
3648 // [K8s JobSpec].
3649 //
3650 // [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
3651 func (m JobPodMaxParallel) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3652 if len(attrs) == 0 {
3653 m.Int64UpDownCounter.Add(ctx, incr)
3654 return
3655 }
3656
3657 o := addOptPool.Get().(*[]metric.AddOption)
3658 defer func() {
3659 *o = (*o)[:0]
3660 addOptPool.Put(o)
3661 }()
3662
3663 *o = append(*o, metric.WithAttributes(attrs...))
3664 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3665 }
3666
3667 // AddSet adds incr to the existing count for set.
3668 //
3669 // This metric aligns with the `parallelism` field of the
3670 // [K8s JobSpec].
3671 //
3672 // [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
3673 func (m JobPodMaxParallel) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3674 if set.Len() == 0 {
3675 m.Int64UpDownCounter.Add(ctx, incr)
3676 return
3677 }
3678
3679 o := addOptPool.Get().(*[]metric.AddOption)
3680 defer func() {
3681 *o = (*o)[:0]
3682 addOptPool.Put(o)
3683 }()
3684
3685 *o = append(*o, metric.WithAttributeSet(set))
3686 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3687 }
3688
3689 // JobPodSuccessful is an instrument used to record metric values conforming to
3690 // the "k8s.job.pod.successful" semantic conventions. It represents the number of
3691 // pods which reached phase Succeeded for a job.
3692 type JobPodSuccessful struct {
3693 metric.Int64UpDownCounter
3694 }
3695
3696 var newJobPodSuccessfulOpts = []metric.Int64UpDownCounterOption{
3697 metric.WithDescription("The number of pods which reached phase Succeeded for a job."),
3698 metric.WithUnit("{pod}"),
3699 }
3700
3701 // NewJobPodSuccessful returns a new JobPodSuccessful instrument.
3702 func NewJobPodSuccessful(
3703 m metric.Meter,
3704 opt ...metric.Int64UpDownCounterOption,
3705 ) (JobPodSuccessful, error) {
3706 // Check if the meter is nil.
3707 if m == nil {
3708 return JobPodSuccessful{noop.Int64UpDownCounter{}}, nil
3709 }
3710
3711 if len(opt) == 0 {
3712 opt = newJobPodSuccessfulOpts
3713 } else {
3714 opt = append(opt, newJobPodSuccessfulOpts...)
3715 }
3716
3717 i, err := m.Int64UpDownCounter(
3718 "k8s.job.pod.successful",
3719 opt...,
3720 )
3721 if err != nil {
3722 return JobPodSuccessful{noop.Int64UpDownCounter{}}, err
3723 }
3724 return JobPodSuccessful{i}, nil
3725 }
3726
3727 // Inst returns the underlying metric instrument.
3728 func (m JobPodSuccessful) Inst() metric.Int64UpDownCounter {
3729 return m.Int64UpDownCounter
3730 }
3731
3732 // Name returns the semantic convention name of the instrument.
3733 func (JobPodSuccessful) Name() string {
3734 return "k8s.job.pod.successful"
3735 }
3736
3737 // Unit returns the semantic convention unit of the instrument
3738 func (JobPodSuccessful) Unit() string {
3739 return "{pod}"
3740 }
3741
3742 // Description returns the semantic convention description of the instrument
3743 func (JobPodSuccessful) Description() string {
3744 return "The number of pods which reached phase Succeeded for a job."
3745 }
3746
3747 // Add adds incr to the existing count for attrs.
3748 //
3749 // This metric aligns with the `succeeded` field of the
3750 // [K8s JobStatus].
3751 //
3752 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
3753 func (m JobPodSuccessful) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3754 if len(attrs) == 0 {
3755 m.Int64UpDownCounter.Add(ctx, incr)
3756 return
3757 }
3758
3759 o := addOptPool.Get().(*[]metric.AddOption)
3760 defer func() {
3761 *o = (*o)[:0]
3762 addOptPool.Put(o)
3763 }()
3764
3765 *o = append(*o, metric.WithAttributes(attrs...))
3766 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3767 }
3768
3769 // AddSet adds incr to the existing count for set.
3770 //
3771 // This metric aligns with the `succeeded` field of the
3772 // [K8s JobStatus].
3773 //
3774 // [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch
3775 func (m JobPodSuccessful) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3776 if set.Len() == 0 {
3777 m.Int64UpDownCounter.Add(ctx, incr)
3778 return
3779 }
3780
3781 o := addOptPool.Get().(*[]metric.AddOption)
3782 defer func() {
3783 *o = (*o)[:0]
3784 addOptPool.Put(o)
3785 }()
3786
3787 *o = append(*o, metric.WithAttributeSet(set))
3788 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3789 }
3790
3791 // NamespacePhase is an instrument used to record metric values conforming to the
3792 // "k8s.namespace.phase" semantic conventions. It represents the describes number
3793 // of K8s namespaces that are currently in a given phase.
3794 type NamespacePhase struct {
3795 metric.Int64UpDownCounter
3796 }
3797
3798 var newNamespacePhaseOpts = []metric.Int64UpDownCounterOption{
3799 metric.WithDescription("Describes number of K8s namespaces that are currently in a given phase."),
3800 metric.WithUnit("{namespace}"),
3801 }
3802
3803 // NewNamespacePhase returns a new NamespacePhase instrument.
3804 func NewNamespacePhase(
3805 m metric.Meter,
3806 opt ...metric.Int64UpDownCounterOption,
3807 ) (NamespacePhase, error) {
3808 // Check if the meter is nil.
3809 if m == nil {
3810 return NamespacePhase{noop.Int64UpDownCounter{}}, nil
3811 }
3812
3813 if len(opt) == 0 {
3814 opt = newNamespacePhaseOpts
3815 } else {
3816 opt = append(opt, newNamespacePhaseOpts...)
3817 }
3818
3819 i, err := m.Int64UpDownCounter(
3820 "k8s.namespace.phase",
3821 opt...,
3822 )
3823 if err != nil {
3824 return NamespacePhase{noop.Int64UpDownCounter{}}, err
3825 }
3826 return NamespacePhase{i}, nil
3827 }
3828
3829 // Inst returns the underlying metric instrument.
3830 func (m NamespacePhase) Inst() metric.Int64UpDownCounter {
3831 return m.Int64UpDownCounter
3832 }
3833
3834 // Name returns the semantic convention name of the instrument.
3835 func (NamespacePhase) Name() string {
3836 return "k8s.namespace.phase"
3837 }
3838
3839 // Unit returns the semantic convention unit of the instrument
3840 func (NamespacePhase) Unit() string {
3841 return "{namespace}"
3842 }
3843
3844 // Description returns the semantic convention description of the instrument
3845 func (NamespacePhase) Description() string {
3846 return "Describes number of K8s namespaces that are currently in a given phase."
3847 }
3848
3849 // Add adds incr to the existing count for attrs.
3850 //
3851 // The namespacePhase is the the phase of the K8s namespace.
3852 func (m NamespacePhase) Add(
3853 ctx context.Context,
3854 incr int64,
3855 namespacePhase NamespacePhaseAttr,
3856 attrs ...attribute.KeyValue,
3857 ) {
3858 if len(attrs) == 0 {
3859 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
3860 attribute.String("k8s.namespace.phase", string(namespacePhase)),
3861 ))
3862 return
3863 }
3864
3865 o := addOptPool.Get().(*[]metric.AddOption)
3866 defer func() {
3867 *o = (*o)[:0]
3868 addOptPool.Put(o)
3869 }()
3870
3871 *o = append(
3872 *o,
3873 metric.WithAttributes(
3874 append(
3875 attrs[:len(attrs):len(attrs)],
3876 attribute.String("k8s.namespace.phase", string(namespacePhase)),
3877 )...,
3878 ),
3879 )
3880
3881 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3882 }
3883
3884 // AddSet adds incr to the existing count for set.
3885 func (m NamespacePhase) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3886 if set.Len() == 0 {
3887 m.Int64UpDownCounter.Add(ctx, incr)
3888 return
3889 }
3890
3891 o := addOptPool.Get().(*[]metric.AddOption)
3892 defer func() {
3893 *o = (*o)[:0]
3894 addOptPool.Put(o)
3895 }()
3896
3897 *o = append(*o, metric.WithAttributeSet(set))
3898 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3899 }
3900
3901 // NodeConditionStatus is an instrument used to record metric values conforming
3902 // to the "k8s.node.condition.status" semantic conventions. It represents the
3903 // describes the condition of a particular Node.
3904 type NodeConditionStatus struct {
3905 metric.Int64UpDownCounter
3906 }
3907
3908 var newNodeConditionStatusOpts = []metric.Int64UpDownCounterOption{
3909 metric.WithDescription("Describes the condition of a particular Node."),
3910 metric.WithUnit("{node}"),
3911 }
3912
3913 // NewNodeConditionStatus returns a new NodeConditionStatus instrument.
3914 func NewNodeConditionStatus(
3915 m metric.Meter,
3916 opt ...metric.Int64UpDownCounterOption,
3917 ) (NodeConditionStatus, error) {
3918 // Check if the meter is nil.
3919 if m == nil {
3920 return NodeConditionStatus{noop.Int64UpDownCounter{}}, nil
3921 }
3922
3923 if len(opt) == 0 {
3924 opt = newNodeConditionStatusOpts
3925 } else {
3926 opt = append(opt, newNodeConditionStatusOpts...)
3927 }
3928
3929 i, err := m.Int64UpDownCounter(
3930 "k8s.node.condition.status",
3931 opt...,
3932 )
3933 if err != nil {
3934 return NodeConditionStatus{noop.Int64UpDownCounter{}}, err
3935 }
3936 return NodeConditionStatus{i}, nil
3937 }
3938
3939 // Inst returns the underlying metric instrument.
3940 func (m NodeConditionStatus) Inst() metric.Int64UpDownCounter {
3941 return m.Int64UpDownCounter
3942 }
3943
3944 // Name returns the semantic convention name of the instrument.
3945 func (NodeConditionStatus) Name() string {
3946 return "k8s.node.condition.status"
3947 }
3948
3949 // Unit returns the semantic convention unit of the instrument
3950 func (NodeConditionStatus) Unit() string {
3951 return "{node}"
3952 }
3953
3954 // Description returns the semantic convention description of the instrument
3955 func (NodeConditionStatus) Description() string {
3956 return "Describes the condition of a particular Node."
3957 }
3958
3959 // Add adds incr to the existing count for attrs.
3960 //
3961 // The nodeConditionStatus is the the status of the condition, one of True,
3962 // False, Unknown.
3963 //
3964 // The nodeConditionType is the the condition type of a K8s Node.
3965 //
3966 // All possible node condition pairs (type and status) will be reported at each
3967 // time interval to avoid missing metrics. Condition pairs corresponding to the
3968 // current conditions' statuses will be non-zero.
3969 func (m NodeConditionStatus) Add(
3970 ctx context.Context,
3971 incr int64,
3972 nodeConditionStatus NodeConditionStatusAttr,
3973 nodeConditionType NodeConditionTypeAttr,
3974 attrs ...attribute.KeyValue,
3975 ) {
3976 if len(attrs) == 0 {
3977 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
3978 attribute.String("k8s.node.condition.status", string(nodeConditionStatus)),
3979 attribute.String("k8s.node.condition.type", string(nodeConditionType)),
3980 ))
3981 return
3982 }
3983
3984 o := addOptPool.Get().(*[]metric.AddOption)
3985 defer func() {
3986 *o = (*o)[:0]
3987 addOptPool.Put(o)
3988 }()
3989
3990 *o = append(
3991 *o,
3992 metric.WithAttributes(
3993 append(
3994 attrs[:len(attrs):len(attrs)],
3995 attribute.String("k8s.node.condition.status", string(nodeConditionStatus)),
3996 attribute.String("k8s.node.condition.type", string(nodeConditionType)),
3997 )...,
3998 ),
3999 )
4000
4001 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4002 }
4003
4004 // AddSet adds incr to the existing count for set.
4005 //
4006 // All possible node condition pairs (type and status) will be reported at each
4007 // time interval to avoid missing metrics. Condition pairs corresponding to the
4008 // current conditions' statuses will be non-zero.
4009 func (m NodeConditionStatus) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4010 if set.Len() == 0 {
4011 m.Int64UpDownCounter.Add(ctx, incr)
4012 return
4013 }
4014
4015 o := addOptPool.Get().(*[]metric.AddOption)
4016 defer func() {
4017 *o = (*o)[:0]
4018 addOptPool.Put(o)
4019 }()
4020
4021 *o = append(*o, metric.WithAttributeSet(set))
4022 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4023 }
4024
4025 // NodeCPUAllocatable is an instrument used to record metric values conforming to
4026 // the "k8s.node.cpu.allocatable" semantic conventions. It represents the amount
4027 // of cpu allocatable on the node.
4028 type NodeCPUAllocatable struct {
4029 metric.Int64UpDownCounter
4030 }
4031
4032 var newNodeCPUAllocatableOpts = []metric.Int64UpDownCounterOption{
4033 metric.WithDescription("Amount of cpu allocatable on the node."),
4034 metric.WithUnit("{cpu}"),
4035 }
4036
4037 // NewNodeCPUAllocatable returns a new NodeCPUAllocatable instrument.
4038 func NewNodeCPUAllocatable(
4039 m metric.Meter,
4040 opt ...metric.Int64UpDownCounterOption,
4041 ) (NodeCPUAllocatable, error) {
4042 // Check if the meter is nil.
4043 if m == nil {
4044 return NodeCPUAllocatable{noop.Int64UpDownCounter{}}, nil
4045 }
4046
4047 if len(opt) == 0 {
4048 opt = newNodeCPUAllocatableOpts
4049 } else {
4050 opt = append(opt, newNodeCPUAllocatableOpts...)
4051 }
4052
4053 i, err := m.Int64UpDownCounter(
4054 "k8s.node.cpu.allocatable",
4055 opt...,
4056 )
4057 if err != nil {
4058 return NodeCPUAllocatable{noop.Int64UpDownCounter{}}, err
4059 }
4060 return NodeCPUAllocatable{i}, nil
4061 }
4062
4063 // Inst returns the underlying metric instrument.
4064 func (m NodeCPUAllocatable) Inst() metric.Int64UpDownCounter {
4065 return m.Int64UpDownCounter
4066 }
4067
4068 // Name returns the semantic convention name of the instrument.
4069 func (NodeCPUAllocatable) Name() string {
4070 return "k8s.node.cpu.allocatable"
4071 }
4072
4073 // Unit returns the semantic convention unit of the instrument
4074 func (NodeCPUAllocatable) Unit() string {
4075 return "{cpu}"
4076 }
4077
4078 // Description returns the semantic convention description of the instrument
4079 func (NodeCPUAllocatable) Description() string {
4080 return "Amount of cpu allocatable on the node."
4081 }
4082
4083 // Add adds incr to the existing count for attrs.
4084 func (m NodeCPUAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
4085 if len(attrs) == 0 {
4086 m.Int64UpDownCounter.Add(ctx, incr)
4087 return
4088 }
4089
4090 o := addOptPool.Get().(*[]metric.AddOption)
4091 defer func() {
4092 *o = (*o)[:0]
4093 addOptPool.Put(o)
4094 }()
4095
4096 *o = append(*o, metric.WithAttributes(attrs...))
4097 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4098 }
4099
4100 // AddSet adds incr to the existing count for set.
4101 func (m NodeCPUAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4102 if set.Len() == 0 {
4103 m.Int64UpDownCounter.Add(ctx, incr)
4104 return
4105 }
4106
4107 o := addOptPool.Get().(*[]metric.AddOption)
4108 defer func() {
4109 *o = (*o)[:0]
4110 addOptPool.Put(o)
4111 }()
4112
4113 *o = append(*o, metric.WithAttributeSet(set))
4114 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4115 }
4116
4117 // NodeCPUTime is an instrument used to record metric values conforming to the
4118 // "k8s.node.cpu.time" semantic conventions. It represents the total CPU time
4119 // consumed.
4120 type NodeCPUTime struct {
4121 metric.Float64Counter
4122 }
4123
4124 var newNodeCPUTimeOpts = []metric.Float64CounterOption{
4125 metric.WithDescription("Total CPU time consumed."),
4126 metric.WithUnit("s"),
4127 }
4128
4129 // NewNodeCPUTime returns a new NodeCPUTime instrument.
4130 func NewNodeCPUTime(
4131 m metric.Meter,
4132 opt ...metric.Float64CounterOption,
4133 ) (NodeCPUTime, error) {
4134 // Check if the meter is nil.
4135 if m == nil {
4136 return NodeCPUTime{noop.Float64Counter{}}, nil
4137 }
4138
4139 if len(opt) == 0 {
4140 opt = newNodeCPUTimeOpts
4141 } else {
4142 opt = append(opt, newNodeCPUTimeOpts...)
4143 }
4144
4145 i, err := m.Float64Counter(
4146 "k8s.node.cpu.time",
4147 opt...,
4148 )
4149 if err != nil {
4150 return NodeCPUTime{noop.Float64Counter{}}, err
4151 }
4152 return NodeCPUTime{i}, nil
4153 }
4154
4155 // Inst returns the underlying metric instrument.
4156 func (m NodeCPUTime) Inst() metric.Float64Counter {
4157 return m.Float64Counter
4158 }
4159
4160 // Name returns the semantic convention name of the instrument.
4161 func (NodeCPUTime) Name() string {
4162 return "k8s.node.cpu.time"
4163 }
4164
4165 // Unit returns the semantic convention unit of the instrument
4166 func (NodeCPUTime) Unit() string {
4167 return "s"
4168 }
4169
4170 // Description returns the semantic convention description of the instrument
4171 func (NodeCPUTime) Description() string {
4172 return "Total CPU time consumed."
4173 }
4174
4175 // Add adds incr to the existing count for attrs.
4176 //
4177 // Total CPU time consumed by the specific Node on all available CPU cores
4178 func (m NodeCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
4179 if len(attrs) == 0 {
4180 m.Float64Counter.Add(ctx, incr)
4181 return
4182 }
4183
4184 o := addOptPool.Get().(*[]metric.AddOption)
4185 defer func() {
4186 *o = (*o)[:0]
4187 addOptPool.Put(o)
4188 }()
4189
4190 *o = append(*o, metric.WithAttributes(attrs...))
4191 m.Float64Counter.Add(ctx, incr, *o...)
4192 }
4193
4194 // AddSet adds incr to the existing count for set.
4195 //
4196 // Total CPU time consumed by the specific Node on all available CPU cores
4197 func (m NodeCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) {
4198 if set.Len() == 0 {
4199 m.Float64Counter.Add(ctx, incr)
4200 return
4201 }
4202
4203 o := addOptPool.Get().(*[]metric.AddOption)
4204 defer func() {
4205 *o = (*o)[:0]
4206 addOptPool.Put(o)
4207 }()
4208
4209 *o = append(*o, metric.WithAttributeSet(set))
4210 m.Float64Counter.Add(ctx, incr, *o...)
4211 }
4212
4213 // NodeCPUUsage is an instrument used to record metric values conforming to the
4214 // "k8s.node.cpu.usage" semantic conventions. It represents the node's CPU usage,
4215 // measured in cpus. Range from 0 to the number of allocatable CPUs.
4216 type NodeCPUUsage struct {
4217 metric.Int64Gauge
4218 }
4219
4220 var newNodeCPUUsageOpts = []metric.Int64GaugeOption{
4221 metric.WithDescription("Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."),
4222 metric.WithUnit("{cpu}"),
4223 }
4224
4225 // NewNodeCPUUsage returns a new NodeCPUUsage instrument.
4226 func NewNodeCPUUsage(
4227 m metric.Meter,
4228 opt ...metric.Int64GaugeOption,
4229 ) (NodeCPUUsage, error) {
4230 // Check if the meter is nil.
4231 if m == nil {
4232 return NodeCPUUsage{noop.Int64Gauge{}}, nil
4233 }
4234
4235 if len(opt) == 0 {
4236 opt = newNodeCPUUsageOpts
4237 } else {
4238 opt = append(opt, newNodeCPUUsageOpts...)
4239 }
4240
4241 i, err := m.Int64Gauge(
4242 "k8s.node.cpu.usage",
4243 opt...,
4244 )
4245 if err != nil {
4246 return NodeCPUUsage{noop.Int64Gauge{}}, err
4247 }
4248 return NodeCPUUsage{i}, nil
4249 }
4250
4251 // Inst returns the underlying metric instrument.
4252 func (m NodeCPUUsage) Inst() metric.Int64Gauge {
4253 return m.Int64Gauge
4254 }
4255
4256 // Name returns the semantic convention name of the instrument.
4257 func (NodeCPUUsage) Name() string {
4258 return "k8s.node.cpu.usage"
4259 }
4260
4261 // Unit returns the semantic convention unit of the instrument
4262 func (NodeCPUUsage) Unit() string {
4263 return "{cpu}"
4264 }
4265
4266 // Description returns the semantic convention description of the instrument
4267 func (NodeCPUUsage) Description() string {
4268 return "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."
4269 }
4270
4271 // Record records val to the current distribution for attrs.
4272 //
4273 // CPU usage of the specific Node on all available CPU cores, averaged over the
4274 // sample window
4275 func (m NodeCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
4276 if len(attrs) == 0 {
4277 m.Int64Gauge.Record(ctx, val)
4278 return
4279 }
4280
4281 o := recOptPool.Get().(*[]metric.RecordOption)
4282 defer func() {
4283 *o = (*o)[:0]
4284 recOptPool.Put(o)
4285 }()
4286
4287 *o = append(*o, metric.WithAttributes(attrs...))
4288 m.Int64Gauge.Record(ctx, val, *o...)
4289 }
4290
4291 // RecordSet records val to the current distribution for set.
4292 //
4293 // CPU usage of the specific Node on all available CPU cores, averaged over the
4294 // sample window
4295 func (m NodeCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) {
4296 if set.Len() == 0 {
4297 m.Int64Gauge.Record(ctx, val)
4298 return
4299 }
4300
4301 o := recOptPool.Get().(*[]metric.RecordOption)
4302 defer func() {
4303 *o = (*o)[:0]
4304 recOptPool.Put(o)
4305 }()
4306
4307 *o = append(*o, metric.WithAttributeSet(set))
4308 m.Int64Gauge.Record(ctx, val, *o...)
4309 }
4310
4311 // NodeEphemeralStorageAllocatable is an instrument used to record metric values
4312 // conforming to the "k8s.node.ephemeral_storage.allocatable" semantic
4313 // conventions. It represents the amount of ephemeral-storage allocatable on the
4314 // node.
4315 type NodeEphemeralStorageAllocatable struct {
4316 metric.Int64UpDownCounter
4317 }
4318
4319 var newNodeEphemeralStorageAllocatableOpts = []metric.Int64UpDownCounterOption{
4320 metric.WithDescription("Amount of ephemeral-storage allocatable on the node."),
4321 metric.WithUnit("By"),
4322 }
4323
4324 // NewNodeEphemeralStorageAllocatable returns a new
4325 // NodeEphemeralStorageAllocatable instrument.
4326 func NewNodeEphemeralStorageAllocatable(
4327 m metric.Meter,
4328 opt ...metric.Int64UpDownCounterOption,
4329 ) (NodeEphemeralStorageAllocatable, error) {
4330 // Check if the meter is nil.
4331 if m == nil {
4332 return NodeEphemeralStorageAllocatable{noop.Int64UpDownCounter{}}, nil
4333 }
4334
4335 if len(opt) == 0 {
4336 opt = newNodeEphemeralStorageAllocatableOpts
4337 } else {
4338 opt = append(opt, newNodeEphemeralStorageAllocatableOpts...)
4339 }
4340
4341 i, err := m.Int64UpDownCounter(
4342 "k8s.node.ephemeral_storage.allocatable",
4343 opt...,
4344 )
4345 if err != nil {
4346 return NodeEphemeralStorageAllocatable{noop.Int64UpDownCounter{}}, err
4347 }
4348 return NodeEphemeralStorageAllocatable{i}, nil
4349 }
4350
4351 // Inst returns the underlying metric instrument.
4352 func (m NodeEphemeralStorageAllocatable) Inst() metric.Int64UpDownCounter {
4353 return m.Int64UpDownCounter
4354 }
4355
4356 // Name returns the semantic convention name of the instrument.
4357 func (NodeEphemeralStorageAllocatable) Name() string {
4358 return "k8s.node.ephemeral_storage.allocatable"
4359 }
4360
4361 // Unit returns the semantic convention unit of the instrument
4362 func (NodeEphemeralStorageAllocatable) Unit() string {
4363 return "By"
4364 }
4365
4366 // Description returns the semantic convention description of the instrument
4367 func (NodeEphemeralStorageAllocatable) Description() string {
4368 return "Amount of ephemeral-storage allocatable on the node."
4369 }
4370
4371 // Add adds incr to the existing count for attrs.
4372 func (m NodeEphemeralStorageAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
4373 if len(attrs) == 0 {
4374 m.Int64UpDownCounter.Add(ctx, incr)
4375 return
4376 }
4377
4378 o := addOptPool.Get().(*[]metric.AddOption)
4379 defer func() {
4380 *o = (*o)[:0]
4381 addOptPool.Put(o)
4382 }()
4383
4384 *o = append(*o, metric.WithAttributes(attrs...))
4385 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4386 }
4387
4388 // AddSet adds incr to the existing count for set.
4389 func (m NodeEphemeralStorageAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4390 if set.Len() == 0 {
4391 m.Int64UpDownCounter.Add(ctx, incr)
4392 return
4393 }
4394
4395 o := addOptPool.Get().(*[]metric.AddOption)
4396 defer func() {
4397 *o = (*o)[:0]
4398 addOptPool.Put(o)
4399 }()
4400
4401 *o = append(*o, metric.WithAttributeSet(set))
4402 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4403 }
4404
4405 // NodeFilesystemAvailable is an instrument used to record metric values
4406 // conforming to the "k8s.node.filesystem.available" semantic conventions. It
4407 // represents the node filesystem available bytes.
4408 type NodeFilesystemAvailable struct {
4409 metric.Int64UpDownCounter
4410 }
4411
4412 var newNodeFilesystemAvailableOpts = []metric.Int64UpDownCounterOption{
4413 metric.WithDescription("Node filesystem available bytes."),
4414 metric.WithUnit("By"),
4415 }
4416
4417 // NewNodeFilesystemAvailable returns a new NodeFilesystemAvailable instrument.
4418 func NewNodeFilesystemAvailable(
4419 m metric.Meter,
4420 opt ...metric.Int64UpDownCounterOption,
4421 ) (NodeFilesystemAvailable, error) {
4422 // Check if the meter is nil.
4423 if m == nil {
4424 return NodeFilesystemAvailable{noop.Int64UpDownCounter{}}, nil
4425 }
4426
4427 if len(opt) == 0 {
4428 opt = newNodeFilesystemAvailableOpts
4429 } else {
4430 opt = append(opt, newNodeFilesystemAvailableOpts...)
4431 }
4432
4433 i, err := m.Int64UpDownCounter(
4434 "k8s.node.filesystem.available",
4435 opt...,
4436 )
4437 if err != nil {
4438 return NodeFilesystemAvailable{noop.Int64UpDownCounter{}}, err
4439 }
4440 return NodeFilesystemAvailable{i}, nil
4441 }
4442
4443 // Inst returns the underlying metric instrument.
4444 func (m NodeFilesystemAvailable) Inst() metric.Int64UpDownCounter {
4445 return m.Int64UpDownCounter
4446 }
4447
4448 // Name returns the semantic convention name of the instrument.
4449 func (NodeFilesystemAvailable) Name() string {
4450 return "k8s.node.filesystem.available"
4451 }
4452
4453 // Unit returns the semantic convention unit of the instrument
4454 func (NodeFilesystemAvailable) Unit() string {
4455 return "By"
4456 }
4457
4458 // Description returns the semantic convention description of the instrument
4459 func (NodeFilesystemAvailable) Description() string {
4460 return "Node filesystem available bytes."
4461 }
4462
4463 // Add adds incr to the existing count for attrs.
4464 //
4465 // This metric is derived from the
4466 // [FsStats.AvailableBytes] field
4467 // of the [NodeStats.Fs]
4468 // of the Kubelet's stats API.
4469 //
4470 // [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
4471 // [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4472 func (m NodeFilesystemAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
4473 if len(attrs) == 0 {
4474 m.Int64UpDownCounter.Add(ctx, incr)
4475 return
4476 }
4477
4478 o := addOptPool.Get().(*[]metric.AddOption)
4479 defer func() {
4480 *o = (*o)[:0]
4481 addOptPool.Put(o)
4482 }()
4483
4484 *o = append(*o, metric.WithAttributes(attrs...))
4485 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4486 }
4487
4488 // AddSet adds incr to the existing count for set.
4489 //
4490 // This metric is derived from the
4491 // [FsStats.AvailableBytes] field
4492 // of the [NodeStats.Fs]
4493 // of the Kubelet's stats API.
4494 //
4495 // [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
4496 // [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4497 func (m NodeFilesystemAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4498 if set.Len() == 0 {
4499 m.Int64UpDownCounter.Add(ctx, incr)
4500 return
4501 }
4502
4503 o := addOptPool.Get().(*[]metric.AddOption)
4504 defer func() {
4505 *o = (*o)[:0]
4506 addOptPool.Put(o)
4507 }()
4508
4509 *o = append(*o, metric.WithAttributeSet(set))
4510 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4511 }
4512
4513 // NodeFilesystemCapacity is an instrument used to record metric values
4514 // conforming to the "k8s.node.filesystem.capacity" semantic conventions. It
4515 // represents the node filesystem capacity.
4516 type NodeFilesystemCapacity struct {
4517 metric.Int64UpDownCounter
4518 }
4519
4520 var newNodeFilesystemCapacityOpts = []metric.Int64UpDownCounterOption{
4521 metric.WithDescription("Node filesystem capacity."),
4522 metric.WithUnit("By"),
4523 }
4524
4525 // NewNodeFilesystemCapacity returns a new NodeFilesystemCapacity instrument.
4526 func NewNodeFilesystemCapacity(
4527 m metric.Meter,
4528 opt ...metric.Int64UpDownCounterOption,
4529 ) (NodeFilesystemCapacity, error) {
4530 // Check if the meter is nil.
4531 if m == nil {
4532 return NodeFilesystemCapacity{noop.Int64UpDownCounter{}}, nil
4533 }
4534
4535 if len(opt) == 0 {
4536 opt = newNodeFilesystemCapacityOpts
4537 } else {
4538 opt = append(opt, newNodeFilesystemCapacityOpts...)
4539 }
4540
4541 i, err := m.Int64UpDownCounter(
4542 "k8s.node.filesystem.capacity",
4543 opt...,
4544 )
4545 if err != nil {
4546 return NodeFilesystemCapacity{noop.Int64UpDownCounter{}}, err
4547 }
4548 return NodeFilesystemCapacity{i}, nil
4549 }
4550
4551 // Inst returns the underlying metric instrument.
4552 func (m NodeFilesystemCapacity) Inst() metric.Int64UpDownCounter {
4553 return m.Int64UpDownCounter
4554 }
4555
4556 // Name returns the semantic convention name of the instrument.
4557 func (NodeFilesystemCapacity) Name() string {
4558 return "k8s.node.filesystem.capacity"
4559 }
4560
4561 // Unit returns the semantic convention unit of the instrument
4562 func (NodeFilesystemCapacity) Unit() string {
4563 return "By"
4564 }
4565
4566 // Description returns the semantic convention description of the instrument
4567 func (NodeFilesystemCapacity) Description() string {
4568 return "Node filesystem capacity."
4569 }
4570
4571 // Add adds incr to the existing count for attrs.
4572 //
4573 // This metric is derived from the
4574 // [FsStats.CapacityBytes] field
4575 // of the [NodeStats.Fs]
4576 // of the Kubelet's stats API.
4577 //
4578 // [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
4579 // [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4580 func (m NodeFilesystemCapacity) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
4581 if len(attrs) == 0 {
4582 m.Int64UpDownCounter.Add(ctx, incr)
4583 return
4584 }
4585
4586 o := addOptPool.Get().(*[]metric.AddOption)
4587 defer func() {
4588 *o = (*o)[:0]
4589 addOptPool.Put(o)
4590 }()
4591
4592 *o = append(*o, metric.WithAttributes(attrs...))
4593 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4594 }
4595
4596 // AddSet adds incr to the existing count for set.
4597 //
4598 // This metric is derived from the
4599 // [FsStats.CapacityBytes] field
4600 // of the [NodeStats.Fs]
4601 // of the Kubelet's stats API.
4602 //
4603 // [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
4604 // [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4605 func (m NodeFilesystemCapacity) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4606 if set.Len() == 0 {
4607 m.Int64UpDownCounter.Add(ctx, incr)
4608 return
4609 }
4610
4611 o := addOptPool.Get().(*[]metric.AddOption)
4612 defer func() {
4613 *o = (*o)[:0]
4614 addOptPool.Put(o)
4615 }()
4616
4617 *o = append(*o, metric.WithAttributeSet(set))
4618 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4619 }
4620
4621 // NodeFilesystemUsage is an instrument used to record metric values conforming
4622 // to the "k8s.node.filesystem.usage" semantic conventions. It represents the
4623 // node filesystem usage.
4624 type NodeFilesystemUsage struct {
4625 metric.Int64UpDownCounter
4626 }
4627
4628 var newNodeFilesystemUsageOpts = []metric.Int64UpDownCounterOption{
4629 metric.WithDescription("Node filesystem usage."),
4630 metric.WithUnit("By"),
4631 }
4632
4633 // NewNodeFilesystemUsage returns a new NodeFilesystemUsage instrument.
4634 func NewNodeFilesystemUsage(
4635 m metric.Meter,
4636 opt ...metric.Int64UpDownCounterOption,
4637 ) (NodeFilesystemUsage, error) {
4638 // Check if the meter is nil.
4639 if m == nil {
4640 return NodeFilesystemUsage{noop.Int64UpDownCounter{}}, nil
4641 }
4642
4643 if len(opt) == 0 {
4644 opt = newNodeFilesystemUsageOpts
4645 } else {
4646 opt = append(opt, newNodeFilesystemUsageOpts...)
4647 }
4648
4649 i, err := m.Int64UpDownCounter(
4650 "k8s.node.filesystem.usage",
4651 opt...,
4652 )
4653 if err != nil {
4654 return NodeFilesystemUsage{noop.Int64UpDownCounter{}}, err
4655 }
4656 return NodeFilesystemUsage{i}, nil
4657 }
4658
4659 // Inst returns the underlying metric instrument.
4660 func (m NodeFilesystemUsage) Inst() metric.Int64UpDownCounter {
4661 return m.Int64UpDownCounter
4662 }
4663
4664 // Name returns the semantic convention name of the instrument.
4665 func (NodeFilesystemUsage) Name() string {
4666 return "k8s.node.filesystem.usage"
4667 }
4668
4669 // Unit returns the semantic convention unit of the instrument
4670 func (NodeFilesystemUsage) Unit() string {
4671 return "By"
4672 }
4673
4674 // Description returns the semantic convention description of the instrument
4675 func (NodeFilesystemUsage) Description() string {
4676 return "Node filesystem usage."
4677 }
4678
4679 // Add adds incr to the existing count for attrs.
4680 //
4681 // This may not equal capacity - available.
4682 //
4683 // This metric is derived from the
4684 // [FsStats.UsedBytes] field
4685 // of the [NodeStats.Fs]
4686 // of the Kubelet's stats API.
4687 //
4688 // [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
4689 // [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4690 func (m NodeFilesystemUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
4691 if len(attrs) == 0 {
4692 m.Int64UpDownCounter.Add(ctx, incr)
4693 return
4694 }
4695
4696 o := addOptPool.Get().(*[]metric.AddOption)
4697 defer func() {
4698 *o = (*o)[:0]
4699 addOptPool.Put(o)
4700 }()
4701
4702 *o = append(*o, metric.WithAttributes(attrs...))
4703 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4704 }
4705
4706 // AddSet adds incr to the existing count for set.
4707 //
4708 // This may not equal capacity - available.
4709 //
4710 // This metric is derived from the
4711 // [FsStats.UsedBytes] field
4712 // of the [NodeStats.Fs]
4713 // of the Kubelet's stats API.
4714 //
4715 // [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
4716 // [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4717 func (m NodeFilesystemUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4718 if set.Len() == 0 {
4719 m.Int64UpDownCounter.Add(ctx, incr)
4720 return
4721 }
4722
4723 o := addOptPool.Get().(*[]metric.AddOption)
4724 defer func() {
4725 *o = (*o)[:0]
4726 addOptPool.Put(o)
4727 }()
4728
4729 *o = append(*o, metric.WithAttributeSet(set))
4730 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4731 }
4732
4733 // NodeMemoryAllocatable is an instrument used to record metric values conforming
4734 // to the "k8s.node.memory.allocatable" semantic conventions. It represents the
4735 // amount of memory allocatable on the node.
4736 type NodeMemoryAllocatable struct {
4737 metric.Int64UpDownCounter
4738 }
4739
4740 var newNodeMemoryAllocatableOpts = []metric.Int64UpDownCounterOption{
4741 metric.WithDescription("Amount of memory allocatable on the node."),
4742 metric.WithUnit("By"),
4743 }
4744
4745 // NewNodeMemoryAllocatable returns a new NodeMemoryAllocatable instrument.
4746 func NewNodeMemoryAllocatable(
4747 m metric.Meter,
4748 opt ...metric.Int64UpDownCounterOption,
4749 ) (NodeMemoryAllocatable, error) {
4750 // Check if the meter is nil.
4751 if m == nil {
4752 return NodeMemoryAllocatable{noop.Int64UpDownCounter{}}, nil
4753 }
4754
4755 if len(opt) == 0 {
4756 opt = newNodeMemoryAllocatableOpts
4757 } else {
4758 opt = append(opt, newNodeMemoryAllocatableOpts...)
4759 }
4760
4761 i, err := m.Int64UpDownCounter(
4762 "k8s.node.memory.allocatable",
4763 opt...,
4764 )
4765 if err != nil {
4766 return NodeMemoryAllocatable{noop.Int64UpDownCounter{}}, err
4767 }
4768 return NodeMemoryAllocatable{i}, nil
4769 }
4770
4771 // Inst returns the underlying metric instrument.
4772 func (m NodeMemoryAllocatable) Inst() metric.Int64UpDownCounter {
4773 return m.Int64UpDownCounter
4774 }
4775
4776 // Name returns the semantic convention name of the instrument.
4777 func (NodeMemoryAllocatable) Name() string {
4778 return "k8s.node.memory.allocatable"
4779 }
4780
4781 // Unit returns the semantic convention unit of the instrument
4782 func (NodeMemoryAllocatable) Unit() string {
4783 return "By"
4784 }
4785
4786 // Description returns the semantic convention description of the instrument
4787 func (NodeMemoryAllocatable) Description() string {
4788 return "Amount of memory allocatable on the node."
4789 }
4790
4791 // Add adds incr to the existing count for attrs.
4792 func (m NodeMemoryAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
4793 if len(attrs) == 0 {
4794 m.Int64UpDownCounter.Add(ctx, incr)
4795 return
4796 }
4797
4798 o := addOptPool.Get().(*[]metric.AddOption)
4799 defer func() {
4800 *o = (*o)[:0]
4801 addOptPool.Put(o)
4802 }()
4803
4804 *o = append(*o, metric.WithAttributes(attrs...))
4805 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4806 }
4807
4808 // AddSet adds incr to the existing count for set.
4809 func (m NodeMemoryAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4810 if set.Len() == 0 {
4811 m.Int64UpDownCounter.Add(ctx, incr)
4812 return
4813 }
4814
4815 o := addOptPool.Get().(*[]metric.AddOption)
4816 defer func() {
4817 *o = (*o)[:0]
4818 addOptPool.Put(o)
4819 }()
4820
4821 *o = append(*o, metric.WithAttributeSet(set))
4822 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4823 }
4824
4825 // NodeMemoryAvailable is an instrument used to record metric values conforming
4826 // to the "k8s.node.memory.available" semantic conventions. It represents the
4827 // node memory available.
4828 type NodeMemoryAvailable struct {
4829 metric.Int64UpDownCounter
4830 }
4831
4832 var newNodeMemoryAvailableOpts = []metric.Int64UpDownCounterOption{
4833 metric.WithDescription("Node memory available."),
4834 metric.WithUnit("By"),
4835 }
4836
4837 // NewNodeMemoryAvailable returns a new NodeMemoryAvailable instrument.
4838 func NewNodeMemoryAvailable(
4839 m metric.Meter,
4840 opt ...metric.Int64UpDownCounterOption,
4841 ) (NodeMemoryAvailable, error) {
4842 // Check if the meter is nil.
4843 if m == nil {
4844 return NodeMemoryAvailable{noop.Int64UpDownCounter{}}, nil
4845 }
4846
4847 if len(opt) == 0 {
4848 opt = newNodeMemoryAvailableOpts
4849 } else {
4850 opt = append(opt, newNodeMemoryAvailableOpts...)
4851 }
4852
4853 i, err := m.Int64UpDownCounter(
4854 "k8s.node.memory.available",
4855 opt...,
4856 )
4857 if err != nil {
4858 return NodeMemoryAvailable{noop.Int64UpDownCounter{}}, err
4859 }
4860 return NodeMemoryAvailable{i}, nil
4861 }
4862
4863 // Inst returns the underlying metric instrument.
4864 func (m NodeMemoryAvailable) Inst() metric.Int64UpDownCounter {
4865 return m.Int64UpDownCounter
4866 }
4867
4868 // Name returns the semantic convention name of the instrument.
4869 func (NodeMemoryAvailable) Name() string {
4870 return "k8s.node.memory.available"
4871 }
4872
4873 // Unit returns the semantic convention unit of the instrument
4874 func (NodeMemoryAvailable) Unit() string {
4875 return "By"
4876 }
4877
4878 // Description returns the semantic convention description of the instrument
4879 func (NodeMemoryAvailable) Description() string {
4880 return "Node memory available."
4881 }
4882
4883 // Add adds incr to the existing count for attrs.
4884 //
4885 // Available memory for use. This is defined as the memory limit -
4886 // workingSetBytes. If memory limit is undefined, the available bytes is omitted.
4887 // This metric is derived from the [MemoryStats.AvailableBytes] field of the
4888 // [NodeStats.Memory] of the Kubelet's stats API.
4889 //
4890 // [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
4891 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4892 func (m NodeMemoryAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
4893 if len(attrs) == 0 {
4894 m.Int64UpDownCounter.Add(ctx, incr)
4895 return
4896 }
4897
4898 o := addOptPool.Get().(*[]metric.AddOption)
4899 defer func() {
4900 *o = (*o)[:0]
4901 addOptPool.Put(o)
4902 }()
4903
4904 *o = append(*o, metric.WithAttributes(attrs...))
4905 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4906 }
4907
4908 // AddSet adds incr to the existing count for set.
4909 //
4910 // Available memory for use. This is defined as the memory limit -
4911 // workingSetBytes. If memory limit is undefined, the available bytes is omitted.
4912 // This metric is derived from the [MemoryStats.AvailableBytes] field of the
4913 // [NodeStats.Memory] of the Kubelet's stats API.
4914 //
4915 // [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
4916 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
4917 func (m NodeMemoryAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
4918 if set.Len() == 0 {
4919 m.Int64UpDownCounter.Add(ctx, incr)
4920 return
4921 }
4922
4923 o := addOptPool.Get().(*[]metric.AddOption)
4924 defer func() {
4925 *o = (*o)[:0]
4926 addOptPool.Put(o)
4927 }()
4928
4929 *o = append(*o, metric.WithAttributeSet(set))
4930 m.Int64UpDownCounter.Add(ctx, incr, *o...)
4931 }
4932
4933 // NodeMemoryPagingFaults is an instrument used to record metric values
4934 // conforming to the "k8s.node.memory.paging.faults" semantic conventions. It
4935 // represents the node memory paging faults.
4936 type NodeMemoryPagingFaults struct {
4937 metric.Int64Counter
4938 }
4939
4940 var newNodeMemoryPagingFaultsOpts = []metric.Int64CounterOption{
4941 metric.WithDescription("Node memory paging faults."),
4942 metric.WithUnit("{fault}"),
4943 }
4944
4945 // NewNodeMemoryPagingFaults returns a new NodeMemoryPagingFaults instrument.
4946 func NewNodeMemoryPagingFaults(
4947 m metric.Meter,
4948 opt ...metric.Int64CounterOption,
4949 ) (NodeMemoryPagingFaults, error) {
4950 // Check if the meter is nil.
4951 if m == nil {
4952 return NodeMemoryPagingFaults{noop.Int64Counter{}}, nil
4953 }
4954
4955 if len(opt) == 0 {
4956 opt = newNodeMemoryPagingFaultsOpts
4957 } else {
4958 opt = append(opt, newNodeMemoryPagingFaultsOpts...)
4959 }
4960
4961 i, err := m.Int64Counter(
4962 "k8s.node.memory.paging.faults",
4963 opt...,
4964 )
4965 if err != nil {
4966 return NodeMemoryPagingFaults{noop.Int64Counter{}}, err
4967 }
4968 return NodeMemoryPagingFaults{i}, nil
4969 }
4970
4971 // Inst returns the underlying metric instrument.
4972 func (m NodeMemoryPagingFaults) Inst() metric.Int64Counter {
4973 return m.Int64Counter
4974 }
4975
4976 // Name returns the semantic convention name of the instrument.
4977 func (NodeMemoryPagingFaults) Name() string {
4978 return "k8s.node.memory.paging.faults"
4979 }
4980
4981 // Unit returns the semantic convention unit of the instrument
4982 func (NodeMemoryPagingFaults) Unit() string {
4983 return "{fault}"
4984 }
4985
4986 // Description returns the semantic convention description of the instrument
4987 func (NodeMemoryPagingFaults) Description() string {
4988 return "Node memory paging faults."
4989 }
4990
4991 // Add adds incr to the existing count for attrs.
4992 //
4993 // All additional attrs passed are included in the recorded value.
4994 //
4995 // Cumulative number of major/minor page faults.
4996 // This metric is derived from the [MemoryStats.PageFaults] and
4997 // [MemoryStats.MajorPageFaults] fields of the [NodeStats.Memory] of the
4998 // Kubelet's stats API.
4999 //
5000 // [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5001 // [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5002 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
5003 func (m NodeMemoryPagingFaults) Add(
5004 ctx context.Context,
5005 incr int64,
5006 attrs ...attribute.KeyValue,
5007 ) {
5008 if len(attrs) == 0 {
5009 m.Int64Counter.Add(ctx, incr)
5010 return
5011 }
5012
5013 o := addOptPool.Get().(*[]metric.AddOption)
5014 defer func() {
5015 *o = (*o)[:0]
5016 addOptPool.Put(o)
5017 }()
5018
5019 *o = append(
5020 *o,
5021 metric.WithAttributes(
5022 attrs...,
5023 ),
5024 )
5025
5026 m.Int64Counter.Add(ctx, incr, *o...)
5027 }
5028
5029 // AddSet adds incr to the existing count for set.
5030 //
5031 // Cumulative number of major/minor page faults.
5032 // This metric is derived from the [MemoryStats.PageFaults] and
5033 // [MemoryStats.MajorPageFaults] fields of the [NodeStats.Memory] of the
5034 // Kubelet's stats API.
5035 //
5036 // [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5037 // [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5038 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
5039 func (m NodeMemoryPagingFaults) AddSet(ctx context.Context, incr int64, set attribute.Set) {
5040 if set.Len() == 0 {
5041 m.Int64Counter.Add(ctx, incr)
5042 return
5043 }
5044
5045 o := addOptPool.Get().(*[]metric.AddOption)
5046 defer func() {
5047 *o = (*o)[:0]
5048 addOptPool.Put(o)
5049 }()
5050
5051 *o = append(*o, metric.WithAttributeSet(set))
5052 m.Int64Counter.Add(ctx, incr, *o...)
5053 }
5054
5055 // AttrSystemPagingFaultType returns an optional attribute for the
5056 // "system.paging.fault.type" semantic convention. It represents the paging fault
5057 // type.
5058 func (NodeMemoryPagingFaults) AttrSystemPagingFaultType(val SystemPagingFaultTypeAttr) attribute.KeyValue {
5059 return attribute.String("system.paging.fault.type", string(val))
5060 }
5061
5062 // NodeMemoryRss is an instrument used to record metric values conforming to the
5063 // "k8s.node.memory.rss" semantic conventions. It represents the node memory RSS.
5064 type NodeMemoryRss struct {
5065 metric.Int64UpDownCounter
5066 }
5067
5068 var newNodeMemoryRssOpts = []metric.Int64UpDownCounterOption{
5069 metric.WithDescription("Node memory RSS."),
5070 metric.WithUnit("By"),
5071 }
5072
5073 // NewNodeMemoryRss returns a new NodeMemoryRss instrument.
5074 func NewNodeMemoryRss(
5075 m metric.Meter,
5076 opt ...metric.Int64UpDownCounterOption,
5077 ) (NodeMemoryRss, error) {
5078 // Check if the meter is nil.
5079 if m == nil {
5080 return NodeMemoryRss{noop.Int64UpDownCounter{}}, nil
5081 }
5082
5083 if len(opt) == 0 {
5084 opt = newNodeMemoryRssOpts
5085 } else {
5086 opt = append(opt, newNodeMemoryRssOpts...)
5087 }
5088
5089 i, err := m.Int64UpDownCounter(
5090 "k8s.node.memory.rss",
5091 opt...,
5092 )
5093 if err != nil {
5094 return NodeMemoryRss{noop.Int64UpDownCounter{}}, err
5095 }
5096 return NodeMemoryRss{i}, nil
5097 }
5098
5099 // Inst returns the underlying metric instrument.
5100 func (m NodeMemoryRss) Inst() metric.Int64UpDownCounter {
5101 return m.Int64UpDownCounter
5102 }
5103
5104 // Name returns the semantic convention name of the instrument.
5105 func (NodeMemoryRss) Name() string {
5106 return "k8s.node.memory.rss"
5107 }
5108
5109 // Unit returns the semantic convention unit of the instrument
5110 func (NodeMemoryRss) Unit() string {
5111 return "By"
5112 }
5113
5114 // Description returns the semantic convention description of the instrument
5115 func (NodeMemoryRss) Description() string {
5116 return "Node memory RSS."
5117 }
5118
5119 // Add adds incr to the existing count for attrs.
5120 //
5121 // The amount of anonymous and swap cache memory (includes transparent
5122 // hugepages).
5123 // This metric is derived from the [MemoryStats.RSSBytes] field of the
5124 // [NodeStats.Memory] of the Kubelet's stats API.
5125 //
5126 // [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5127 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
5128 func (m NodeMemoryRss) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
5129 if len(attrs) == 0 {
5130 m.Int64UpDownCounter.Add(ctx, incr)
5131 return
5132 }
5133
5134 o := addOptPool.Get().(*[]metric.AddOption)
5135 defer func() {
5136 *o = (*o)[:0]
5137 addOptPool.Put(o)
5138 }()
5139
5140 *o = append(*o, metric.WithAttributes(attrs...))
5141 m.Int64UpDownCounter.Add(ctx, incr, *o...)
5142 }
5143
5144 // AddSet adds incr to the existing count for set.
5145 //
5146 // The amount of anonymous and swap cache memory (includes transparent
5147 // hugepages).
5148 // This metric is derived from the [MemoryStats.RSSBytes] field of the
5149 // [NodeStats.Memory] of the Kubelet's stats API.
5150 //
5151 // [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5152 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
5153 func (m NodeMemoryRss) AddSet(ctx context.Context, incr int64, set attribute.Set) {
5154 if set.Len() == 0 {
5155 m.Int64UpDownCounter.Add(ctx, incr)
5156 return
5157 }
5158
5159 o := addOptPool.Get().(*[]metric.AddOption)
5160 defer func() {
5161 *o = (*o)[:0]
5162 addOptPool.Put(o)
5163 }()
5164
5165 *o = append(*o, metric.WithAttributeSet(set))
5166 m.Int64UpDownCounter.Add(ctx, incr, *o...)
5167 }
5168
5169 // NodeMemoryUsage is an instrument used to record metric values conforming to
5170 // the "k8s.node.memory.usage" semantic conventions. It represents the memory
5171 // usage of the Node.
5172 type NodeMemoryUsage struct {
5173 metric.Int64Gauge
5174 }
5175
5176 var newNodeMemoryUsageOpts = []metric.Int64GaugeOption{
5177 metric.WithDescription("Memory usage of the Node."),
5178 metric.WithUnit("By"),
5179 }
5180
5181 // NewNodeMemoryUsage returns a new NodeMemoryUsage instrument.
5182 func NewNodeMemoryUsage(
5183 m metric.Meter,
5184 opt ...metric.Int64GaugeOption,
5185 ) (NodeMemoryUsage, error) {
5186 // Check if the meter is nil.
5187 if m == nil {
5188 return NodeMemoryUsage{noop.Int64Gauge{}}, nil
5189 }
5190
5191 if len(opt) == 0 {
5192 opt = newNodeMemoryUsageOpts
5193 } else {
5194 opt = append(opt, newNodeMemoryUsageOpts...)
5195 }
5196
5197 i, err := m.Int64Gauge(
5198 "k8s.node.memory.usage",
5199 opt...,
5200 )
5201 if err != nil {
5202 return NodeMemoryUsage{noop.Int64Gauge{}}, err
5203 }
5204 return NodeMemoryUsage{i}, nil
5205 }
5206
5207 // Inst returns the underlying metric instrument.
5208 func (m NodeMemoryUsage) Inst() metric.Int64Gauge {
5209 return m.Int64Gauge
5210 }
5211
5212 // Name returns the semantic convention name of the instrument.
5213 func (NodeMemoryUsage) Name() string {
5214 return "k8s.node.memory.usage"
5215 }
5216
5217 // Unit returns the semantic convention unit of the instrument
5218 func (NodeMemoryUsage) Unit() string {
5219 return "By"
5220 }
5221
5222 // Description returns the semantic convention description of the instrument
5223 func (NodeMemoryUsage) Description() string {
5224 return "Memory usage of the Node."
5225 }
5226
5227 // Record records val to the current distribution for attrs.
5228 //
5229 // Total memory usage of the Node
5230 func (m NodeMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
5231 if len(attrs) == 0 {
5232 m.Int64Gauge.Record(ctx, val)
5233 return
5234 }
5235
5236 o := recOptPool.Get().(*[]metric.RecordOption)
5237 defer func() {
5238 *o = (*o)[:0]
5239 recOptPool.Put(o)
5240 }()
5241
5242 *o = append(*o, metric.WithAttributes(attrs...))
5243 m.Int64Gauge.Record(ctx, val, *o...)
5244 }
5245
5246 // RecordSet records val to the current distribution for set.
5247 //
5248 // Total memory usage of the Node
5249 func (m NodeMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) {
5250 if set.Len() == 0 {
5251 m.Int64Gauge.Record(ctx, val)
5252 return
5253 }
5254
5255 o := recOptPool.Get().(*[]metric.RecordOption)
5256 defer func() {
5257 *o = (*o)[:0]
5258 recOptPool.Put(o)
5259 }()
5260
5261 *o = append(*o, metric.WithAttributeSet(set))
5262 m.Int64Gauge.Record(ctx, val, *o...)
5263 }
5264
5265 // NodeMemoryWorkingSet is an instrument used to record metric values conforming
5266 // to the "k8s.node.memory.working_set" semantic conventions. It represents the
5267 // node memory working set.
5268 type NodeMemoryWorkingSet struct {
5269 metric.Int64UpDownCounter
5270 }
5271
5272 var newNodeMemoryWorkingSetOpts = []metric.Int64UpDownCounterOption{
5273 metric.WithDescription("Node memory working set."),
5274 metric.WithUnit("By"),
5275 }
5276
5277 // NewNodeMemoryWorkingSet returns a new NodeMemoryWorkingSet instrument.
5278 func NewNodeMemoryWorkingSet(
5279 m metric.Meter,
5280 opt ...metric.Int64UpDownCounterOption,
5281 ) (NodeMemoryWorkingSet, error) {
5282 // Check if the meter is nil.
5283 if m == nil {
5284 return NodeMemoryWorkingSet{noop.Int64UpDownCounter{}}, nil
5285 }
5286
5287 if len(opt) == 0 {
5288 opt = newNodeMemoryWorkingSetOpts
5289 } else {
5290 opt = append(opt, newNodeMemoryWorkingSetOpts...)
5291 }
5292
5293 i, err := m.Int64UpDownCounter(
5294 "k8s.node.memory.working_set",
5295 opt...,
5296 )
5297 if err != nil {
5298 return NodeMemoryWorkingSet{noop.Int64UpDownCounter{}}, err
5299 }
5300 return NodeMemoryWorkingSet{i}, nil
5301 }
5302
5303 // Inst returns the underlying metric instrument.
5304 func (m NodeMemoryWorkingSet) Inst() metric.Int64UpDownCounter {
5305 return m.Int64UpDownCounter
5306 }
5307
5308 // Name returns the semantic convention name of the instrument.
5309 func (NodeMemoryWorkingSet) Name() string {
5310 return "k8s.node.memory.working_set"
5311 }
5312
5313 // Unit returns the semantic convention unit of the instrument
5314 func (NodeMemoryWorkingSet) Unit() string {
5315 return "By"
5316 }
5317
5318 // Description returns the semantic convention description of the instrument
5319 func (NodeMemoryWorkingSet) Description() string {
5320 return "Node memory working set."
5321 }
5322
5323 // Add adds incr to the existing count for attrs.
5324 //
5325 // The amount of working set memory. This includes recently accessed memory,
5326 // dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes.
5327 // This metric is derived from the [MemoryStats.WorkingSetBytes] field of the
5328 // [NodeStats.Memory] of the Kubelet's stats API.
5329 //
5330 // [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5331 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
5332 func (m NodeMemoryWorkingSet) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
5333 if len(attrs) == 0 {
5334 m.Int64UpDownCounter.Add(ctx, incr)
5335 return
5336 }
5337
5338 o := addOptPool.Get().(*[]metric.AddOption)
5339 defer func() {
5340 *o = (*o)[:0]
5341 addOptPool.Put(o)
5342 }()
5343
5344 *o = append(*o, metric.WithAttributes(attrs...))
5345 m.Int64UpDownCounter.Add(ctx, incr, *o...)
5346 }
5347
5348 // AddSet adds incr to the existing count for set.
5349 //
5350 // The amount of working set memory. This includes recently accessed memory,
5351 // dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes.
5352 // This metric is derived from the [MemoryStats.WorkingSetBytes] field of the
5353 // [NodeStats.Memory] of the Kubelet's stats API.
5354 //
5355 // [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
5356 // [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats
5357 func (m NodeMemoryWorkingSet) AddSet(ctx context.Context, incr int64, set attribute.Set) {
5358 if set.Len() == 0 {
5359 m.Int64UpDownCounter.Add(ctx, incr)
5360 return
5361 }
5362
5363 o := addOptPool.Get().(*[]metric.AddOption)
5364 defer func() {
5365 *o = (*o)[:0]
5366 addOptPool.Put(o)
5367 }()
5368
5369 *o = append(*o, metric.WithAttributeSet(set))
5370 m.Int64UpDownCounter.Add(ctx, incr, *o...)
5371 }
5372
5373 // NodeNetworkErrors is an instrument used to record metric values conforming to
5374 // the "k8s.node.network.errors" semantic conventions. It represents the node
5375 // network errors.
5376 type NodeNetworkErrors struct {
5377 metric.Int64Counter
5378 }
5379
5380 var newNodeNetworkErrorsOpts = []metric.Int64CounterOption{
5381 metric.WithDescription("Node network errors."),
5382 metric.WithUnit("{error}"),
5383 }
5384
5385 // NewNodeNetworkErrors returns a new NodeNetworkErrors instrument.
5386 func NewNodeNetworkErrors(
5387 m metric.Meter,
5388 opt ...metric.Int64CounterOption,
5389 ) (NodeNetworkErrors, error) {
5390 // Check if the meter is nil.
5391 if m == nil {
5392 return NodeNetworkErrors{noop.Int64Counter{}}, nil
5393 }
5394
5395 if len(opt) == 0 {
5396 opt = newNodeNetworkErrorsOpts
5397 } else {
5398 opt = append(opt, newNodeNetworkErrorsOpts...)
5399 }
5400
5401 i, err := m.Int64Counter(
5402 "k8s.node.network.errors",
5403 opt...,
5404 )
5405 if err != nil {
5406 return NodeNetworkErrors{noop.Int64Counter{}}, err
5407 }
5408 return NodeNetworkErrors{i}, nil
5409 }
5410
5411 // Inst returns the underlying metric instrument.
5412 func (m NodeNetworkErrors) Inst() metric.Int64Counter {
5413 return m.Int64Counter
5414 }
5415
5416 // Name returns the semantic convention name of the instrument.
5417 func (NodeNetworkErrors) Name() string {
5418 return "k8s.node.network.errors"
5419 }
5420
5421 // Unit returns the semantic convention unit of the instrument
5422 func (NodeNetworkErrors) Unit() string {
5423 return "{error}"
5424 }
5425
5426 // Description returns the semantic convention description of the instrument
5427 func (NodeNetworkErrors) Description() string {
5428 return "Node network errors."
5429 }
5430
5431 // Add adds incr to the existing count for attrs.
5432 //
5433 // All additional attrs passed are included in the recorded value.
5434 func (m NodeNetworkErrors) Add(
5435 ctx context.Context,
5436 incr int64,
5437 attrs ...attribute.KeyValue,
5438 ) {
5439 if len(attrs) == 0 {
5440 m.Int64Counter.Add(ctx, incr)
5441 return
5442 }
5443
5444 o := addOptPool.Get().(*[]metric.AddOption)
5445 defer func() {
5446 *o = (*o)[:0]
5447 addOptPool.Put(o)
5448 }()
5449
5450 *o = append(
5451 *o,
5452 metric.WithAttributes(
5453 attrs...,
5454 ),
5455 )
5456
5457 m.Int64Counter.Add(ctx, incr, *o...)
5458 }
5459
5460 // AddSet adds incr to the existing count for set.
5461 func (m NodeNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) {
5462 if set.Len() == 0 {
5463 m.Int64Counter.Add(ctx, incr)
5464 return
5465 }
5466
5467 o := addOptPool.Get().(*[]metric.AddOption)
5468 defer func() {
5469 *o = (*o)[:0]
5470 addOptPool.Put(o)
5471 }()
5472
5473 *o = append(*o, metric.WithAttributeSet(set))
5474 m.Int64Counter.Add(ctx, incr, *o...)
5475 }
5476
5477 // AttrNetworkInterfaceName returns an optional attribute for the
5478 // "network.interface.name" semantic convention. It represents the network
5479 // interface name.
5480 func (NodeNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue {
5481 return attribute.String("network.interface.name", val)
5482 }
5483
5484 // AttrNetworkIODirection returns an optional attribute for the
5485 // "network.io.direction" semantic convention. It represents the network IO
5486 // operation direction.
5487 func (NodeNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
5488 return attribute.String("network.io.direction", string(val))
5489 }
5490
5491 // NodeNetworkIO is an instrument used to record metric values conforming to the
5492 // "k8s.node.network.io" semantic conventions. It represents the network bytes
5493 // for the Node.
5494 type NodeNetworkIO struct {
5495 metric.Int64Counter
5496 }
5497
5498 var newNodeNetworkIOOpts = []metric.Int64CounterOption{
5499 metric.WithDescription("Network bytes for the Node."),
5500 metric.WithUnit("By"),
5501 }
5502
5503 // NewNodeNetworkIO returns a new NodeNetworkIO instrument.
5504 func NewNodeNetworkIO(
5505 m metric.Meter,
5506 opt ...metric.Int64CounterOption,
5507 ) (NodeNetworkIO, error) {
5508 // Check if the meter is nil.
5509 if m == nil {
5510 return NodeNetworkIO{noop.Int64Counter{}}, nil
5511 }
5512
5513 if len(opt) == 0 {
5514 opt = newNodeNetworkIOOpts
5515 } else {
5516 opt = append(opt, newNodeNetworkIOOpts...)
5517 }
5518
5519 i, err := m.Int64Counter(
5520 "k8s.node.network.io",
5521 opt...,
5522 )
5523 if err != nil {
5524 return NodeNetworkIO{noop.Int64Counter{}}, err
5525 }
5526 return NodeNetworkIO{i}, nil
5527 }
5528
5529 // Inst returns the underlying metric instrument.
5530 func (m NodeNetworkIO) Inst() metric.Int64Counter {
5531 return m.Int64Counter
5532 }
5533
5534 // Name returns the semantic convention name of the instrument.
5535 func (NodeNetworkIO) Name() string {
5536 return "k8s.node.network.io"
5537 }
5538
5539 // Unit returns the semantic convention unit of the instrument
5540 func (NodeNetworkIO) Unit() string {
5541 return "By"
5542 }
5543
5544 // Description returns the semantic convention description of the instrument
5545 func (NodeNetworkIO) Description() string {
5546 return "Network bytes for the Node."
5547 }
5548
5549 // Add adds incr to the existing count for attrs.
5550 //
5551 // All additional attrs passed are included in the recorded value.
5552 func (m NodeNetworkIO) Add(
5553 ctx context.Context,
5554 incr int64,
5555 attrs ...attribute.KeyValue,
5556 ) {
5557 if len(attrs) == 0 {
5558 m.Int64Counter.Add(ctx, incr)
5559 return
5560 }
5561
5562 o := addOptPool.Get().(*[]metric.AddOption)
5563 defer func() {
5564 *o = (*o)[:0]
5565 addOptPool.Put(o)
5566 }()
5567
5568 *o = append(
5569 *o,
5570 metric.WithAttributes(
5571 attrs...,
5572 ),
5573 )
5574
5575 m.Int64Counter.Add(ctx, incr, *o...)
5576 }
5577
5578 // AddSet adds incr to the existing count for set.
5579 func (m NodeNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) {
5580 if set.Len() == 0 {
5581 m.Int64Counter.Add(ctx, incr)
5582 return
5583 }
5584
5585 o := addOptPool.Get().(*[]metric.AddOption)
5586 defer func() {
5587 *o = (*o)[:0]
5588 addOptPool.Put(o)
5589 }()
5590
5591 *o = append(*o, metric.WithAttributeSet(set))
5592 m.Int64Counter.Add(ctx, incr, *o...)
5593 }
5594
5595 // AttrNetworkInterfaceName returns an optional attribute for the
5596 // "network.interface.name" semantic convention. It represents the network
5597 // interface name.
5598 func (NodeNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue {
5599 return attribute.String("network.interface.name", val)
5600 }
5601
5602 // AttrNetworkIODirection returns an optional attribute for the
5603 // "network.io.direction" semantic convention. It represents the network IO
5604 // operation direction.
5605 func (NodeNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
5606 return attribute.String("network.io.direction", string(val))
5607 }
5608
5609 // NodePodAllocatable is an instrument used to record metric values conforming to
5610 // the "k8s.node.pod.allocatable" semantic conventions. It represents the amount
5611 // of pods allocatable on the node.
5612 type NodePodAllocatable struct {
5613 metric.Int64UpDownCounter
5614 }
5615
5616 var newNodePodAllocatableOpts = []metric.Int64UpDownCounterOption{
5617 metric.WithDescription("Amount of pods allocatable on the node."),
5618 metric.WithUnit("{pod}"),
5619 }
5620
5621 // NewNodePodAllocatable returns a new NodePodAllocatable instrument.
5622 func NewNodePodAllocatable(
5623 m metric.Meter,
5624 opt ...metric.Int64UpDownCounterOption,
5625 ) (NodePodAllocatable, error) {
5626 // Check if the meter is nil.
5627 if m == nil {
5628 return NodePodAllocatable{noop.Int64UpDownCounter{}}, nil
5629 }
5630
5631 if len(opt) == 0 {
5632 opt = newNodePodAllocatableOpts
5633 } else {
5634 opt = append(opt, newNodePodAllocatableOpts...)
5635 }
5636
5637 i, err := m.Int64UpDownCounter(
5638 "k8s.node.pod.allocatable",
5639 opt...,
5640 )
5641 if err != nil {
5642 return NodePodAllocatable{noop.Int64UpDownCounter{}}, err
5643 }
5644 return NodePodAllocatable{i}, nil
5645 }
5646
5647 // Inst returns the underlying metric instrument.
5648 func (m NodePodAllocatable) Inst() metric.Int64UpDownCounter {
5649 return m.Int64UpDownCounter
5650 }
5651
5652 // Name returns the semantic convention name of the instrument.
5653 func (NodePodAllocatable) Name() string {
5654 return "k8s.node.pod.allocatable"
5655 }
5656
5657 // Unit returns the semantic convention unit of the instrument
5658 func (NodePodAllocatable) Unit() string {
5659 return "{pod}"
5660 }
5661
5662 // Description returns the semantic convention description of the instrument
5663 func (NodePodAllocatable) Description() string {
5664 return "Amount of pods allocatable on the node."
5665 }
5666
5667 // Add adds incr to the existing count for attrs.
5668 func (m NodePodAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
5669 if len(attrs) == 0 {
5670 m.Int64UpDownCounter.Add(ctx, incr)
5671 return
5672 }
5673
5674 o := addOptPool.Get().(*[]metric.AddOption)
5675 defer func() {
5676 *o = (*o)[:0]
5677 addOptPool.Put(o)
5678 }()
5679
5680 *o = append(*o, metric.WithAttributes(attrs...))
5681 m.Int64UpDownCounter.Add(ctx, incr, *o...)
5682 }
5683
5684 // AddSet adds incr to the existing count for set.
5685 func (m NodePodAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
5686 if set.Len() == 0 {
5687 m.Int64UpDownCounter.Add(ctx, incr)
5688 return
5689 }
5690
5691 o := addOptPool.Get().(*[]metric.AddOption)
5692 defer func() {
5693 *o = (*o)[:0]
5694 addOptPool.Put(o)
5695 }()
5696
5697 *o = append(*o, metric.WithAttributeSet(set))
5698 m.Int64UpDownCounter.Add(ctx, incr, *o...)
5699 }
5700
5701 // NodeUptime is an instrument used to record metric values conforming to the
5702 // "k8s.node.uptime" semantic conventions. It represents the time the Node has
5703 // been running.
5704 type NodeUptime struct {
5705 metric.Float64Gauge
5706 }
5707
5708 var newNodeUptimeOpts = []metric.Float64GaugeOption{
5709 metric.WithDescription("The time the Node has been running."),
5710 metric.WithUnit("s"),
5711 }
5712
5713 // NewNodeUptime returns a new NodeUptime instrument.
5714 func NewNodeUptime(
5715 m metric.Meter,
5716 opt ...metric.Float64GaugeOption,
5717 ) (NodeUptime, error) {
5718 // Check if the meter is nil.
5719 if m == nil {
5720 return NodeUptime{noop.Float64Gauge{}}, nil
5721 }
5722
5723 if len(opt) == 0 {
5724 opt = newNodeUptimeOpts
5725 } else {
5726 opt = append(opt, newNodeUptimeOpts...)
5727 }
5728
5729 i, err := m.Float64Gauge(
5730 "k8s.node.uptime",
5731 opt...,
5732 )
5733 if err != nil {
5734 return NodeUptime{noop.Float64Gauge{}}, err
5735 }
5736 return NodeUptime{i}, nil
5737 }
5738
5739 // Inst returns the underlying metric instrument.
5740 func (m NodeUptime) Inst() metric.Float64Gauge {
5741 return m.Float64Gauge
5742 }
5743
5744 // Name returns the semantic convention name of the instrument.
5745 func (NodeUptime) Name() string {
5746 return "k8s.node.uptime"
5747 }
5748
5749 // Unit returns the semantic convention unit of the instrument
5750 func (NodeUptime) Unit() string {
5751 return "s"
5752 }
5753
5754 // Description returns the semantic convention description of the instrument
5755 func (NodeUptime) Description() string {
5756 return "The time the Node has been running."
5757 }
5758
5759 // Record records val to the current distribution for attrs.
5760 //
5761 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
5762 // seconds as a floating point number with the highest precision available.
5763 // The actual accuracy would depend on the instrumentation and operating system.
5764 func (m NodeUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
5765 if len(attrs) == 0 {
5766 m.Float64Gauge.Record(ctx, val)
5767 return
5768 }
5769
5770 o := recOptPool.Get().(*[]metric.RecordOption)
5771 defer func() {
5772 *o = (*o)[:0]
5773 recOptPool.Put(o)
5774 }()
5775
5776 *o = append(*o, metric.WithAttributes(attrs...))
5777 m.Float64Gauge.Record(ctx, val, *o...)
5778 }
5779
5780 // RecordSet records val to the current distribution for set.
5781 //
5782 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
5783 // seconds as a floating point number with the highest precision available.
5784 // The actual accuracy would depend on the instrumentation and operating system.
5785 func (m NodeUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) {
5786 if set.Len() == 0 {
5787 m.Float64Gauge.Record(ctx, val)
5788 return
5789 }
5790
5791 o := recOptPool.Get().(*[]metric.RecordOption)
5792 defer func() {
5793 *o = (*o)[:0]
5794 recOptPool.Put(o)
5795 }()
5796
5797 *o = append(*o, metric.WithAttributeSet(set))
5798 m.Float64Gauge.Record(ctx, val, *o...)
5799 }
5800
5801 // PodCPUTime is an instrument used to record metric values conforming to the
5802 // "k8s.pod.cpu.time" semantic conventions. It represents the total CPU time
5803 // consumed.
5804 type PodCPUTime struct {
5805 metric.Float64Counter
5806 }
5807
5808 var newPodCPUTimeOpts = []metric.Float64CounterOption{
5809 metric.WithDescription("Total CPU time consumed."),
5810 metric.WithUnit("s"),
5811 }
5812
5813 // NewPodCPUTime returns a new PodCPUTime instrument.
5814 func NewPodCPUTime(
5815 m metric.Meter,
5816 opt ...metric.Float64CounterOption,
5817 ) (PodCPUTime, error) {
5818 // Check if the meter is nil.
5819 if m == nil {
5820 return PodCPUTime{noop.Float64Counter{}}, nil
5821 }
5822
5823 if len(opt) == 0 {
5824 opt = newPodCPUTimeOpts
5825 } else {
5826 opt = append(opt, newPodCPUTimeOpts...)
5827 }
5828
5829 i, err := m.Float64Counter(
5830 "k8s.pod.cpu.time",
5831 opt...,
5832 )
5833 if err != nil {
5834 return PodCPUTime{noop.Float64Counter{}}, err
5835 }
5836 return PodCPUTime{i}, nil
5837 }
5838
5839 // Inst returns the underlying metric instrument.
5840 func (m PodCPUTime) Inst() metric.Float64Counter {
5841 return m.Float64Counter
5842 }
5843
5844 // Name returns the semantic convention name of the instrument.
5845 func (PodCPUTime) Name() string {
5846 return "k8s.pod.cpu.time"
5847 }
5848
5849 // Unit returns the semantic convention unit of the instrument
5850 func (PodCPUTime) Unit() string {
5851 return "s"
5852 }
5853
5854 // Description returns the semantic convention description of the instrument
5855 func (PodCPUTime) Description() string {
5856 return "Total CPU time consumed."
5857 }
5858
5859 // Add adds incr to the existing count for attrs.
5860 //
5861 // Total CPU time consumed by the specific Pod on all available CPU cores
5862 func (m PodCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
5863 if len(attrs) == 0 {
5864 m.Float64Counter.Add(ctx, incr)
5865 return
5866 }
5867
5868 o := addOptPool.Get().(*[]metric.AddOption)
5869 defer func() {
5870 *o = (*o)[:0]
5871 addOptPool.Put(o)
5872 }()
5873
5874 *o = append(*o, metric.WithAttributes(attrs...))
5875 m.Float64Counter.Add(ctx, incr, *o...)
5876 }
5877
5878 // AddSet adds incr to the existing count for set.
5879 //
5880 // Total CPU time consumed by the specific Pod on all available CPU cores
5881 func (m PodCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) {
5882 if set.Len() == 0 {
5883 m.Float64Counter.Add(ctx, incr)
5884 return
5885 }
5886
5887 o := addOptPool.Get().(*[]metric.AddOption)
5888 defer func() {
5889 *o = (*o)[:0]
5890 addOptPool.Put(o)
5891 }()
5892
5893 *o = append(*o, metric.WithAttributeSet(set))
5894 m.Float64Counter.Add(ctx, incr, *o...)
5895 }
5896
5897 // PodCPUUsage is an instrument used to record metric values conforming to the
5898 // "k8s.pod.cpu.usage" semantic conventions. It represents the pod's CPU usage,
5899 // measured in cpus. Range from 0 to the number of allocatable CPUs.
5900 type PodCPUUsage struct {
5901 metric.Int64Gauge
5902 }
5903
5904 var newPodCPUUsageOpts = []metric.Int64GaugeOption{
5905 metric.WithDescription("Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."),
5906 metric.WithUnit("{cpu}"),
5907 }
5908
5909 // NewPodCPUUsage returns a new PodCPUUsage instrument.
5910 func NewPodCPUUsage(
5911 m metric.Meter,
5912 opt ...metric.Int64GaugeOption,
5913 ) (PodCPUUsage, error) {
5914 // Check if the meter is nil.
5915 if m == nil {
5916 return PodCPUUsage{noop.Int64Gauge{}}, nil
5917 }
5918
5919 if len(opt) == 0 {
5920 opt = newPodCPUUsageOpts
5921 } else {
5922 opt = append(opt, newPodCPUUsageOpts...)
5923 }
5924
5925 i, err := m.Int64Gauge(
5926 "k8s.pod.cpu.usage",
5927 opt...,
5928 )
5929 if err != nil {
5930 return PodCPUUsage{noop.Int64Gauge{}}, err
5931 }
5932 return PodCPUUsage{i}, nil
5933 }
5934
5935 // Inst returns the underlying metric instrument.
5936 func (m PodCPUUsage) Inst() metric.Int64Gauge {
5937 return m.Int64Gauge
5938 }
5939
5940 // Name returns the semantic convention name of the instrument.
5941 func (PodCPUUsage) Name() string {
5942 return "k8s.pod.cpu.usage"
5943 }
5944
5945 // Unit returns the semantic convention unit of the instrument
5946 func (PodCPUUsage) Unit() string {
5947 return "{cpu}"
5948 }
5949
5950 // Description returns the semantic convention description of the instrument
5951 func (PodCPUUsage) Description() string {
5952 return "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."
5953 }
5954
5955 // Record records val to the current distribution for attrs.
5956 //
5957 // CPU usage of the specific Pod on all available CPU cores, averaged over the
5958 // sample window
5959 func (m PodCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
5960 if len(attrs) == 0 {
5961 m.Int64Gauge.Record(ctx, val)
5962 return
5963 }
5964
5965 o := recOptPool.Get().(*[]metric.RecordOption)
5966 defer func() {
5967 *o = (*o)[:0]
5968 recOptPool.Put(o)
5969 }()
5970
5971 *o = append(*o, metric.WithAttributes(attrs...))
5972 m.Int64Gauge.Record(ctx, val, *o...)
5973 }
5974
5975 // RecordSet records val to the current distribution for set.
5976 //
5977 // CPU usage of the specific Pod on all available CPU cores, averaged over the
5978 // sample window
5979 func (m PodCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) {
5980 if set.Len() == 0 {
5981 m.Int64Gauge.Record(ctx, val)
5982 return
5983 }
5984
5985 o := recOptPool.Get().(*[]metric.RecordOption)
5986 defer func() {
5987 *o = (*o)[:0]
5988 recOptPool.Put(o)
5989 }()
5990
5991 *o = append(*o, metric.WithAttributeSet(set))
5992 m.Int64Gauge.Record(ctx, val, *o...)
5993 }
5994
5995 // PodFilesystemAvailable is an instrument used to record metric values
5996 // conforming to the "k8s.pod.filesystem.available" semantic conventions. It
5997 // represents the pod filesystem available bytes.
5998 type PodFilesystemAvailable struct {
5999 metric.Int64UpDownCounter
6000 }
6001
6002 var newPodFilesystemAvailableOpts = []metric.Int64UpDownCounterOption{
6003 metric.WithDescription("Pod filesystem available bytes."),
6004 metric.WithUnit("By"),
6005 }
6006
6007 // NewPodFilesystemAvailable returns a new PodFilesystemAvailable instrument.
6008 func NewPodFilesystemAvailable(
6009 m metric.Meter,
6010 opt ...metric.Int64UpDownCounterOption,
6011 ) (PodFilesystemAvailable, error) {
6012 // Check if the meter is nil.
6013 if m == nil {
6014 return PodFilesystemAvailable{noop.Int64UpDownCounter{}}, nil
6015 }
6016
6017 if len(opt) == 0 {
6018 opt = newPodFilesystemAvailableOpts
6019 } else {
6020 opt = append(opt, newPodFilesystemAvailableOpts...)
6021 }
6022
6023 i, err := m.Int64UpDownCounter(
6024 "k8s.pod.filesystem.available",
6025 opt...,
6026 )
6027 if err != nil {
6028 return PodFilesystemAvailable{noop.Int64UpDownCounter{}}, err
6029 }
6030 return PodFilesystemAvailable{i}, nil
6031 }
6032
6033 // Inst returns the underlying metric instrument.
6034 func (m PodFilesystemAvailable) Inst() metric.Int64UpDownCounter {
6035 return m.Int64UpDownCounter
6036 }
6037
6038 // Name returns the semantic convention name of the instrument.
6039 func (PodFilesystemAvailable) Name() string {
6040 return "k8s.pod.filesystem.available"
6041 }
6042
6043 // Unit returns the semantic convention unit of the instrument
6044 func (PodFilesystemAvailable) Unit() string {
6045 return "By"
6046 }
6047
6048 // Description returns the semantic convention description of the instrument
6049 func (PodFilesystemAvailable) Description() string {
6050 return "Pod filesystem available bytes."
6051 }
6052
6053 // Add adds incr to the existing count for attrs.
6054 //
6055 // This metric is derived from the
6056 // [FsStats.AvailableBytes] field
6057 // of the [PodStats.EphemeralStorage]
6058 // of the Kubelet's stats API.
6059 //
6060 // [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
6061 // [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6062 func (m PodFilesystemAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
6063 if len(attrs) == 0 {
6064 m.Int64UpDownCounter.Add(ctx, incr)
6065 return
6066 }
6067
6068 o := addOptPool.Get().(*[]metric.AddOption)
6069 defer func() {
6070 *o = (*o)[:0]
6071 addOptPool.Put(o)
6072 }()
6073
6074 *o = append(*o, metric.WithAttributes(attrs...))
6075 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6076 }
6077
6078 // AddSet adds incr to the existing count for set.
6079 //
6080 // This metric is derived from the
6081 // [FsStats.AvailableBytes] field
6082 // of the [PodStats.EphemeralStorage]
6083 // of the Kubelet's stats API.
6084 //
6085 // [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
6086 // [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6087 func (m PodFilesystemAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6088 if set.Len() == 0 {
6089 m.Int64UpDownCounter.Add(ctx, incr)
6090 return
6091 }
6092
6093 o := addOptPool.Get().(*[]metric.AddOption)
6094 defer func() {
6095 *o = (*o)[:0]
6096 addOptPool.Put(o)
6097 }()
6098
6099 *o = append(*o, metric.WithAttributeSet(set))
6100 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6101 }
6102
6103 // PodFilesystemCapacity is an instrument used to record metric values conforming
6104 // to the "k8s.pod.filesystem.capacity" semantic conventions. It represents the
6105 // pod filesystem capacity.
6106 type PodFilesystemCapacity struct {
6107 metric.Int64UpDownCounter
6108 }
6109
6110 var newPodFilesystemCapacityOpts = []metric.Int64UpDownCounterOption{
6111 metric.WithDescription("Pod filesystem capacity."),
6112 metric.WithUnit("By"),
6113 }
6114
6115 // NewPodFilesystemCapacity returns a new PodFilesystemCapacity instrument.
6116 func NewPodFilesystemCapacity(
6117 m metric.Meter,
6118 opt ...metric.Int64UpDownCounterOption,
6119 ) (PodFilesystemCapacity, error) {
6120 // Check if the meter is nil.
6121 if m == nil {
6122 return PodFilesystemCapacity{noop.Int64UpDownCounter{}}, nil
6123 }
6124
6125 if len(opt) == 0 {
6126 opt = newPodFilesystemCapacityOpts
6127 } else {
6128 opt = append(opt, newPodFilesystemCapacityOpts...)
6129 }
6130
6131 i, err := m.Int64UpDownCounter(
6132 "k8s.pod.filesystem.capacity",
6133 opt...,
6134 )
6135 if err != nil {
6136 return PodFilesystemCapacity{noop.Int64UpDownCounter{}}, err
6137 }
6138 return PodFilesystemCapacity{i}, nil
6139 }
6140
6141 // Inst returns the underlying metric instrument.
6142 func (m PodFilesystemCapacity) Inst() metric.Int64UpDownCounter {
6143 return m.Int64UpDownCounter
6144 }
6145
6146 // Name returns the semantic convention name of the instrument.
6147 func (PodFilesystemCapacity) Name() string {
6148 return "k8s.pod.filesystem.capacity"
6149 }
6150
6151 // Unit returns the semantic convention unit of the instrument
6152 func (PodFilesystemCapacity) Unit() string {
6153 return "By"
6154 }
6155
6156 // Description returns the semantic convention description of the instrument
6157 func (PodFilesystemCapacity) Description() string {
6158 return "Pod filesystem capacity."
6159 }
6160
6161 // Add adds incr to the existing count for attrs.
6162 //
6163 // This metric is derived from the
6164 // [FsStats.CapacityBytes] field
6165 // of the [PodStats.EphemeralStorage]
6166 // of the Kubelet's stats API.
6167 //
6168 // [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
6169 // [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6170 func (m PodFilesystemCapacity) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
6171 if len(attrs) == 0 {
6172 m.Int64UpDownCounter.Add(ctx, incr)
6173 return
6174 }
6175
6176 o := addOptPool.Get().(*[]metric.AddOption)
6177 defer func() {
6178 *o = (*o)[:0]
6179 addOptPool.Put(o)
6180 }()
6181
6182 *o = append(*o, metric.WithAttributes(attrs...))
6183 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6184 }
6185
6186 // AddSet adds incr to the existing count for set.
6187 //
6188 // This metric is derived from the
6189 // [FsStats.CapacityBytes] field
6190 // of the [PodStats.EphemeralStorage]
6191 // of the Kubelet's stats API.
6192 //
6193 // [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
6194 // [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6195 func (m PodFilesystemCapacity) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6196 if set.Len() == 0 {
6197 m.Int64UpDownCounter.Add(ctx, incr)
6198 return
6199 }
6200
6201 o := addOptPool.Get().(*[]metric.AddOption)
6202 defer func() {
6203 *o = (*o)[:0]
6204 addOptPool.Put(o)
6205 }()
6206
6207 *o = append(*o, metric.WithAttributeSet(set))
6208 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6209 }
6210
6211 // PodFilesystemUsage is an instrument used to record metric values conforming to
6212 // the "k8s.pod.filesystem.usage" semantic conventions. It represents the pod
6213 // filesystem usage.
6214 type PodFilesystemUsage struct {
6215 metric.Int64UpDownCounter
6216 }
6217
6218 var newPodFilesystemUsageOpts = []metric.Int64UpDownCounterOption{
6219 metric.WithDescription("Pod filesystem usage."),
6220 metric.WithUnit("By"),
6221 }
6222
6223 // NewPodFilesystemUsage returns a new PodFilesystemUsage instrument.
6224 func NewPodFilesystemUsage(
6225 m metric.Meter,
6226 opt ...metric.Int64UpDownCounterOption,
6227 ) (PodFilesystemUsage, error) {
6228 // Check if the meter is nil.
6229 if m == nil {
6230 return PodFilesystemUsage{noop.Int64UpDownCounter{}}, nil
6231 }
6232
6233 if len(opt) == 0 {
6234 opt = newPodFilesystemUsageOpts
6235 } else {
6236 opt = append(opt, newPodFilesystemUsageOpts...)
6237 }
6238
6239 i, err := m.Int64UpDownCounter(
6240 "k8s.pod.filesystem.usage",
6241 opt...,
6242 )
6243 if err != nil {
6244 return PodFilesystemUsage{noop.Int64UpDownCounter{}}, err
6245 }
6246 return PodFilesystemUsage{i}, nil
6247 }
6248
6249 // Inst returns the underlying metric instrument.
6250 func (m PodFilesystemUsage) Inst() metric.Int64UpDownCounter {
6251 return m.Int64UpDownCounter
6252 }
6253
6254 // Name returns the semantic convention name of the instrument.
6255 func (PodFilesystemUsage) Name() string {
6256 return "k8s.pod.filesystem.usage"
6257 }
6258
6259 // Unit returns the semantic convention unit of the instrument
6260 func (PodFilesystemUsage) Unit() string {
6261 return "By"
6262 }
6263
6264 // Description returns the semantic convention description of the instrument
6265 func (PodFilesystemUsage) Description() string {
6266 return "Pod filesystem usage."
6267 }
6268
6269 // Add adds incr to the existing count for attrs.
6270 //
6271 // This may not equal capacity - available.
6272 //
6273 // This metric is derived from the
6274 // [FsStats.UsedBytes] field
6275 // of the [PodStats.EphemeralStorage]
6276 // of the Kubelet's stats API.
6277 //
6278 // [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
6279 // [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6280 func (m PodFilesystemUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
6281 if len(attrs) == 0 {
6282 m.Int64UpDownCounter.Add(ctx, incr)
6283 return
6284 }
6285
6286 o := addOptPool.Get().(*[]metric.AddOption)
6287 defer func() {
6288 *o = (*o)[:0]
6289 addOptPool.Put(o)
6290 }()
6291
6292 *o = append(*o, metric.WithAttributes(attrs...))
6293 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6294 }
6295
6296 // AddSet adds incr to the existing count for set.
6297 //
6298 // This may not equal capacity - available.
6299 //
6300 // This metric is derived from the
6301 // [FsStats.UsedBytes] field
6302 // of the [PodStats.EphemeralStorage]
6303 // of the Kubelet's stats API.
6304 //
6305 // [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats
6306 // [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6307 func (m PodFilesystemUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6308 if set.Len() == 0 {
6309 m.Int64UpDownCounter.Add(ctx, incr)
6310 return
6311 }
6312
6313 o := addOptPool.Get().(*[]metric.AddOption)
6314 defer func() {
6315 *o = (*o)[:0]
6316 addOptPool.Put(o)
6317 }()
6318
6319 *o = append(*o, metric.WithAttributeSet(set))
6320 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6321 }
6322
6323 // PodMemoryAvailable is an instrument used to record metric values conforming to
6324 // the "k8s.pod.memory.available" semantic conventions. It represents the pod
6325 // memory available.
6326 type PodMemoryAvailable struct {
6327 metric.Int64UpDownCounter
6328 }
6329
6330 var newPodMemoryAvailableOpts = []metric.Int64UpDownCounterOption{
6331 metric.WithDescription("Pod memory available."),
6332 metric.WithUnit("By"),
6333 }
6334
6335 // NewPodMemoryAvailable returns a new PodMemoryAvailable instrument.
6336 func NewPodMemoryAvailable(
6337 m metric.Meter,
6338 opt ...metric.Int64UpDownCounterOption,
6339 ) (PodMemoryAvailable, error) {
6340 // Check if the meter is nil.
6341 if m == nil {
6342 return PodMemoryAvailable{noop.Int64UpDownCounter{}}, nil
6343 }
6344
6345 if len(opt) == 0 {
6346 opt = newPodMemoryAvailableOpts
6347 } else {
6348 opt = append(opt, newPodMemoryAvailableOpts...)
6349 }
6350
6351 i, err := m.Int64UpDownCounter(
6352 "k8s.pod.memory.available",
6353 opt...,
6354 )
6355 if err != nil {
6356 return PodMemoryAvailable{noop.Int64UpDownCounter{}}, err
6357 }
6358 return PodMemoryAvailable{i}, nil
6359 }
6360
6361 // Inst returns the underlying metric instrument.
6362 func (m PodMemoryAvailable) Inst() metric.Int64UpDownCounter {
6363 return m.Int64UpDownCounter
6364 }
6365
6366 // Name returns the semantic convention name of the instrument.
6367 func (PodMemoryAvailable) Name() string {
6368 return "k8s.pod.memory.available"
6369 }
6370
6371 // Unit returns the semantic convention unit of the instrument
6372 func (PodMemoryAvailable) Unit() string {
6373 return "By"
6374 }
6375
6376 // Description returns the semantic convention description of the instrument
6377 func (PodMemoryAvailable) Description() string {
6378 return "Pod memory available."
6379 }
6380
6381 // Add adds incr to the existing count for attrs.
6382 //
6383 // Available memory for use. This is defined as the memory limit -
6384 // workingSetBytes. If memory limit is undefined, the available bytes is omitted.
6385 // This metric is derived from the [MemoryStats.AvailableBytes] field of the
6386 // [PodStats.Memory] of the Kubelet's stats API.
6387 //
6388 // [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6389 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6390 func (m PodMemoryAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
6391 if len(attrs) == 0 {
6392 m.Int64UpDownCounter.Add(ctx, incr)
6393 return
6394 }
6395
6396 o := addOptPool.Get().(*[]metric.AddOption)
6397 defer func() {
6398 *o = (*o)[:0]
6399 addOptPool.Put(o)
6400 }()
6401
6402 *o = append(*o, metric.WithAttributes(attrs...))
6403 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6404 }
6405
6406 // AddSet adds incr to the existing count for set.
6407 //
6408 // Available memory for use. This is defined as the memory limit -
6409 // workingSetBytes. If memory limit is undefined, the available bytes is omitted.
6410 // This metric is derived from the [MemoryStats.AvailableBytes] field of the
6411 // [PodStats.Memory] of the Kubelet's stats API.
6412 //
6413 // [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6414 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6415 func (m PodMemoryAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6416 if set.Len() == 0 {
6417 m.Int64UpDownCounter.Add(ctx, incr)
6418 return
6419 }
6420
6421 o := addOptPool.Get().(*[]metric.AddOption)
6422 defer func() {
6423 *o = (*o)[:0]
6424 addOptPool.Put(o)
6425 }()
6426
6427 *o = append(*o, metric.WithAttributeSet(set))
6428 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6429 }
6430
6431 // PodMemoryPagingFaults is an instrument used to record metric values conforming
6432 // to the "k8s.pod.memory.paging.faults" semantic conventions. It represents the
6433 // pod memory paging faults.
6434 type PodMemoryPagingFaults struct {
6435 metric.Int64Counter
6436 }
6437
6438 var newPodMemoryPagingFaultsOpts = []metric.Int64CounterOption{
6439 metric.WithDescription("Pod memory paging faults."),
6440 metric.WithUnit("{fault}"),
6441 }
6442
6443 // NewPodMemoryPagingFaults returns a new PodMemoryPagingFaults instrument.
6444 func NewPodMemoryPagingFaults(
6445 m metric.Meter,
6446 opt ...metric.Int64CounterOption,
6447 ) (PodMemoryPagingFaults, error) {
6448 // Check if the meter is nil.
6449 if m == nil {
6450 return PodMemoryPagingFaults{noop.Int64Counter{}}, nil
6451 }
6452
6453 if len(opt) == 0 {
6454 opt = newPodMemoryPagingFaultsOpts
6455 } else {
6456 opt = append(opt, newPodMemoryPagingFaultsOpts...)
6457 }
6458
6459 i, err := m.Int64Counter(
6460 "k8s.pod.memory.paging.faults",
6461 opt...,
6462 )
6463 if err != nil {
6464 return PodMemoryPagingFaults{noop.Int64Counter{}}, err
6465 }
6466 return PodMemoryPagingFaults{i}, nil
6467 }
6468
6469 // Inst returns the underlying metric instrument.
6470 func (m PodMemoryPagingFaults) Inst() metric.Int64Counter {
6471 return m.Int64Counter
6472 }
6473
6474 // Name returns the semantic convention name of the instrument.
6475 func (PodMemoryPagingFaults) Name() string {
6476 return "k8s.pod.memory.paging.faults"
6477 }
6478
6479 // Unit returns the semantic convention unit of the instrument
6480 func (PodMemoryPagingFaults) Unit() string {
6481 return "{fault}"
6482 }
6483
6484 // Description returns the semantic convention description of the instrument
6485 func (PodMemoryPagingFaults) Description() string {
6486 return "Pod memory paging faults."
6487 }
6488
6489 // Add adds incr to the existing count for attrs.
6490 //
6491 // All additional attrs passed are included in the recorded value.
6492 //
6493 // Cumulative number of major/minor page faults.
6494 // This metric is derived from the [MemoryStats.PageFaults] and
6495 // [MemoryStats.MajorPageFaults] field of the [PodStats.Memory] of the Kubelet's
6496 // stats API.
6497 //
6498 // [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6499 // [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6500 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6501 func (m PodMemoryPagingFaults) Add(
6502 ctx context.Context,
6503 incr int64,
6504 attrs ...attribute.KeyValue,
6505 ) {
6506 if len(attrs) == 0 {
6507 m.Int64Counter.Add(ctx, incr)
6508 return
6509 }
6510
6511 o := addOptPool.Get().(*[]metric.AddOption)
6512 defer func() {
6513 *o = (*o)[:0]
6514 addOptPool.Put(o)
6515 }()
6516
6517 *o = append(
6518 *o,
6519 metric.WithAttributes(
6520 attrs...,
6521 ),
6522 )
6523
6524 m.Int64Counter.Add(ctx, incr, *o...)
6525 }
6526
6527 // AddSet adds incr to the existing count for set.
6528 //
6529 // Cumulative number of major/minor page faults.
6530 // This metric is derived from the [MemoryStats.PageFaults] and
6531 // [MemoryStats.MajorPageFaults] field of the [PodStats.Memory] of the Kubelet's
6532 // stats API.
6533 //
6534 // [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6535 // [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6536 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6537 func (m PodMemoryPagingFaults) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6538 if set.Len() == 0 {
6539 m.Int64Counter.Add(ctx, incr)
6540 return
6541 }
6542
6543 o := addOptPool.Get().(*[]metric.AddOption)
6544 defer func() {
6545 *o = (*o)[:0]
6546 addOptPool.Put(o)
6547 }()
6548
6549 *o = append(*o, metric.WithAttributeSet(set))
6550 m.Int64Counter.Add(ctx, incr, *o...)
6551 }
6552
6553 // AttrSystemPagingFaultType returns an optional attribute for the
6554 // "system.paging.fault.type" semantic convention. It represents the paging fault
6555 // type.
6556 func (PodMemoryPagingFaults) AttrSystemPagingFaultType(val SystemPagingFaultTypeAttr) attribute.KeyValue {
6557 return attribute.String("system.paging.fault.type", string(val))
6558 }
6559
6560 // PodMemoryRss is an instrument used to record metric values conforming to the
6561 // "k8s.pod.memory.rss" semantic conventions. It represents the pod memory RSS.
6562 type PodMemoryRss struct {
6563 metric.Int64UpDownCounter
6564 }
6565
6566 var newPodMemoryRssOpts = []metric.Int64UpDownCounterOption{
6567 metric.WithDescription("Pod memory RSS."),
6568 metric.WithUnit("By"),
6569 }
6570
6571 // NewPodMemoryRss returns a new PodMemoryRss instrument.
6572 func NewPodMemoryRss(
6573 m metric.Meter,
6574 opt ...metric.Int64UpDownCounterOption,
6575 ) (PodMemoryRss, error) {
6576 // Check if the meter is nil.
6577 if m == nil {
6578 return PodMemoryRss{noop.Int64UpDownCounter{}}, nil
6579 }
6580
6581 if len(opt) == 0 {
6582 opt = newPodMemoryRssOpts
6583 } else {
6584 opt = append(opt, newPodMemoryRssOpts...)
6585 }
6586
6587 i, err := m.Int64UpDownCounter(
6588 "k8s.pod.memory.rss",
6589 opt...,
6590 )
6591 if err != nil {
6592 return PodMemoryRss{noop.Int64UpDownCounter{}}, err
6593 }
6594 return PodMemoryRss{i}, nil
6595 }
6596
6597 // Inst returns the underlying metric instrument.
6598 func (m PodMemoryRss) Inst() metric.Int64UpDownCounter {
6599 return m.Int64UpDownCounter
6600 }
6601
6602 // Name returns the semantic convention name of the instrument.
6603 func (PodMemoryRss) Name() string {
6604 return "k8s.pod.memory.rss"
6605 }
6606
6607 // Unit returns the semantic convention unit of the instrument
6608 func (PodMemoryRss) Unit() string {
6609 return "By"
6610 }
6611
6612 // Description returns the semantic convention description of the instrument
6613 func (PodMemoryRss) Description() string {
6614 return "Pod memory RSS."
6615 }
6616
6617 // Add adds incr to the existing count for attrs.
6618 //
6619 // The amount of anonymous and swap cache memory (includes transparent
6620 // hugepages).
6621 // This metric is derived from the [MemoryStats.RSSBytes] field of the
6622 // [PodStats.Memory] of the Kubelet's stats API.
6623 //
6624 // [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6625 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6626 func (m PodMemoryRss) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
6627 if len(attrs) == 0 {
6628 m.Int64UpDownCounter.Add(ctx, incr)
6629 return
6630 }
6631
6632 o := addOptPool.Get().(*[]metric.AddOption)
6633 defer func() {
6634 *o = (*o)[:0]
6635 addOptPool.Put(o)
6636 }()
6637
6638 *o = append(*o, metric.WithAttributes(attrs...))
6639 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6640 }
6641
6642 // AddSet adds incr to the existing count for set.
6643 //
6644 // The amount of anonymous and swap cache memory (includes transparent
6645 // hugepages).
6646 // This metric is derived from the [MemoryStats.RSSBytes] field of the
6647 // [PodStats.Memory] of the Kubelet's stats API.
6648 //
6649 // [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6650 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6651 func (m PodMemoryRss) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6652 if set.Len() == 0 {
6653 m.Int64UpDownCounter.Add(ctx, incr)
6654 return
6655 }
6656
6657 o := addOptPool.Get().(*[]metric.AddOption)
6658 defer func() {
6659 *o = (*o)[:0]
6660 addOptPool.Put(o)
6661 }()
6662
6663 *o = append(*o, metric.WithAttributeSet(set))
6664 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6665 }
6666
6667 // PodMemoryUsage is an instrument used to record metric values conforming to the
6668 // "k8s.pod.memory.usage" semantic conventions. It represents the memory usage of
6669 // the Pod.
6670 type PodMemoryUsage struct {
6671 metric.Int64Gauge
6672 }
6673
6674 var newPodMemoryUsageOpts = []metric.Int64GaugeOption{
6675 metric.WithDescription("Memory usage of the Pod."),
6676 metric.WithUnit("By"),
6677 }
6678
6679 // NewPodMemoryUsage returns a new PodMemoryUsage instrument.
6680 func NewPodMemoryUsage(
6681 m metric.Meter,
6682 opt ...metric.Int64GaugeOption,
6683 ) (PodMemoryUsage, error) {
6684 // Check if the meter is nil.
6685 if m == nil {
6686 return PodMemoryUsage{noop.Int64Gauge{}}, nil
6687 }
6688
6689 if len(opt) == 0 {
6690 opt = newPodMemoryUsageOpts
6691 } else {
6692 opt = append(opt, newPodMemoryUsageOpts...)
6693 }
6694
6695 i, err := m.Int64Gauge(
6696 "k8s.pod.memory.usage",
6697 opt...,
6698 )
6699 if err != nil {
6700 return PodMemoryUsage{noop.Int64Gauge{}}, err
6701 }
6702 return PodMemoryUsage{i}, nil
6703 }
6704
6705 // Inst returns the underlying metric instrument.
6706 func (m PodMemoryUsage) Inst() metric.Int64Gauge {
6707 return m.Int64Gauge
6708 }
6709
6710 // Name returns the semantic convention name of the instrument.
6711 func (PodMemoryUsage) Name() string {
6712 return "k8s.pod.memory.usage"
6713 }
6714
6715 // Unit returns the semantic convention unit of the instrument
6716 func (PodMemoryUsage) Unit() string {
6717 return "By"
6718 }
6719
6720 // Description returns the semantic convention description of the instrument
6721 func (PodMemoryUsage) Description() string {
6722 return "Memory usage of the Pod."
6723 }
6724
6725 // Record records val to the current distribution for attrs.
6726 //
6727 // Total memory usage of the Pod
6728 func (m PodMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
6729 if len(attrs) == 0 {
6730 m.Int64Gauge.Record(ctx, val)
6731 return
6732 }
6733
6734 o := recOptPool.Get().(*[]metric.RecordOption)
6735 defer func() {
6736 *o = (*o)[:0]
6737 recOptPool.Put(o)
6738 }()
6739
6740 *o = append(*o, metric.WithAttributes(attrs...))
6741 m.Int64Gauge.Record(ctx, val, *o...)
6742 }
6743
6744 // RecordSet records val to the current distribution for set.
6745 //
6746 // Total memory usage of the Pod
6747 func (m PodMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) {
6748 if set.Len() == 0 {
6749 m.Int64Gauge.Record(ctx, val)
6750 return
6751 }
6752
6753 o := recOptPool.Get().(*[]metric.RecordOption)
6754 defer func() {
6755 *o = (*o)[:0]
6756 recOptPool.Put(o)
6757 }()
6758
6759 *o = append(*o, metric.WithAttributeSet(set))
6760 m.Int64Gauge.Record(ctx, val, *o...)
6761 }
6762
6763 // PodMemoryWorkingSet is an instrument used to record metric values conforming
6764 // to the "k8s.pod.memory.working_set" semantic conventions. It represents the
6765 // pod memory working set.
6766 type PodMemoryWorkingSet struct {
6767 metric.Int64UpDownCounter
6768 }
6769
6770 var newPodMemoryWorkingSetOpts = []metric.Int64UpDownCounterOption{
6771 metric.WithDescription("Pod memory working set."),
6772 metric.WithUnit("By"),
6773 }
6774
6775 // NewPodMemoryWorkingSet returns a new PodMemoryWorkingSet instrument.
6776 func NewPodMemoryWorkingSet(
6777 m metric.Meter,
6778 opt ...metric.Int64UpDownCounterOption,
6779 ) (PodMemoryWorkingSet, error) {
6780 // Check if the meter is nil.
6781 if m == nil {
6782 return PodMemoryWorkingSet{noop.Int64UpDownCounter{}}, nil
6783 }
6784
6785 if len(opt) == 0 {
6786 opt = newPodMemoryWorkingSetOpts
6787 } else {
6788 opt = append(opt, newPodMemoryWorkingSetOpts...)
6789 }
6790
6791 i, err := m.Int64UpDownCounter(
6792 "k8s.pod.memory.working_set",
6793 opt...,
6794 )
6795 if err != nil {
6796 return PodMemoryWorkingSet{noop.Int64UpDownCounter{}}, err
6797 }
6798 return PodMemoryWorkingSet{i}, nil
6799 }
6800
6801 // Inst returns the underlying metric instrument.
6802 func (m PodMemoryWorkingSet) Inst() metric.Int64UpDownCounter {
6803 return m.Int64UpDownCounter
6804 }
6805
6806 // Name returns the semantic convention name of the instrument.
6807 func (PodMemoryWorkingSet) Name() string {
6808 return "k8s.pod.memory.working_set"
6809 }
6810
6811 // Unit returns the semantic convention unit of the instrument
6812 func (PodMemoryWorkingSet) Unit() string {
6813 return "By"
6814 }
6815
6816 // Description returns the semantic convention description of the instrument
6817 func (PodMemoryWorkingSet) Description() string {
6818 return "Pod memory working set."
6819 }
6820
6821 // Add adds incr to the existing count for attrs.
6822 //
6823 // The amount of working set memory. This includes recently accessed memory,
6824 // dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes.
6825 // This metric is derived from the [MemoryStats.WorkingSetBytes] field of the
6826 // [PodStats.Memory] of the Kubelet's stats API.
6827 //
6828 // [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6829 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6830 func (m PodMemoryWorkingSet) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
6831 if len(attrs) == 0 {
6832 m.Int64UpDownCounter.Add(ctx, incr)
6833 return
6834 }
6835
6836 o := addOptPool.Get().(*[]metric.AddOption)
6837 defer func() {
6838 *o = (*o)[:0]
6839 addOptPool.Put(o)
6840 }()
6841
6842 *o = append(*o, metric.WithAttributes(attrs...))
6843 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6844 }
6845
6846 // AddSet adds incr to the existing count for set.
6847 //
6848 // The amount of working set memory. This includes recently accessed memory,
6849 // dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes.
6850 // This metric is derived from the [MemoryStats.WorkingSetBytes] field of the
6851 // [PodStats.Memory] of the Kubelet's stats API.
6852 //
6853 // [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats
6854 // [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
6855 func (m PodMemoryWorkingSet) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6856 if set.Len() == 0 {
6857 m.Int64UpDownCounter.Add(ctx, incr)
6858 return
6859 }
6860
6861 o := addOptPool.Get().(*[]metric.AddOption)
6862 defer func() {
6863 *o = (*o)[:0]
6864 addOptPool.Put(o)
6865 }()
6866
6867 *o = append(*o, metric.WithAttributeSet(set))
6868 m.Int64UpDownCounter.Add(ctx, incr, *o...)
6869 }
6870
6871 // PodNetworkErrors is an instrument used to record metric values conforming to
6872 // the "k8s.pod.network.errors" semantic conventions. It represents the pod
6873 // network errors.
6874 type PodNetworkErrors struct {
6875 metric.Int64Counter
6876 }
6877
6878 var newPodNetworkErrorsOpts = []metric.Int64CounterOption{
6879 metric.WithDescription("Pod network errors."),
6880 metric.WithUnit("{error}"),
6881 }
6882
6883 // NewPodNetworkErrors returns a new PodNetworkErrors instrument.
6884 func NewPodNetworkErrors(
6885 m metric.Meter,
6886 opt ...metric.Int64CounterOption,
6887 ) (PodNetworkErrors, error) {
6888 // Check if the meter is nil.
6889 if m == nil {
6890 return PodNetworkErrors{noop.Int64Counter{}}, nil
6891 }
6892
6893 if len(opt) == 0 {
6894 opt = newPodNetworkErrorsOpts
6895 } else {
6896 opt = append(opt, newPodNetworkErrorsOpts...)
6897 }
6898
6899 i, err := m.Int64Counter(
6900 "k8s.pod.network.errors",
6901 opt...,
6902 )
6903 if err != nil {
6904 return PodNetworkErrors{noop.Int64Counter{}}, err
6905 }
6906 return PodNetworkErrors{i}, nil
6907 }
6908
6909 // Inst returns the underlying metric instrument.
6910 func (m PodNetworkErrors) Inst() metric.Int64Counter {
6911 return m.Int64Counter
6912 }
6913
6914 // Name returns the semantic convention name of the instrument.
6915 func (PodNetworkErrors) Name() string {
6916 return "k8s.pod.network.errors"
6917 }
6918
6919 // Unit returns the semantic convention unit of the instrument
6920 func (PodNetworkErrors) Unit() string {
6921 return "{error}"
6922 }
6923
6924 // Description returns the semantic convention description of the instrument
6925 func (PodNetworkErrors) Description() string {
6926 return "Pod network errors."
6927 }
6928
6929 // Add adds incr to the existing count for attrs.
6930 //
6931 // All additional attrs passed are included in the recorded value.
6932 func (m PodNetworkErrors) Add(
6933 ctx context.Context,
6934 incr int64,
6935 attrs ...attribute.KeyValue,
6936 ) {
6937 if len(attrs) == 0 {
6938 m.Int64Counter.Add(ctx, incr)
6939 return
6940 }
6941
6942 o := addOptPool.Get().(*[]metric.AddOption)
6943 defer func() {
6944 *o = (*o)[:0]
6945 addOptPool.Put(o)
6946 }()
6947
6948 *o = append(
6949 *o,
6950 metric.WithAttributes(
6951 attrs...,
6952 ),
6953 )
6954
6955 m.Int64Counter.Add(ctx, incr, *o...)
6956 }
6957
6958 // AddSet adds incr to the existing count for set.
6959 func (m PodNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) {
6960 if set.Len() == 0 {
6961 m.Int64Counter.Add(ctx, incr)
6962 return
6963 }
6964
6965 o := addOptPool.Get().(*[]metric.AddOption)
6966 defer func() {
6967 *o = (*o)[:0]
6968 addOptPool.Put(o)
6969 }()
6970
6971 *o = append(*o, metric.WithAttributeSet(set))
6972 m.Int64Counter.Add(ctx, incr, *o...)
6973 }
6974
6975 // AttrNetworkInterfaceName returns an optional attribute for the
6976 // "network.interface.name" semantic convention. It represents the network
6977 // interface name.
6978 func (PodNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue {
6979 return attribute.String("network.interface.name", val)
6980 }
6981
6982 // AttrNetworkIODirection returns an optional attribute for the
6983 // "network.io.direction" semantic convention. It represents the network IO
6984 // operation direction.
6985 func (PodNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
6986 return attribute.String("network.io.direction", string(val))
6987 }
6988
6989 // PodNetworkIO is an instrument used to record metric values conforming to the
6990 // "k8s.pod.network.io" semantic conventions. It represents the network bytes for
6991 // the Pod.
6992 type PodNetworkIO struct {
6993 metric.Int64Counter
6994 }
6995
6996 var newPodNetworkIOOpts = []metric.Int64CounterOption{
6997 metric.WithDescription("Network bytes for the Pod."),
6998 metric.WithUnit("By"),
6999 }
7000
7001 // NewPodNetworkIO returns a new PodNetworkIO instrument.
7002 func NewPodNetworkIO(
7003 m metric.Meter,
7004 opt ...metric.Int64CounterOption,
7005 ) (PodNetworkIO, error) {
7006 // Check if the meter is nil.
7007 if m == nil {
7008 return PodNetworkIO{noop.Int64Counter{}}, nil
7009 }
7010
7011 if len(opt) == 0 {
7012 opt = newPodNetworkIOOpts
7013 } else {
7014 opt = append(opt, newPodNetworkIOOpts...)
7015 }
7016
7017 i, err := m.Int64Counter(
7018 "k8s.pod.network.io",
7019 opt...,
7020 )
7021 if err != nil {
7022 return PodNetworkIO{noop.Int64Counter{}}, err
7023 }
7024 return PodNetworkIO{i}, nil
7025 }
7026
7027 // Inst returns the underlying metric instrument.
7028 func (m PodNetworkIO) Inst() metric.Int64Counter {
7029 return m.Int64Counter
7030 }
7031
7032 // Name returns the semantic convention name of the instrument.
7033 func (PodNetworkIO) Name() string {
7034 return "k8s.pod.network.io"
7035 }
7036
7037 // Unit returns the semantic convention unit of the instrument
7038 func (PodNetworkIO) Unit() string {
7039 return "By"
7040 }
7041
7042 // Description returns the semantic convention description of the instrument
7043 func (PodNetworkIO) Description() string {
7044 return "Network bytes for the Pod."
7045 }
7046
7047 // Add adds incr to the existing count for attrs.
7048 //
7049 // All additional attrs passed are included in the recorded value.
7050 func (m PodNetworkIO) Add(
7051 ctx context.Context,
7052 incr int64,
7053 attrs ...attribute.KeyValue,
7054 ) {
7055 if len(attrs) == 0 {
7056 m.Int64Counter.Add(ctx, incr)
7057 return
7058 }
7059
7060 o := addOptPool.Get().(*[]metric.AddOption)
7061 defer func() {
7062 *o = (*o)[:0]
7063 addOptPool.Put(o)
7064 }()
7065
7066 *o = append(
7067 *o,
7068 metric.WithAttributes(
7069 attrs...,
7070 ),
7071 )
7072
7073 m.Int64Counter.Add(ctx, incr, *o...)
7074 }
7075
7076 // AddSet adds incr to the existing count for set.
7077 func (m PodNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) {
7078 if set.Len() == 0 {
7079 m.Int64Counter.Add(ctx, incr)
7080 return
7081 }
7082
7083 o := addOptPool.Get().(*[]metric.AddOption)
7084 defer func() {
7085 *o = (*o)[:0]
7086 addOptPool.Put(o)
7087 }()
7088
7089 *o = append(*o, metric.WithAttributeSet(set))
7090 m.Int64Counter.Add(ctx, incr, *o...)
7091 }
7092
7093 // AttrNetworkInterfaceName returns an optional attribute for the
7094 // "network.interface.name" semantic convention. It represents the network
7095 // interface name.
7096 func (PodNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue {
7097 return attribute.String("network.interface.name", val)
7098 }
7099
7100 // AttrNetworkIODirection returns an optional attribute for the
7101 // "network.io.direction" semantic convention. It represents the network IO
7102 // operation direction.
7103 func (PodNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
7104 return attribute.String("network.io.direction", string(val))
7105 }
7106
7107 // PodStatusPhase is an instrument used to record metric values conforming to the
7108 // "k8s.pod.status.phase" semantic conventions. It represents the describes
7109 // number of K8s Pods that are currently in a given phase.
7110 type PodStatusPhase struct {
7111 metric.Int64UpDownCounter
7112 }
7113
7114 var newPodStatusPhaseOpts = []metric.Int64UpDownCounterOption{
7115 metric.WithDescription("Describes number of K8s Pods that are currently in a given phase."),
7116 metric.WithUnit("{pod}"),
7117 }
7118
7119 // NewPodStatusPhase returns a new PodStatusPhase instrument.
7120 func NewPodStatusPhase(
7121 m metric.Meter,
7122 opt ...metric.Int64UpDownCounterOption,
7123 ) (PodStatusPhase, error) {
7124 // Check if the meter is nil.
7125 if m == nil {
7126 return PodStatusPhase{noop.Int64UpDownCounter{}}, nil
7127 }
7128
7129 if len(opt) == 0 {
7130 opt = newPodStatusPhaseOpts
7131 } else {
7132 opt = append(opt, newPodStatusPhaseOpts...)
7133 }
7134
7135 i, err := m.Int64UpDownCounter(
7136 "k8s.pod.status.phase",
7137 opt...,
7138 )
7139 if err != nil {
7140 return PodStatusPhase{noop.Int64UpDownCounter{}}, err
7141 }
7142 return PodStatusPhase{i}, nil
7143 }
7144
7145 // Inst returns the underlying metric instrument.
7146 func (m PodStatusPhase) Inst() metric.Int64UpDownCounter {
7147 return m.Int64UpDownCounter
7148 }
7149
7150 // Name returns the semantic convention name of the instrument.
7151 func (PodStatusPhase) Name() string {
7152 return "k8s.pod.status.phase"
7153 }
7154
7155 // Unit returns the semantic convention unit of the instrument
7156 func (PodStatusPhase) Unit() string {
7157 return "{pod}"
7158 }
7159
7160 // Description returns the semantic convention description of the instrument
7161 func (PodStatusPhase) Description() string {
7162 return "Describes number of K8s Pods that are currently in a given phase."
7163 }
7164
7165 // Add adds incr to the existing count for attrs.
7166 //
7167 // The podStatusPhase is the the phase for the pod. Corresponds to the `phase`
7168 // field of the: [K8s PodStatus]
7169 //
7170 // [K8s PodStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.33/#podstatus-v1-core
7171 //
7172 // All possible pod phases will be reported at each time interval to avoid
7173 // missing metrics.
7174 // Only the value corresponding to the current phase will be non-zero.
7175 func (m PodStatusPhase) Add(
7176 ctx context.Context,
7177 incr int64,
7178 podStatusPhase PodStatusPhaseAttr,
7179 attrs ...attribute.KeyValue,
7180 ) {
7181 if len(attrs) == 0 {
7182 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
7183 attribute.String("k8s.pod.status.phase", string(podStatusPhase)),
7184 ))
7185 return
7186 }
7187
7188 o := addOptPool.Get().(*[]metric.AddOption)
7189 defer func() {
7190 *o = (*o)[:0]
7191 addOptPool.Put(o)
7192 }()
7193
7194 *o = append(
7195 *o,
7196 metric.WithAttributes(
7197 append(
7198 attrs[:len(attrs):len(attrs)],
7199 attribute.String("k8s.pod.status.phase", string(podStatusPhase)),
7200 )...,
7201 ),
7202 )
7203
7204 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7205 }
7206
7207 // AddSet adds incr to the existing count for set.
7208 //
7209 // All possible pod phases will be reported at each time interval to avoid
7210 // missing metrics.
7211 // Only the value corresponding to the current phase will be non-zero.
7212 func (m PodStatusPhase) AddSet(ctx context.Context, incr int64, set attribute.Set) {
7213 if set.Len() == 0 {
7214 m.Int64UpDownCounter.Add(ctx, incr)
7215 return
7216 }
7217
7218 o := addOptPool.Get().(*[]metric.AddOption)
7219 defer func() {
7220 *o = (*o)[:0]
7221 addOptPool.Put(o)
7222 }()
7223
7224 *o = append(*o, metric.WithAttributeSet(set))
7225 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7226 }
7227
7228 // PodStatusReason is an instrument used to record metric values conforming to
7229 // the "k8s.pod.status.reason" semantic conventions. It represents the describes
7230 // the number of K8s Pods that are currently in a state for a given reason.
7231 type PodStatusReason struct {
7232 metric.Int64UpDownCounter
7233 }
7234
7235 var newPodStatusReasonOpts = []metric.Int64UpDownCounterOption{
7236 metric.WithDescription("Describes the number of K8s Pods that are currently in a state for a given reason."),
7237 metric.WithUnit("{pod}"),
7238 }
7239
7240 // NewPodStatusReason returns a new PodStatusReason instrument.
7241 func NewPodStatusReason(
7242 m metric.Meter,
7243 opt ...metric.Int64UpDownCounterOption,
7244 ) (PodStatusReason, error) {
7245 // Check if the meter is nil.
7246 if m == nil {
7247 return PodStatusReason{noop.Int64UpDownCounter{}}, nil
7248 }
7249
7250 if len(opt) == 0 {
7251 opt = newPodStatusReasonOpts
7252 } else {
7253 opt = append(opt, newPodStatusReasonOpts...)
7254 }
7255
7256 i, err := m.Int64UpDownCounter(
7257 "k8s.pod.status.reason",
7258 opt...,
7259 )
7260 if err != nil {
7261 return PodStatusReason{noop.Int64UpDownCounter{}}, err
7262 }
7263 return PodStatusReason{i}, nil
7264 }
7265
7266 // Inst returns the underlying metric instrument.
7267 func (m PodStatusReason) Inst() metric.Int64UpDownCounter {
7268 return m.Int64UpDownCounter
7269 }
7270
7271 // Name returns the semantic convention name of the instrument.
7272 func (PodStatusReason) Name() string {
7273 return "k8s.pod.status.reason"
7274 }
7275
7276 // Unit returns the semantic convention unit of the instrument
7277 func (PodStatusReason) Unit() string {
7278 return "{pod}"
7279 }
7280
7281 // Description returns the semantic convention description of the instrument
7282 func (PodStatusReason) Description() string {
7283 return "Describes the number of K8s Pods that are currently in a state for a given reason."
7284 }
7285
7286 // Add adds incr to the existing count for attrs.
7287 //
7288 // The podStatusReason is the the reason for the pod state. Corresponds to the
7289 // `reason` field of the: [K8s PodStatus]
7290 //
7291 // [K8s PodStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.33/#podstatus-v1-core
7292 //
7293 // All possible pod status reasons will be reported at each time interval to
7294 // avoid missing metrics.
7295 // Only the value corresponding to the current reason will be non-zero.
7296 func (m PodStatusReason) Add(
7297 ctx context.Context,
7298 incr int64,
7299 podStatusReason PodStatusReasonAttr,
7300 attrs ...attribute.KeyValue,
7301 ) {
7302 if len(attrs) == 0 {
7303 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
7304 attribute.String("k8s.pod.status.reason", string(podStatusReason)),
7305 ))
7306 return
7307 }
7308
7309 o := addOptPool.Get().(*[]metric.AddOption)
7310 defer func() {
7311 *o = (*o)[:0]
7312 addOptPool.Put(o)
7313 }()
7314
7315 *o = append(
7316 *o,
7317 metric.WithAttributes(
7318 append(
7319 attrs[:len(attrs):len(attrs)],
7320 attribute.String("k8s.pod.status.reason", string(podStatusReason)),
7321 )...,
7322 ),
7323 )
7324
7325 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7326 }
7327
7328 // AddSet adds incr to the existing count for set.
7329 //
7330 // All possible pod status reasons will be reported at each time interval to
7331 // avoid missing metrics.
7332 // Only the value corresponding to the current reason will be non-zero.
7333 func (m PodStatusReason) AddSet(ctx context.Context, incr int64, set attribute.Set) {
7334 if set.Len() == 0 {
7335 m.Int64UpDownCounter.Add(ctx, incr)
7336 return
7337 }
7338
7339 o := addOptPool.Get().(*[]metric.AddOption)
7340 defer func() {
7341 *o = (*o)[:0]
7342 addOptPool.Put(o)
7343 }()
7344
7345 *o = append(*o, metric.WithAttributeSet(set))
7346 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7347 }
7348
7349 // PodUptime is an instrument used to record metric values conforming to the
7350 // "k8s.pod.uptime" semantic conventions. It represents the time the Pod has been
7351 // running.
7352 type PodUptime struct {
7353 metric.Float64Gauge
7354 }
7355
7356 var newPodUptimeOpts = []metric.Float64GaugeOption{
7357 metric.WithDescription("The time the Pod has been running."),
7358 metric.WithUnit("s"),
7359 }
7360
7361 // NewPodUptime returns a new PodUptime instrument.
7362 func NewPodUptime(
7363 m metric.Meter,
7364 opt ...metric.Float64GaugeOption,
7365 ) (PodUptime, error) {
7366 // Check if the meter is nil.
7367 if m == nil {
7368 return PodUptime{noop.Float64Gauge{}}, nil
7369 }
7370
7371 if len(opt) == 0 {
7372 opt = newPodUptimeOpts
7373 } else {
7374 opt = append(opt, newPodUptimeOpts...)
7375 }
7376
7377 i, err := m.Float64Gauge(
7378 "k8s.pod.uptime",
7379 opt...,
7380 )
7381 if err != nil {
7382 return PodUptime{noop.Float64Gauge{}}, err
7383 }
7384 return PodUptime{i}, nil
7385 }
7386
7387 // Inst returns the underlying metric instrument.
7388 func (m PodUptime) Inst() metric.Float64Gauge {
7389 return m.Float64Gauge
7390 }
7391
7392 // Name returns the semantic convention name of the instrument.
7393 func (PodUptime) Name() string {
7394 return "k8s.pod.uptime"
7395 }
7396
7397 // Unit returns the semantic convention unit of the instrument
7398 func (PodUptime) Unit() string {
7399 return "s"
7400 }
7401
7402 // Description returns the semantic convention description of the instrument
7403 func (PodUptime) Description() string {
7404 return "The time the Pod has been running."
7405 }
7406
7407 // Record records val to the current distribution for attrs.
7408 //
7409 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
7410 // seconds as a floating point number with the highest precision available.
7411 // The actual accuracy would depend on the instrumentation and operating system.
7412 func (m PodUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
7413 if len(attrs) == 0 {
7414 m.Float64Gauge.Record(ctx, val)
7415 return
7416 }
7417
7418 o := recOptPool.Get().(*[]metric.RecordOption)
7419 defer func() {
7420 *o = (*o)[:0]
7421 recOptPool.Put(o)
7422 }()
7423
7424 *o = append(*o, metric.WithAttributes(attrs...))
7425 m.Float64Gauge.Record(ctx, val, *o...)
7426 }
7427
7428 // RecordSet records val to the current distribution for set.
7429 //
7430 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
7431 // seconds as a floating point number with the highest precision available.
7432 // The actual accuracy would depend on the instrumentation and operating system.
7433 func (m PodUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) {
7434 if set.Len() == 0 {
7435 m.Float64Gauge.Record(ctx, val)
7436 return
7437 }
7438
7439 o := recOptPool.Get().(*[]metric.RecordOption)
7440 defer func() {
7441 *o = (*o)[:0]
7442 recOptPool.Put(o)
7443 }()
7444
7445 *o = append(*o, metric.WithAttributeSet(set))
7446 m.Float64Gauge.Record(ctx, val, *o...)
7447 }
7448
7449 // PodVolumeAvailable is an instrument used to record metric values conforming to
7450 // the "k8s.pod.volume.available" semantic conventions. It represents the pod
7451 // volume storage space available.
7452 type PodVolumeAvailable struct {
7453 metric.Int64UpDownCounter
7454 }
7455
7456 var newPodVolumeAvailableOpts = []metric.Int64UpDownCounterOption{
7457 metric.WithDescription("Pod volume storage space available."),
7458 metric.WithUnit("By"),
7459 }
7460
7461 // NewPodVolumeAvailable returns a new PodVolumeAvailable instrument.
7462 func NewPodVolumeAvailable(
7463 m metric.Meter,
7464 opt ...metric.Int64UpDownCounterOption,
7465 ) (PodVolumeAvailable, error) {
7466 // Check if the meter is nil.
7467 if m == nil {
7468 return PodVolumeAvailable{noop.Int64UpDownCounter{}}, nil
7469 }
7470
7471 if len(opt) == 0 {
7472 opt = newPodVolumeAvailableOpts
7473 } else {
7474 opt = append(opt, newPodVolumeAvailableOpts...)
7475 }
7476
7477 i, err := m.Int64UpDownCounter(
7478 "k8s.pod.volume.available",
7479 opt...,
7480 )
7481 if err != nil {
7482 return PodVolumeAvailable{noop.Int64UpDownCounter{}}, err
7483 }
7484 return PodVolumeAvailable{i}, nil
7485 }
7486
7487 // Inst returns the underlying metric instrument.
7488 func (m PodVolumeAvailable) Inst() metric.Int64UpDownCounter {
7489 return m.Int64UpDownCounter
7490 }
7491
7492 // Name returns the semantic convention name of the instrument.
7493 func (PodVolumeAvailable) Name() string {
7494 return "k8s.pod.volume.available"
7495 }
7496
7497 // Unit returns the semantic convention unit of the instrument
7498 func (PodVolumeAvailable) Unit() string {
7499 return "By"
7500 }
7501
7502 // Description returns the semantic convention description of the instrument
7503 func (PodVolumeAvailable) Description() string {
7504 return "Pod volume storage space available."
7505 }
7506
7507 // Add adds incr to the existing count for attrs.
7508 //
7509 // The volumeName is the the name of the K8s volume.
7510 //
7511 // All additional attrs passed are included in the recorded value.
7512 //
7513 // This metric is derived from the
7514 // [VolumeStats.AvailableBytes] field
7515 // of the [PodStats] of the
7516 // Kubelet's stats API.
7517 //
7518 // [VolumeStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7519 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7520 func (m PodVolumeAvailable) Add(
7521 ctx context.Context,
7522 incr int64,
7523 volumeName string,
7524 attrs ...attribute.KeyValue,
7525 ) {
7526 if len(attrs) == 0 {
7527 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
7528 attribute.String("k8s.volume.name", volumeName),
7529 ))
7530 return
7531 }
7532
7533 o := addOptPool.Get().(*[]metric.AddOption)
7534 defer func() {
7535 *o = (*o)[:0]
7536 addOptPool.Put(o)
7537 }()
7538
7539 *o = append(
7540 *o,
7541 metric.WithAttributes(
7542 append(
7543 attrs[:len(attrs):len(attrs)],
7544 attribute.String("k8s.volume.name", volumeName),
7545 )...,
7546 ),
7547 )
7548
7549 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7550 }
7551
7552 // AddSet adds incr to the existing count for set.
7553 //
7554 // This metric is derived from the
7555 // [VolumeStats.AvailableBytes] field
7556 // of the [PodStats] of the
7557 // Kubelet's stats API.
7558 //
7559 // [VolumeStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7560 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7561 func (m PodVolumeAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
7562 if set.Len() == 0 {
7563 m.Int64UpDownCounter.Add(ctx, incr)
7564 return
7565 }
7566
7567 o := addOptPool.Get().(*[]metric.AddOption)
7568 defer func() {
7569 *o = (*o)[:0]
7570 addOptPool.Put(o)
7571 }()
7572
7573 *o = append(*o, metric.WithAttributeSet(set))
7574 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7575 }
7576
7577 // AttrVolumeType returns an optional attribute for the "k8s.volume.type"
7578 // semantic convention. It represents the type of the K8s volume.
7579 func (PodVolumeAvailable) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue {
7580 return attribute.String("k8s.volume.type", string(val))
7581 }
7582
7583 // PodVolumeCapacity is an instrument used to record metric values conforming to
7584 // the "k8s.pod.volume.capacity" semantic conventions. It represents the pod
7585 // volume total capacity.
7586 type PodVolumeCapacity struct {
7587 metric.Int64UpDownCounter
7588 }
7589
7590 var newPodVolumeCapacityOpts = []metric.Int64UpDownCounterOption{
7591 metric.WithDescription("Pod volume total capacity."),
7592 metric.WithUnit("By"),
7593 }
7594
7595 // NewPodVolumeCapacity returns a new PodVolumeCapacity instrument.
7596 func NewPodVolumeCapacity(
7597 m metric.Meter,
7598 opt ...metric.Int64UpDownCounterOption,
7599 ) (PodVolumeCapacity, error) {
7600 // Check if the meter is nil.
7601 if m == nil {
7602 return PodVolumeCapacity{noop.Int64UpDownCounter{}}, nil
7603 }
7604
7605 if len(opt) == 0 {
7606 opt = newPodVolumeCapacityOpts
7607 } else {
7608 opt = append(opt, newPodVolumeCapacityOpts...)
7609 }
7610
7611 i, err := m.Int64UpDownCounter(
7612 "k8s.pod.volume.capacity",
7613 opt...,
7614 )
7615 if err != nil {
7616 return PodVolumeCapacity{noop.Int64UpDownCounter{}}, err
7617 }
7618 return PodVolumeCapacity{i}, nil
7619 }
7620
7621 // Inst returns the underlying metric instrument.
7622 func (m PodVolumeCapacity) Inst() metric.Int64UpDownCounter {
7623 return m.Int64UpDownCounter
7624 }
7625
7626 // Name returns the semantic convention name of the instrument.
7627 func (PodVolumeCapacity) Name() string {
7628 return "k8s.pod.volume.capacity"
7629 }
7630
7631 // Unit returns the semantic convention unit of the instrument
7632 func (PodVolumeCapacity) Unit() string {
7633 return "By"
7634 }
7635
7636 // Description returns the semantic convention description of the instrument
7637 func (PodVolumeCapacity) Description() string {
7638 return "Pod volume total capacity."
7639 }
7640
7641 // Add adds incr to the existing count for attrs.
7642 //
7643 // The volumeName is the the name of the K8s volume.
7644 //
7645 // All additional attrs passed are included in the recorded value.
7646 //
7647 // This metric is derived from the
7648 // [VolumeStats.CapacityBytes] field
7649 // of the [PodStats] of the
7650 // Kubelet's stats API.
7651 //
7652 // [VolumeStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7653 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7654 func (m PodVolumeCapacity) Add(
7655 ctx context.Context,
7656 incr int64,
7657 volumeName string,
7658 attrs ...attribute.KeyValue,
7659 ) {
7660 if len(attrs) == 0 {
7661 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
7662 attribute.String("k8s.volume.name", volumeName),
7663 ))
7664 return
7665 }
7666
7667 o := addOptPool.Get().(*[]metric.AddOption)
7668 defer func() {
7669 *o = (*o)[:0]
7670 addOptPool.Put(o)
7671 }()
7672
7673 *o = append(
7674 *o,
7675 metric.WithAttributes(
7676 append(
7677 attrs[:len(attrs):len(attrs)],
7678 attribute.String("k8s.volume.name", volumeName),
7679 )...,
7680 ),
7681 )
7682
7683 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7684 }
7685
7686 // AddSet adds incr to the existing count for set.
7687 //
7688 // This metric is derived from the
7689 // [VolumeStats.CapacityBytes] field
7690 // of the [PodStats] of the
7691 // Kubelet's stats API.
7692 //
7693 // [VolumeStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7694 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7695 func (m PodVolumeCapacity) AddSet(ctx context.Context, incr int64, set attribute.Set) {
7696 if set.Len() == 0 {
7697 m.Int64UpDownCounter.Add(ctx, incr)
7698 return
7699 }
7700
7701 o := addOptPool.Get().(*[]metric.AddOption)
7702 defer func() {
7703 *o = (*o)[:0]
7704 addOptPool.Put(o)
7705 }()
7706
7707 *o = append(*o, metric.WithAttributeSet(set))
7708 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7709 }
7710
7711 // AttrVolumeType returns an optional attribute for the "k8s.volume.type"
7712 // semantic convention. It represents the type of the K8s volume.
7713 func (PodVolumeCapacity) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue {
7714 return attribute.String("k8s.volume.type", string(val))
7715 }
7716
7717 // PodVolumeInodeCount is an instrument used to record metric values conforming
7718 // to the "k8s.pod.volume.inode.count" semantic conventions. It represents the
7719 // total inodes in the filesystem of the Pod's volume.
7720 type PodVolumeInodeCount struct {
7721 metric.Int64UpDownCounter
7722 }
7723
7724 var newPodVolumeInodeCountOpts = []metric.Int64UpDownCounterOption{
7725 metric.WithDescription("The total inodes in the filesystem of the Pod's volume."),
7726 metric.WithUnit("{inode}"),
7727 }
7728
7729 // NewPodVolumeInodeCount returns a new PodVolumeInodeCount instrument.
7730 func NewPodVolumeInodeCount(
7731 m metric.Meter,
7732 opt ...metric.Int64UpDownCounterOption,
7733 ) (PodVolumeInodeCount, error) {
7734 // Check if the meter is nil.
7735 if m == nil {
7736 return PodVolumeInodeCount{noop.Int64UpDownCounter{}}, nil
7737 }
7738
7739 if len(opt) == 0 {
7740 opt = newPodVolumeInodeCountOpts
7741 } else {
7742 opt = append(opt, newPodVolumeInodeCountOpts...)
7743 }
7744
7745 i, err := m.Int64UpDownCounter(
7746 "k8s.pod.volume.inode.count",
7747 opt...,
7748 )
7749 if err != nil {
7750 return PodVolumeInodeCount{noop.Int64UpDownCounter{}}, err
7751 }
7752 return PodVolumeInodeCount{i}, nil
7753 }
7754
7755 // Inst returns the underlying metric instrument.
7756 func (m PodVolumeInodeCount) Inst() metric.Int64UpDownCounter {
7757 return m.Int64UpDownCounter
7758 }
7759
7760 // Name returns the semantic convention name of the instrument.
7761 func (PodVolumeInodeCount) Name() string {
7762 return "k8s.pod.volume.inode.count"
7763 }
7764
7765 // Unit returns the semantic convention unit of the instrument
7766 func (PodVolumeInodeCount) Unit() string {
7767 return "{inode}"
7768 }
7769
7770 // Description returns the semantic convention description of the instrument
7771 func (PodVolumeInodeCount) Description() string {
7772 return "The total inodes in the filesystem of the Pod's volume."
7773 }
7774
7775 // Add adds incr to the existing count for attrs.
7776 //
7777 // The volumeName is the the name of the K8s volume.
7778 //
7779 // All additional attrs passed are included in the recorded value.
7780 //
7781 // This metric is derived from the
7782 // [VolumeStats.Inodes] field
7783 // of the [PodStats] of the
7784 // Kubelet's stats API.
7785 //
7786 // [VolumeStats.Inodes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7787 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7788 func (m PodVolumeInodeCount) Add(
7789 ctx context.Context,
7790 incr int64,
7791 volumeName string,
7792 attrs ...attribute.KeyValue,
7793 ) {
7794 if len(attrs) == 0 {
7795 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
7796 attribute.String("k8s.volume.name", volumeName),
7797 ))
7798 return
7799 }
7800
7801 o := addOptPool.Get().(*[]metric.AddOption)
7802 defer func() {
7803 *o = (*o)[:0]
7804 addOptPool.Put(o)
7805 }()
7806
7807 *o = append(
7808 *o,
7809 metric.WithAttributes(
7810 append(
7811 attrs[:len(attrs):len(attrs)],
7812 attribute.String("k8s.volume.name", volumeName),
7813 )...,
7814 ),
7815 )
7816
7817 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7818 }
7819
7820 // AddSet adds incr to the existing count for set.
7821 //
7822 // This metric is derived from the
7823 // [VolumeStats.Inodes] field
7824 // of the [PodStats] of the
7825 // Kubelet's stats API.
7826 //
7827 // [VolumeStats.Inodes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7828 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7829 func (m PodVolumeInodeCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
7830 if set.Len() == 0 {
7831 m.Int64UpDownCounter.Add(ctx, incr)
7832 return
7833 }
7834
7835 o := addOptPool.Get().(*[]metric.AddOption)
7836 defer func() {
7837 *o = (*o)[:0]
7838 addOptPool.Put(o)
7839 }()
7840
7841 *o = append(*o, metric.WithAttributeSet(set))
7842 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7843 }
7844
7845 // AttrVolumeType returns an optional attribute for the "k8s.volume.type"
7846 // semantic convention. It represents the type of the K8s volume.
7847 func (PodVolumeInodeCount) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue {
7848 return attribute.String("k8s.volume.type", string(val))
7849 }
7850
7851 // PodVolumeInodeFree is an instrument used to record metric values conforming to
7852 // the "k8s.pod.volume.inode.free" semantic conventions. It represents the free
7853 // inodes in the filesystem of the Pod's volume.
7854 type PodVolumeInodeFree struct {
7855 metric.Int64UpDownCounter
7856 }
7857
7858 var newPodVolumeInodeFreeOpts = []metric.Int64UpDownCounterOption{
7859 metric.WithDescription("The free inodes in the filesystem of the Pod's volume."),
7860 metric.WithUnit("{inode}"),
7861 }
7862
7863 // NewPodVolumeInodeFree returns a new PodVolumeInodeFree instrument.
7864 func NewPodVolumeInodeFree(
7865 m metric.Meter,
7866 opt ...metric.Int64UpDownCounterOption,
7867 ) (PodVolumeInodeFree, error) {
7868 // Check if the meter is nil.
7869 if m == nil {
7870 return PodVolumeInodeFree{noop.Int64UpDownCounter{}}, nil
7871 }
7872
7873 if len(opt) == 0 {
7874 opt = newPodVolumeInodeFreeOpts
7875 } else {
7876 opt = append(opt, newPodVolumeInodeFreeOpts...)
7877 }
7878
7879 i, err := m.Int64UpDownCounter(
7880 "k8s.pod.volume.inode.free",
7881 opt...,
7882 )
7883 if err != nil {
7884 return PodVolumeInodeFree{noop.Int64UpDownCounter{}}, err
7885 }
7886 return PodVolumeInodeFree{i}, nil
7887 }
7888
7889 // Inst returns the underlying metric instrument.
7890 func (m PodVolumeInodeFree) Inst() metric.Int64UpDownCounter {
7891 return m.Int64UpDownCounter
7892 }
7893
7894 // Name returns the semantic convention name of the instrument.
7895 func (PodVolumeInodeFree) Name() string {
7896 return "k8s.pod.volume.inode.free"
7897 }
7898
7899 // Unit returns the semantic convention unit of the instrument
7900 func (PodVolumeInodeFree) Unit() string {
7901 return "{inode}"
7902 }
7903
7904 // Description returns the semantic convention description of the instrument
7905 func (PodVolumeInodeFree) Description() string {
7906 return "The free inodes in the filesystem of the Pod's volume."
7907 }
7908
7909 // Add adds incr to the existing count for attrs.
7910 //
7911 // The volumeName is the the name of the K8s volume.
7912 //
7913 // All additional attrs passed are included in the recorded value.
7914 //
7915 // This metric is derived from the
7916 // [VolumeStats.InodesFree] field
7917 // of the [PodStats] of the
7918 // Kubelet's stats API.
7919 //
7920 // [VolumeStats.InodesFree]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7921 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7922 func (m PodVolumeInodeFree) Add(
7923 ctx context.Context,
7924 incr int64,
7925 volumeName string,
7926 attrs ...attribute.KeyValue,
7927 ) {
7928 if len(attrs) == 0 {
7929 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
7930 attribute.String("k8s.volume.name", volumeName),
7931 ))
7932 return
7933 }
7934
7935 o := addOptPool.Get().(*[]metric.AddOption)
7936 defer func() {
7937 *o = (*o)[:0]
7938 addOptPool.Put(o)
7939 }()
7940
7941 *o = append(
7942 *o,
7943 metric.WithAttributes(
7944 append(
7945 attrs[:len(attrs):len(attrs)],
7946 attribute.String("k8s.volume.name", volumeName),
7947 )...,
7948 ),
7949 )
7950
7951 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7952 }
7953
7954 // AddSet adds incr to the existing count for set.
7955 //
7956 // This metric is derived from the
7957 // [VolumeStats.InodesFree] field
7958 // of the [PodStats] of the
7959 // Kubelet's stats API.
7960 //
7961 // [VolumeStats.InodesFree]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
7962 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
7963 func (m PodVolumeInodeFree) AddSet(ctx context.Context, incr int64, set attribute.Set) {
7964 if set.Len() == 0 {
7965 m.Int64UpDownCounter.Add(ctx, incr)
7966 return
7967 }
7968
7969 o := addOptPool.Get().(*[]metric.AddOption)
7970 defer func() {
7971 *o = (*o)[:0]
7972 addOptPool.Put(o)
7973 }()
7974
7975 *o = append(*o, metric.WithAttributeSet(set))
7976 m.Int64UpDownCounter.Add(ctx, incr, *o...)
7977 }
7978
7979 // AttrVolumeType returns an optional attribute for the "k8s.volume.type"
7980 // semantic convention. It represents the type of the K8s volume.
7981 func (PodVolumeInodeFree) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue {
7982 return attribute.String("k8s.volume.type", string(val))
7983 }
7984
7985 // PodVolumeInodeUsed is an instrument used to record metric values conforming to
7986 // the "k8s.pod.volume.inode.used" semantic conventions. It represents the inodes
7987 // used by the filesystem of the Pod's volume.
7988 type PodVolumeInodeUsed struct {
7989 metric.Int64UpDownCounter
7990 }
7991
7992 var newPodVolumeInodeUsedOpts = []metric.Int64UpDownCounterOption{
7993 metric.WithDescription("The inodes used by the filesystem of the Pod's volume."),
7994 metric.WithUnit("{inode}"),
7995 }
7996
7997 // NewPodVolumeInodeUsed returns a new PodVolumeInodeUsed instrument.
7998 func NewPodVolumeInodeUsed(
7999 m metric.Meter,
8000 opt ...metric.Int64UpDownCounterOption,
8001 ) (PodVolumeInodeUsed, error) {
8002 // Check if the meter is nil.
8003 if m == nil {
8004 return PodVolumeInodeUsed{noop.Int64UpDownCounter{}}, nil
8005 }
8006
8007 if len(opt) == 0 {
8008 opt = newPodVolumeInodeUsedOpts
8009 } else {
8010 opt = append(opt, newPodVolumeInodeUsedOpts...)
8011 }
8012
8013 i, err := m.Int64UpDownCounter(
8014 "k8s.pod.volume.inode.used",
8015 opt...,
8016 )
8017 if err != nil {
8018 return PodVolumeInodeUsed{noop.Int64UpDownCounter{}}, err
8019 }
8020 return PodVolumeInodeUsed{i}, nil
8021 }
8022
8023 // Inst returns the underlying metric instrument.
8024 func (m PodVolumeInodeUsed) Inst() metric.Int64UpDownCounter {
8025 return m.Int64UpDownCounter
8026 }
8027
8028 // Name returns the semantic convention name of the instrument.
8029 func (PodVolumeInodeUsed) Name() string {
8030 return "k8s.pod.volume.inode.used"
8031 }
8032
8033 // Unit returns the semantic convention unit of the instrument
8034 func (PodVolumeInodeUsed) Unit() string {
8035 return "{inode}"
8036 }
8037
8038 // Description returns the semantic convention description of the instrument
8039 func (PodVolumeInodeUsed) Description() string {
8040 return "The inodes used by the filesystem of the Pod's volume."
8041 }
8042
8043 // Add adds incr to the existing count for attrs.
8044 //
8045 // The volumeName is the the name of the K8s volume.
8046 //
8047 // All additional attrs passed are included in the recorded value.
8048 //
8049 // This metric is derived from the
8050 // [VolumeStats.InodesUsed] field
8051 // of the [PodStats] of the
8052 // Kubelet's stats API.
8053 //
8054 // This may not be equal to `inodes - free` because filesystem may share inodes
8055 // with other filesystems.
8056 //
8057 // [VolumeStats.InodesUsed]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
8058 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
8059 func (m PodVolumeInodeUsed) Add(
8060 ctx context.Context,
8061 incr int64,
8062 volumeName string,
8063 attrs ...attribute.KeyValue,
8064 ) {
8065 if len(attrs) == 0 {
8066 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
8067 attribute.String("k8s.volume.name", volumeName),
8068 ))
8069 return
8070 }
8071
8072 o := addOptPool.Get().(*[]metric.AddOption)
8073 defer func() {
8074 *o = (*o)[:0]
8075 addOptPool.Put(o)
8076 }()
8077
8078 *o = append(
8079 *o,
8080 metric.WithAttributes(
8081 append(
8082 attrs[:len(attrs):len(attrs)],
8083 attribute.String("k8s.volume.name", volumeName),
8084 )...,
8085 ),
8086 )
8087
8088 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8089 }
8090
8091 // AddSet adds incr to the existing count for set.
8092 //
8093 // This metric is derived from the
8094 // [VolumeStats.InodesUsed] field
8095 // of the [PodStats] of the
8096 // Kubelet's stats API.
8097 //
8098 // This may not be equal to `inodes - free` because filesystem may share inodes
8099 // with other filesystems.
8100 //
8101 // [VolumeStats.InodesUsed]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
8102 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
8103 func (m PodVolumeInodeUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8104 if set.Len() == 0 {
8105 m.Int64UpDownCounter.Add(ctx, incr)
8106 return
8107 }
8108
8109 o := addOptPool.Get().(*[]metric.AddOption)
8110 defer func() {
8111 *o = (*o)[:0]
8112 addOptPool.Put(o)
8113 }()
8114
8115 *o = append(*o, metric.WithAttributeSet(set))
8116 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8117 }
8118
8119 // AttrVolumeType returns an optional attribute for the "k8s.volume.type"
8120 // semantic convention. It represents the type of the K8s volume.
8121 func (PodVolumeInodeUsed) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue {
8122 return attribute.String("k8s.volume.type", string(val))
8123 }
8124
8125 // PodVolumeUsage is an instrument used to record metric values conforming to the
8126 // "k8s.pod.volume.usage" semantic conventions. It represents the pod volume
8127 // usage.
8128 type PodVolumeUsage struct {
8129 metric.Int64UpDownCounter
8130 }
8131
8132 var newPodVolumeUsageOpts = []metric.Int64UpDownCounterOption{
8133 metric.WithDescription("Pod volume usage."),
8134 metric.WithUnit("By"),
8135 }
8136
8137 // NewPodVolumeUsage returns a new PodVolumeUsage instrument.
8138 func NewPodVolumeUsage(
8139 m metric.Meter,
8140 opt ...metric.Int64UpDownCounterOption,
8141 ) (PodVolumeUsage, error) {
8142 // Check if the meter is nil.
8143 if m == nil {
8144 return PodVolumeUsage{noop.Int64UpDownCounter{}}, nil
8145 }
8146
8147 if len(opt) == 0 {
8148 opt = newPodVolumeUsageOpts
8149 } else {
8150 opt = append(opt, newPodVolumeUsageOpts...)
8151 }
8152
8153 i, err := m.Int64UpDownCounter(
8154 "k8s.pod.volume.usage",
8155 opt...,
8156 )
8157 if err != nil {
8158 return PodVolumeUsage{noop.Int64UpDownCounter{}}, err
8159 }
8160 return PodVolumeUsage{i}, nil
8161 }
8162
8163 // Inst returns the underlying metric instrument.
8164 func (m PodVolumeUsage) Inst() metric.Int64UpDownCounter {
8165 return m.Int64UpDownCounter
8166 }
8167
8168 // Name returns the semantic convention name of the instrument.
8169 func (PodVolumeUsage) Name() string {
8170 return "k8s.pod.volume.usage"
8171 }
8172
8173 // Unit returns the semantic convention unit of the instrument
8174 func (PodVolumeUsage) Unit() string {
8175 return "By"
8176 }
8177
8178 // Description returns the semantic convention description of the instrument
8179 func (PodVolumeUsage) Description() string {
8180 return "Pod volume usage."
8181 }
8182
8183 // Add adds incr to the existing count for attrs.
8184 //
8185 // The volumeName is the the name of the K8s volume.
8186 //
8187 // All additional attrs passed are included in the recorded value.
8188 //
8189 // This may not equal capacity - available.
8190 //
8191 // This metric is derived from the
8192 // [VolumeStats.UsedBytes] field
8193 // of the [PodStats] of the
8194 // Kubelet's stats API.
8195 //
8196 // [VolumeStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
8197 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
8198 func (m PodVolumeUsage) Add(
8199 ctx context.Context,
8200 incr int64,
8201 volumeName string,
8202 attrs ...attribute.KeyValue,
8203 ) {
8204 if len(attrs) == 0 {
8205 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
8206 attribute.String("k8s.volume.name", volumeName),
8207 ))
8208 return
8209 }
8210
8211 o := addOptPool.Get().(*[]metric.AddOption)
8212 defer func() {
8213 *o = (*o)[:0]
8214 addOptPool.Put(o)
8215 }()
8216
8217 *o = append(
8218 *o,
8219 metric.WithAttributes(
8220 append(
8221 attrs[:len(attrs):len(attrs)],
8222 attribute.String("k8s.volume.name", volumeName),
8223 )...,
8224 ),
8225 )
8226
8227 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8228 }
8229
8230 // AddSet adds incr to the existing count for set.
8231 //
8232 // This may not equal capacity - available.
8233 //
8234 // This metric is derived from the
8235 // [VolumeStats.UsedBytes] field
8236 // of the [PodStats] of the
8237 // Kubelet's stats API.
8238 //
8239 // [VolumeStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats
8240 // [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats
8241 func (m PodVolumeUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8242 if set.Len() == 0 {
8243 m.Int64UpDownCounter.Add(ctx, incr)
8244 return
8245 }
8246
8247 o := addOptPool.Get().(*[]metric.AddOption)
8248 defer func() {
8249 *o = (*o)[:0]
8250 addOptPool.Put(o)
8251 }()
8252
8253 *o = append(*o, metric.WithAttributeSet(set))
8254 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8255 }
8256
8257 // AttrVolumeType returns an optional attribute for the "k8s.volume.type"
8258 // semantic convention. It represents the type of the K8s volume.
8259 func (PodVolumeUsage) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue {
8260 return attribute.String("k8s.volume.type", string(val))
8261 }
8262
8263 // ReplicaSetPodAvailable is an instrument used to record metric values
8264 // conforming to the "k8s.replicaset.pod.available" semantic conventions. It
8265 // represents the total number of available replica pods (ready for at least
8266 // minReadySeconds) targeted by this replicaset.
8267 type ReplicaSetPodAvailable struct {
8268 metric.Int64UpDownCounter
8269 }
8270
8271 var newReplicaSetPodAvailableOpts = []metric.Int64UpDownCounterOption{
8272 metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset."),
8273 metric.WithUnit("{pod}"),
8274 }
8275
8276 // NewReplicaSetPodAvailable returns a new ReplicaSetPodAvailable instrument.
8277 func NewReplicaSetPodAvailable(
8278 m metric.Meter,
8279 opt ...metric.Int64UpDownCounterOption,
8280 ) (ReplicaSetPodAvailable, error) {
8281 // Check if the meter is nil.
8282 if m == nil {
8283 return ReplicaSetPodAvailable{noop.Int64UpDownCounter{}}, nil
8284 }
8285
8286 if len(opt) == 0 {
8287 opt = newReplicaSetPodAvailableOpts
8288 } else {
8289 opt = append(opt, newReplicaSetPodAvailableOpts...)
8290 }
8291
8292 i, err := m.Int64UpDownCounter(
8293 "k8s.replicaset.pod.available",
8294 opt...,
8295 )
8296 if err != nil {
8297 return ReplicaSetPodAvailable{noop.Int64UpDownCounter{}}, err
8298 }
8299 return ReplicaSetPodAvailable{i}, nil
8300 }
8301
8302 // Inst returns the underlying metric instrument.
8303 func (m ReplicaSetPodAvailable) Inst() metric.Int64UpDownCounter {
8304 return m.Int64UpDownCounter
8305 }
8306
8307 // Name returns the semantic convention name of the instrument.
8308 func (ReplicaSetPodAvailable) Name() string {
8309 return "k8s.replicaset.pod.available"
8310 }
8311
8312 // Unit returns the semantic convention unit of the instrument
8313 func (ReplicaSetPodAvailable) Unit() string {
8314 return "{pod}"
8315 }
8316
8317 // Description returns the semantic convention description of the instrument
8318 func (ReplicaSetPodAvailable) Description() string {
8319 return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset."
8320 }
8321
8322 // Add adds incr to the existing count for attrs.
8323 //
8324 // This metric aligns with the `availableReplicas` field of the
8325 // [K8s ReplicaSetStatus].
8326 //
8327 // [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps
8328 func (m ReplicaSetPodAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
8329 if len(attrs) == 0 {
8330 m.Int64UpDownCounter.Add(ctx, incr)
8331 return
8332 }
8333
8334 o := addOptPool.Get().(*[]metric.AddOption)
8335 defer func() {
8336 *o = (*o)[:0]
8337 addOptPool.Put(o)
8338 }()
8339
8340 *o = append(*o, metric.WithAttributes(attrs...))
8341 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8342 }
8343
8344 // AddSet adds incr to the existing count for set.
8345 //
8346 // This metric aligns with the `availableReplicas` field of the
8347 // [K8s ReplicaSetStatus].
8348 //
8349 // [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps
8350 func (m ReplicaSetPodAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8351 if set.Len() == 0 {
8352 m.Int64UpDownCounter.Add(ctx, incr)
8353 return
8354 }
8355
8356 o := addOptPool.Get().(*[]metric.AddOption)
8357 defer func() {
8358 *o = (*o)[:0]
8359 addOptPool.Put(o)
8360 }()
8361
8362 *o = append(*o, metric.WithAttributeSet(set))
8363 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8364 }
8365
8366 // ReplicaSetPodDesired is an instrument used to record metric values conforming
8367 // to the "k8s.replicaset.pod.desired" semantic conventions. It represents the
8368 // number of desired replica pods in this replicaset.
8369 type ReplicaSetPodDesired struct {
8370 metric.Int64UpDownCounter
8371 }
8372
8373 var newReplicaSetPodDesiredOpts = []metric.Int64UpDownCounterOption{
8374 metric.WithDescription("Number of desired replica pods in this replicaset."),
8375 metric.WithUnit("{pod}"),
8376 }
8377
8378 // NewReplicaSetPodDesired returns a new ReplicaSetPodDesired instrument.
8379 func NewReplicaSetPodDesired(
8380 m metric.Meter,
8381 opt ...metric.Int64UpDownCounterOption,
8382 ) (ReplicaSetPodDesired, error) {
8383 // Check if the meter is nil.
8384 if m == nil {
8385 return ReplicaSetPodDesired{noop.Int64UpDownCounter{}}, nil
8386 }
8387
8388 if len(opt) == 0 {
8389 opt = newReplicaSetPodDesiredOpts
8390 } else {
8391 opt = append(opt, newReplicaSetPodDesiredOpts...)
8392 }
8393
8394 i, err := m.Int64UpDownCounter(
8395 "k8s.replicaset.pod.desired",
8396 opt...,
8397 )
8398 if err != nil {
8399 return ReplicaSetPodDesired{noop.Int64UpDownCounter{}}, err
8400 }
8401 return ReplicaSetPodDesired{i}, nil
8402 }
8403
8404 // Inst returns the underlying metric instrument.
8405 func (m ReplicaSetPodDesired) Inst() metric.Int64UpDownCounter {
8406 return m.Int64UpDownCounter
8407 }
8408
8409 // Name returns the semantic convention name of the instrument.
8410 func (ReplicaSetPodDesired) Name() string {
8411 return "k8s.replicaset.pod.desired"
8412 }
8413
8414 // Unit returns the semantic convention unit of the instrument
8415 func (ReplicaSetPodDesired) Unit() string {
8416 return "{pod}"
8417 }
8418
8419 // Description returns the semantic convention description of the instrument
8420 func (ReplicaSetPodDesired) Description() string {
8421 return "Number of desired replica pods in this replicaset."
8422 }
8423
8424 // Add adds incr to the existing count for attrs.
8425 //
8426 // This metric aligns with the `replicas` field of the
8427 // [K8s ReplicaSetSpec].
8428 //
8429 // [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps
8430 func (m ReplicaSetPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
8431 if len(attrs) == 0 {
8432 m.Int64UpDownCounter.Add(ctx, incr)
8433 return
8434 }
8435
8436 o := addOptPool.Get().(*[]metric.AddOption)
8437 defer func() {
8438 *o = (*o)[:0]
8439 addOptPool.Put(o)
8440 }()
8441
8442 *o = append(*o, metric.WithAttributes(attrs...))
8443 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8444 }
8445
8446 // AddSet adds incr to the existing count for set.
8447 //
8448 // This metric aligns with the `replicas` field of the
8449 // [K8s ReplicaSetSpec].
8450 //
8451 // [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps
8452 func (m ReplicaSetPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8453 if set.Len() == 0 {
8454 m.Int64UpDownCounter.Add(ctx, incr)
8455 return
8456 }
8457
8458 o := addOptPool.Get().(*[]metric.AddOption)
8459 defer func() {
8460 *o = (*o)[:0]
8461 addOptPool.Put(o)
8462 }()
8463
8464 *o = append(*o, metric.WithAttributeSet(set))
8465 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8466 }
8467
8468 // ReplicationControllerPodAvailable is an instrument used to record metric
8469 // values conforming to the "k8s.replicationcontroller.pod.available" semantic
8470 // conventions. It represents the total number of available replica pods (ready
8471 // for at least minReadySeconds) targeted by this replication controller.
8472 type ReplicationControllerPodAvailable struct {
8473 metric.Int64UpDownCounter
8474 }
8475
8476 var newReplicationControllerPodAvailableOpts = []metric.Int64UpDownCounterOption{
8477 metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller."),
8478 metric.WithUnit("{pod}"),
8479 }
8480
8481 // NewReplicationControllerPodAvailable returns a new
8482 // ReplicationControllerPodAvailable instrument.
8483 func NewReplicationControllerPodAvailable(
8484 m metric.Meter,
8485 opt ...metric.Int64UpDownCounterOption,
8486 ) (ReplicationControllerPodAvailable, error) {
8487 // Check if the meter is nil.
8488 if m == nil {
8489 return ReplicationControllerPodAvailable{noop.Int64UpDownCounter{}}, nil
8490 }
8491
8492 if len(opt) == 0 {
8493 opt = newReplicationControllerPodAvailableOpts
8494 } else {
8495 opt = append(opt, newReplicationControllerPodAvailableOpts...)
8496 }
8497
8498 i, err := m.Int64UpDownCounter(
8499 "k8s.replicationcontroller.pod.available",
8500 opt...,
8501 )
8502 if err != nil {
8503 return ReplicationControllerPodAvailable{noop.Int64UpDownCounter{}}, err
8504 }
8505 return ReplicationControllerPodAvailable{i}, nil
8506 }
8507
8508 // Inst returns the underlying metric instrument.
8509 func (m ReplicationControllerPodAvailable) Inst() metric.Int64UpDownCounter {
8510 return m.Int64UpDownCounter
8511 }
8512
8513 // Name returns the semantic convention name of the instrument.
8514 func (ReplicationControllerPodAvailable) Name() string {
8515 return "k8s.replicationcontroller.pod.available"
8516 }
8517
8518 // Unit returns the semantic convention unit of the instrument
8519 func (ReplicationControllerPodAvailable) Unit() string {
8520 return "{pod}"
8521 }
8522
8523 // Description returns the semantic convention description of the instrument
8524 func (ReplicationControllerPodAvailable) Description() string {
8525 return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller."
8526 }
8527
8528 // Add adds incr to the existing count for attrs.
8529 //
8530 // This metric aligns with the `availableReplicas` field of the
8531 // [K8s ReplicationControllerStatus]
8532 //
8533 // [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core
8534 func (m ReplicationControllerPodAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
8535 if len(attrs) == 0 {
8536 m.Int64UpDownCounter.Add(ctx, incr)
8537 return
8538 }
8539
8540 o := addOptPool.Get().(*[]metric.AddOption)
8541 defer func() {
8542 *o = (*o)[:0]
8543 addOptPool.Put(o)
8544 }()
8545
8546 *o = append(*o, metric.WithAttributes(attrs...))
8547 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8548 }
8549
8550 // AddSet adds incr to the existing count for set.
8551 //
8552 // This metric aligns with the `availableReplicas` field of the
8553 // [K8s ReplicationControllerStatus]
8554 //
8555 // [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core
8556 func (m ReplicationControllerPodAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8557 if set.Len() == 0 {
8558 m.Int64UpDownCounter.Add(ctx, incr)
8559 return
8560 }
8561
8562 o := addOptPool.Get().(*[]metric.AddOption)
8563 defer func() {
8564 *o = (*o)[:0]
8565 addOptPool.Put(o)
8566 }()
8567
8568 *o = append(*o, metric.WithAttributeSet(set))
8569 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8570 }
8571
8572 // ReplicationControllerPodDesired is an instrument used to record metric values
8573 // conforming to the "k8s.replicationcontroller.pod.desired" semantic
8574 // conventions. It represents the number of desired replica pods in this
8575 // replication controller.
8576 type ReplicationControllerPodDesired struct {
8577 metric.Int64UpDownCounter
8578 }
8579
8580 var newReplicationControllerPodDesiredOpts = []metric.Int64UpDownCounterOption{
8581 metric.WithDescription("Number of desired replica pods in this replication controller."),
8582 metric.WithUnit("{pod}"),
8583 }
8584
8585 // NewReplicationControllerPodDesired returns a new
8586 // ReplicationControllerPodDesired instrument.
8587 func NewReplicationControllerPodDesired(
8588 m metric.Meter,
8589 opt ...metric.Int64UpDownCounterOption,
8590 ) (ReplicationControllerPodDesired, error) {
8591 // Check if the meter is nil.
8592 if m == nil {
8593 return ReplicationControllerPodDesired{noop.Int64UpDownCounter{}}, nil
8594 }
8595
8596 if len(opt) == 0 {
8597 opt = newReplicationControllerPodDesiredOpts
8598 } else {
8599 opt = append(opt, newReplicationControllerPodDesiredOpts...)
8600 }
8601
8602 i, err := m.Int64UpDownCounter(
8603 "k8s.replicationcontroller.pod.desired",
8604 opt...,
8605 )
8606 if err != nil {
8607 return ReplicationControllerPodDesired{noop.Int64UpDownCounter{}}, err
8608 }
8609 return ReplicationControllerPodDesired{i}, nil
8610 }
8611
8612 // Inst returns the underlying metric instrument.
8613 func (m ReplicationControllerPodDesired) Inst() metric.Int64UpDownCounter {
8614 return m.Int64UpDownCounter
8615 }
8616
8617 // Name returns the semantic convention name of the instrument.
8618 func (ReplicationControllerPodDesired) Name() string {
8619 return "k8s.replicationcontroller.pod.desired"
8620 }
8621
8622 // Unit returns the semantic convention unit of the instrument
8623 func (ReplicationControllerPodDesired) Unit() string {
8624 return "{pod}"
8625 }
8626
8627 // Description returns the semantic convention description of the instrument
8628 func (ReplicationControllerPodDesired) Description() string {
8629 return "Number of desired replica pods in this replication controller."
8630 }
8631
8632 // Add adds incr to the existing count for attrs.
8633 //
8634 // This metric aligns with the `replicas` field of the
8635 // [K8s ReplicationControllerSpec]
8636 //
8637 // [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core
8638 func (m ReplicationControllerPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
8639 if len(attrs) == 0 {
8640 m.Int64UpDownCounter.Add(ctx, incr)
8641 return
8642 }
8643
8644 o := addOptPool.Get().(*[]metric.AddOption)
8645 defer func() {
8646 *o = (*o)[:0]
8647 addOptPool.Put(o)
8648 }()
8649
8650 *o = append(*o, metric.WithAttributes(attrs...))
8651 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8652 }
8653
8654 // AddSet adds incr to the existing count for set.
8655 //
8656 // This metric aligns with the `replicas` field of the
8657 // [K8s ReplicationControllerSpec]
8658 //
8659 // [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core
8660 func (m ReplicationControllerPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8661 if set.Len() == 0 {
8662 m.Int64UpDownCounter.Add(ctx, incr)
8663 return
8664 }
8665
8666 o := addOptPool.Get().(*[]metric.AddOption)
8667 defer func() {
8668 *o = (*o)[:0]
8669 addOptPool.Put(o)
8670 }()
8671
8672 *o = append(*o, metric.WithAttributeSet(set))
8673 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8674 }
8675
8676 // ResourceQuotaCPULimitHard is an instrument used to record metric values
8677 // conforming to the "k8s.resourcequota.cpu.limit.hard" semantic conventions. It
8678 // represents the CPU limits in a specific namespace.
8679 // The value represents the configured quota limit of the resource in the
8680 // namespace.
8681 type ResourceQuotaCPULimitHard struct {
8682 metric.Int64UpDownCounter
8683 }
8684
8685 var newResourceQuotaCPULimitHardOpts = []metric.Int64UpDownCounterOption{
8686 metric.WithDescription("The CPU limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."),
8687 metric.WithUnit("{cpu}"),
8688 }
8689
8690 // NewResourceQuotaCPULimitHard returns a new ResourceQuotaCPULimitHard
8691 // instrument.
8692 func NewResourceQuotaCPULimitHard(
8693 m metric.Meter,
8694 opt ...metric.Int64UpDownCounterOption,
8695 ) (ResourceQuotaCPULimitHard, error) {
8696 // Check if the meter is nil.
8697 if m == nil {
8698 return ResourceQuotaCPULimitHard{noop.Int64UpDownCounter{}}, nil
8699 }
8700
8701 if len(opt) == 0 {
8702 opt = newResourceQuotaCPULimitHardOpts
8703 } else {
8704 opt = append(opt, newResourceQuotaCPULimitHardOpts...)
8705 }
8706
8707 i, err := m.Int64UpDownCounter(
8708 "k8s.resourcequota.cpu.limit.hard",
8709 opt...,
8710 )
8711 if err != nil {
8712 return ResourceQuotaCPULimitHard{noop.Int64UpDownCounter{}}, err
8713 }
8714 return ResourceQuotaCPULimitHard{i}, nil
8715 }
8716
8717 // Inst returns the underlying metric instrument.
8718 func (m ResourceQuotaCPULimitHard) Inst() metric.Int64UpDownCounter {
8719 return m.Int64UpDownCounter
8720 }
8721
8722 // Name returns the semantic convention name of the instrument.
8723 func (ResourceQuotaCPULimitHard) Name() string {
8724 return "k8s.resourcequota.cpu.limit.hard"
8725 }
8726
8727 // Unit returns the semantic convention unit of the instrument
8728 func (ResourceQuotaCPULimitHard) Unit() string {
8729 return "{cpu}"
8730 }
8731
8732 // Description returns the semantic convention description of the instrument
8733 func (ResourceQuotaCPULimitHard) Description() string {
8734 return "The CPU limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."
8735 }
8736
8737 // Add adds incr to the existing count for attrs.
8738 //
8739 // This metric is retrieved from the `hard` field of the
8740 // [K8s ResourceQuotaStatus].
8741 //
8742 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
8743 func (m ResourceQuotaCPULimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
8744 if len(attrs) == 0 {
8745 m.Int64UpDownCounter.Add(ctx, incr)
8746 return
8747 }
8748
8749 o := addOptPool.Get().(*[]metric.AddOption)
8750 defer func() {
8751 *o = (*o)[:0]
8752 addOptPool.Put(o)
8753 }()
8754
8755 *o = append(*o, metric.WithAttributes(attrs...))
8756 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8757 }
8758
8759 // AddSet adds incr to the existing count for set.
8760 //
8761 // This metric is retrieved from the `hard` field of the
8762 // [K8s ResourceQuotaStatus].
8763 //
8764 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
8765 func (m ResourceQuotaCPULimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8766 if set.Len() == 0 {
8767 m.Int64UpDownCounter.Add(ctx, incr)
8768 return
8769 }
8770
8771 o := addOptPool.Get().(*[]metric.AddOption)
8772 defer func() {
8773 *o = (*o)[:0]
8774 addOptPool.Put(o)
8775 }()
8776
8777 *o = append(*o, metric.WithAttributeSet(set))
8778 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8779 }
8780
8781 // ResourceQuotaCPULimitUsed is an instrument used to record metric values
8782 // conforming to the "k8s.resourcequota.cpu.limit.used" semantic conventions. It
8783 // represents the CPU limits in a specific namespace.
8784 // The value represents the current observed total usage of the resource in the
8785 // namespace.
8786 type ResourceQuotaCPULimitUsed struct {
8787 metric.Int64UpDownCounter
8788 }
8789
8790 var newResourceQuotaCPULimitUsedOpts = []metric.Int64UpDownCounterOption{
8791 metric.WithDescription("The CPU limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."),
8792 metric.WithUnit("{cpu}"),
8793 }
8794
8795 // NewResourceQuotaCPULimitUsed returns a new ResourceQuotaCPULimitUsed
8796 // instrument.
8797 func NewResourceQuotaCPULimitUsed(
8798 m metric.Meter,
8799 opt ...metric.Int64UpDownCounterOption,
8800 ) (ResourceQuotaCPULimitUsed, error) {
8801 // Check if the meter is nil.
8802 if m == nil {
8803 return ResourceQuotaCPULimitUsed{noop.Int64UpDownCounter{}}, nil
8804 }
8805
8806 if len(opt) == 0 {
8807 opt = newResourceQuotaCPULimitUsedOpts
8808 } else {
8809 opt = append(opt, newResourceQuotaCPULimitUsedOpts...)
8810 }
8811
8812 i, err := m.Int64UpDownCounter(
8813 "k8s.resourcequota.cpu.limit.used",
8814 opt...,
8815 )
8816 if err != nil {
8817 return ResourceQuotaCPULimitUsed{noop.Int64UpDownCounter{}}, err
8818 }
8819 return ResourceQuotaCPULimitUsed{i}, nil
8820 }
8821
8822 // Inst returns the underlying metric instrument.
8823 func (m ResourceQuotaCPULimitUsed) Inst() metric.Int64UpDownCounter {
8824 return m.Int64UpDownCounter
8825 }
8826
8827 // Name returns the semantic convention name of the instrument.
8828 func (ResourceQuotaCPULimitUsed) Name() string {
8829 return "k8s.resourcequota.cpu.limit.used"
8830 }
8831
8832 // Unit returns the semantic convention unit of the instrument
8833 func (ResourceQuotaCPULimitUsed) Unit() string {
8834 return "{cpu}"
8835 }
8836
8837 // Description returns the semantic convention description of the instrument
8838 func (ResourceQuotaCPULimitUsed) Description() string {
8839 return "The CPU limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."
8840 }
8841
8842 // Add adds incr to the existing count for attrs.
8843 //
8844 // This metric is retrieved from the `used` field of the
8845 // [K8s ResourceQuotaStatus].
8846 //
8847 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
8848 func (m ResourceQuotaCPULimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
8849 if len(attrs) == 0 {
8850 m.Int64UpDownCounter.Add(ctx, incr)
8851 return
8852 }
8853
8854 o := addOptPool.Get().(*[]metric.AddOption)
8855 defer func() {
8856 *o = (*o)[:0]
8857 addOptPool.Put(o)
8858 }()
8859
8860 *o = append(*o, metric.WithAttributes(attrs...))
8861 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8862 }
8863
8864 // AddSet adds incr to the existing count for set.
8865 //
8866 // This metric is retrieved from the `used` field of the
8867 // [K8s ResourceQuotaStatus].
8868 //
8869 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
8870 func (m ResourceQuotaCPULimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8871 if set.Len() == 0 {
8872 m.Int64UpDownCounter.Add(ctx, incr)
8873 return
8874 }
8875
8876 o := addOptPool.Get().(*[]metric.AddOption)
8877 defer func() {
8878 *o = (*o)[:0]
8879 addOptPool.Put(o)
8880 }()
8881
8882 *o = append(*o, metric.WithAttributeSet(set))
8883 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8884 }
8885
8886 // ResourceQuotaCPURequestHard is an instrument used to record metric values
8887 // conforming to the "k8s.resourcequota.cpu.request.hard" semantic conventions.
8888 // It represents the CPU requests in a specific namespace.
8889 // The value represents the configured quota limit of the resource in the
8890 // namespace.
8891 type ResourceQuotaCPURequestHard struct {
8892 metric.Int64UpDownCounter
8893 }
8894
8895 var newResourceQuotaCPURequestHardOpts = []metric.Int64UpDownCounterOption{
8896 metric.WithDescription("The CPU requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."),
8897 metric.WithUnit("{cpu}"),
8898 }
8899
8900 // NewResourceQuotaCPURequestHard returns a new ResourceQuotaCPURequestHard
8901 // instrument.
8902 func NewResourceQuotaCPURequestHard(
8903 m metric.Meter,
8904 opt ...metric.Int64UpDownCounterOption,
8905 ) (ResourceQuotaCPURequestHard, error) {
8906 // Check if the meter is nil.
8907 if m == nil {
8908 return ResourceQuotaCPURequestHard{noop.Int64UpDownCounter{}}, nil
8909 }
8910
8911 if len(opt) == 0 {
8912 opt = newResourceQuotaCPURequestHardOpts
8913 } else {
8914 opt = append(opt, newResourceQuotaCPURequestHardOpts...)
8915 }
8916
8917 i, err := m.Int64UpDownCounter(
8918 "k8s.resourcequota.cpu.request.hard",
8919 opt...,
8920 )
8921 if err != nil {
8922 return ResourceQuotaCPURequestHard{noop.Int64UpDownCounter{}}, err
8923 }
8924 return ResourceQuotaCPURequestHard{i}, nil
8925 }
8926
8927 // Inst returns the underlying metric instrument.
8928 func (m ResourceQuotaCPURequestHard) Inst() metric.Int64UpDownCounter {
8929 return m.Int64UpDownCounter
8930 }
8931
8932 // Name returns the semantic convention name of the instrument.
8933 func (ResourceQuotaCPURequestHard) Name() string {
8934 return "k8s.resourcequota.cpu.request.hard"
8935 }
8936
8937 // Unit returns the semantic convention unit of the instrument
8938 func (ResourceQuotaCPURequestHard) Unit() string {
8939 return "{cpu}"
8940 }
8941
8942 // Description returns the semantic convention description of the instrument
8943 func (ResourceQuotaCPURequestHard) Description() string {
8944 return "The CPU requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."
8945 }
8946
8947 // Add adds incr to the existing count for attrs.
8948 //
8949 // This metric is retrieved from the `hard` field of the
8950 // [K8s ResourceQuotaStatus].
8951 //
8952 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
8953 func (m ResourceQuotaCPURequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
8954 if len(attrs) == 0 {
8955 m.Int64UpDownCounter.Add(ctx, incr)
8956 return
8957 }
8958
8959 o := addOptPool.Get().(*[]metric.AddOption)
8960 defer func() {
8961 *o = (*o)[:0]
8962 addOptPool.Put(o)
8963 }()
8964
8965 *o = append(*o, metric.WithAttributes(attrs...))
8966 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8967 }
8968
8969 // AddSet adds incr to the existing count for set.
8970 //
8971 // This metric is retrieved from the `hard` field of the
8972 // [K8s ResourceQuotaStatus].
8973 //
8974 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
8975 func (m ResourceQuotaCPURequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
8976 if set.Len() == 0 {
8977 m.Int64UpDownCounter.Add(ctx, incr)
8978 return
8979 }
8980
8981 o := addOptPool.Get().(*[]metric.AddOption)
8982 defer func() {
8983 *o = (*o)[:0]
8984 addOptPool.Put(o)
8985 }()
8986
8987 *o = append(*o, metric.WithAttributeSet(set))
8988 m.Int64UpDownCounter.Add(ctx, incr, *o...)
8989 }
8990
8991 // ResourceQuotaCPURequestUsed is an instrument used to record metric values
8992 // conforming to the "k8s.resourcequota.cpu.request.used" semantic conventions.
8993 // It represents the CPU requests in a specific namespace.
8994 // The value represents the current observed total usage of the resource in the
8995 // namespace.
8996 type ResourceQuotaCPURequestUsed struct {
8997 metric.Int64UpDownCounter
8998 }
8999
9000 var newResourceQuotaCPURequestUsedOpts = []metric.Int64UpDownCounterOption{
9001 metric.WithDescription("The CPU requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."),
9002 metric.WithUnit("{cpu}"),
9003 }
9004
9005 // NewResourceQuotaCPURequestUsed returns a new ResourceQuotaCPURequestUsed
9006 // instrument.
9007 func NewResourceQuotaCPURequestUsed(
9008 m metric.Meter,
9009 opt ...metric.Int64UpDownCounterOption,
9010 ) (ResourceQuotaCPURequestUsed, error) {
9011 // Check if the meter is nil.
9012 if m == nil {
9013 return ResourceQuotaCPURequestUsed{noop.Int64UpDownCounter{}}, nil
9014 }
9015
9016 if len(opt) == 0 {
9017 opt = newResourceQuotaCPURequestUsedOpts
9018 } else {
9019 opt = append(opt, newResourceQuotaCPURequestUsedOpts...)
9020 }
9021
9022 i, err := m.Int64UpDownCounter(
9023 "k8s.resourcequota.cpu.request.used",
9024 opt...,
9025 )
9026 if err != nil {
9027 return ResourceQuotaCPURequestUsed{noop.Int64UpDownCounter{}}, err
9028 }
9029 return ResourceQuotaCPURequestUsed{i}, nil
9030 }
9031
9032 // Inst returns the underlying metric instrument.
9033 func (m ResourceQuotaCPURequestUsed) Inst() metric.Int64UpDownCounter {
9034 return m.Int64UpDownCounter
9035 }
9036
9037 // Name returns the semantic convention name of the instrument.
9038 func (ResourceQuotaCPURequestUsed) Name() string {
9039 return "k8s.resourcequota.cpu.request.used"
9040 }
9041
9042 // Unit returns the semantic convention unit of the instrument
9043 func (ResourceQuotaCPURequestUsed) Unit() string {
9044 return "{cpu}"
9045 }
9046
9047 // Description returns the semantic convention description of the instrument
9048 func (ResourceQuotaCPURequestUsed) Description() string {
9049 return "The CPU requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."
9050 }
9051
9052 // Add adds incr to the existing count for attrs.
9053 //
9054 // This metric is retrieved from the `used` field of the
9055 // [K8s ResourceQuotaStatus].
9056 //
9057 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9058 func (m ResourceQuotaCPURequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
9059 if len(attrs) == 0 {
9060 m.Int64UpDownCounter.Add(ctx, incr)
9061 return
9062 }
9063
9064 o := addOptPool.Get().(*[]metric.AddOption)
9065 defer func() {
9066 *o = (*o)[:0]
9067 addOptPool.Put(o)
9068 }()
9069
9070 *o = append(*o, metric.WithAttributes(attrs...))
9071 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9072 }
9073
9074 // AddSet adds incr to the existing count for set.
9075 //
9076 // This metric is retrieved from the `used` field of the
9077 // [K8s ResourceQuotaStatus].
9078 //
9079 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9080 func (m ResourceQuotaCPURequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9081 if set.Len() == 0 {
9082 m.Int64UpDownCounter.Add(ctx, incr)
9083 return
9084 }
9085
9086 o := addOptPool.Get().(*[]metric.AddOption)
9087 defer func() {
9088 *o = (*o)[:0]
9089 addOptPool.Put(o)
9090 }()
9091
9092 *o = append(*o, metric.WithAttributeSet(set))
9093 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9094 }
9095
9096 // ResourceQuotaEphemeralStorageLimitHard is an instrument used to record metric
9097 // values conforming to the "k8s.resourcequota.ephemeral_storage.limit.hard"
9098 // semantic conventions. It represents the sum of local ephemeral storage limits
9099 // in the namespace.
9100 // The value represents the configured quota limit of the resource in the
9101 // namespace.
9102 type ResourceQuotaEphemeralStorageLimitHard struct {
9103 metric.Int64UpDownCounter
9104 }
9105
9106 var newResourceQuotaEphemeralStorageLimitHardOpts = []metric.Int64UpDownCounterOption{
9107 metric.WithDescription("The sum of local ephemeral storage limits in the namespace. The value represents the configured quota limit of the resource in the namespace."),
9108 metric.WithUnit("By"),
9109 }
9110
9111 // NewResourceQuotaEphemeralStorageLimitHard returns a new
9112 // ResourceQuotaEphemeralStorageLimitHard instrument.
9113 func NewResourceQuotaEphemeralStorageLimitHard(
9114 m metric.Meter,
9115 opt ...metric.Int64UpDownCounterOption,
9116 ) (ResourceQuotaEphemeralStorageLimitHard, error) {
9117 // Check if the meter is nil.
9118 if m == nil {
9119 return ResourceQuotaEphemeralStorageLimitHard{noop.Int64UpDownCounter{}}, nil
9120 }
9121
9122 if len(opt) == 0 {
9123 opt = newResourceQuotaEphemeralStorageLimitHardOpts
9124 } else {
9125 opt = append(opt, newResourceQuotaEphemeralStorageLimitHardOpts...)
9126 }
9127
9128 i, err := m.Int64UpDownCounter(
9129 "k8s.resourcequota.ephemeral_storage.limit.hard",
9130 opt...,
9131 )
9132 if err != nil {
9133 return ResourceQuotaEphemeralStorageLimitHard{noop.Int64UpDownCounter{}}, err
9134 }
9135 return ResourceQuotaEphemeralStorageLimitHard{i}, nil
9136 }
9137
9138 // Inst returns the underlying metric instrument.
9139 func (m ResourceQuotaEphemeralStorageLimitHard) Inst() metric.Int64UpDownCounter {
9140 return m.Int64UpDownCounter
9141 }
9142
9143 // Name returns the semantic convention name of the instrument.
9144 func (ResourceQuotaEphemeralStorageLimitHard) Name() string {
9145 return "k8s.resourcequota.ephemeral_storage.limit.hard"
9146 }
9147
9148 // Unit returns the semantic convention unit of the instrument
9149 func (ResourceQuotaEphemeralStorageLimitHard) Unit() string {
9150 return "By"
9151 }
9152
9153 // Description returns the semantic convention description of the instrument
9154 func (ResourceQuotaEphemeralStorageLimitHard) Description() string {
9155 return "The sum of local ephemeral storage limits in the namespace. The value represents the configured quota limit of the resource in the namespace."
9156 }
9157
9158 // Add adds incr to the existing count for attrs.
9159 //
9160 // This metric is retrieved from the `hard` field of the
9161 // [K8s ResourceQuotaStatus].
9162 //
9163 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9164 func (m ResourceQuotaEphemeralStorageLimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
9165 if len(attrs) == 0 {
9166 m.Int64UpDownCounter.Add(ctx, incr)
9167 return
9168 }
9169
9170 o := addOptPool.Get().(*[]metric.AddOption)
9171 defer func() {
9172 *o = (*o)[:0]
9173 addOptPool.Put(o)
9174 }()
9175
9176 *o = append(*o, metric.WithAttributes(attrs...))
9177 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9178 }
9179
9180 // AddSet adds incr to the existing count for set.
9181 //
9182 // This metric is retrieved from the `hard` field of the
9183 // [K8s ResourceQuotaStatus].
9184 //
9185 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9186 func (m ResourceQuotaEphemeralStorageLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9187 if set.Len() == 0 {
9188 m.Int64UpDownCounter.Add(ctx, incr)
9189 return
9190 }
9191
9192 o := addOptPool.Get().(*[]metric.AddOption)
9193 defer func() {
9194 *o = (*o)[:0]
9195 addOptPool.Put(o)
9196 }()
9197
9198 *o = append(*o, metric.WithAttributeSet(set))
9199 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9200 }
9201
9202 // ResourceQuotaEphemeralStorageLimitUsed is an instrument used to record metric
9203 // values conforming to the "k8s.resourcequota.ephemeral_storage.limit.used"
9204 // semantic conventions. It represents the sum of local ephemeral storage limits
9205 // in the namespace.
9206 // The value represents the current observed total usage of the resource in the
9207 // namespace.
9208 type ResourceQuotaEphemeralStorageLimitUsed struct {
9209 metric.Int64UpDownCounter
9210 }
9211
9212 var newResourceQuotaEphemeralStorageLimitUsedOpts = []metric.Int64UpDownCounterOption{
9213 metric.WithDescription("The sum of local ephemeral storage limits in the namespace. The value represents the current observed total usage of the resource in the namespace."),
9214 metric.WithUnit("By"),
9215 }
9216
9217 // NewResourceQuotaEphemeralStorageLimitUsed returns a new
9218 // ResourceQuotaEphemeralStorageLimitUsed instrument.
9219 func NewResourceQuotaEphemeralStorageLimitUsed(
9220 m metric.Meter,
9221 opt ...metric.Int64UpDownCounterOption,
9222 ) (ResourceQuotaEphemeralStorageLimitUsed, error) {
9223 // Check if the meter is nil.
9224 if m == nil {
9225 return ResourceQuotaEphemeralStorageLimitUsed{noop.Int64UpDownCounter{}}, nil
9226 }
9227
9228 if len(opt) == 0 {
9229 opt = newResourceQuotaEphemeralStorageLimitUsedOpts
9230 } else {
9231 opt = append(opt, newResourceQuotaEphemeralStorageLimitUsedOpts...)
9232 }
9233
9234 i, err := m.Int64UpDownCounter(
9235 "k8s.resourcequota.ephemeral_storage.limit.used",
9236 opt...,
9237 )
9238 if err != nil {
9239 return ResourceQuotaEphemeralStorageLimitUsed{noop.Int64UpDownCounter{}}, err
9240 }
9241 return ResourceQuotaEphemeralStorageLimitUsed{i}, nil
9242 }
9243
9244 // Inst returns the underlying metric instrument.
9245 func (m ResourceQuotaEphemeralStorageLimitUsed) Inst() metric.Int64UpDownCounter {
9246 return m.Int64UpDownCounter
9247 }
9248
9249 // Name returns the semantic convention name of the instrument.
9250 func (ResourceQuotaEphemeralStorageLimitUsed) Name() string {
9251 return "k8s.resourcequota.ephemeral_storage.limit.used"
9252 }
9253
9254 // Unit returns the semantic convention unit of the instrument
9255 func (ResourceQuotaEphemeralStorageLimitUsed) Unit() string {
9256 return "By"
9257 }
9258
9259 // Description returns the semantic convention description of the instrument
9260 func (ResourceQuotaEphemeralStorageLimitUsed) Description() string {
9261 return "The sum of local ephemeral storage limits in the namespace. The value represents the current observed total usage of the resource in the namespace."
9262 }
9263
9264 // Add adds incr to the existing count for attrs.
9265 //
9266 // This metric is retrieved from the `used` field of the
9267 // [K8s ResourceQuotaStatus].
9268 //
9269 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9270 func (m ResourceQuotaEphemeralStorageLimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
9271 if len(attrs) == 0 {
9272 m.Int64UpDownCounter.Add(ctx, incr)
9273 return
9274 }
9275
9276 o := addOptPool.Get().(*[]metric.AddOption)
9277 defer func() {
9278 *o = (*o)[:0]
9279 addOptPool.Put(o)
9280 }()
9281
9282 *o = append(*o, metric.WithAttributes(attrs...))
9283 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9284 }
9285
9286 // AddSet adds incr to the existing count for set.
9287 //
9288 // This metric is retrieved from the `used` field of the
9289 // [K8s ResourceQuotaStatus].
9290 //
9291 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9292 func (m ResourceQuotaEphemeralStorageLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9293 if set.Len() == 0 {
9294 m.Int64UpDownCounter.Add(ctx, incr)
9295 return
9296 }
9297
9298 o := addOptPool.Get().(*[]metric.AddOption)
9299 defer func() {
9300 *o = (*o)[:0]
9301 addOptPool.Put(o)
9302 }()
9303
9304 *o = append(*o, metric.WithAttributeSet(set))
9305 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9306 }
9307
9308 // ResourceQuotaEphemeralStorageRequestHard is an instrument used to record
9309 // metric values conforming to the
9310 // "k8s.resourcequota.ephemeral_storage.request.hard" semantic conventions. It
9311 // represents the sum of local ephemeral storage requests in the namespace.
9312 // The value represents the configured quota limit of the resource in the
9313 // namespace.
9314 type ResourceQuotaEphemeralStorageRequestHard struct {
9315 metric.Int64UpDownCounter
9316 }
9317
9318 var newResourceQuotaEphemeralStorageRequestHardOpts = []metric.Int64UpDownCounterOption{
9319 metric.WithDescription("The sum of local ephemeral storage requests in the namespace. The value represents the configured quota limit of the resource in the namespace."),
9320 metric.WithUnit("By"),
9321 }
9322
9323 // NewResourceQuotaEphemeralStorageRequestHard returns a new
9324 // ResourceQuotaEphemeralStorageRequestHard instrument.
9325 func NewResourceQuotaEphemeralStorageRequestHard(
9326 m metric.Meter,
9327 opt ...metric.Int64UpDownCounterOption,
9328 ) (ResourceQuotaEphemeralStorageRequestHard, error) {
9329 // Check if the meter is nil.
9330 if m == nil {
9331 return ResourceQuotaEphemeralStorageRequestHard{noop.Int64UpDownCounter{}}, nil
9332 }
9333
9334 if len(opt) == 0 {
9335 opt = newResourceQuotaEphemeralStorageRequestHardOpts
9336 } else {
9337 opt = append(opt, newResourceQuotaEphemeralStorageRequestHardOpts...)
9338 }
9339
9340 i, err := m.Int64UpDownCounter(
9341 "k8s.resourcequota.ephemeral_storage.request.hard",
9342 opt...,
9343 )
9344 if err != nil {
9345 return ResourceQuotaEphemeralStorageRequestHard{noop.Int64UpDownCounter{}}, err
9346 }
9347 return ResourceQuotaEphemeralStorageRequestHard{i}, nil
9348 }
9349
9350 // Inst returns the underlying metric instrument.
9351 func (m ResourceQuotaEphemeralStorageRequestHard) Inst() metric.Int64UpDownCounter {
9352 return m.Int64UpDownCounter
9353 }
9354
9355 // Name returns the semantic convention name of the instrument.
9356 func (ResourceQuotaEphemeralStorageRequestHard) Name() string {
9357 return "k8s.resourcequota.ephemeral_storage.request.hard"
9358 }
9359
9360 // Unit returns the semantic convention unit of the instrument
9361 func (ResourceQuotaEphemeralStorageRequestHard) Unit() string {
9362 return "By"
9363 }
9364
9365 // Description returns the semantic convention description of the instrument
9366 func (ResourceQuotaEphemeralStorageRequestHard) Description() string {
9367 return "The sum of local ephemeral storage requests in the namespace. The value represents the configured quota limit of the resource in the namespace."
9368 }
9369
9370 // Add adds incr to the existing count for attrs.
9371 //
9372 // This metric is retrieved from the `hard` field of the
9373 // [K8s ResourceQuotaStatus].
9374 //
9375 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9376 func (m ResourceQuotaEphemeralStorageRequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
9377 if len(attrs) == 0 {
9378 m.Int64UpDownCounter.Add(ctx, incr)
9379 return
9380 }
9381
9382 o := addOptPool.Get().(*[]metric.AddOption)
9383 defer func() {
9384 *o = (*o)[:0]
9385 addOptPool.Put(o)
9386 }()
9387
9388 *o = append(*o, metric.WithAttributes(attrs...))
9389 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9390 }
9391
9392 // AddSet adds incr to the existing count for set.
9393 //
9394 // This metric is retrieved from the `hard` field of the
9395 // [K8s ResourceQuotaStatus].
9396 //
9397 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9398 func (m ResourceQuotaEphemeralStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9399 if set.Len() == 0 {
9400 m.Int64UpDownCounter.Add(ctx, incr)
9401 return
9402 }
9403
9404 o := addOptPool.Get().(*[]metric.AddOption)
9405 defer func() {
9406 *o = (*o)[:0]
9407 addOptPool.Put(o)
9408 }()
9409
9410 *o = append(*o, metric.WithAttributeSet(set))
9411 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9412 }
9413
9414 // ResourceQuotaEphemeralStorageRequestUsed is an instrument used to record
9415 // metric values conforming to the
9416 // "k8s.resourcequota.ephemeral_storage.request.used" semantic conventions. It
9417 // represents the sum of local ephemeral storage requests in the namespace.
9418 // The value represents the current observed total usage of the resource in the
9419 // namespace.
9420 type ResourceQuotaEphemeralStorageRequestUsed struct {
9421 metric.Int64UpDownCounter
9422 }
9423
9424 var newResourceQuotaEphemeralStorageRequestUsedOpts = []metric.Int64UpDownCounterOption{
9425 metric.WithDescription("The sum of local ephemeral storage requests in the namespace. The value represents the current observed total usage of the resource in the namespace."),
9426 metric.WithUnit("By"),
9427 }
9428
9429 // NewResourceQuotaEphemeralStorageRequestUsed returns a new
9430 // ResourceQuotaEphemeralStorageRequestUsed instrument.
9431 func NewResourceQuotaEphemeralStorageRequestUsed(
9432 m metric.Meter,
9433 opt ...metric.Int64UpDownCounterOption,
9434 ) (ResourceQuotaEphemeralStorageRequestUsed, error) {
9435 // Check if the meter is nil.
9436 if m == nil {
9437 return ResourceQuotaEphemeralStorageRequestUsed{noop.Int64UpDownCounter{}}, nil
9438 }
9439
9440 if len(opt) == 0 {
9441 opt = newResourceQuotaEphemeralStorageRequestUsedOpts
9442 } else {
9443 opt = append(opt, newResourceQuotaEphemeralStorageRequestUsedOpts...)
9444 }
9445
9446 i, err := m.Int64UpDownCounter(
9447 "k8s.resourcequota.ephemeral_storage.request.used",
9448 opt...,
9449 )
9450 if err != nil {
9451 return ResourceQuotaEphemeralStorageRequestUsed{noop.Int64UpDownCounter{}}, err
9452 }
9453 return ResourceQuotaEphemeralStorageRequestUsed{i}, nil
9454 }
9455
9456 // Inst returns the underlying metric instrument.
9457 func (m ResourceQuotaEphemeralStorageRequestUsed) Inst() metric.Int64UpDownCounter {
9458 return m.Int64UpDownCounter
9459 }
9460
9461 // Name returns the semantic convention name of the instrument.
9462 func (ResourceQuotaEphemeralStorageRequestUsed) Name() string {
9463 return "k8s.resourcequota.ephemeral_storage.request.used"
9464 }
9465
9466 // Unit returns the semantic convention unit of the instrument
9467 func (ResourceQuotaEphemeralStorageRequestUsed) Unit() string {
9468 return "By"
9469 }
9470
9471 // Description returns the semantic convention description of the instrument
9472 func (ResourceQuotaEphemeralStorageRequestUsed) Description() string {
9473 return "The sum of local ephemeral storage requests in the namespace. The value represents the current observed total usage of the resource in the namespace."
9474 }
9475
9476 // Add adds incr to the existing count for attrs.
9477 //
9478 // This metric is retrieved from the `used` field of the
9479 // [K8s ResourceQuotaStatus].
9480 //
9481 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9482 func (m ResourceQuotaEphemeralStorageRequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
9483 if len(attrs) == 0 {
9484 m.Int64UpDownCounter.Add(ctx, incr)
9485 return
9486 }
9487
9488 o := addOptPool.Get().(*[]metric.AddOption)
9489 defer func() {
9490 *o = (*o)[:0]
9491 addOptPool.Put(o)
9492 }()
9493
9494 *o = append(*o, metric.WithAttributes(attrs...))
9495 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9496 }
9497
9498 // AddSet adds incr to the existing count for set.
9499 //
9500 // This metric is retrieved from the `used` field of the
9501 // [K8s ResourceQuotaStatus].
9502 //
9503 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9504 func (m ResourceQuotaEphemeralStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9505 if set.Len() == 0 {
9506 m.Int64UpDownCounter.Add(ctx, incr)
9507 return
9508 }
9509
9510 o := addOptPool.Get().(*[]metric.AddOption)
9511 defer func() {
9512 *o = (*o)[:0]
9513 addOptPool.Put(o)
9514 }()
9515
9516 *o = append(*o, metric.WithAttributeSet(set))
9517 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9518 }
9519
9520 // ResourceQuotaHugepageCountRequestHard is an instrument used to record metric
9521 // values conforming to the "k8s.resourcequota.hugepage_count.request.hard"
9522 // semantic conventions. It represents the huge page requests in a specific
9523 // namespace.
9524 // The value represents the configured quota limit of the resource in the
9525 // namespace.
9526 type ResourceQuotaHugepageCountRequestHard struct {
9527 metric.Int64UpDownCounter
9528 }
9529
9530 var newResourceQuotaHugepageCountRequestHardOpts = []metric.Int64UpDownCounterOption{
9531 metric.WithDescription("The huge page requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."),
9532 metric.WithUnit("{hugepage}"),
9533 }
9534
9535 // NewResourceQuotaHugepageCountRequestHard returns a new
9536 // ResourceQuotaHugepageCountRequestHard instrument.
9537 func NewResourceQuotaHugepageCountRequestHard(
9538 m metric.Meter,
9539 opt ...metric.Int64UpDownCounterOption,
9540 ) (ResourceQuotaHugepageCountRequestHard, error) {
9541 // Check if the meter is nil.
9542 if m == nil {
9543 return ResourceQuotaHugepageCountRequestHard{noop.Int64UpDownCounter{}}, nil
9544 }
9545
9546 if len(opt) == 0 {
9547 opt = newResourceQuotaHugepageCountRequestHardOpts
9548 } else {
9549 opt = append(opt, newResourceQuotaHugepageCountRequestHardOpts...)
9550 }
9551
9552 i, err := m.Int64UpDownCounter(
9553 "k8s.resourcequota.hugepage_count.request.hard",
9554 opt...,
9555 )
9556 if err != nil {
9557 return ResourceQuotaHugepageCountRequestHard{noop.Int64UpDownCounter{}}, err
9558 }
9559 return ResourceQuotaHugepageCountRequestHard{i}, nil
9560 }
9561
9562 // Inst returns the underlying metric instrument.
9563 func (m ResourceQuotaHugepageCountRequestHard) Inst() metric.Int64UpDownCounter {
9564 return m.Int64UpDownCounter
9565 }
9566
9567 // Name returns the semantic convention name of the instrument.
9568 func (ResourceQuotaHugepageCountRequestHard) Name() string {
9569 return "k8s.resourcequota.hugepage_count.request.hard"
9570 }
9571
9572 // Unit returns the semantic convention unit of the instrument
9573 func (ResourceQuotaHugepageCountRequestHard) Unit() string {
9574 return "{hugepage}"
9575 }
9576
9577 // Description returns the semantic convention description of the instrument
9578 func (ResourceQuotaHugepageCountRequestHard) Description() string {
9579 return "The huge page requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."
9580 }
9581
9582 // Add adds incr to the existing count for attrs.
9583 //
9584 // The hugepageSize is the the size (identifier) of the K8s huge page.
9585 //
9586 // This metric is retrieved from the `hard` field of the
9587 // [K8s ResourceQuotaStatus].
9588 //
9589 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9590 func (m ResourceQuotaHugepageCountRequestHard) Add(
9591 ctx context.Context,
9592 incr int64,
9593 hugepageSize string,
9594 attrs ...attribute.KeyValue,
9595 ) {
9596 if len(attrs) == 0 {
9597 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
9598 attribute.String("k8s.hugepage.size", hugepageSize),
9599 ))
9600 return
9601 }
9602
9603 o := addOptPool.Get().(*[]metric.AddOption)
9604 defer func() {
9605 *o = (*o)[:0]
9606 addOptPool.Put(o)
9607 }()
9608
9609 *o = append(
9610 *o,
9611 metric.WithAttributes(
9612 append(
9613 attrs[:len(attrs):len(attrs)],
9614 attribute.String("k8s.hugepage.size", hugepageSize),
9615 )...,
9616 ),
9617 )
9618
9619 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9620 }
9621
9622 // AddSet adds incr to the existing count for set.
9623 //
9624 // This metric is retrieved from the `hard` field of the
9625 // [K8s ResourceQuotaStatus].
9626 //
9627 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9628 func (m ResourceQuotaHugepageCountRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9629 if set.Len() == 0 {
9630 m.Int64UpDownCounter.Add(ctx, incr)
9631 return
9632 }
9633
9634 o := addOptPool.Get().(*[]metric.AddOption)
9635 defer func() {
9636 *o = (*o)[:0]
9637 addOptPool.Put(o)
9638 }()
9639
9640 *o = append(*o, metric.WithAttributeSet(set))
9641 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9642 }
9643
9644 // ResourceQuotaHugepageCountRequestUsed is an instrument used to record metric
9645 // values conforming to the "k8s.resourcequota.hugepage_count.request.used"
9646 // semantic conventions. It represents the huge page requests in a specific
9647 // namespace.
9648 // The value represents the current observed total usage of the resource in the
9649 // namespace.
9650 type ResourceQuotaHugepageCountRequestUsed struct {
9651 metric.Int64UpDownCounter
9652 }
9653
9654 var newResourceQuotaHugepageCountRequestUsedOpts = []metric.Int64UpDownCounterOption{
9655 metric.WithDescription("The huge page requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."),
9656 metric.WithUnit("{hugepage}"),
9657 }
9658
9659 // NewResourceQuotaHugepageCountRequestUsed returns a new
9660 // ResourceQuotaHugepageCountRequestUsed instrument.
9661 func NewResourceQuotaHugepageCountRequestUsed(
9662 m metric.Meter,
9663 opt ...metric.Int64UpDownCounterOption,
9664 ) (ResourceQuotaHugepageCountRequestUsed, error) {
9665 // Check if the meter is nil.
9666 if m == nil {
9667 return ResourceQuotaHugepageCountRequestUsed{noop.Int64UpDownCounter{}}, nil
9668 }
9669
9670 if len(opt) == 0 {
9671 opt = newResourceQuotaHugepageCountRequestUsedOpts
9672 } else {
9673 opt = append(opt, newResourceQuotaHugepageCountRequestUsedOpts...)
9674 }
9675
9676 i, err := m.Int64UpDownCounter(
9677 "k8s.resourcequota.hugepage_count.request.used",
9678 opt...,
9679 )
9680 if err != nil {
9681 return ResourceQuotaHugepageCountRequestUsed{noop.Int64UpDownCounter{}}, err
9682 }
9683 return ResourceQuotaHugepageCountRequestUsed{i}, nil
9684 }
9685
9686 // Inst returns the underlying metric instrument.
9687 func (m ResourceQuotaHugepageCountRequestUsed) Inst() metric.Int64UpDownCounter {
9688 return m.Int64UpDownCounter
9689 }
9690
9691 // Name returns the semantic convention name of the instrument.
9692 func (ResourceQuotaHugepageCountRequestUsed) Name() string {
9693 return "k8s.resourcequota.hugepage_count.request.used"
9694 }
9695
9696 // Unit returns the semantic convention unit of the instrument
9697 func (ResourceQuotaHugepageCountRequestUsed) Unit() string {
9698 return "{hugepage}"
9699 }
9700
9701 // Description returns the semantic convention description of the instrument
9702 func (ResourceQuotaHugepageCountRequestUsed) Description() string {
9703 return "The huge page requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."
9704 }
9705
9706 // Add adds incr to the existing count for attrs.
9707 //
9708 // The hugepageSize is the the size (identifier) of the K8s huge page.
9709 //
9710 // This metric is retrieved from the `used` field of the
9711 // [K8s ResourceQuotaStatus].
9712 //
9713 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9714 func (m ResourceQuotaHugepageCountRequestUsed) Add(
9715 ctx context.Context,
9716 incr int64,
9717 hugepageSize string,
9718 attrs ...attribute.KeyValue,
9719 ) {
9720 if len(attrs) == 0 {
9721 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
9722 attribute.String("k8s.hugepage.size", hugepageSize),
9723 ))
9724 return
9725 }
9726
9727 o := addOptPool.Get().(*[]metric.AddOption)
9728 defer func() {
9729 *o = (*o)[:0]
9730 addOptPool.Put(o)
9731 }()
9732
9733 *o = append(
9734 *o,
9735 metric.WithAttributes(
9736 append(
9737 attrs[:len(attrs):len(attrs)],
9738 attribute.String("k8s.hugepage.size", hugepageSize),
9739 )...,
9740 ),
9741 )
9742
9743 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9744 }
9745
9746 // AddSet adds incr to the existing count for set.
9747 //
9748 // This metric is retrieved from the `used` field of the
9749 // [K8s ResourceQuotaStatus].
9750 //
9751 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9752 func (m ResourceQuotaHugepageCountRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9753 if set.Len() == 0 {
9754 m.Int64UpDownCounter.Add(ctx, incr)
9755 return
9756 }
9757
9758 o := addOptPool.Get().(*[]metric.AddOption)
9759 defer func() {
9760 *o = (*o)[:0]
9761 addOptPool.Put(o)
9762 }()
9763
9764 *o = append(*o, metric.WithAttributeSet(set))
9765 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9766 }
9767
9768 // ResourceQuotaMemoryLimitHard is an instrument used to record metric values
9769 // conforming to the "k8s.resourcequota.memory.limit.hard" semantic conventions.
9770 // It represents the memory limits in a specific namespace.
9771 // The value represents the configured quota limit of the resource in the
9772 // namespace.
9773 type ResourceQuotaMemoryLimitHard struct {
9774 metric.Int64UpDownCounter
9775 }
9776
9777 var newResourceQuotaMemoryLimitHardOpts = []metric.Int64UpDownCounterOption{
9778 metric.WithDescription("The memory limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."),
9779 metric.WithUnit("By"),
9780 }
9781
9782 // NewResourceQuotaMemoryLimitHard returns a new ResourceQuotaMemoryLimitHard
9783 // instrument.
9784 func NewResourceQuotaMemoryLimitHard(
9785 m metric.Meter,
9786 opt ...metric.Int64UpDownCounterOption,
9787 ) (ResourceQuotaMemoryLimitHard, error) {
9788 // Check if the meter is nil.
9789 if m == nil {
9790 return ResourceQuotaMemoryLimitHard{noop.Int64UpDownCounter{}}, nil
9791 }
9792
9793 if len(opt) == 0 {
9794 opt = newResourceQuotaMemoryLimitHardOpts
9795 } else {
9796 opt = append(opt, newResourceQuotaMemoryLimitHardOpts...)
9797 }
9798
9799 i, err := m.Int64UpDownCounter(
9800 "k8s.resourcequota.memory.limit.hard",
9801 opt...,
9802 )
9803 if err != nil {
9804 return ResourceQuotaMemoryLimitHard{noop.Int64UpDownCounter{}}, err
9805 }
9806 return ResourceQuotaMemoryLimitHard{i}, nil
9807 }
9808
9809 // Inst returns the underlying metric instrument.
9810 func (m ResourceQuotaMemoryLimitHard) Inst() metric.Int64UpDownCounter {
9811 return m.Int64UpDownCounter
9812 }
9813
9814 // Name returns the semantic convention name of the instrument.
9815 func (ResourceQuotaMemoryLimitHard) Name() string {
9816 return "k8s.resourcequota.memory.limit.hard"
9817 }
9818
9819 // Unit returns the semantic convention unit of the instrument
9820 func (ResourceQuotaMemoryLimitHard) Unit() string {
9821 return "By"
9822 }
9823
9824 // Description returns the semantic convention description of the instrument
9825 func (ResourceQuotaMemoryLimitHard) Description() string {
9826 return "The memory limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."
9827 }
9828
9829 // Add adds incr to the existing count for attrs.
9830 //
9831 // This metric is retrieved from the `hard` field of the
9832 // [K8s ResourceQuotaStatus].
9833 //
9834 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9835 func (m ResourceQuotaMemoryLimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
9836 if len(attrs) == 0 {
9837 m.Int64UpDownCounter.Add(ctx, incr)
9838 return
9839 }
9840
9841 o := addOptPool.Get().(*[]metric.AddOption)
9842 defer func() {
9843 *o = (*o)[:0]
9844 addOptPool.Put(o)
9845 }()
9846
9847 *o = append(*o, metric.WithAttributes(attrs...))
9848 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9849 }
9850
9851 // AddSet adds incr to the existing count for set.
9852 //
9853 // This metric is retrieved from the `hard` field of the
9854 // [K8s ResourceQuotaStatus].
9855 //
9856 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9857 func (m ResourceQuotaMemoryLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9858 if set.Len() == 0 {
9859 m.Int64UpDownCounter.Add(ctx, incr)
9860 return
9861 }
9862
9863 o := addOptPool.Get().(*[]metric.AddOption)
9864 defer func() {
9865 *o = (*o)[:0]
9866 addOptPool.Put(o)
9867 }()
9868
9869 *o = append(*o, metric.WithAttributeSet(set))
9870 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9871 }
9872
9873 // ResourceQuotaMemoryLimitUsed is an instrument used to record metric values
9874 // conforming to the "k8s.resourcequota.memory.limit.used" semantic conventions.
9875 // It represents the memory limits in a specific namespace.
9876 // The value represents the current observed total usage of the resource in the
9877 // namespace.
9878 type ResourceQuotaMemoryLimitUsed struct {
9879 metric.Int64UpDownCounter
9880 }
9881
9882 var newResourceQuotaMemoryLimitUsedOpts = []metric.Int64UpDownCounterOption{
9883 metric.WithDescription("The memory limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."),
9884 metric.WithUnit("By"),
9885 }
9886
9887 // NewResourceQuotaMemoryLimitUsed returns a new ResourceQuotaMemoryLimitUsed
9888 // instrument.
9889 func NewResourceQuotaMemoryLimitUsed(
9890 m metric.Meter,
9891 opt ...metric.Int64UpDownCounterOption,
9892 ) (ResourceQuotaMemoryLimitUsed, error) {
9893 // Check if the meter is nil.
9894 if m == nil {
9895 return ResourceQuotaMemoryLimitUsed{noop.Int64UpDownCounter{}}, nil
9896 }
9897
9898 if len(opt) == 0 {
9899 opt = newResourceQuotaMemoryLimitUsedOpts
9900 } else {
9901 opt = append(opt, newResourceQuotaMemoryLimitUsedOpts...)
9902 }
9903
9904 i, err := m.Int64UpDownCounter(
9905 "k8s.resourcequota.memory.limit.used",
9906 opt...,
9907 )
9908 if err != nil {
9909 return ResourceQuotaMemoryLimitUsed{noop.Int64UpDownCounter{}}, err
9910 }
9911 return ResourceQuotaMemoryLimitUsed{i}, nil
9912 }
9913
9914 // Inst returns the underlying metric instrument.
9915 func (m ResourceQuotaMemoryLimitUsed) Inst() metric.Int64UpDownCounter {
9916 return m.Int64UpDownCounter
9917 }
9918
9919 // Name returns the semantic convention name of the instrument.
9920 func (ResourceQuotaMemoryLimitUsed) Name() string {
9921 return "k8s.resourcequota.memory.limit.used"
9922 }
9923
9924 // Unit returns the semantic convention unit of the instrument
9925 func (ResourceQuotaMemoryLimitUsed) Unit() string {
9926 return "By"
9927 }
9928
9929 // Description returns the semantic convention description of the instrument
9930 func (ResourceQuotaMemoryLimitUsed) Description() string {
9931 return "The memory limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."
9932 }
9933
9934 // Add adds incr to the existing count for attrs.
9935 //
9936 // This metric is retrieved from the `used` field of the
9937 // [K8s ResourceQuotaStatus].
9938 //
9939 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9940 func (m ResourceQuotaMemoryLimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
9941 if len(attrs) == 0 {
9942 m.Int64UpDownCounter.Add(ctx, incr)
9943 return
9944 }
9945
9946 o := addOptPool.Get().(*[]metric.AddOption)
9947 defer func() {
9948 *o = (*o)[:0]
9949 addOptPool.Put(o)
9950 }()
9951
9952 *o = append(*o, metric.WithAttributes(attrs...))
9953 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9954 }
9955
9956 // AddSet adds incr to the existing count for set.
9957 //
9958 // This metric is retrieved from the `used` field of the
9959 // [K8s ResourceQuotaStatus].
9960 //
9961 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
9962 func (m ResourceQuotaMemoryLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
9963 if set.Len() == 0 {
9964 m.Int64UpDownCounter.Add(ctx, incr)
9965 return
9966 }
9967
9968 o := addOptPool.Get().(*[]metric.AddOption)
9969 defer func() {
9970 *o = (*o)[:0]
9971 addOptPool.Put(o)
9972 }()
9973
9974 *o = append(*o, metric.WithAttributeSet(set))
9975 m.Int64UpDownCounter.Add(ctx, incr, *o...)
9976 }
9977
9978 // ResourceQuotaMemoryRequestHard is an instrument used to record metric values
9979 // conforming to the "k8s.resourcequota.memory.request.hard" semantic
9980 // conventions. It represents the memory requests in a specific namespace.
9981 // The value represents the configured quota limit of the resource in the
9982 // namespace.
9983 type ResourceQuotaMemoryRequestHard struct {
9984 metric.Int64UpDownCounter
9985 }
9986
9987 var newResourceQuotaMemoryRequestHardOpts = []metric.Int64UpDownCounterOption{
9988 metric.WithDescription("The memory requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."),
9989 metric.WithUnit("By"),
9990 }
9991
9992 // NewResourceQuotaMemoryRequestHard returns a new ResourceQuotaMemoryRequestHard
9993 // instrument.
9994 func NewResourceQuotaMemoryRequestHard(
9995 m metric.Meter,
9996 opt ...metric.Int64UpDownCounterOption,
9997 ) (ResourceQuotaMemoryRequestHard, error) {
9998 // Check if the meter is nil.
9999 if m == nil {
10000 return ResourceQuotaMemoryRequestHard{noop.Int64UpDownCounter{}}, nil
10001 }
10002
10003 if len(opt) == 0 {
10004 opt = newResourceQuotaMemoryRequestHardOpts
10005 } else {
10006 opt = append(opt, newResourceQuotaMemoryRequestHardOpts...)
10007 }
10008
10009 i, err := m.Int64UpDownCounter(
10010 "k8s.resourcequota.memory.request.hard",
10011 opt...,
10012 )
10013 if err != nil {
10014 return ResourceQuotaMemoryRequestHard{noop.Int64UpDownCounter{}}, err
10015 }
10016 return ResourceQuotaMemoryRequestHard{i}, nil
10017 }
10018
10019 // Inst returns the underlying metric instrument.
10020 func (m ResourceQuotaMemoryRequestHard) Inst() metric.Int64UpDownCounter {
10021 return m.Int64UpDownCounter
10022 }
10023
10024 // Name returns the semantic convention name of the instrument.
10025 func (ResourceQuotaMemoryRequestHard) Name() string {
10026 return "k8s.resourcequota.memory.request.hard"
10027 }
10028
10029 // Unit returns the semantic convention unit of the instrument
10030 func (ResourceQuotaMemoryRequestHard) Unit() string {
10031 return "By"
10032 }
10033
10034 // Description returns the semantic convention description of the instrument
10035 func (ResourceQuotaMemoryRequestHard) Description() string {
10036 return "The memory requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."
10037 }
10038
10039 // Add adds incr to the existing count for attrs.
10040 //
10041 // This metric is retrieved from the `hard` field of the
10042 // [K8s ResourceQuotaStatus].
10043 //
10044 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10045 func (m ResourceQuotaMemoryRequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
10046 if len(attrs) == 0 {
10047 m.Int64UpDownCounter.Add(ctx, incr)
10048 return
10049 }
10050
10051 o := addOptPool.Get().(*[]metric.AddOption)
10052 defer func() {
10053 *o = (*o)[:0]
10054 addOptPool.Put(o)
10055 }()
10056
10057 *o = append(*o, metric.WithAttributes(attrs...))
10058 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10059 }
10060
10061 // AddSet adds incr to the existing count for set.
10062 //
10063 // This metric is retrieved from the `hard` field of the
10064 // [K8s ResourceQuotaStatus].
10065 //
10066 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10067 func (m ResourceQuotaMemoryRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10068 if set.Len() == 0 {
10069 m.Int64UpDownCounter.Add(ctx, incr)
10070 return
10071 }
10072
10073 o := addOptPool.Get().(*[]metric.AddOption)
10074 defer func() {
10075 *o = (*o)[:0]
10076 addOptPool.Put(o)
10077 }()
10078
10079 *o = append(*o, metric.WithAttributeSet(set))
10080 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10081 }
10082
10083 // ResourceQuotaMemoryRequestUsed is an instrument used to record metric values
10084 // conforming to the "k8s.resourcequota.memory.request.used" semantic
10085 // conventions. It represents the memory requests in a specific namespace.
10086 // The value represents the current observed total usage of the resource in the
10087 // namespace.
10088 type ResourceQuotaMemoryRequestUsed struct {
10089 metric.Int64UpDownCounter
10090 }
10091
10092 var newResourceQuotaMemoryRequestUsedOpts = []metric.Int64UpDownCounterOption{
10093 metric.WithDescription("The memory requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."),
10094 metric.WithUnit("By"),
10095 }
10096
10097 // NewResourceQuotaMemoryRequestUsed returns a new ResourceQuotaMemoryRequestUsed
10098 // instrument.
10099 func NewResourceQuotaMemoryRequestUsed(
10100 m metric.Meter,
10101 opt ...metric.Int64UpDownCounterOption,
10102 ) (ResourceQuotaMemoryRequestUsed, error) {
10103 // Check if the meter is nil.
10104 if m == nil {
10105 return ResourceQuotaMemoryRequestUsed{noop.Int64UpDownCounter{}}, nil
10106 }
10107
10108 if len(opt) == 0 {
10109 opt = newResourceQuotaMemoryRequestUsedOpts
10110 } else {
10111 opt = append(opt, newResourceQuotaMemoryRequestUsedOpts...)
10112 }
10113
10114 i, err := m.Int64UpDownCounter(
10115 "k8s.resourcequota.memory.request.used",
10116 opt...,
10117 )
10118 if err != nil {
10119 return ResourceQuotaMemoryRequestUsed{noop.Int64UpDownCounter{}}, err
10120 }
10121 return ResourceQuotaMemoryRequestUsed{i}, nil
10122 }
10123
10124 // Inst returns the underlying metric instrument.
10125 func (m ResourceQuotaMemoryRequestUsed) Inst() metric.Int64UpDownCounter {
10126 return m.Int64UpDownCounter
10127 }
10128
10129 // Name returns the semantic convention name of the instrument.
10130 func (ResourceQuotaMemoryRequestUsed) Name() string {
10131 return "k8s.resourcequota.memory.request.used"
10132 }
10133
10134 // Unit returns the semantic convention unit of the instrument
10135 func (ResourceQuotaMemoryRequestUsed) Unit() string {
10136 return "By"
10137 }
10138
10139 // Description returns the semantic convention description of the instrument
10140 func (ResourceQuotaMemoryRequestUsed) Description() string {
10141 return "The memory requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."
10142 }
10143
10144 // Add adds incr to the existing count for attrs.
10145 //
10146 // This metric is retrieved from the `used` field of the
10147 // [K8s ResourceQuotaStatus].
10148 //
10149 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10150 func (m ResourceQuotaMemoryRequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
10151 if len(attrs) == 0 {
10152 m.Int64UpDownCounter.Add(ctx, incr)
10153 return
10154 }
10155
10156 o := addOptPool.Get().(*[]metric.AddOption)
10157 defer func() {
10158 *o = (*o)[:0]
10159 addOptPool.Put(o)
10160 }()
10161
10162 *o = append(*o, metric.WithAttributes(attrs...))
10163 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10164 }
10165
10166 // AddSet adds incr to the existing count for set.
10167 //
10168 // This metric is retrieved from the `used` field of the
10169 // [K8s ResourceQuotaStatus].
10170 //
10171 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10172 func (m ResourceQuotaMemoryRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10173 if set.Len() == 0 {
10174 m.Int64UpDownCounter.Add(ctx, incr)
10175 return
10176 }
10177
10178 o := addOptPool.Get().(*[]metric.AddOption)
10179 defer func() {
10180 *o = (*o)[:0]
10181 addOptPool.Put(o)
10182 }()
10183
10184 *o = append(*o, metric.WithAttributeSet(set))
10185 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10186 }
10187
10188 // ResourceQuotaObjectCountHard is an instrument used to record metric values
10189 // conforming to the "k8s.resourcequota.object_count.hard" semantic conventions.
10190 // It represents the object count limits in a specific namespace.
10191 // The value represents the configured quota limit of the resource in the
10192 // namespace.
10193 type ResourceQuotaObjectCountHard struct {
10194 metric.Int64UpDownCounter
10195 }
10196
10197 var newResourceQuotaObjectCountHardOpts = []metric.Int64UpDownCounterOption{
10198 metric.WithDescription("The object count limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."),
10199 metric.WithUnit("{object}"),
10200 }
10201
10202 // NewResourceQuotaObjectCountHard returns a new ResourceQuotaObjectCountHard
10203 // instrument.
10204 func NewResourceQuotaObjectCountHard(
10205 m metric.Meter,
10206 opt ...metric.Int64UpDownCounterOption,
10207 ) (ResourceQuotaObjectCountHard, error) {
10208 // Check if the meter is nil.
10209 if m == nil {
10210 return ResourceQuotaObjectCountHard{noop.Int64UpDownCounter{}}, nil
10211 }
10212
10213 if len(opt) == 0 {
10214 opt = newResourceQuotaObjectCountHardOpts
10215 } else {
10216 opt = append(opt, newResourceQuotaObjectCountHardOpts...)
10217 }
10218
10219 i, err := m.Int64UpDownCounter(
10220 "k8s.resourcequota.object_count.hard",
10221 opt...,
10222 )
10223 if err != nil {
10224 return ResourceQuotaObjectCountHard{noop.Int64UpDownCounter{}}, err
10225 }
10226 return ResourceQuotaObjectCountHard{i}, nil
10227 }
10228
10229 // Inst returns the underlying metric instrument.
10230 func (m ResourceQuotaObjectCountHard) Inst() metric.Int64UpDownCounter {
10231 return m.Int64UpDownCounter
10232 }
10233
10234 // Name returns the semantic convention name of the instrument.
10235 func (ResourceQuotaObjectCountHard) Name() string {
10236 return "k8s.resourcequota.object_count.hard"
10237 }
10238
10239 // Unit returns the semantic convention unit of the instrument
10240 func (ResourceQuotaObjectCountHard) Unit() string {
10241 return "{object}"
10242 }
10243
10244 // Description returns the semantic convention description of the instrument
10245 func (ResourceQuotaObjectCountHard) Description() string {
10246 return "The object count limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."
10247 }
10248
10249 // Add adds incr to the existing count for attrs.
10250 //
10251 // The resourcequotaResourceName is the the name of the K8s resource a resource
10252 // quota defines.
10253 //
10254 // This metric is retrieved from the `hard` field of the
10255 // [K8s ResourceQuotaStatus].
10256 //
10257 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10258 func (m ResourceQuotaObjectCountHard) Add(
10259 ctx context.Context,
10260 incr int64,
10261 resourcequotaResourceName string,
10262 attrs ...attribute.KeyValue,
10263 ) {
10264 if len(attrs) == 0 {
10265 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
10266 attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName),
10267 ))
10268 return
10269 }
10270
10271 o := addOptPool.Get().(*[]metric.AddOption)
10272 defer func() {
10273 *o = (*o)[:0]
10274 addOptPool.Put(o)
10275 }()
10276
10277 *o = append(
10278 *o,
10279 metric.WithAttributes(
10280 append(
10281 attrs[:len(attrs):len(attrs)],
10282 attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName),
10283 )...,
10284 ),
10285 )
10286
10287 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10288 }
10289
10290 // AddSet adds incr to the existing count for set.
10291 //
10292 // This metric is retrieved from the `hard` field of the
10293 // [K8s ResourceQuotaStatus].
10294 //
10295 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10296 func (m ResourceQuotaObjectCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10297 if set.Len() == 0 {
10298 m.Int64UpDownCounter.Add(ctx, incr)
10299 return
10300 }
10301
10302 o := addOptPool.Get().(*[]metric.AddOption)
10303 defer func() {
10304 *o = (*o)[:0]
10305 addOptPool.Put(o)
10306 }()
10307
10308 *o = append(*o, metric.WithAttributeSet(set))
10309 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10310 }
10311
10312 // ResourceQuotaObjectCountUsed is an instrument used to record metric values
10313 // conforming to the "k8s.resourcequota.object_count.used" semantic conventions.
10314 // It represents the object count limits in a specific namespace.
10315 // The value represents the current observed total usage of the resource in the
10316 // namespace.
10317 type ResourceQuotaObjectCountUsed struct {
10318 metric.Int64UpDownCounter
10319 }
10320
10321 var newResourceQuotaObjectCountUsedOpts = []metric.Int64UpDownCounterOption{
10322 metric.WithDescription("The object count limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."),
10323 metric.WithUnit("{object}"),
10324 }
10325
10326 // NewResourceQuotaObjectCountUsed returns a new ResourceQuotaObjectCountUsed
10327 // instrument.
10328 func NewResourceQuotaObjectCountUsed(
10329 m metric.Meter,
10330 opt ...metric.Int64UpDownCounterOption,
10331 ) (ResourceQuotaObjectCountUsed, error) {
10332 // Check if the meter is nil.
10333 if m == nil {
10334 return ResourceQuotaObjectCountUsed{noop.Int64UpDownCounter{}}, nil
10335 }
10336
10337 if len(opt) == 0 {
10338 opt = newResourceQuotaObjectCountUsedOpts
10339 } else {
10340 opt = append(opt, newResourceQuotaObjectCountUsedOpts...)
10341 }
10342
10343 i, err := m.Int64UpDownCounter(
10344 "k8s.resourcequota.object_count.used",
10345 opt...,
10346 )
10347 if err != nil {
10348 return ResourceQuotaObjectCountUsed{noop.Int64UpDownCounter{}}, err
10349 }
10350 return ResourceQuotaObjectCountUsed{i}, nil
10351 }
10352
10353 // Inst returns the underlying metric instrument.
10354 func (m ResourceQuotaObjectCountUsed) Inst() metric.Int64UpDownCounter {
10355 return m.Int64UpDownCounter
10356 }
10357
10358 // Name returns the semantic convention name of the instrument.
10359 func (ResourceQuotaObjectCountUsed) Name() string {
10360 return "k8s.resourcequota.object_count.used"
10361 }
10362
10363 // Unit returns the semantic convention unit of the instrument
10364 func (ResourceQuotaObjectCountUsed) Unit() string {
10365 return "{object}"
10366 }
10367
10368 // Description returns the semantic convention description of the instrument
10369 func (ResourceQuotaObjectCountUsed) Description() string {
10370 return "The object count limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."
10371 }
10372
10373 // Add adds incr to the existing count for attrs.
10374 //
10375 // The resourcequotaResourceName is the the name of the K8s resource a resource
10376 // quota defines.
10377 //
10378 // This metric is retrieved from the `used` field of the
10379 // [K8s ResourceQuotaStatus].
10380 //
10381 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10382 func (m ResourceQuotaObjectCountUsed) Add(
10383 ctx context.Context,
10384 incr int64,
10385 resourcequotaResourceName string,
10386 attrs ...attribute.KeyValue,
10387 ) {
10388 if len(attrs) == 0 {
10389 m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes(
10390 attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName),
10391 ))
10392 return
10393 }
10394
10395 o := addOptPool.Get().(*[]metric.AddOption)
10396 defer func() {
10397 *o = (*o)[:0]
10398 addOptPool.Put(o)
10399 }()
10400
10401 *o = append(
10402 *o,
10403 metric.WithAttributes(
10404 append(
10405 attrs[:len(attrs):len(attrs)],
10406 attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName),
10407 )...,
10408 ),
10409 )
10410
10411 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10412 }
10413
10414 // AddSet adds incr to the existing count for set.
10415 //
10416 // This metric is retrieved from the `used` field of the
10417 // [K8s ResourceQuotaStatus].
10418 //
10419 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10420 func (m ResourceQuotaObjectCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10421 if set.Len() == 0 {
10422 m.Int64UpDownCounter.Add(ctx, incr)
10423 return
10424 }
10425
10426 o := addOptPool.Get().(*[]metric.AddOption)
10427 defer func() {
10428 *o = (*o)[:0]
10429 addOptPool.Put(o)
10430 }()
10431
10432 *o = append(*o, metric.WithAttributeSet(set))
10433 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10434 }
10435
10436 // ResourceQuotaPersistentvolumeclaimCountHard is an instrument used to record
10437 // metric values conforming to the
10438 // "k8s.resourcequota.persistentvolumeclaim_count.hard" semantic conventions. It
10439 // represents the total number of PersistentVolumeClaims that can exist in the
10440 // namespace.
10441 // The value represents the configured quota limit of the resource in the
10442 // namespace.
10443 type ResourceQuotaPersistentvolumeclaimCountHard struct {
10444 metric.Int64UpDownCounter
10445 }
10446
10447 var newResourceQuotaPersistentvolumeclaimCountHardOpts = []metric.Int64UpDownCounterOption{
10448 metric.WithDescription("The total number of PersistentVolumeClaims that can exist in the namespace. The value represents the configured quota limit of the resource in the namespace."),
10449 metric.WithUnit("{persistentvolumeclaim}"),
10450 }
10451
10452 // NewResourceQuotaPersistentvolumeclaimCountHard returns a new
10453 // ResourceQuotaPersistentvolumeclaimCountHard instrument.
10454 func NewResourceQuotaPersistentvolumeclaimCountHard(
10455 m metric.Meter,
10456 opt ...metric.Int64UpDownCounterOption,
10457 ) (ResourceQuotaPersistentvolumeclaimCountHard, error) {
10458 // Check if the meter is nil.
10459 if m == nil {
10460 return ResourceQuotaPersistentvolumeclaimCountHard{noop.Int64UpDownCounter{}}, nil
10461 }
10462
10463 if len(opt) == 0 {
10464 opt = newResourceQuotaPersistentvolumeclaimCountHardOpts
10465 } else {
10466 opt = append(opt, newResourceQuotaPersistentvolumeclaimCountHardOpts...)
10467 }
10468
10469 i, err := m.Int64UpDownCounter(
10470 "k8s.resourcequota.persistentvolumeclaim_count.hard",
10471 opt...,
10472 )
10473 if err != nil {
10474 return ResourceQuotaPersistentvolumeclaimCountHard{noop.Int64UpDownCounter{}}, err
10475 }
10476 return ResourceQuotaPersistentvolumeclaimCountHard{i}, nil
10477 }
10478
10479 // Inst returns the underlying metric instrument.
10480 func (m ResourceQuotaPersistentvolumeclaimCountHard) Inst() metric.Int64UpDownCounter {
10481 return m.Int64UpDownCounter
10482 }
10483
10484 // Name returns the semantic convention name of the instrument.
10485 func (ResourceQuotaPersistentvolumeclaimCountHard) Name() string {
10486 return "k8s.resourcequota.persistentvolumeclaim_count.hard"
10487 }
10488
10489 // Unit returns the semantic convention unit of the instrument
10490 func (ResourceQuotaPersistentvolumeclaimCountHard) Unit() string {
10491 return "{persistentvolumeclaim}"
10492 }
10493
10494 // Description returns the semantic convention description of the instrument
10495 func (ResourceQuotaPersistentvolumeclaimCountHard) Description() string {
10496 return "The total number of PersistentVolumeClaims that can exist in the namespace. The value represents the configured quota limit of the resource in the namespace."
10497 }
10498
10499 // Add adds incr to the existing count for attrs.
10500 //
10501 // All additional attrs passed are included in the recorded value.
10502 //
10503 // This metric is retrieved from the `hard` field of the
10504 // [K8s ResourceQuotaStatus].
10505 //
10506 // The `k8s.storageclass.name` should be required when a resource quota is
10507 // defined for a specific
10508 // storage class.
10509 //
10510 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10511 func (m ResourceQuotaPersistentvolumeclaimCountHard) Add(
10512 ctx context.Context,
10513 incr int64,
10514 attrs ...attribute.KeyValue,
10515 ) {
10516 if len(attrs) == 0 {
10517 m.Int64UpDownCounter.Add(ctx, incr)
10518 return
10519 }
10520
10521 o := addOptPool.Get().(*[]metric.AddOption)
10522 defer func() {
10523 *o = (*o)[:0]
10524 addOptPool.Put(o)
10525 }()
10526
10527 *o = append(
10528 *o,
10529 metric.WithAttributes(
10530 attrs...,
10531 ),
10532 )
10533
10534 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10535 }
10536
10537 // AddSet adds incr to the existing count for set.
10538 //
10539 // This metric is retrieved from the `hard` field of the
10540 // [K8s ResourceQuotaStatus].
10541 //
10542 // The `k8s.storageclass.name` should be required when a resource quota is
10543 // defined for a specific
10544 // storage class.
10545 //
10546 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10547 func (m ResourceQuotaPersistentvolumeclaimCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10548 if set.Len() == 0 {
10549 m.Int64UpDownCounter.Add(ctx, incr)
10550 return
10551 }
10552
10553 o := addOptPool.Get().(*[]metric.AddOption)
10554 defer func() {
10555 *o = (*o)[:0]
10556 addOptPool.Put(o)
10557 }()
10558
10559 *o = append(*o, metric.WithAttributeSet(set))
10560 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10561 }
10562
10563 // AttrStorageclassName returns an optional attribute for the
10564 // "k8s.storageclass.name" semantic convention. It represents the name of K8s
10565 // [StorageClass] object.
10566 //
10567 // [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io
10568 func (ResourceQuotaPersistentvolumeclaimCountHard) AttrStorageclassName(val string) attribute.KeyValue {
10569 return attribute.String("k8s.storageclass.name", val)
10570 }
10571
10572 // ResourceQuotaPersistentvolumeclaimCountUsed is an instrument used to record
10573 // metric values conforming to the
10574 // "k8s.resourcequota.persistentvolumeclaim_count.used" semantic conventions. It
10575 // represents the total number of PersistentVolumeClaims that can exist in the
10576 // namespace.
10577 // The value represents the current observed total usage of the resource in the
10578 // namespace.
10579 type ResourceQuotaPersistentvolumeclaimCountUsed struct {
10580 metric.Int64UpDownCounter
10581 }
10582
10583 var newResourceQuotaPersistentvolumeclaimCountUsedOpts = []metric.Int64UpDownCounterOption{
10584 metric.WithDescription("The total number of PersistentVolumeClaims that can exist in the namespace. The value represents the current observed total usage of the resource in the namespace."),
10585 metric.WithUnit("{persistentvolumeclaim}"),
10586 }
10587
10588 // NewResourceQuotaPersistentvolumeclaimCountUsed returns a new
10589 // ResourceQuotaPersistentvolumeclaimCountUsed instrument.
10590 func NewResourceQuotaPersistentvolumeclaimCountUsed(
10591 m metric.Meter,
10592 opt ...metric.Int64UpDownCounterOption,
10593 ) (ResourceQuotaPersistentvolumeclaimCountUsed, error) {
10594 // Check if the meter is nil.
10595 if m == nil {
10596 return ResourceQuotaPersistentvolumeclaimCountUsed{noop.Int64UpDownCounter{}}, nil
10597 }
10598
10599 if len(opt) == 0 {
10600 opt = newResourceQuotaPersistentvolumeclaimCountUsedOpts
10601 } else {
10602 opt = append(opt, newResourceQuotaPersistentvolumeclaimCountUsedOpts...)
10603 }
10604
10605 i, err := m.Int64UpDownCounter(
10606 "k8s.resourcequota.persistentvolumeclaim_count.used",
10607 opt...,
10608 )
10609 if err != nil {
10610 return ResourceQuotaPersistentvolumeclaimCountUsed{noop.Int64UpDownCounter{}}, err
10611 }
10612 return ResourceQuotaPersistentvolumeclaimCountUsed{i}, nil
10613 }
10614
10615 // Inst returns the underlying metric instrument.
10616 func (m ResourceQuotaPersistentvolumeclaimCountUsed) Inst() metric.Int64UpDownCounter {
10617 return m.Int64UpDownCounter
10618 }
10619
10620 // Name returns the semantic convention name of the instrument.
10621 func (ResourceQuotaPersistentvolumeclaimCountUsed) Name() string {
10622 return "k8s.resourcequota.persistentvolumeclaim_count.used"
10623 }
10624
10625 // Unit returns the semantic convention unit of the instrument
10626 func (ResourceQuotaPersistentvolumeclaimCountUsed) Unit() string {
10627 return "{persistentvolumeclaim}"
10628 }
10629
10630 // Description returns the semantic convention description of the instrument
10631 func (ResourceQuotaPersistentvolumeclaimCountUsed) Description() string {
10632 return "The total number of PersistentVolumeClaims that can exist in the namespace. The value represents the current observed total usage of the resource in the namespace."
10633 }
10634
10635 // Add adds incr to the existing count for attrs.
10636 //
10637 // All additional attrs passed are included in the recorded value.
10638 //
10639 // This metric is retrieved from the `used` field of the
10640 // [K8s ResourceQuotaStatus].
10641 //
10642 // The `k8s.storageclass.name` should be required when a resource quota is
10643 // defined for a specific
10644 // storage class.
10645 //
10646 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10647 func (m ResourceQuotaPersistentvolumeclaimCountUsed) Add(
10648 ctx context.Context,
10649 incr int64,
10650 attrs ...attribute.KeyValue,
10651 ) {
10652 if len(attrs) == 0 {
10653 m.Int64UpDownCounter.Add(ctx, incr)
10654 return
10655 }
10656
10657 o := addOptPool.Get().(*[]metric.AddOption)
10658 defer func() {
10659 *o = (*o)[:0]
10660 addOptPool.Put(o)
10661 }()
10662
10663 *o = append(
10664 *o,
10665 metric.WithAttributes(
10666 attrs...,
10667 ),
10668 )
10669
10670 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10671 }
10672
10673 // AddSet adds incr to the existing count for set.
10674 //
10675 // This metric is retrieved from the `used` field of the
10676 // [K8s ResourceQuotaStatus].
10677 //
10678 // The `k8s.storageclass.name` should be required when a resource quota is
10679 // defined for a specific
10680 // storage class.
10681 //
10682 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10683 func (m ResourceQuotaPersistentvolumeclaimCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10684 if set.Len() == 0 {
10685 m.Int64UpDownCounter.Add(ctx, incr)
10686 return
10687 }
10688
10689 o := addOptPool.Get().(*[]metric.AddOption)
10690 defer func() {
10691 *o = (*o)[:0]
10692 addOptPool.Put(o)
10693 }()
10694
10695 *o = append(*o, metric.WithAttributeSet(set))
10696 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10697 }
10698
10699 // AttrStorageclassName returns an optional attribute for the
10700 // "k8s.storageclass.name" semantic convention. It represents the name of K8s
10701 // [StorageClass] object.
10702 //
10703 // [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io
10704 func (ResourceQuotaPersistentvolumeclaimCountUsed) AttrStorageclassName(val string) attribute.KeyValue {
10705 return attribute.String("k8s.storageclass.name", val)
10706 }
10707
10708 // ResourceQuotaStorageRequestHard is an instrument used to record metric values
10709 // conforming to the "k8s.resourcequota.storage.request.hard" semantic
10710 // conventions. It represents the storage requests in a specific namespace.
10711 // The value represents the configured quota limit of the resource in the
10712 // namespace.
10713 type ResourceQuotaStorageRequestHard struct {
10714 metric.Int64UpDownCounter
10715 }
10716
10717 var newResourceQuotaStorageRequestHardOpts = []metric.Int64UpDownCounterOption{
10718 metric.WithDescription("The storage requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."),
10719 metric.WithUnit("By"),
10720 }
10721
10722 // NewResourceQuotaStorageRequestHard returns a new
10723 // ResourceQuotaStorageRequestHard instrument.
10724 func NewResourceQuotaStorageRequestHard(
10725 m metric.Meter,
10726 opt ...metric.Int64UpDownCounterOption,
10727 ) (ResourceQuotaStorageRequestHard, error) {
10728 // Check if the meter is nil.
10729 if m == nil {
10730 return ResourceQuotaStorageRequestHard{noop.Int64UpDownCounter{}}, nil
10731 }
10732
10733 if len(opt) == 0 {
10734 opt = newResourceQuotaStorageRequestHardOpts
10735 } else {
10736 opt = append(opt, newResourceQuotaStorageRequestHardOpts...)
10737 }
10738
10739 i, err := m.Int64UpDownCounter(
10740 "k8s.resourcequota.storage.request.hard",
10741 opt...,
10742 )
10743 if err != nil {
10744 return ResourceQuotaStorageRequestHard{noop.Int64UpDownCounter{}}, err
10745 }
10746 return ResourceQuotaStorageRequestHard{i}, nil
10747 }
10748
10749 // Inst returns the underlying metric instrument.
10750 func (m ResourceQuotaStorageRequestHard) Inst() metric.Int64UpDownCounter {
10751 return m.Int64UpDownCounter
10752 }
10753
10754 // Name returns the semantic convention name of the instrument.
10755 func (ResourceQuotaStorageRequestHard) Name() string {
10756 return "k8s.resourcequota.storage.request.hard"
10757 }
10758
10759 // Unit returns the semantic convention unit of the instrument
10760 func (ResourceQuotaStorageRequestHard) Unit() string {
10761 return "By"
10762 }
10763
10764 // Description returns the semantic convention description of the instrument
10765 func (ResourceQuotaStorageRequestHard) Description() string {
10766 return "The storage requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."
10767 }
10768
10769 // Add adds incr to the existing count for attrs.
10770 //
10771 // All additional attrs passed are included in the recorded value.
10772 //
10773 // This metric is retrieved from the `hard` field of the
10774 // [K8s ResourceQuotaStatus].
10775 //
10776 // The `k8s.storageclass.name` should be required when a resource quota is
10777 // defined for a specific
10778 // storage class.
10779 //
10780 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10781 func (m ResourceQuotaStorageRequestHard) Add(
10782 ctx context.Context,
10783 incr int64,
10784 attrs ...attribute.KeyValue,
10785 ) {
10786 if len(attrs) == 0 {
10787 m.Int64UpDownCounter.Add(ctx, incr)
10788 return
10789 }
10790
10791 o := addOptPool.Get().(*[]metric.AddOption)
10792 defer func() {
10793 *o = (*o)[:0]
10794 addOptPool.Put(o)
10795 }()
10796
10797 *o = append(
10798 *o,
10799 metric.WithAttributes(
10800 attrs...,
10801 ),
10802 )
10803
10804 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10805 }
10806
10807 // AddSet adds incr to the existing count for set.
10808 //
10809 // This metric is retrieved from the `hard` field of the
10810 // [K8s ResourceQuotaStatus].
10811 //
10812 // The `k8s.storageclass.name` should be required when a resource quota is
10813 // defined for a specific
10814 // storage class.
10815 //
10816 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10817 func (m ResourceQuotaStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10818 if set.Len() == 0 {
10819 m.Int64UpDownCounter.Add(ctx, incr)
10820 return
10821 }
10822
10823 o := addOptPool.Get().(*[]metric.AddOption)
10824 defer func() {
10825 *o = (*o)[:0]
10826 addOptPool.Put(o)
10827 }()
10828
10829 *o = append(*o, metric.WithAttributeSet(set))
10830 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10831 }
10832
10833 // AttrStorageclassName returns an optional attribute for the
10834 // "k8s.storageclass.name" semantic convention. It represents the name of K8s
10835 // [StorageClass] object.
10836 //
10837 // [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io
10838 func (ResourceQuotaStorageRequestHard) AttrStorageclassName(val string) attribute.KeyValue {
10839 return attribute.String("k8s.storageclass.name", val)
10840 }
10841
10842 // ResourceQuotaStorageRequestUsed is an instrument used to record metric values
10843 // conforming to the "k8s.resourcequota.storage.request.used" semantic
10844 // conventions. It represents the storage requests in a specific namespace.
10845 // The value represents the current observed total usage of the resource in the
10846 // namespace.
10847 type ResourceQuotaStorageRequestUsed struct {
10848 metric.Int64UpDownCounter
10849 }
10850
10851 var newResourceQuotaStorageRequestUsedOpts = []metric.Int64UpDownCounterOption{
10852 metric.WithDescription("The storage requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."),
10853 metric.WithUnit("By"),
10854 }
10855
10856 // NewResourceQuotaStorageRequestUsed returns a new
10857 // ResourceQuotaStorageRequestUsed instrument.
10858 func NewResourceQuotaStorageRequestUsed(
10859 m metric.Meter,
10860 opt ...metric.Int64UpDownCounterOption,
10861 ) (ResourceQuotaStorageRequestUsed, error) {
10862 // Check if the meter is nil.
10863 if m == nil {
10864 return ResourceQuotaStorageRequestUsed{noop.Int64UpDownCounter{}}, nil
10865 }
10866
10867 if len(opt) == 0 {
10868 opt = newResourceQuotaStorageRequestUsedOpts
10869 } else {
10870 opt = append(opt, newResourceQuotaStorageRequestUsedOpts...)
10871 }
10872
10873 i, err := m.Int64UpDownCounter(
10874 "k8s.resourcequota.storage.request.used",
10875 opt...,
10876 )
10877 if err != nil {
10878 return ResourceQuotaStorageRequestUsed{noop.Int64UpDownCounter{}}, err
10879 }
10880 return ResourceQuotaStorageRequestUsed{i}, nil
10881 }
10882
10883 // Inst returns the underlying metric instrument.
10884 func (m ResourceQuotaStorageRequestUsed) Inst() metric.Int64UpDownCounter {
10885 return m.Int64UpDownCounter
10886 }
10887
10888 // Name returns the semantic convention name of the instrument.
10889 func (ResourceQuotaStorageRequestUsed) Name() string {
10890 return "k8s.resourcequota.storage.request.used"
10891 }
10892
10893 // Unit returns the semantic convention unit of the instrument
10894 func (ResourceQuotaStorageRequestUsed) Unit() string {
10895 return "By"
10896 }
10897
10898 // Description returns the semantic convention description of the instrument
10899 func (ResourceQuotaStorageRequestUsed) Description() string {
10900 return "The storage requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."
10901 }
10902
10903 // Add adds incr to the existing count for attrs.
10904 //
10905 // All additional attrs passed are included in the recorded value.
10906 //
10907 // This metric is retrieved from the `used` field of the
10908 // [K8s ResourceQuotaStatus].
10909 //
10910 // The `k8s.storageclass.name` should be required when a resource quota is
10911 // defined for a specific
10912 // storage class.
10913 //
10914 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10915 func (m ResourceQuotaStorageRequestUsed) Add(
10916 ctx context.Context,
10917 incr int64,
10918 attrs ...attribute.KeyValue,
10919 ) {
10920 if len(attrs) == 0 {
10921 m.Int64UpDownCounter.Add(ctx, incr)
10922 return
10923 }
10924
10925 o := addOptPool.Get().(*[]metric.AddOption)
10926 defer func() {
10927 *o = (*o)[:0]
10928 addOptPool.Put(o)
10929 }()
10930
10931 *o = append(
10932 *o,
10933 metric.WithAttributes(
10934 attrs...,
10935 ),
10936 )
10937
10938 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10939 }
10940
10941 // AddSet adds incr to the existing count for set.
10942 //
10943 // This metric is retrieved from the `used` field of the
10944 // [K8s ResourceQuotaStatus].
10945 //
10946 // The `k8s.storageclass.name` should be required when a resource quota is
10947 // defined for a specific
10948 // storage class.
10949 //
10950 // [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core
10951 func (m ResourceQuotaStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) {
10952 if set.Len() == 0 {
10953 m.Int64UpDownCounter.Add(ctx, incr)
10954 return
10955 }
10956
10957 o := addOptPool.Get().(*[]metric.AddOption)
10958 defer func() {
10959 *o = (*o)[:0]
10960 addOptPool.Put(o)
10961 }()
10962
10963 *o = append(*o, metric.WithAttributeSet(set))
10964 m.Int64UpDownCounter.Add(ctx, incr, *o...)
10965 }
10966
10967 // AttrStorageclassName returns an optional attribute for the
10968 // "k8s.storageclass.name" semantic convention. It represents the name of K8s
10969 // [StorageClass] object.
10970 //
10971 // [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io
10972 func (ResourceQuotaStorageRequestUsed) AttrStorageclassName(val string) attribute.KeyValue {
10973 return attribute.String("k8s.storageclass.name", val)
10974 }
10975
10976 // ServiceEndpointCount is an instrument used to record metric values conforming
10977 // to the "k8s.service.endpoint.count" semantic conventions. It represents the
10978 // number of endpoints for a service by condition and address type.
10979 type ServiceEndpointCount struct {
10980 metric.Int64Gauge
10981 }
10982
10983 var newServiceEndpointCountOpts = []metric.Int64GaugeOption{
10984 metric.WithDescription("Number of endpoints for a service by condition and address type."),
10985 metric.WithUnit("{endpoint}"),
10986 }
10987
10988 // NewServiceEndpointCount returns a new ServiceEndpointCount instrument.
10989 func NewServiceEndpointCount(
10990 m metric.Meter,
10991 opt ...metric.Int64GaugeOption,
10992 ) (ServiceEndpointCount, error) {
10993 // Check if the meter is nil.
10994 if m == nil {
10995 return ServiceEndpointCount{noop.Int64Gauge{}}, nil
10996 }
10997
10998 if len(opt) == 0 {
10999 opt = newServiceEndpointCountOpts
11000 } else {
11001 opt = append(opt, newServiceEndpointCountOpts...)
11002 }
11003
11004 i, err := m.Int64Gauge(
11005 "k8s.service.endpoint.count",
11006 opt...,
11007 )
11008 if err != nil {
11009 return ServiceEndpointCount{noop.Int64Gauge{}}, err
11010 }
11011 return ServiceEndpointCount{i}, nil
11012 }
11013
11014 // Inst returns the underlying metric instrument.
11015 func (m ServiceEndpointCount) Inst() metric.Int64Gauge {
11016 return m.Int64Gauge
11017 }
11018
11019 // Name returns the semantic convention name of the instrument.
11020 func (ServiceEndpointCount) Name() string {
11021 return "k8s.service.endpoint.count"
11022 }
11023
11024 // Unit returns the semantic convention unit of the instrument
11025 func (ServiceEndpointCount) Unit() string {
11026 return "{endpoint}"
11027 }
11028
11029 // Description returns the semantic convention description of the instrument
11030 func (ServiceEndpointCount) Description() string {
11031 return "Number of endpoints for a service by condition and address type."
11032 }
11033
11034 // Record records val to the current distribution for attrs.
11035 //
11036 // The serviceEndpointAddressType is the the address type of the service
11037 // endpoint.
11038 //
11039 // The serviceEndpointCondition is the the condition of the service endpoint.
11040 //
11041 // All additional attrs passed are included in the recorded value.
11042 //
11043 // This metric is derived from the Kubernetes [EndpointSlice API].
11044 // It reports the number of network endpoints backing a Service, broken down by
11045 // their condition and address type.
11046 //
11047 // In dual-stack or multi-protocol clusters, separate counts are reported for
11048 // each address family (`IPv4`, `IPv6`, `FQDN`).
11049 //
11050 // When the optional `zone` attribute is enabled, counts are further broken down
11051 // by availability zone for zone-aware monitoring.
11052 //
11053 // An endpoint may be reported under multiple conditions simultaneously (e.g.,
11054 // both `serving` and `terminating` during a graceful shutdown).
11055 // See [K8s EndpointConditions] for more details.
11056 //
11057 // The conditions represent:
11058 //
11059 // - `ready`: Endpoints capable of receiving new connections.
11060 // - `serving`: Endpoints currently handling traffic.
11061 // - `terminating`: Endpoints that are being phased out but may still be
11062 // handling existing connections.
11063 //
11064 // For Services with `publishNotReadyAddresses` enabled (common for headless
11065 // StatefulSets),
11066 // this metric will include endpoints that are published despite not being ready.
11067 // The `k8s.service.publish_not_ready_addresses` resource attribute indicates
11068 // this setting.
11069 //
11070 // [EndpointSlice API]: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/
11071 // [K8s EndpointConditions]: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/
11072 func (m ServiceEndpointCount) Record(
11073 ctx context.Context,
11074 val int64,
11075 serviceEndpointAddressType ServiceEndpointAddressTypeAttr,
11076 serviceEndpointCondition ServiceEndpointConditionAttr,
11077 attrs ...attribute.KeyValue,
11078 ) {
11079 if len(attrs) == 0 {
11080 m.Int64Gauge.Record(ctx, val, metric.WithAttributes(
11081 attribute.String("k8s.service.endpoint.address_type", string(serviceEndpointAddressType)),
11082 attribute.String("k8s.service.endpoint.condition", string(serviceEndpointCondition)),
11083 ))
11084 return
11085 }
11086
11087 o := recOptPool.Get().(*[]metric.RecordOption)
11088 defer func() {
11089 *o = (*o)[:0]
11090 recOptPool.Put(o)
11091 }()
11092
11093 *o = append(
11094 *o,
11095 metric.WithAttributes(
11096 append(
11097 attrs[:len(attrs):len(attrs)],
11098 attribute.String("k8s.service.endpoint.address_type", string(serviceEndpointAddressType)),
11099 attribute.String("k8s.service.endpoint.condition", string(serviceEndpointCondition)),
11100 )...,
11101 ),
11102 )
11103
11104 m.Int64Gauge.Record(ctx, val, *o...)
11105 }
11106
11107 // RecordSet records val to the current distribution for set.
11108 //
11109 // This metric is derived from the Kubernetes [EndpointSlice API].
11110 // It reports the number of network endpoints backing a Service, broken down by
11111 // their condition and address type.
11112 //
11113 // In dual-stack or multi-protocol clusters, separate counts are reported for
11114 // each address family (`IPv4`, `IPv6`, `FQDN`).
11115 //
11116 // When the optional `zone` attribute is enabled, counts are further broken down
11117 // by availability zone for zone-aware monitoring.
11118 //
11119 // An endpoint may be reported under multiple conditions simultaneously (e.g.,
11120 // both `serving` and `terminating` during a graceful shutdown).
11121 // See [K8s EndpointConditions] for more details.
11122 //
11123 // The conditions represent:
11124 //
11125 // - `ready`: Endpoints capable of receiving new connections.
11126 // - `serving`: Endpoints currently handling traffic.
11127 // - `terminating`: Endpoints that are being phased out but may still be
11128 // handling existing connections.
11129 //
11130 // For Services with `publishNotReadyAddresses` enabled (common for headless
11131 // StatefulSets),
11132 // this metric will include endpoints that are published despite not being ready.
11133 // The `k8s.service.publish_not_ready_addresses` resource attribute indicates
11134 // this setting.
11135 //
11136 // [EndpointSlice API]: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/
11137 // [K8s EndpointConditions]: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/
11138 func (m ServiceEndpointCount) RecordSet(ctx context.Context, val int64, set attribute.Set) {
11139 if set.Len() == 0 {
11140 m.Int64Gauge.Record(ctx, val)
11141 return
11142 }
11143
11144 o := recOptPool.Get().(*[]metric.RecordOption)
11145 defer func() {
11146 *o = (*o)[:0]
11147 recOptPool.Put(o)
11148 }()
11149
11150 *o = append(*o, metric.WithAttributeSet(set))
11151 m.Int64Gauge.Record(ctx, val, *o...)
11152 }
11153
11154 // AttrServiceEndpointZone returns an optional attribute for the
11155 // "k8s.service.endpoint.zone" semantic convention. It represents the zone of the
11156 // service endpoint.
11157 func (ServiceEndpointCount) AttrServiceEndpointZone(val string) attribute.KeyValue {
11158 return attribute.String("k8s.service.endpoint.zone", val)
11159 }
11160
11161 // ServiceLoadBalancerIngressCount is an instrument used to record metric values
11162 // conforming to the "k8s.service.load_balancer.ingress.count" semantic
11163 // conventions. It represents the number of load balancer ingress points
11164 // (external IPs/hostnames) assigned to the service.
11165 type ServiceLoadBalancerIngressCount struct {
11166 metric.Int64Gauge
11167 }
11168
11169 var newServiceLoadBalancerIngressCountOpts = []metric.Int64GaugeOption{
11170 metric.WithDescription("Number of load balancer ingress points (external IPs/hostnames) assigned to the service."),
11171 metric.WithUnit("{ingress}"),
11172 }
11173
11174 // NewServiceLoadBalancerIngressCount returns a new
11175 // ServiceLoadBalancerIngressCount instrument.
11176 func NewServiceLoadBalancerIngressCount(
11177 m metric.Meter,
11178 opt ...metric.Int64GaugeOption,
11179 ) (ServiceLoadBalancerIngressCount, error) {
11180 // Check if the meter is nil.
11181 if m == nil {
11182 return ServiceLoadBalancerIngressCount{noop.Int64Gauge{}}, nil
11183 }
11184
11185 if len(opt) == 0 {
11186 opt = newServiceLoadBalancerIngressCountOpts
11187 } else {
11188 opt = append(opt, newServiceLoadBalancerIngressCountOpts...)
11189 }
11190
11191 i, err := m.Int64Gauge(
11192 "k8s.service.load_balancer.ingress.count",
11193 opt...,
11194 )
11195 if err != nil {
11196 return ServiceLoadBalancerIngressCount{noop.Int64Gauge{}}, err
11197 }
11198 return ServiceLoadBalancerIngressCount{i}, nil
11199 }
11200
11201 // Inst returns the underlying metric instrument.
11202 func (m ServiceLoadBalancerIngressCount) Inst() metric.Int64Gauge {
11203 return m.Int64Gauge
11204 }
11205
11206 // Name returns the semantic convention name of the instrument.
11207 func (ServiceLoadBalancerIngressCount) Name() string {
11208 return "k8s.service.load_balancer.ingress.count"
11209 }
11210
11211 // Unit returns the semantic convention unit of the instrument
11212 func (ServiceLoadBalancerIngressCount) Unit() string {
11213 return "{ingress}"
11214 }
11215
11216 // Description returns the semantic convention description of the instrument
11217 func (ServiceLoadBalancerIngressCount) Description() string {
11218 return "Number of load balancer ingress points (external IPs/hostnames) assigned to the service."
11219 }
11220
11221 // Record records val to the current distribution for attrs.
11222 //
11223 // This metric reports the number of external ingress points (IP addresses or
11224 // hostnames)
11225 // assigned to a LoadBalancer Service.
11226 //
11227 // It is only emitted for Services of type `LoadBalancer` and reflects the
11228 // assignments
11229 // made by the underlying infrastructure's load balancer controller in the
11230 // [.status.loadBalancer.ingress] field.
11231 //
11232 // A value of `0` indicates that no ingress points have been assigned yet (e.g.,
11233 // during provisioning).
11234 // A value greater than `1` may occur when multiple IPs or hostnames are assigned
11235 // (e.g., dual-stack configurations).
11236 //
11237 // This metric signals that external endpoints have been assigned by the load
11238 // balancer controller, but it does not
11239 // guarantee that the load balancer is healthy.
11240 //
11241 // [.status.loadBalancer.ingress]: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceStatus
11242 func (m ServiceLoadBalancerIngressCount) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
11243 if len(attrs) == 0 {
11244 m.Int64Gauge.Record(ctx, val)
11245 return
11246 }
11247
11248 o := recOptPool.Get().(*[]metric.RecordOption)
11249 defer func() {
11250 *o = (*o)[:0]
11251 recOptPool.Put(o)
11252 }()
11253
11254 *o = append(*o, metric.WithAttributes(attrs...))
11255 m.Int64Gauge.Record(ctx, val, *o...)
11256 }
11257
11258 // RecordSet records val to the current distribution for set.
11259 //
11260 // This metric reports the number of external ingress points (IP addresses or
11261 // hostnames)
11262 // assigned to a LoadBalancer Service.
11263 //
11264 // It is only emitted for Services of type `LoadBalancer` and reflects the
11265 // assignments
11266 // made by the underlying infrastructure's load balancer controller in the
11267 // [.status.loadBalancer.ingress] field.
11268 //
11269 // A value of `0` indicates that no ingress points have been assigned yet (e.g.,
11270 // during provisioning).
11271 // A value greater than `1` may occur when multiple IPs or hostnames are assigned
11272 // (e.g., dual-stack configurations).
11273 //
11274 // This metric signals that external endpoints have been assigned by the load
11275 // balancer controller, but it does not
11276 // guarantee that the load balancer is healthy.
11277 //
11278 // [.status.loadBalancer.ingress]: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceStatus
11279 func (m ServiceLoadBalancerIngressCount) RecordSet(ctx context.Context, val int64, set attribute.Set) {
11280 if set.Len() == 0 {
11281 m.Int64Gauge.Record(ctx, val)
11282 return
11283 }
11284
11285 o := recOptPool.Get().(*[]metric.RecordOption)
11286 defer func() {
11287 *o = (*o)[:0]
11288 recOptPool.Put(o)
11289 }()
11290
11291 *o = append(*o, metric.WithAttributeSet(set))
11292 m.Int64Gauge.Record(ctx, val, *o...)
11293 }
11294
11295 // StatefulSetPodCurrent is an instrument used to record metric values conforming
11296 // to the "k8s.statefulset.pod.current" semantic conventions. It represents the
11297 // number of replica pods created by the statefulset controller from the
11298 // statefulset version indicated by currentRevision.
11299 type StatefulSetPodCurrent struct {
11300 metric.Int64UpDownCounter
11301 }
11302
11303 var newStatefulSetPodCurrentOpts = []metric.Int64UpDownCounterOption{
11304 metric.WithDescription("The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision."),
11305 metric.WithUnit("{pod}"),
11306 }
11307
11308 // NewStatefulSetPodCurrent returns a new StatefulSetPodCurrent instrument.
11309 func NewStatefulSetPodCurrent(
11310 m metric.Meter,
11311 opt ...metric.Int64UpDownCounterOption,
11312 ) (StatefulSetPodCurrent, error) {
11313 // Check if the meter is nil.
11314 if m == nil {
11315 return StatefulSetPodCurrent{noop.Int64UpDownCounter{}}, nil
11316 }
11317
11318 if len(opt) == 0 {
11319 opt = newStatefulSetPodCurrentOpts
11320 } else {
11321 opt = append(opt, newStatefulSetPodCurrentOpts...)
11322 }
11323
11324 i, err := m.Int64UpDownCounter(
11325 "k8s.statefulset.pod.current",
11326 opt...,
11327 )
11328 if err != nil {
11329 return StatefulSetPodCurrent{noop.Int64UpDownCounter{}}, err
11330 }
11331 return StatefulSetPodCurrent{i}, nil
11332 }
11333
11334 // Inst returns the underlying metric instrument.
11335 func (m StatefulSetPodCurrent) Inst() metric.Int64UpDownCounter {
11336 return m.Int64UpDownCounter
11337 }
11338
11339 // Name returns the semantic convention name of the instrument.
11340 func (StatefulSetPodCurrent) Name() string {
11341 return "k8s.statefulset.pod.current"
11342 }
11343
11344 // Unit returns the semantic convention unit of the instrument
11345 func (StatefulSetPodCurrent) Unit() string {
11346 return "{pod}"
11347 }
11348
11349 // Description returns the semantic convention description of the instrument
11350 func (StatefulSetPodCurrent) Description() string {
11351 return "The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision."
11352 }
11353
11354 // Add adds incr to the existing count for attrs.
11355 //
11356 // This metric aligns with the `currentReplicas` field of the
11357 // [K8s StatefulSetStatus].
11358 //
11359 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
11360 func (m StatefulSetPodCurrent) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
11361 if len(attrs) == 0 {
11362 m.Int64UpDownCounter.Add(ctx, incr)
11363 return
11364 }
11365
11366 o := addOptPool.Get().(*[]metric.AddOption)
11367 defer func() {
11368 *o = (*o)[:0]
11369 addOptPool.Put(o)
11370 }()
11371
11372 *o = append(*o, metric.WithAttributes(attrs...))
11373 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11374 }
11375
11376 // AddSet adds incr to the existing count for set.
11377 //
11378 // This metric aligns with the `currentReplicas` field of the
11379 // [K8s StatefulSetStatus].
11380 //
11381 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
11382 func (m StatefulSetPodCurrent) AddSet(ctx context.Context, incr int64, set attribute.Set) {
11383 if set.Len() == 0 {
11384 m.Int64UpDownCounter.Add(ctx, incr)
11385 return
11386 }
11387
11388 o := addOptPool.Get().(*[]metric.AddOption)
11389 defer func() {
11390 *o = (*o)[:0]
11391 addOptPool.Put(o)
11392 }()
11393
11394 *o = append(*o, metric.WithAttributeSet(set))
11395 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11396 }
11397
11398 // StatefulSetPodDesired is an instrument used to record metric values conforming
11399 // to the "k8s.statefulset.pod.desired" semantic conventions. It represents the
11400 // number of desired replica pods in this statefulset.
11401 type StatefulSetPodDesired struct {
11402 metric.Int64UpDownCounter
11403 }
11404
11405 var newStatefulSetPodDesiredOpts = []metric.Int64UpDownCounterOption{
11406 metric.WithDescription("Number of desired replica pods in this statefulset."),
11407 metric.WithUnit("{pod}"),
11408 }
11409
11410 // NewStatefulSetPodDesired returns a new StatefulSetPodDesired instrument.
11411 func NewStatefulSetPodDesired(
11412 m metric.Meter,
11413 opt ...metric.Int64UpDownCounterOption,
11414 ) (StatefulSetPodDesired, error) {
11415 // Check if the meter is nil.
11416 if m == nil {
11417 return StatefulSetPodDesired{noop.Int64UpDownCounter{}}, nil
11418 }
11419
11420 if len(opt) == 0 {
11421 opt = newStatefulSetPodDesiredOpts
11422 } else {
11423 opt = append(opt, newStatefulSetPodDesiredOpts...)
11424 }
11425
11426 i, err := m.Int64UpDownCounter(
11427 "k8s.statefulset.pod.desired",
11428 opt...,
11429 )
11430 if err != nil {
11431 return StatefulSetPodDesired{noop.Int64UpDownCounter{}}, err
11432 }
11433 return StatefulSetPodDesired{i}, nil
11434 }
11435
11436 // Inst returns the underlying metric instrument.
11437 func (m StatefulSetPodDesired) Inst() metric.Int64UpDownCounter {
11438 return m.Int64UpDownCounter
11439 }
11440
11441 // Name returns the semantic convention name of the instrument.
11442 func (StatefulSetPodDesired) Name() string {
11443 return "k8s.statefulset.pod.desired"
11444 }
11445
11446 // Unit returns the semantic convention unit of the instrument
11447 func (StatefulSetPodDesired) Unit() string {
11448 return "{pod}"
11449 }
11450
11451 // Description returns the semantic convention description of the instrument
11452 func (StatefulSetPodDesired) Description() string {
11453 return "Number of desired replica pods in this statefulset."
11454 }
11455
11456 // Add adds incr to the existing count for attrs.
11457 //
11458 // This metric aligns with the `replicas` field of the
11459 // [K8s StatefulSetSpec].
11460 //
11461 // [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps
11462 func (m StatefulSetPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
11463 if len(attrs) == 0 {
11464 m.Int64UpDownCounter.Add(ctx, incr)
11465 return
11466 }
11467
11468 o := addOptPool.Get().(*[]metric.AddOption)
11469 defer func() {
11470 *o = (*o)[:0]
11471 addOptPool.Put(o)
11472 }()
11473
11474 *o = append(*o, metric.WithAttributes(attrs...))
11475 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11476 }
11477
11478 // AddSet adds incr to the existing count for set.
11479 //
11480 // This metric aligns with the `replicas` field of the
11481 // [K8s StatefulSetSpec].
11482 //
11483 // [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps
11484 func (m StatefulSetPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) {
11485 if set.Len() == 0 {
11486 m.Int64UpDownCounter.Add(ctx, incr)
11487 return
11488 }
11489
11490 o := addOptPool.Get().(*[]metric.AddOption)
11491 defer func() {
11492 *o = (*o)[:0]
11493 addOptPool.Put(o)
11494 }()
11495
11496 *o = append(*o, metric.WithAttributeSet(set))
11497 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11498 }
11499
11500 // StatefulSetPodReady is an instrument used to record metric values conforming
11501 // to the "k8s.statefulset.pod.ready" semantic conventions. It represents the
11502 // number of replica pods created for this statefulset with a Ready Condition.
11503 type StatefulSetPodReady struct {
11504 metric.Int64UpDownCounter
11505 }
11506
11507 var newStatefulSetPodReadyOpts = []metric.Int64UpDownCounterOption{
11508 metric.WithDescription("The number of replica pods created for this statefulset with a Ready Condition."),
11509 metric.WithUnit("{pod}"),
11510 }
11511
11512 // NewStatefulSetPodReady returns a new StatefulSetPodReady instrument.
11513 func NewStatefulSetPodReady(
11514 m metric.Meter,
11515 opt ...metric.Int64UpDownCounterOption,
11516 ) (StatefulSetPodReady, error) {
11517 // Check if the meter is nil.
11518 if m == nil {
11519 return StatefulSetPodReady{noop.Int64UpDownCounter{}}, nil
11520 }
11521
11522 if len(opt) == 0 {
11523 opt = newStatefulSetPodReadyOpts
11524 } else {
11525 opt = append(opt, newStatefulSetPodReadyOpts...)
11526 }
11527
11528 i, err := m.Int64UpDownCounter(
11529 "k8s.statefulset.pod.ready",
11530 opt...,
11531 )
11532 if err != nil {
11533 return StatefulSetPodReady{noop.Int64UpDownCounter{}}, err
11534 }
11535 return StatefulSetPodReady{i}, nil
11536 }
11537
11538 // Inst returns the underlying metric instrument.
11539 func (m StatefulSetPodReady) Inst() metric.Int64UpDownCounter {
11540 return m.Int64UpDownCounter
11541 }
11542
11543 // Name returns the semantic convention name of the instrument.
11544 func (StatefulSetPodReady) Name() string {
11545 return "k8s.statefulset.pod.ready"
11546 }
11547
11548 // Unit returns the semantic convention unit of the instrument
11549 func (StatefulSetPodReady) Unit() string {
11550 return "{pod}"
11551 }
11552
11553 // Description returns the semantic convention description of the instrument
11554 func (StatefulSetPodReady) Description() string {
11555 return "The number of replica pods created for this statefulset with a Ready Condition."
11556 }
11557
11558 // Add adds incr to the existing count for attrs.
11559 //
11560 // This metric aligns with the `readyReplicas` field of the
11561 // [K8s StatefulSetStatus].
11562 //
11563 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
11564 func (m StatefulSetPodReady) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
11565 if len(attrs) == 0 {
11566 m.Int64UpDownCounter.Add(ctx, incr)
11567 return
11568 }
11569
11570 o := addOptPool.Get().(*[]metric.AddOption)
11571 defer func() {
11572 *o = (*o)[:0]
11573 addOptPool.Put(o)
11574 }()
11575
11576 *o = append(*o, metric.WithAttributes(attrs...))
11577 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11578 }
11579
11580 // AddSet adds incr to the existing count for set.
11581 //
11582 // This metric aligns with the `readyReplicas` field of the
11583 // [K8s StatefulSetStatus].
11584 //
11585 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
11586 func (m StatefulSetPodReady) AddSet(ctx context.Context, incr int64, set attribute.Set) {
11587 if set.Len() == 0 {
11588 m.Int64UpDownCounter.Add(ctx, incr)
11589 return
11590 }
11591
11592 o := addOptPool.Get().(*[]metric.AddOption)
11593 defer func() {
11594 *o = (*o)[:0]
11595 addOptPool.Put(o)
11596 }()
11597
11598 *o = append(*o, metric.WithAttributeSet(set))
11599 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11600 }
11601
11602 // StatefulSetPodUpdated is an instrument used to record metric values conforming
11603 // to the "k8s.statefulset.pod.updated" semantic conventions. It represents the
11604 // number of replica pods created by the statefulset controller from the
11605 // statefulset version indicated by updateRevision.
11606 type StatefulSetPodUpdated struct {
11607 metric.Int64UpDownCounter
11608 }
11609
11610 var newStatefulSetPodUpdatedOpts = []metric.Int64UpDownCounterOption{
11611 metric.WithDescription("Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision."),
11612 metric.WithUnit("{pod}"),
11613 }
11614
11615 // NewStatefulSetPodUpdated returns a new StatefulSetPodUpdated instrument.
11616 func NewStatefulSetPodUpdated(
11617 m metric.Meter,
11618 opt ...metric.Int64UpDownCounterOption,
11619 ) (StatefulSetPodUpdated, error) {
11620 // Check if the meter is nil.
11621 if m == nil {
11622 return StatefulSetPodUpdated{noop.Int64UpDownCounter{}}, nil
11623 }
11624
11625 if len(opt) == 0 {
11626 opt = newStatefulSetPodUpdatedOpts
11627 } else {
11628 opt = append(opt, newStatefulSetPodUpdatedOpts...)
11629 }
11630
11631 i, err := m.Int64UpDownCounter(
11632 "k8s.statefulset.pod.updated",
11633 opt...,
11634 )
11635 if err != nil {
11636 return StatefulSetPodUpdated{noop.Int64UpDownCounter{}}, err
11637 }
11638 return StatefulSetPodUpdated{i}, nil
11639 }
11640
11641 // Inst returns the underlying metric instrument.
11642 func (m StatefulSetPodUpdated) Inst() metric.Int64UpDownCounter {
11643 return m.Int64UpDownCounter
11644 }
11645
11646 // Name returns the semantic convention name of the instrument.
11647 func (StatefulSetPodUpdated) Name() string {
11648 return "k8s.statefulset.pod.updated"
11649 }
11650
11651 // Unit returns the semantic convention unit of the instrument
11652 func (StatefulSetPodUpdated) Unit() string {
11653 return "{pod}"
11654 }
11655
11656 // Description returns the semantic convention description of the instrument
11657 func (StatefulSetPodUpdated) Description() string {
11658 return "Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision."
11659 }
11660
11661 // Add adds incr to the existing count for attrs.
11662 //
11663 // This metric aligns with the `updatedReplicas` field of the
11664 // [K8s StatefulSetStatus].
11665 //
11666 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
11667 func (m StatefulSetPodUpdated) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
11668 if len(attrs) == 0 {
11669 m.Int64UpDownCounter.Add(ctx, incr)
11670 return
11671 }
11672
11673 o := addOptPool.Get().(*[]metric.AddOption)
11674 defer func() {
11675 *o = (*o)[:0]
11676 addOptPool.Put(o)
11677 }()
11678
11679 *o = append(*o, metric.WithAttributes(attrs...))
11680 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11681 }
11682
11683 // AddSet adds incr to the existing count for set.
11684 //
11685 // This metric aligns with the `updatedReplicas` field of the
11686 // [K8s StatefulSetStatus].
11687 //
11688 // [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps
11689 func (m StatefulSetPodUpdated) AddSet(ctx context.Context, incr int64, set attribute.Set) {
11690 if set.Len() == 0 {
11691 m.Int64UpDownCounter.Add(ctx, incr)
11692 return
11693 }
11694
11695 o := addOptPool.Get().(*[]metric.AddOption)
11696 defer func() {
11697 *o = (*o)[:0]
11698 addOptPool.Put(o)
11699 }()
11700
11701 *o = append(*o, metric.WithAttributeSet(set))
11702 m.Int64UpDownCounter.Add(ctx, incr, *o...)
11703 }