| 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 |
// VolumeTypeAttr is an attribute conforming to the k8s.volume.type semantic |
| 185 |
// conventions. It represents the type of the K8s volume. |
| 186 |
type VolumeTypeAttr string |
| 187 |
|
| 188 |
var ( |
| 189 |
// VolumeTypePersistentVolumeClaim is a [persistentVolumeClaim] volume. |
| 190 |
// |
| 191 |
// [persistentVolumeClaim]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim |
| 192 |
VolumeTypePersistentVolumeClaim VolumeTypeAttr = "persistentVolumeClaim" |
| 193 |
// VolumeTypeConfigMap is a [configMap] volume. |
| 194 |
// |
| 195 |
// [configMap]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#configmap |
| 196 |
VolumeTypeConfigMap VolumeTypeAttr = "configMap" |
| 197 |
// VolumeTypeDownwardAPI is a [downwardAPI] volume. |
| 198 |
// |
| 199 |
// [downwardAPI]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#downwardapi |
| 200 |
VolumeTypeDownwardAPI VolumeTypeAttr = "downwardAPI" |
| 201 |
// VolumeTypeEmptyDir is an [emptyDir] volume. |
| 202 |
// |
| 203 |
// [emptyDir]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#emptydir |
| 204 |
VolumeTypeEmptyDir VolumeTypeAttr = "emptyDir" |
| 205 |
// VolumeTypeSecret is a [secret] volume. |
| 206 |
// |
| 207 |
// [secret]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#secret |
| 208 |
VolumeTypeSecret VolumeTypeAttr = "secret" |
| 209 |
// VolumeTypeLocal is a [local] volume. |
| 210 |
// |
| 211 |
// [local]: https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#local |
| 212 |
VolumeTypeLocal VolumeTypeAttr = "local" |
| 213 |
) |
| 214 |
|
| 215 |
// NetworkIODirectionAttr is an attribute conforming to the network.io.direction |
| 216 |
// semantic conventions. It represents the network IO operation direction. |
| 217 |
type NetworkIODirectionAttr string |
| 218 |
|
| 219 |
var ( |
| 220 |
// NetworkIODirectionTransmit is the standardized value "transmit" of |
| 221 |
// NetworkIODirectionAttr. |
| 222 |
NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit" |
| 223 |
// NetworkIODirectionReceive is the standardized value "receive" of |
| 224 |
// NetworkIODirectionAttr. |
| 225 |
NetworkIODirectionReceive NetworkIODirectionAttr = "receive" |
| 226 |
) |
| 227 |
|
| 228 |
// SystemPagingFaultTypeAttr is an attribute conforming to the |
| 229 |
// system.paging.fault.type semantic conventions. It represents the paging fault |
| 230 |
// type. |
| 231 |
type SystemPagingFaultTypeAttr string |
| 232 |
|
| 233 |
var ( |
| 234 |
// SystemPagingFaultTypeMajor is the standardized value "major" of |
| 235 |
// SystemPagingFaultTypeAttr. |
| 236 |
SystemPagingFaultTypeMajor SystemPagingFaultTypeAttr = "major" |
| 237 |
// SystemPagingFaultTypeMinor is the standardized value "minor" of |
| 238 |
// SystemPagingFaultTypeAttr. |
| 239 |
SystemPagingFaultTypeMinor SystemPagingFaultTypeAttr = "minor" |
| 240 |
) |
| 241 |
|
| 242 |
// ContainerCPULimit is an instrument used to record metric values conforming to |
| 243 |
// the "k8s.container.cpu.limit" semantic conventions. It represents the maximum |
| 244 |
// CPU resource limit set for the container. |
| 245 |
type ContainerCPULimit struct { |
| 246 |
metric.Int64UpDownCounter |
| 247 |
} |
| 248 |
|
| 249 |
var newContainerCPULimitOpts = []metric.Int64UpDownCounterOption{ |
| 250 |
metric.WithDescription("Maximum CPU resource limit set for the container."), |
| 251 |
metric.WithUnit("{cpu}"), |
| 252 |
} |
| 253 |
|
| 254 |
// NewContainerCPULimit returns a new ContainerCPULimit instrument. |
| 255 |
func NewContainerCPULimit( |
| 256 |
m metric.Meter, |
| 257 |
opt ...metric.Int64UpDownCounterOption, |
| 258 |
) (ContainerCPULimit, error) { |
| 259 |
// Check if the meter is nil. |
| 260 |
if m == nil { |
| 261 |
return ContainerCPULimit{noop.Int64UpDownCounter{}}, nil |
| 262 |
} |
| 263 |
|
| 264 |
if len(opt) == 0 { |
| 265 |
opt = newContainerCPULimitOpts |
| 266 |
} else { |
| 267 |
opt = append(opt, newContainerCPULimitOpts...) |
| 268 |
} |
| 269 |
|
| 270 |
i, err := m.Int64UpDownCounter( |
| 271 |
"k8s.container.cpu.limit", |
| 272 |
opt..., |
| 273 |
) |
| 274 |
if err != nil { |
| 275 |
return ContainerCPULimit{noop.Int64UpDownCounter{}}, err |
| 276 |
} |
| 277 |
return ContainerCPULimit{i}, nil |
| 278 |
} |
| 279 |
|
| 280 |
// Inst returns the underlying metric instrument. |
| 281 |
func (m ContainerCPULimit) Inst() metric.Int64UpDownCounter { |
| 282 |
return m.Int64UpDownCounter |
| 283 |
} |
| 284 |
|
| 285 |
// Name returns the semantic convention name of the instrument. |
| 286 |
func (ContainerCPULimit) Name() string { |
| 287 |
return "k8s.container.cpu.limit" |
| 288 |
} |
| 289 |
|
| 290 |
// Unit returns the semantic convention unit of the instrument |
| 291 |
func (ContainerCPULimit) Unit() string { |
| 292 |
return "{cpu}" |
| 293 |
} |
| 294 |
|
| 295 |
// Description returns the semantic convention description of the instrument |
| 296 |
func (ContainerCPULimit) Description() string { |
| 297 |
return "Maximum CPU resource limit set for the container." |
| 298 |
} |
| 299 |
|
| 300 |
// Add adds incr to the existing count for attrs. |
| 301 |
// |
| 302 |
// See |
| 303 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 304 |
// for details. |
| 305 |
func (m ContainerCPULimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 306 |
if len(attrs) == 0 { |
| 307 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 308 |
return |
| 309 |
} |
| 310 |
|
| 311 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 312 |
defer func() { |
| 313 |
*o = (*o)[:0] |
| 314 |
addOptPool.Put(o) |
| 315 |
}() |
| 316 |
|
| 317 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 318 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 319 |
} |
| 320 |
|
| 321 |
// AddSet adds incr to the existing count for set. |
| 322 |
// |
| 323 |
// See |
| 324 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 325 |
// for details. |
| 326 |
func (m ContainerCPULimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 327 |
if set.Len() == 0 { |
| 328 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 329 |
return |
| 330 |
} |
| 331 |
|
| 332 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 333 |
defer func() { |
| 334 |
*o = (*o)[:0] |
| 335 |
addOptPool.Put(o) |
| 336 |
}() |
| 337 |
|
| 338 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 339 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 340 |
} |
| 341 |
|
| 342 |
// ContainerCPULimitUtilization is an instrument used to record metric values |
| 343 |
// conforming to the "k8s.container.cpu.limit_utilization" semantic conventions. |
| 344 |
// It represents the ratio of container CPU usage to its CPU limit. |
| 345 |
type ContainerCPULimitUtilization struct { |
| 346 |
metric.Int64Gauge |
| 347 |
} |
| 348 |
|
| 349 |
var newContainerCPULimitUtilizationOpts = []metric.Int64GaugeOption{ |
| 350 |
metric.WithDescription("The ratio of container CPU usage to its CPU limit."), |
| 351 |
metric.WithUnit("1"), |
| 352 |
} |
| 353 |
|
| 354 |
// NewContainerCPULimitUtilization returns a new ContainerCPULimitUtilization |
| 355 |
// instrument. |
| 356 |
func NewContainerCPULimitUtilization( |
| 357 |
m metric.Meter, |
| 358 |
opt ...metric.Int64GaugeOption, |
| 359 |
) (ContainerCPULimitUtilization, error) { |
| 360 |
// Check if the meter is nil. |
| 361 |
if m == nil { |
| 362 |
return ContainerCPULimitUtilization{noop.Int64Gauge{}}, nil |
| 363 |
} |
| 364 |
|
| 365 |
if len(opt) == 0 { |
| 366 |
opt = newContainerCPULimitUtilizationOpts |
| 367 |
} else { |
| 368 |
opt = append(opt, newContainerCPULimitUtilizationOpts...) |
| 369 |
} |
| 370 |
|
| 371 |
i, err := m.Int64Gauge( |
| 372 |
"k8s.container.cpu.limit_utilization", |
| 373 |
opt..., |
| 374 |
) |
| 375 |
if err != nil { |
| 376 |
return ContainerCPULimitUtilization{noop.Int64Gauge{}}, err |
| 377 |
} |
| 378 |
return ContainerCPULimitUtilization{i}, nil |
| 379 |
} |
| 380 |
|
| 381 |
// Inst returns the underlying metric instrument. |
| 382 |
func (m ContainerCPULimitUtilization) Inst() metric.Int64Gauge { |
| 383 |
return m.Int64Gauge |
| 384 |
} |
| 385 |
|
| 386 |
// Name returns the semantic convention name of the instrument. |
| 387 |
func (ContainerCPULimitUtilization) Name() string { |
| 388 |
return "k8s.container.cpu.limit_utilization" |
| 389 |
} |
| 390 |
|
| 391 |
// Unit returns the semantic convention unit of the instrument |
| 392 |
func (ContainerCPULimitUtilization) Unit() string { |
| 393 |
return "1" |
| 394 |
} |
| 395 |
|
| 396 |
// Description returns the semantic convention description of the instrument |
| 397 |
func (ContainerCPULimitUtilization) Description() string { |
| 398 |
return "The ratio of container CPU usage to its CPU limit." |
| 399 |
} |
| 400 |
|
| 401 |
// Record records val to the current distribution for attrs. |
| 402 |
// |
| 403 |
// The value range is [0.0,1.0]. A value of 1.0 means the container is using 100% |
| 404 |
// of its CPU limit. If the CPU limit is not set, this metric SHOULD NOT be |
| 405 |
// emitted for that container. |
| 406 |
func (m ContainerCPULimitUtilization) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 407 |
if len(attrs) == 0 { |
| 408 |
m.Int64Gauge.Record(ctx, val) |
| 409 |
return |
| 410 |
} |
| 411 |
|
| 412 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 413 |
defer func() { |
| 414 |
*o = (*o)[:0] |
| 415 |
recOptPool.Put(o) |
| 416 |
}() |
| 417 |
|
| 418 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 419 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 420 |
} |
| 421 |
|
| 422 |
// RecordSet records val to the current distribution for set. |
| 423 |
// |
| 424 |
// The value range is [0.0,1.0]. A value of 1.0 means the container is using 100% |
| 425 |
// of its CPU limit. If the CPU limit is not set, this metric SHOULD NOT be |
| 426 |
// emitted for that container. |
| 427 |
func (m ContainerCPULimitUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 428 |
if set.Len() == 0 { |
| 429 |
m.Int64Gauge.Record(ctx, val) |
| 430 |
return |
| 431 |
} |
| 432 |
|
| 433 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 434 |
defer func() { |
| 435 |
*o = (*o)[:0] |
| 436 |
recOptPool.Put(o) |
| 437 |
}() |
| 438 |
|
| 439 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 440 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 441 |
} |
| 442 |
|
| 443 |
// ContainerCPURequest is an instrument used to record metric values conforming |
| 444 |
// to the "k8s.container.cpu.request" semantic conventions. It represents the CPU |
| 445 |
// resource requested for the container. |
| 446 |
type ContainerCPURequest struct { |
| 447 |
metric.Int64UpDownCounter |
| 448 |
} |
| 449 |
|
| 450 |
var newContainerCPURequestOpts = []metric.Int64UpDownCounterOption{ |
| 451 |
metric.WithDescription("CPU resource requested for the container."), |
| 452 |
metric.WithUnit("{cpu}"), |
| 453 |
} |
| 454 |
|
| 455 |
// NewContainerCPURequest returns a new ContainerCPURequest instrument. |
| 456 |
func NewContainerCPURequest( |
| 457 |
m metric.Meter, |
| 458 |
opt ...metric.Int64UpDownCounterOption, |
| 459 |
) (ContainerCPURequest, error) { |
| 460 |
// Check if the meter is nil. |
| 461 |
if m == nil { |
| 462 |
return ContainerCPURequest{noop.Int64UpDownCounter{}}, nil |
| 463 |
} |
| 464 |
|
| 465 |
if len(opt) == 0 { |
| 466 |
opt = newContainerCPURequestOpts |
| 467 |
} else { |
| 468 |
opt = append(opt, newContainerCPURequestOpts...) |
| 469 |
} |
| 470 |
|
| 471 |
i, err := m.Int64UpDownCounter( |
| 472 |
"k8s.container.cpu.request", |
| 473 |
opt..., |
| 474 |
) |
| 475 |
if err != nil { |
| 476 |
return ContainerCPURequest{noop.Int64UpDownCounter{}}, err |
| 477 |
} |
| 478 |
return ContainerCPURequest{i}, nil |
| 479 |
} |
| 480 |
|
| 481 |
// Inst returns the underlying metric instrument. |
| 482 |
func (m ContainerCPURequest) Inst() metric.Int64UpDownCounter { |
| 483 |
return m.Int64UpDownCounter |
| 484 |
} |
| 485 |
|
| 486 |
// Name returns the semantic convention name of the instrument. |
| 487 |
func (ContainerCPURequest) Name() string { |
| 488 |
return "k8s.container.cpu.request" |
| 489 |
} |
| 490 |
|
| 491 |
// Unit returns the semantic convention unit of the instrument |
| 492 |
func (ContainerCPURequest) Unit() string { |
| 493 |
return "{cpu}" |
| 494 |
} |
| 495 |
|
| 496 |
// Description returns the semantic convention description of the instrument |
| 497 |
func (ContainerCPURequest) Description() string { |
| 498 |
return "CPU resource requested for the container." |
| 499 |
} |
| 500 |
|
| 501 |
// Add adds incr to the existing count for attrs. |
| 502 |
// |
| 503 |
// See |
| 504 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 505 |
// for details. |
| 506 |
func (m ContainerCPURequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 507 |
if len(attrs) == 0 { |
| 508 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 509 |
return |
| 510 |
} |
| 511 |
|
| 512 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 513 |
defer func() { |
| 514 |
*o = (*o)[:0] |
| 515 |
addOptPool.Put(o) |
| 516 |
}() |
| 517 |
|
| 518 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 519 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 520 |
} |
| 521 |
|
| 522 |
// AddSet adds incr to the existing count for set. |
| 523 |
// |
| 524 |
// See |
| 525 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 526 |
// for details. |
| 527 |
func (m ContainerCPURequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 528 |
if set.Len() == 0 { |
| 529 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 530 |
return |
| 531 |
} |
| 532 |
|
| 533 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 534 |
defer func() { |
| 535 |
*o = (*o)[:0] |
| 536 |
addOptPool.Put(o) |
| 537 |
}() |
| 538 |
|
| 539 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 540 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 541 |
} |
| 542 |
|
| 543 |
// ContainerCPURequestUtilization is an instrument used to record metric values |
| 544 |
// conforming to the "k8s.container.cpu.request_utilization" semantic |
| 545 |
// conventions. It represents the ratio of container CPU usage to its CPU |
| 546 |
// request. |
| 547 |
type ContainerCPURequestUtilization struct { |
| 548 |
metric.Int64Gauge |
| 549 |
} |
| 550 |
|
| 551 |
var newContainerCPURequestUtilizationOpts = []metric.Int64GaugeOption{ |
| 552 |
metric.WithDescription("The ratio of container CPU usage to its CPU request."), |
| 553 |
metric.WithUnit("1"), |
| 554 |
} |
| 555 |
|
| 556 |
// NewContainerCPURequestUtilization returns a new ContainerCPURequestUtilization |
| 557 |
// instrument. |
| 558 |
func NewContainerCPURequestUtilization( |
| 559 |
m metric.Meter, |
| 560 |
opt ...metric.Int64GaugeOption, |
| 561 |
) (ContainerCPURequestUtilization, error) { |
| 562 |
// Check if the meter is nil. |
| 563 |
if m == nil { |
| 564 |
return ContainerCPURequestUtilization{noop.Int64Gauge{}}, nil |
| 565 |
} |
| 566 |
|
| 567 |
if len(opt) == 0 { |
| 568 |
opt = newContainerCPURequestUtilizationOpts |
| 569 |
} else { |
| 570 |
opt = append(opt, newContainerCPURequestUtilizationOpts...) |
| 571 |
} |
| 572 |
|
| 573 |
i, err := m.Int64Gauge( |
| 574 |
"k8s.container.cpu.request_utilization", |
| 575 |
opt..., |
| 576 |
) |
| 577 |
if err != nil { |
| 578 |
return ContainerCPURequestUtilization{noop.Int64Gauge{}}, err |
| 579 |
} |
| 580 |
return ContainerCPURequestUtilization{i}, nil |
| 581 |
} |
| 582 |
|
| 583 |
// Inst returns the underlying metric instrument. |
| 584 |
func (m ContainerCPURequestUtilization) Inst() metric.Int64Gauge { |
| 585 |
return m.Int64Gauge |
| 586 |
} |
| 587 |
|
| 588 |
// Name returns the semantic convention name of the instrument. |
| 589 |
func (ContainerCPURequestUtilization) Name() string { |
| 590 |
return "k8s.container.cpu.request_utilization" |
| 591 |
} |
| 592 |
|
| 593 |
// Unit returns the semantic convention unit of the instrument |
| 594 |
func (ContainerCPURequestUtilization) Unit() string { |
| 595 |
return "1" |
| 596 |
} |
| 597 |
|
| 598 |
// Description returns the semantic convention description of the instrument |
| 599 |
func (ContainerCPURequestUtilization) Description() string { |
| 600 |
return "The ratio of container CPU usage to its CPU request." |
| 601 |
} |
| 602 |
|
| 603 |
// Record records val to the current distribution for attrs. |
| 604 |
func (m ContainerCPURequestUtilization) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 605 |
if len(attrs) == 0 { |
| 606 |
m.Int64Gauge.Record(ctx, val) |
| 607 |
return |
| 608 |
} |
| 609 |
|
| 610 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 611 |
defer func() { |
| 612 |
*o = (*o)[:0] |
| 613 |
recOptPool.Put(o) |
| 614 |
}() |
| 615 |
|
| 616 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 617 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 618 |
} |
| 619 |
|
| 620 |
// RecordSet records val to the current distribution for set. |
| 621 |
func (m ContainerCPURequestUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 622 |
if set.Len() == 0 { |
| 623 |
m.Int64Gauge.Record(ctx, val) |
| 624 |
return |
| 625 |
} |
| 626 |
|
| 627 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 628 |
defer func() { |
| 629 |
*o = (*o)[:0] |
| 630 |
recOptPool.Put(o) |
| 631 |
}() |
| 632 |
|
| 633 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 634 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 635 |
} |
| 636 |
|
| 637 |
// ContainerEphemeralStorageLimit is an instrument used to record metric values |
| 638 |
// conforming to the "k8s.container.ephemeral_storage.limit" semantic |
| 639 |
// conventions. It represents the maximum ephemeral storage resource limit set |
| 640 |
// for the container. |
| 641 |
type ContainerEphemeralStorageLimit struct { |
| 642 |
metric.Int64UpDownCounter |
| 643 |
} |
| 644 |
|
| 645 |
var newContainerEphemeralStorageLimitOpts = []metric.Int64UpDownCounterOption{ |
| 646 |
metric.WithDescription("Maximum ephemeral storage resource limit set for the container."), |
| 647 |
metric.WithUnit("By"), |
| 648 |
} |
| 649 |
|
| 650 |
// NewContainerEphemeralStorageLimit returns a new ContainerEphemeralStorageLimit |
| 651 |
// instrument. |
| 652 |
func NewContainerEphemeralStorageLimit( |
| 653 |
m metric.Meter, |
| 654 |
opt ...metric.Int64UpDownCounterOption, |
| 655 |
) (ContainerEphemeralStorageLimit, error) { |
| 656 |
// Check if the meter is nil. |
| 657 |
if m == nil { |
| 658 |
return ContainerEphemeralStorageLimit{noop.Int64UpDownCounter{}}, nil |
| 659 |
} |
| 660 |
|
| 661 |
if len(opt) == 0 { |
| 662 |
opt = newContainerEphemeralStorageLimitOpts |
| 663 |
} else { |
| 664 |
opt = append(opt, newContainerEphemeralStorageLimitOpts...) |
| 665 |
} |
| 666 |
|
| 667 |
i, err := m.Int64UpDownCounter( |
| 668 |
"k8s.container.ephemeral_storage.limit", |
| 669 |
opt..., |
| 670 |
) |
| 671 |
if err != nil { |
| 672 |
return ContainerEphemeralStorageLimit{noop.Int64UpDownCounter{}}, err |
| 673 |
} |
| 674 |
return ContainerEphemeralStorageLimit{i}, nil |
| 675 |
} |
| 676 |
|
| 677 |
// Inst returns the underlying metric instrument. |
| 678 |
func (m ContainerEphemeralStorageLimit) Inst() metric.Int64UpDownCounter { |
| 679 |
return m.Int64UpDownCounter |
| 680 |
} |
| 681 |
|
| 682 |
// Name returns the semantic convention name of the instrument. |
| 683 |
func (ContainerEphemeralStorageLimit) Name() string { |
| 684 |
return "k8s.container.ephemeral_storage.limit" |
| 685 |
} |
| 686 |
|
| 687 |
// Unit returns the semantic convention unit of the instrument |
| 688 |
func (ContainerEphemeralStorageLimit) Unit() string { |
| 689 |
return "By" |
| 690 |
} |
| 691 |
|
| 692 |
// Description returns the semantic convention description of the instrument |
| 693 |
func (ContainerEphemeralStorageLimit) Description() string { |
| 694 |
return "Maximum ephemeral storage resource limit set for the container." |
| 695 |
} |
| 696 |
|
| 697 |
// Add adds incr to the existing count for attrs. |
| 698 |
// |
| 699 |
// See |
| 700 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 701 |
// for details. |
| 702 |
func (m ContainerEphemeralStorageLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 703 |
if len(attrs) == 0 { |
| 704 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 705 |
return |
| 706 |
} |
| 707 |
|
| 708 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 709 |
defer func() { |
| 710 |
*o = (*o)[:0] |
| 711 |
addOptPool.Put(o) |
| 712 |
}() |
| 713 |
|
| 714 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 715 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 716 |
} |
| 717 |
|
| 718 |
// AddSet adds incr to the existing count for set. |
| 719 |
// |
| 720 |
// See |
| 721 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 722 |
// for details. |
| 723 |
func (m ContainerEphemeralStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 724 |
if set.Len() == 0 { |
| 725 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 726 |
return |
| 727 |
} |
| 728 |
|
| 729 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 730 |
defer func() { |
| 731 |
*o = (*o)[:0] |
| 732 |
addOptPool.Put(o) |
| 733 |
}() |
| 734 |
|
| 735 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 736 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 737 |
} |
| 738 |
|
| 739 |
// ContainerEphemeralStorageRequest is an instrument used to record metric values |
| 740 |
// conforming to the "k8s.container.ephemeral_storage.request" semantic |
| 741 |
// conventions. It represents the ephemeral storage resource requested for the |
| 742 |
// container. |
| 743 |
type ContainerEphemeralStorageRequest struct { |
| 744 |
metric.Int64UpDownCounter |
| 745 |
} |
| 746 |
|
| 747 |
var newContainerEphemeralStorageRequestOpts = []metric.Int64UpDownCounterOption{ |
| 748 |
metric.WithDescription("Ephemeral storage resource requested for the container."), |
| 749 |
metric.WithUnit("By"), |
| 750 |
} |
| 751 |
|
| 752 |
// NewContainerEphemeralStorageRequest returns a new |
| 753 |
// ContainerEphemeralStorageRequest instrument. |
| 754 |
func NewContainerEphemeralStorageRequest( |
| 755 |
m metric.Meter, |
| 756 |
opt ...metric.Int64UpDownCounterOption, |
| 757 |
) (ContainerEphemeralStorageRequest, error) { |
| 758 |
// Check if the meter is nil. |
| 759 |
if m == nil { |
| 760 |
return ContainerEphemeralStorageRequest{noop.Int64UpDownCounter{}}, nil |
| 761 |
} |
| 762 |
|
| 763 |
if len(opt) == 0 { |
| 764 |
opt = newContainerEphemeralStorageRequestOpts |
| 765 |
} else { |
| 766 |
opt = append(opt, newContainerEphemeralStorageRequestOpts...) |
| 767 |
} |
| 768 |
|
| 769 |
i, err := m.Int64UpDownCounter( |
| 770 |
"k8s.container.ephemeral_storage.request", |
| 771 |
opt..., |
| 772 |
) |
| 773 |
if err != nil { |
| 774 |
return ContainerEphemeralStorageRequest{noop.Int64UpDownCounter{}}, err |
| 775 |
} |
| 776 |
return ContainerEphemeralStorageRequest{i}, nil |
| 777 |
} |
| 778 |
|
| 779 |
// Inst returns the underlying metric instrument. |
| 780 |
func (m ContainerEphemeralStorageRequest) Inst() metric.Int64UpDownCounter { |
| 781 |
return m.Int64UpDownCounter |
| 782 |
} |
| 783 |
|
| 784 |
// Name returns the semantic convention name of the instrument. |
| 785 |
func (ContainerEphemeralStorageRequest) Name() string { |
| 786 |
return "k8s.container.ephemeral_storage.request" |
| 787 |
} |
| 788 |
|
| 789 |
// Unit returns the semantic convention unit of the instrument |
| 790 |
func (ContainerEphemeralStorageRequest) Unit() string { |
| 791 |
return "By" |
| 792 |
} |
| 793 |
|
| 794 |
// Description returns the semantic convention description of the instrument |
| 795 |
func (ContainerEphemeralStorageRequest) Description() string { |
| 796 |
return "Ephemeral storage resource requested for the container." |
| 797 |
} |
| 798 |
|
| 799 |
// Add adds incr to the existing count for attrs. |
| 800 |
// |
| 801 |
// See |
| 802 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 803 |
// for details. |
| 804 |
func (m ContainerEphemeralStorageRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 805 |
if len(attrs) == 0 { |
| 806 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 807 |
return |
| 808 |
} |
| 809 |
|
| 810 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 811 |
defer func() { |
| 812 |
*o = (*o)[:0] |
| 813 |
addOptPool.Put(o) |
| 814 |
}() |
| 815 |
|
| 816 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 817 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 818 |
} |
| 819 |
|
| 820 |
// AddSet adds incr to the existing count for set. |
| 821 |
// |
| 822 |
// See |
| 823 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 824 |
// for details. |
| 825 |
func (m ContainerEphemeralStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 826 |
if set.Len() == 0 { |
| 827 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 828 |
return |
| 829 |
} |
| 830 |
|
| 831 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 832 |
defer func() { |
| 833 |
*o = (*o)[:0] |
| 834 |
addOptPool.Put(o) |
| 835 |
}() |
| 836 |
|
| 837 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 838 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 839 |
} |
| 840 |
|
| 841 |
// ContainerMemoryLimit is an instrument used to record metric values conforming |
| 842 |
// to the "k8s.container.memory.limit" semantic conventions. It represents the |
| 843 |
// maximum memory resource limit set for the container. |
| 844 |
type ContainerMemoryLimit struct { |
| 845 |
metric.Int64UpDownCounter |
| 846 |
} |
| 847 |
|
| 848 |
var newContainerMemoryLimitOpts = []metric.Int64UpDownCounterOption{ |
| 849 |
metric.WithDescription("Maximum memory resource limit set for the container."), |
| 850 |
metric.WithUnit("By"), |
| 851 |
} |
| 852 |
|
| 853 |
// NewContainerMemoryLimit returns a new ContainerMemoryLimit instrument. |
| 854 |
func NewContainerMemoryLimit( |
| 855 |
m metric.Meter, |
| 856 |
opt ...metric.Int64UpDownCounterOption, |
| 857 |
) (ContainerMemoryLimit, error) { |
| 858 |
// Check if the meter is nil. |
| 859 |
if m == nil { |
| 860 |
return ContainerMemoryLimit{noop.Int64UpDownCounter{}}, nil |
| 861 |
} |
| 862 |
|
| 863 |
if len(opt) == 0 { |
| 864 |
opt = newContainerMemoryLimitOpts |
| 865 |
} else { |
| 866 |
opt = append(opt, newContainerMemoryLimitOpts...) |
| 867 |
} |
| 868 |
|
| 869 |
i, err := m.Int64UpDownCounter( |
| 870 |
"k8s.container.memory.limit", |
| 871 |
opt..., |
| 872 |
) |
| 873 |
if err != nil { |
| 874 |
return ContainerMemoryLimit{noop.Int64UpDownCounter{}}, err |
| 875 |
} |
| 876 |
return ContainerMemoryLimit{i}, nil |
| 877 |
} |
| 878 |
|
| 879 |
// Inst returns the underlying metric instrument. |
| 880 |
func (m ContainerMemoryLimit) Inst() metric.Int64UpDownCounter { |
| 881 |
return m.Int64UpDownCounter |
| 882 |
} |
| 883 |
|
| 884 |
// Name returns the semantic convention name of the instrument. |
| 885 |
func (ContainerMemoryLimit) Name() string { |
| 886 |
return "k8s.container.memory.limit" |
| 887 |
} |
| 888 |
|
| 889 |
// Unit returns the semantic convention unit of the instrument |
| 890 |
func (ContainerMemoryLimit) Unit() string { |
| 891 |
return "By" |
| 892 |
} |
| 893 |
|
| 894 |
// Description returns the semantic convention description of the instrument |
| 895 |
func (ContainerMemoryLimit) Description() string { |
| 896 |
return "Maximum memory resource limit set for the container." |
| 897 |
} |
| 898 |
|
| 899 |
// Add adds incr to the existing count for attrs. |
| 900 |
// |
| 901 |
// See |
| 902 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 903 |
// for details. |
| 904 |
func (m ContainerMemoryLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 905 |
if len(attrs) == 0 { |
| 906 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 907 |
return |
| 908 |
} |
| 909 |
|
| 910 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 911 |
defer func() { |
| 912 |
*o = (*o)[:0] |
| 913 |
addOptPool.Put(o) |
| 914 |
}() |
| 915 |
|
| 916 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 917 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 918 |
} |
| 919 |
|
| 920 |
// AddSet adds incr to the existing count for set. |
| 921 |
// |
| 922 |
// See |
| 923 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 924 |
// for details. |
| 925 |
func (m ContainerMemoryLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 926 |
if set.Len() == 0 { |
| 927 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 928 |
return |
| 929 |
} |
| 930 |
|
| 931 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 932 |
defer func() { |
| 933 |
*o = (*o)[:0] |
| 934 |
addOptPool.Put(o) |
| 935 |
}() |
| 936 |
|
| 937 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 938 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 939 |
} |
| 940 |
|
| 941 |
// ContainerMemoryRequest is an instrument used to record metric values |
| 942 |
// conforming to the "k8s.container.memory.request" semantic conventions. It |
| 943 |
// represents the memory resource requested for the container. |
| 944 |
type ContainerMemoryRequest struct { |
| 945 |
metric.Int64UpDownCounter |
| 946 |
} |
| 947 |
|
| 948 |
var newContainerMemoryRequestOpts = []metric.Int64UpDownCounterOption{ |
| 949 |
metric.WithDescription("Memory resource requested for the container."), |
| 950 |
metric.WithUnit("By"), |
| 951 |
} |
| 952 |
|
| 953 |
// NewContainerMemoryRequest returns a new ContainerMemoryRequest instrument. |
| 954 |
func NewContainerMemoryRequest( |
| 955 |
m metric.Meter, |
| 956 |
opt ...metric.Int64UpDownCounterOption, |
| 957 |
) (ContainerMemoryRequest, error) { |
| 958 |
// Check if the meter is nil. |
| 959 |
if m == nil { |
| 960 |
return ContainerMemoryRequest{noop.Int64UpDownCounter{}}, nil |
| 961 |
} |
| 962 |
|
| 963 |
if len(opt) == 0 { |
| 964 |
opt = newContainerMemoryRequestOpts |
| 965 |
} else { |
| 966 |
opt = append(opt, newContainerMemoryRequestOpts...) |
| 967 |
} |
| 968 |
|
| 969 |
i, err := m.Int64UpDownCounter( |
| 970 |
"k8s.container.memory.request", |
| 971 |
opt..., |
| 972 |
) |
| 973 |
if err != nil { |
| 974 |
return ContainerMemoryRequest{noop.Int64UpDownCounter{}}, err |
| 975 |
} |
| 976 |
return ContainerMemoryRequest{i}, nil |
| 977 |
} |
| 978 |
|
| 979 |
// Inst returns the underlying metric instrument. |
| 980 |
func (m ContainerMemoryRequest) Inst() metric.Int64UpDownCounter { |
| 981 |
return m.Int64UpDownCounter |
| 982 |
} |
| 983 |
|
| 984 |
// Name returns the semantic convention name of the instrument. |
| 985 |
func (ContainerMemoryRequest) Name() string { |
| 986 |
return "k8s.container.memory.request" |
| 987 |
} |
| 988 |
|
| 989 |
// Unit returns the semantic convention unit of the instrument |
| 990 |
func (ContainerMemoryRequest) Unit() string { |
| 991 |
return "By" |
| 992 |
} |
| 993 |
|
| 994 |
// Description returns the semantic convention description of the instrument |
| 995 |
func (ContainerMemoryRequest) Description() string { |
| 996 |
return "Memory resource requested for the container." |
| 997 |
} |
| 998 |
|
| 999 |
// Add adds incr to the existing count for attrs. |
| 1000 |
// |
| 1001 |
// See |
| 1002 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1003 |
// for details. |
| 1004 |
func (m ContainerMemoryRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1005 |
if len(attrs) == 0 { |
| 1006 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1007 |
return |
| 1008 |
} |
| 1009 |
|
| 1010 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1011 |
defer func() { |
| 1012 |
*o = (*o)[:0] |
| 1013 |
addOptPool.Put(o) |
| 1014 |
}() |
| 1015 |
|
| 1016 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1017 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1018 |
} |
| 1019 |
|
| 1020 |
// AddSet adds incr to the existing count for set. |
| 1021 |
// |
| 1022 |
// See |
| 1023 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1024 |
// for details. |
| 1025 |
func (m ContainerMemoryRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1026 |
if set.Len() == 0 { |
| 1027 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1028 |
return |
| 1029 |
} |
| 1030 |
|
| 1031 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1032 |
defer func() { |
| 1033 |
*o = (*o)[:0] |
| 1034 |
addOptPool.Put(o) |
| 1035 |
}() |
| 1036 |
|
| 1037 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1038 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1039 |
} |
| 1040 |
|
| 1041 |
// ContainerReady is an instrument used to record metric values conforming to the |
| 1042 |
// "k8s.container.ready" semantic conventions. It represents the indicates |
| 1043 |
// whether the container is currently marked as ready to accept traffic, based on |
| 1044 |
// its readiness probe (1 = ready, 0 = not ready). |
| 1045 |
type ContainerReady struct { |
| 1046 |
metric.Int64UpDownCounter |
| 1047 |
} |
| 1048 |
|
| 1049 |
var newContainerReadyOpts = []metric.Int64UpDownCounterOption{ |
| 1050 |
metric.WithDescription("Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready)."), |
| 1051 |
metric.WithUnit("{container}"), |
| 1052 |
} |
| 1053 |
|
| 1054 |
// NewContainerReady returns a new ContainerReady instrument. |
| 1055 |
func NewContainerReady( |
| 1056 |
m metric.Meter, |
| 1057 |
opt ...metric.Int64UpDownCounterOption, |
| 1058 |
) (ContainerReady, error) { |
| 1059 |
// Check if the meter is nil. |
| 1060 |
if m == nil { |
| 1061 |
return ContainerReady{noop.Int64UpDownCounter{}}, nil |
| 1062 |
} |
| 1063 |
|
| 1064 |
if len(opt) == 0 { |
| 1065 |
opt = newContainerReadyOpts |
| 1066 |
} else { |
| 1067 |
opt = append(opt, newContainerReadyOpts...) |
| 1068 |
} |
| 1069 |
|
| 1070 |
i, err := m.Int64UpDownCounter( |
| 1071 |
"k8s.container.ready", |
| 1072 |
opt..., |
| 1073 |
) |
| 1074 |
if err != nil { |
| 1075 |
return ContainerReady{noop.Int64UpDownCounter{}}, err |
| 1076 |
} |
| 1077 |
return ContainerReady{i}, nil |
| 1078 |
} |
| 1079 |
|
| 1080 |
// Inst returns the underlying metric instrument. |
| 1081 |
func (m ContainerReady) Inst() metric.Int64UpDownCounter { |
| 1082 |
return m.Int64UpDownCounter |
| 1083 |
} |
| 1084 |
|
| 1085 |
// Name returns the semantic convention name of the instrument. |
| 1086 |
func (ContainerReady) Name() string { |
| 1087 |
return "k8s.container.ready" |
| 1088 |
} |
| 1089 |
|
| 1090 |
// Unit returns the semantic convention unit of the instrument |
| 1091 |
func (ContainerReady) Unit() string { |
| 1092 |
return "{container}" |
| 1093 |
} |
| 1094 |
|
| 1095 |
// Description returns the semantic convention description of the instrument |
| 1096 |
func (ContainerReady) Description() string { |
| 1097 |
return "Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready)." |
| 1098 |
} |
| 1099 |
|
| 1100 |
// Add adds incr to the existing count for attrs. |
| 1101 |
// |
| 1102 |
// This metric SHOULD reflect the value of the `ready` field in the |
| 1103 |
// [K8s ContainerStatus]. |
| 1104 |
// |
| 1105 |
// [K8s ContainerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core |
| 1106 |
func (m ContainerReady) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1107 |
if len(attrs) == 0 { |
| 1108 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1109 |
return |
| 1110 |
} |
| 1111 |
|
| 1112 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1113 |
defer func() { |
| 1114 |
*o = (*o)[:0] |
| 1115 |
addOptPool.Put(o) |
| 1116 |
}() |
| 1117 |
|
| 1118 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1119 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1120 |
} |
| 1121 |
|
| 1122 |
// AddSet adds incr to the existing count for set. |
| 1123 |
// |
| 1124 |
// This metric SHOULD reflect the value of the `ready` field in the |
| 1125 |
// [K8s ContainerStatus]. |
| 1126 |
// |
| 1127 |
// [K8s ContainerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core |
| 1128 |
func (m ContainerReady) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1129 |
if set.Len() == 0 { |
| 1130 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1131 |
return |
| 1132 |
} |
| 1133 |
|
| 1134 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1135 |
defer func() { |
| 1136 |
*o = (*o)[:0] |
| 1137 |
addOptPool.Put(o) |
| 1138 |
}() |
| 1139 |
|
| 1140 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1141 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1142 |
} |
| 1143 |
|
| 1144 |
// ContainerRestartCount is an instrument used to record metric values conforming |
| 1145 |
// to the "k8s.container.restart.count" semantic conventions. It represents the |
| 1146 |
// describes how many times the container has restarted (since the last counter |
| 1147 |
// reset). |
| 1148 |
type ContainerRestartCount struct { |
| 1149 |
metric.Int64UpDownCounter |
| 1150 |
} |
| 1151 |
|
| 1152 |
var newContainerRestartCountOpts = []metric.Int64UpDownCounterOption{ |
| 1153 |
metric.WithDescription("Describes how many times the container has restarted (since the last counter reset)."), |
| 1154 |
metric.WithUnit("{restart}"), |
| 1155 |
} |
| 1156 |
|
| 1157 |
// NewContainerRestartCount returns a new ContainerRestartCount instrument. |
| 1158 |
func NewContainerRestartCount( |
| 1159 |
m metric.Meter, |
| 1160 |
opt ...metric.Int64UpDownCounterOption, |
| 1161 |
) (ContainerRestartCount, error) { |
| 1162 |
// Check if the meter is nil. |
| 1163 |
if m == nil { |
| 1164 |
return ContainerRestartCount{noop.Int64UpDownCounter{}}, nil |
| 1165 |
} |
| 1166 |
|
| 1167 |
if len(opt) == 0 { |
| 1168 |
opt = newContainerRestartCountOpts |
| 1169 |
} else { |
| 1170 |
opt = append(opt, newContainerRestartCountOpts...) |
| 1171 |
} |
| 1172 |
|
| 1173 |
i, err := m.Int64UpDownCounter( |
| 1174 |
"k8s.container.restart.count", |
| 1175 |
opt..., |
| 1176 |
) |
| 1177 |
if err != nil { |
| 1178 |
return ContainerRestartCount{noop.Int64UpDownCounter{}}, err |
| 1179 |
} |
| 1180 |
return ContainerRestartCount{i}, nil |
| 1181 |
} |
| 1182 |
|
| 1183 |
// Inst returns the underlying metric instrument. |
| 1184 |
func (m ContainerRestartCount) Inst() metric.Int64UpDownCounter { |
| 1185 |
return m.Int64UpDownCounter |
| 1186 |
} |
| 1187 |
|
| 1188 |
// Name returns the semantic convention name of the instrument. |
| 1189 |
func (ContainerRestartCount) Name() string { |
| 1190 |
return "k8s.container.restart.count" |
| 1191 |
} |
| 1192 |
|
| 1193 |
// Unit returns the semantic convention unit of the instrument |
| 1194 |
func (ContainerRestartCount) Unit() string { |
| 1195 |
return "{restart}" |
| 1196 |
} |
| 1197 |
|
| 1198 |
// Description returns the semantic convention description of the instrument |
| 1199 |
func (ContainerRestartCount) Description() string { |
| 1200 |
return "Describes how many times the container has restarted (since the last counter reset)." |
| 1201 |
} |
| 1202 |
|
| 1203 |
// Add adds incr to the existing count for attrs. |
| 1204 |
// |
| 1205 |
// This value is pulled directly from the K8s API and the value can go |
| 1206 |
// indefinitely high and be reset to 0 |
| 1207 |
// at any time depending on how your kubelet is configured to prune dead |
| 1208 |
// containers. |
| 1209 |
// It is best to not depend too much on the exact value but rather look at it as |
| 1210 |
// either == 0, in which case you can conclude there were no restarts in the |
| 1211 |
// recent past, or > 0, in which case |
| 1212 |
// you can conclude there were restarts in the recent past, and not try and |
| 1213 |
// analyze the value beyond that. |
| 1214 |
func (m ContainerRestartCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1215 |
if len(attrs) == 0 { |
| 1216 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1217 |
return |
| 1218 |
} |
| 1219 |
|
| 1220 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1221 |
defer func() { |
| 1222 |
*o = (*o)[:0] |
| 1223 |
addOptPool.Put(o) |
| 1224 |
}() |
| 1225 |
|
| 1226 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1227 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1228 |
} |
| 1229 |
|
| 1230 |
// AddSet adds incr to the existing count for set. |
| 1231 |
// |
| 1232 |
// This value is pulled directly from the K8s API and the value can go |
| 1233 |
// indefinitely high and be reset to 0 |
| 1234 |
// at any time depending on how your kubelet is configured to prune dead |
| 1235 |
// containers. |
| 1236 |
// It is best to not depend too much on the exact value but rather look at it as |
| 1237 |
// either == 0, in which case you can conclude there were no restarts in the |
| 1238 |
// recent past, or > 0, in which case |
| 1239 |
// you can conclude there were restarts in the recent past, and not try and |
| 1240 |
// analyze the value beyond that. |
| 1241 |
func (m ContainerRestartCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1242 |
if set.Len() == 0 { |
| 1243 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1244 |
return |
| 1245 |
} |
| 1246 |
|
| 1247 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1248 |
defer func() { |
| 1249 |
*o = (*o)[:0] |
| 1250 |
addOptPool.Put(o) |
| 1251 |
}() |
| 1252 |
|
| 1253 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1254 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1255 |
} |
| 1256 |
|
| 1257 |
// ContainerStatusReason is an instrument used to record metric values conforming |
| 1258 |
// to the "k8s.container.status.reason" semantic conventions. It represents the |
| 1259 |
// describes the number of K8s containers that are currently in a state for a |
| 1260 |
// given reason. |
| 1261 |
type ContainerStatusReason struct { |
| 1262 |
metric.Int64UpDownCounter |
| 1263 |
} |
| 1264 |
|
| 1265 |
var newContainerStatusReasonOpts = []metric.Int64UpDownCounterOption{ |
| 1266 |
metric.WithDescription("Describes the number of K8s containers that are currently in a state for a given reason."), |
| 1267 |
metric.WithUnit("{container}"), |
| 1268 |
} |
| 1269 |
|
| 1270 |
// NewContainerStatusReason returns a new ContainerStatusReason instrument. |
| 1271 |
func NewContainerStatusReason( |
| 1272 |
m metric.Meter, |
| 1273 |
opt ...metric.Int64UpDownCounterOption, |
| 1274 |
) (ContainerStatusReason, error) { |
| 1275 |
// Check if the meter is nil. |
| 1276 |
if m == nil { |
| 1277 |
return ContainerStatusReason{noop.Int64UpDownCounter{}}, nil |
| 1278 |
} |
| 1279 |
|
| 1280 |
if len(opt) == 0 { |
| 1281 |
opt = newContainerStatusReasonOpts |
| 1282 |
} else { |
| 1283 |
opt = append(opt, newContainerStatusReasonOpts...) |
| 1284 |
} |
| 1285 |
|
| 1286 |
i, err := m.Int64UpDownCounter( |
| 1287 |
"k8s.container.status.reason", |
| 1288 |
opt..., |
| 1289 |
) |
| 1290 |
if err != nil { |
| 1291 |
return ContainerStatusReason{noop.Int64UpDownCounter{}}, err |
| 1292 |
} |
| 1293 |
return ContainerStatusReason{i}, nil |
| 1294 |
} |
| 1295 |
|
| 1296 |
// Inst returns the underlying metric instrument. |
| 1297 |
func (m ContainerStatusReason) Inst() metric.Int64UpDownCounter { |
| 1298 |
return m.Int64UpDownCounter |
| 1299 |
} |
| 1300 |
|
| 1301 |
// Name returns the semantic convention name of the instrument. |
| 1302 |
func (ContainerStatusReason) Name() string { |
| 1303 |
return "k8s.container.status.reason" |
| 1304 |
} |
| 1305 |
|
| 1306 |
// Unit returns the semantic convention unit of the instrument |
| 1307 |
func (ContainerStatusReason) Unit() string { |
| 1308 |
return "{container}" |
| 1309 |
} |
| 1310 |
|
| 1311 |
// Description returns the semantic convention description of the instrument |
| 1312 |
func (ContainerStatusReason) Description() string { |
| 1313 |
return "Describes the number of K8s containers that are currently in a state for a given reason." |
| 1314 |
} |
| 1315 |
|
| 1316 |
// Add adds incr to the existing count for attrs. |
| 1317 |
// |
| 1318 |
// The containerStatusReason is the the reason for the container state. |
| 1319 |
// Corresponds to the `reason` field of the: [K8s ContainerStateWaiting] or |
| 1320 |
// [K8s ContainerStateTerminated] |
| 1321 |
// |
| 1322 |
// [K8s ContainerStateWaiting]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatewaiting-v1-core |
| 1323 |
// [K8s ContainerStateTerminated]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstateterminated-v1-core |
| 1324 |
// |
| 1325 |
// All possible container state reasons will be reported at each time interval to |
| 1326 |
// avoid missing metrics. |
| 1327 |
// Only the value corresponding to the current state reason will be non-zero. |
| 1328 |
func (m ContainerStatusReason) Add( |
| 1329 |
ctx context.Context, |
| 1330 |
incr int64, |
| 1331 |
containerStatusReason ContainerStatusReasonAttr, |
| 1332 |
attrs ...attribute.KeyValue, |
| 1333 |
) { |
| 1334 |
if len(attrs) == 0 { |
| 1335 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 1336 |
attribute.String("k8s.container.status.reason", string(containerStatusReason)), |
| 1337 |
)) |
| 1338 |
return |
| 1339 |
} |
| 1340 |
|
| 1341 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1342 |
defer func() { |
| 1343 |
*o = (*o)[:0] |
| 1344 |
addOptPool.Put(o) |
| 1345 |
}() |
| 1346 |
|
| 1347 |
*o = append( |
| 1348 |
*o, |
| 1349 |
metric.WithAttributes( |
| 1350 |
append( |
| 1351 |
attrs, |
| 1352 |
attribute.String("k8s.container.status.reason", string(containerStatusReason)), |
| 1353 |
)..., |
| 1354 |
), |
| 1355 |
) |
| 1356 |
|
| 1357 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1358 |
} |
| 1359 |
|
| 1360 |
// AddSet adds incr to the existing count for set. |
| 1361 |
// |
| 1362 |
// All possible container state reasons will be reported at each time interval to |
| 1363 |
// avoid missing metrics. |
| 1364 |
// Only the value corresponding to the current state reason will be non-zero. |
| 1365 |
func (m ContainerStatusReason) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1366 |
if set.Len() == 0 { |
| 1367 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1368 |
return |
| 1369 |
} |
| 1370 |
|
| 1371 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1372 |
defer func() { |
| 1373 |
*o = (*o)[:0] |
| 1374 |
addOptPool.Put(o) |
| 1375 |
}() |
| 1376 |
|
| 1377 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1378 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1379 |
} |
| 1380 |
|
| 1381 |
// ContainerStatusState is an instrument used to record metric values conforming |
| 1382 |
// to the "k8s.container.status.state" semantic conventions. It represents the |
| 1383 |
// describes the number of K8s containers that are currently in a given state. |
| 1384 |
type ContainerStatusState struct { |
| 1385 |
metric.Int64UpDownCounter |
| 1386 |
} |
| 1387 |
|
| 1388 |
var newContainerStatusStateOpts = []metric.Int64UpDownCounterOption{ |
| 1389 |
metric.WithDescription("Describes the number of K8s containers that are currently in a given state."), |
| 1390 |
metric.WithUnit("{container}"), |
| 1391 |
} |
| 1392 |
|
| 1393 |
// NewContainerStatusState returns a new ContainerStatusState instrument. |
| 1394 |
func NewContainerStatusState( |
| 1395 |
m metric.Meter, |
| 1396 |
opt ...metric.Int64UpDownCounterOption, |
| 1397 |
) (ContainerStatusState, error) { |
| 1398 |
// Check if the meter is nil. |
| 1399 |
if m == nil { |
| 1400 |
return ContainerStatusState{noop.Int64UpDownCounter{}}, nil |
| 1401 |
} |
| 1402 |
|
| 1403 |
if len(opt) == 0 { |
| 1404 |
opt = newContainerStatusStateOpts |
| 1405 |
} else { |
| 1406 |
opt = append(opt, newContainerStatusStateOpts...) |
| 1407 |
} |
| 1408 |
|
| 1409 |
i, err := m.Int64UpDownCounter( |
| 1410 |
"k8s.container.status.state", |
| 1411 |
opt..., |
| 1412 |
) |
| 1413 |
if err != nil { |
| 1414 |
return ContainerStatusState{noop.Int64UpDownCounter{}}, err |
| 1415 |
} |
| 1416 |
return ContainerStatusState{i}, nil |
| 1417 |
} |
| 1418 |
|
| 1419 |
// Inst returns the underlying metric instrument. |
| 1420 |
func (m ContainerStatusState) Inst() metric.Int64UpDownCounter { |
| 1421 |
return m.Int64UpDownCounter |
| 1422 |
} |
| 1423 |
|
| 1424 |
// Name returns the semantic convention name of the instrument. |
| 1425 |
func (ContainerStatusState) Name() string { |
| 1426 |
return "k8s.container.status.state" |
| 1427 |
} |
| 1428 |
|
| 1429 |
// Unit returns the semantic convention unit of the instrument |
| 1430 |
func (ContainerStatusState) Unit() string { |
| 1431 |
return "{container}" |
| 1432 |
} |
| 1433 |
|
| 1434 |
// Description returns the semantic convention description of the instrument |
| 1435 |
func (ContainerStatusState) Description() string { |
| 1436 |
return "Describes the number of K8s containers that are currently in a given state." |
| 1437 |
} |
| 1438 |
|
| 1439 |
// Add adds incr to the existing count for attrs. |
| 1440 |
// |
| 1441 |
// The containerStatusState is the the state of the container. |
| 1442 |
// [K8s ContainerState] |
| 1443 |
// |
| 1444 |
// [K8s ContainerState]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstate-v1-core |
| 1445 |
// |
| 1446 |
// All possible container states will be reported at each time interval to avoid |
| 1447 |
// missing metrics. |
| 1448 |
// Only the value corresponding to the current state will be non-zero. |
| 1449 |
func (m ContainerStatusState) Add( |
| 1450 |
ctx context.Context, |
| 1451 |
incr int64, |
| 1452 |
containerStatusState ContainerStatusStateAttr, |
| 1453 |
attrs ...attribute.KeyValue, |
| 1454 |
) { |
| 1455 |
if len(attrs) == 0 { |
| 1456 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 1457 |
attribute.String("k8s.container.status.state", string(containerStatusState)), |
| 1458 |
)) |
| 1459 |
return |
| 1460 |
} |
| 1461 |
|
| 1462 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1463 |
defer func() { |
| 1464 |
*o = (*o)[:0] |
| 1465 |
addOptPool.Put(o) |
| 1466 |
}() |
| 1467 |
|
| 1468 |
*o = append( |
| 1469 |
*o, |
| 1470 |
metric.WithAttributes( |
| 1471 |
append( |
| 1472 |
attrs, |
| 1473 |
attribute.String("k8s.container.status.state", string(containerStatusState)), |
| 1474 |
)..., |
| 1475 |
), |
| 1476 |
) |
| 1477 |
|
| 1478 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1479 |
} |
| 1480 |
|
| 1481 |
// AddSet adds incr to the existing count for set. |
| 1482 |
// |
| 1483 |
// All possible container states will be reported at each time interval to avoid |
| 1484 |
// missing metrics. |
| 1485 |
// Only the value corresponding to the current state will be non-zero. |
| 1486 |
func (m ContainerStatusState) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1487 |
if set.Len() == 0 { |
| 1488 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1489 |
return |
| 1490 |
} |
| 1491 |
|
| 1492 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1493 |
defer func() { |
| 1494 |
*o = (*o)[:0] |
| 1495 |
addOptPool.Put(o) |
| 1496 |
}() |
| 1497 |
|
| 1498 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1499 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1500 |
} |
| 1501 |
|
| 1502 |
// ContainerStorageLimit is an instrument used to record metric values conforming |
| 1503 |
// to the "k8s.container.storage.limit" semantic conventions. It represents the |
| 1504 |
// maximum storage resource limit set for the container. |
| 1505 |
type ContainerStorageLimit struct { |
| 1506 |
metric.Int64UpDownCounter |
| 1507 |
} |
| 1508 |
|
| 1509 |
var newContainerStorageLimitOpts = []metric.Int64UpDownCounterOption{ |
| 1510 |
metric.WithDescription("Maximum storage resource limit set for the container."), |
| 1511 |
metric.WithUnit("By"), |
| 1512 |
} |
| 1513 |
|
| 1514 |
// NewContainerStorageLimit returns a new ContainerStorageLimit instrument. |
| 1515 |
func NewContainerStorageLimit( |
| 1516 |
m metric.Meter, |
| 1517 |
opt ...metric.Int64UpDownCounterOption, |
| 1518 |
) (ContainerStorageLimit, error) { |
| 1519 |
// Check if the meter is nil. |
| 1520 |
if m == nil { |
| 1521 |
return ContainerStorageLimit{noop.Int64UpDownCounter{}}, nil |
| 1522 |
} |
| 1523 |
|
| 1524 |
if len(opt) == 0 { |
| 1525 |
opt = newContainerStorageLimitOpts |
| 1526 |
} else { |
| 1527 |
opt = append(opt, newContainerStorageLimitOpts...) |
| 1528 |
} |
| 1529 |
|
| 1530 |
i, err := m.Int64UpDownCounter( |
| 1531 |
"k8s.container.storage.limit", |
| 1532 |
opt..., |
| 1533 |
) |
| 1534 |
if err != nil { |
| 1535 |
return ContainerStorageLimit{noop.Int64UpDownCounter{}}, err |
| 1536 |
} |
| 1537 |
return ContainerStorageLimit{i}, nil |
| 1538 |
} |
| 1539 |
|
| 1540 |
// Inst returns the underlying metric instrument. |
| 1541 |
func (m ContainerStorageLimit) Inst() metric.Int64UpDownCounter { |
| 1542 |
return m.Int64UpDownCounter |
| 1543 |
} |
| 1544 |
|
| 1545 |
// Name returns the semantic convention name of the instrument. |
| 1546 |
func (ContainerStorageLimit) Name() string { |
| 1547 |
return "k8s.container.storage.limit" |
| 1548 |
} |
| 1549 |
|
| 1550 |
// Unit returns the semantic convention unit of the instrument |
| 1551 |
func (ContainerStorageLimit) Unit() string { |
| 1552 |
return "By" |
| 1553 |
} |
| 1554 |
|
| 1555 |
// Description returns the semantic convention description of the instrument |
| 1556 |
func (ContainerStorageLimit) Description() string { |
| 1557 |
return "Maximum storage resource limit set for the container." |
| 1558 |
} |
| 1559 |
|
| 1560 |
// Add adds incr to the existing count for attrs. |
| 1561 |
// |
| 1562 |
// See |
| 1563 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1564 |
// for details. |
| 1565 |
func (m ContainerStorageLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1566 |
if len(attrs) == 0 { |
| 1567 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1568 |
return |
| 1569 |
} |
| 1570 |
|
| 1571 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1572 |
defer func() { |
| 1573 |
*o = (*o)[:0] |
| 1574 |
addOptPool.Put(o) |
| 1575 |
}() |
| 1576 |
|
| 1577 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1578 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1579 |
} |
| 1580 |
|
| 1581 |
// AddSet adds incr to the existing count for set. |
| 1582 |
// |
| 1583 |
// See |
| 1584 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1585 |
// for details. |
| 1586 |
func (m ContainerStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1587 |
if set.Len() == 0 { |
| 1588 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1589 |
return |
| 1590 |
} |
| 1591 |
|
| 1592 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1593 |
defer func() { |
| 1594 |
*o = (*o)[:0] |
| 1595 |
addOptPool.Put(o) |
| 1596 |
}() |
| 1597 |
|
| 1598 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1599 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1600 |
} |
| 1601 |
|
| 1602 |
// ContainerStorageRequest is an instrument used to record metric values |
| 1603 |
// conforming to the "k8s.container.storage.request" semantic conventions. It |
| 1604 |
// represents the storage resource requested for the container. |
| 1605 |
type ContainerStorageRequest struct { |
| 1606 |
metric.Int64UpDownCounter |
| 1607 |
} |
| 1608 |
|
| 1609 |
var newContainerStorageRequestOpts = []metric.Int64UpDownCounterOption{ |
| 1610 |
metric.WithDescription("Storage resource requested for the container."), |
| 1611 |
metric.WithUnit("By"), |
| 1612 |
} |
| 1613 |
|
| 1614 |
// NewContainerStorageRequest returns a new ContainerStorageRequest instrument. |
| 1615 |
func NewContainerStorageRequest( |
| 1616 |
m metric.Meter, |
| 1617 |
opt ...metric.Int64UpDownCounterOption, |
| 1618 |
) (ContainerStorageRequest, error) { |
| 1619 |
// Check if the meter is nil. |
| 1620 |
if m == nil { |
| 1621 |
return ContainerStorageRequest{noop.Int64UpDownCounter{}}, nil |
| 1622 |
} |
| 1623 |
|
| 1624 |
if len(opt) == 0 { |
| 1625 |
opt = newContainerStorageRequestOpts |
| 1626 |
} else { |
| 1627 |
opt = append(opt, newContainerStorageRequestOpts...) |
| 1628 |
} |
| 1629 |
|
| 1630 |
i, err := m.Int64UpDownCounter( |
| 1631 |
"k8s.container.storage.request", |
| 1632 |
opt..., |
| 1633 |
) |
| 1634 |
if err != nil { |
| 1635 |
return ContainerStorageRequest{noop.Int64UpDownCounter{}}, err |
| 1636 |
} |
| 1637 |
return ContainerStorageRequest{i}, nil |
| 1638 |
} |
| 1639 |
|
| 1640 |
// Inst returns the underlying metric instrument. |
| 1641 |
func (m ContainerStorageRequest) Inst() metric.Int64UpDownCounter { |
| 1642 |
return m.Int64UpDownCounter |
| 1643 |
} |
| 1644 |
|
| 1645 |
// Name returns the semantic convention name of the instrument. |
| 1646 |
func (ContainerStorageRequest) Name() string { |
| 1647 |
return "k8s.container.storage.request" |
| 1648 |
} |
| 1649 |
|
| 1650 |
// Unit returns the semantic convention unit of the instrument |
| 1651 |
func (ContainerStorageRequest) Unit() string { |
| 1652 |
return "By" |
| 1653 |
} |
| 1654 |
|
| 1655 |
// Description returns the semantic convention description of the instrument |
| 1656 |
func (ContainerStorageRequest) Description() string { |
| 1657 |
return "Storage resource requested for the container." |
| 1658 |
} |
| 1659 |
|
| 1660 |
// Add adds incr to the existing count for attrs. |
| 1661 |
// |
| 1662 |
// See |
| 1663 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1664 |
// for details. |
| 1665 |
func (m ContainerStorageRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1666 |
if len(attrs) == 0 { |
| 1667 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1668 |
return |
| 1669 |
} |
| 1670 |
|
| 1671 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1672 |
defer func() { |
| 1673 |
*o = (*o)[:0] |
| 1674 |
addOptPool.Put(o) |
| 1675 |
}() |
| 1676 |
|
| 1677 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1678 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1679 |
} |
| 1680 |
|
| 1681 |
// AddSet adds incr to the existing count for set. |
| 1682 |
// |
| 1683 |
// See |
| 1684 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1685 |
// for details. |
| 1686 |
func (m ContainerStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1687 |
if set.Len() == 0 { |
| 1688 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1689 |
return |
| 1690 |
} |
| 1691 |
|
| 1692 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1693 |
defer func() { |
| 1694 |
*o = (*o)[:0] |
| 1695 |
addOptPool.Put(o) |
| 1696 |
}() |
| 1697 |
|
| 1698 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1699 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1700 |
} |
| 1701 |
|
| 1702 |
// CronJobJobActive is an instrument used to record metric values conforming to |
| 1703 |
// the "k8s.cronjob.job.active" semantic conventions. It represents the number of |
| 1704 |
// actively running jobs for a cronjob. |
| 1705 |
type CronJobJobActive struct { |
| 1706 |
metric.Int64UpDownCounter |
| 1707 |
} |
| 1708 |
|
| 1709 |
var newCronJobJobActiveOpts = []metric.Int64UpDownCounterOption{ |
| 1710 |
metric.WithDescription("The number of actively running jobs for a cronjob."), |
| 1711 |
metric.WithUnit("{job}"), |
| 1712 |
} |
| 1713 |
|
| 1714 |
// NewCronJobJobActive returns a new CronJobJobActive instrument. |
| 1715 |
func NewCronJobJobActive( |
| 1716 |
m metric.Meter, |
| 1717 |
opt ...metric.Int64UpDownCounterOption, |
| 1718 |
) (CronJobJobActive, error) { |
| 1719 |
// Check if the meter is nil. |
| 1720 |
if m == nil { |
| 1721 |
return CronJobJobActive{noop.Int64UpDownCounter{}}, nil |
| 1722 |
} |
| 1723 |
|
| 1724 |
if len(opt) == 0 { |
| 1725 |
opt = newCronJobJobActiveOpts |
| 1726 |
} else { |
| 1727 |
opt = append(opt, newCronJobJobActiveOpts...) |
| 1728 |
} |
| 1729 |
|
| 1730 |
i, err := m.Int64UpDownCounter( |
| 1731 |
"k8s.cronjob.job.active", |
| 1732 |
opt..., |
| 1733 |
) |
| 1734 |
if err != nil { |
| 1735 |
return CronJobJobActive{noop.Int64UpDownCounter{}}, err |
| 1736 |
} |
| 1737 |
return CronJobJobActive{i}, nil |
| 1738 |
} |
| 1739 |
|
| 1740 |
// Inst returns the underlying metric instrument. |
| 1741 |
func (m CronJobJobActive) Inst() metric.Int64UpDownCounter { |
| 1742 |
return m.Int64UpDownCounter |
| 1743 |
} |
| 1744 |
|
| 1745 |
// Name returns the semantic convention name of the instrument. |
| 1746 |
func (CronJobJobActive) Name() string { |
| 1747 |
return "k8s.cronjob.job.active" |
| 1748 |
} |
| 1749 |
|
| 1750 |
// Unit returns the semantic convention unit of the instrument |
| 1751 |
func (CronJobJobActive) Unit() string { |
| 1752 |
return "{job}" |
| 1753 |
} |
| 1754 |
|
| 1755 |
// Description returns the semantic convention description of the instrument |
| 1756 |
func (CronJobJobActive) Description() string { |
| 1757 |
return "The number of actively running jobs for a cronjob." |
| 1758 |
} |
| 1759 |
|
| 1760 |
// Add adds incr to the existing count for attrs. |
| 1761 |
// |
| 1762 |
// This metric aligns with the `active` field of the |
| 1763 |
// [K8s CronJobStatus]. |
| 1764 |
// |
| 1765 |
// [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch |
| 1766 |
func (m CronJobJobActive) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1767 |
if len(attrs) == 0 { |
| 1768 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1769 |
return |
| 1770 |
} |
| 1771 |
|
| 1772 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1773 |
defer func() { |
| 1774 |
*o = (*o)[:0] |
| 1775 |
addOptPool.Put(o) |
| 1776 |
}() |
| 1777 |
|
| 1778 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1779 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1780 |
} |
| 1781 |
|
| 1782 |
// AddSet adds incr to the existing count for set. |
| 1783 |
// |
| 1784 |
// This metric aligns with the `active` field of the |
| 1785 |
// [K8s CronJobStatus]. |
| 1786 |
// |
| 1787 |
// [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch |
| 1788 |
func (m CronJobJobActive) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1789 |
if set.Len() == 0 { |
| 1790 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1791 |
return |
| 1792 |
} |
| 1793 |
|
| 1794 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1795 |
defer func() { |
| 1796 |
*o = (*o)[:0] |
| 1797 |
addOptPool.Put(o) |
| 1798 |
}() |
| 1799 |
|
| 1800 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1801 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1802 |
} |
| 1803 |
|
| 1804 |
// DaemonSetNodeCurrentScheduled is an instrument used to record metric values |
| 1805 |
// conforming to the "k8s.daemonset.node.current_scheduled" semantic conventions. |
| 1806 |
// It represents the number of nodes that are running at least 1 daemon pod and |
| 1807 |
// are supposed to run the daemon pod. |
| 1808 |
type DaemonSetNodeCurrentScheduled struct { |
| 1809 |
metric.Int64UpDownCounter |
| 1810 |
} |
| 1811 |
|
| 1812 |
var newDaemonSetNodeCurrentScheduledOpts = []metric.Int64UpDownCounterOption{ |
| 1813 |
metric.WithDescription("Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod."), |
| 1814 |
metric.WithUnit("{node}"), |
| 1815 |
} |
| 1816 |
|
| 1817 |
// NewDaemonSetNodeCurrentScheduled returns a new DaemonSetNodeCurrentScheduled |
| 1818 |
// instrument. |
| 1819 |
func NewDaemonSetNodeCurrentScheduled( |
| 1820 |
m metric.Meter, |
| 1821 |
opt ...metric.Int64UpDownCounterOption, |
| 1822 |
) (DaemonSetNodeCurrentScheduled, error) { |
| 1823 |
// Check if the meter is nil. |
| 1824 |
if m == nil { |
| 1825 |
return DaemonSetNodeCurrentScheduled{noop.Int64UpDownCounter{}}, nil |
| 1826 |
} |
| 1827 |
|
| 1828 |
if len(opt) == 0 { |
| 1829 |
opt = newDaemonSetNodeCurrentScheduledOpts |
| 1830 |
} else { |
| 1831 |
opt = append(opt, newDaemonSetNodeCurrentScheduledOpts...) |
| 1832 |
} |
| 1833 |
|
| 1834 |
i, err := m.Int64UpDownCounter( |
| 1835 |
"k8s.daemonset.node.current_scheduled", |
| 1836 |
opt..., |
| 1837 |
) |
| 1838 |
if err != nil { |
| 1839 |
return DaemonSetNodeCurrentScheduled{noop.Int64UpDownCounter{}}, err |
| 1840 |
} |
| 1841 |
return DaemonSetNodeCurrentScheduled{i}, nil |
| 1842 |
} |
| 1843 |
|
| 1844 |
// Inst returns the underlying metric instrument. |
| 1845 |
func (m DaemonSetNodeCurrentScheduled) Inst() metric.Int64UpDownCounter { |
| 1846 |
return m.Int64UpDownCounter |
| 1847 |
} |
| 1848 |
|
| 1849 |
// Name returns the semantic convention name of the instrument. |
| 1850 |
func (DaemonSetNodeCurrentScheduled) Name() string { |
| 1851 |
return "k8s.daemonset.node.current_scheduled" |
| 1852 |
} |
| 1853 |
|
| 1854 |
// Unit returns the semantic convention unit of the instrument |
| 1855 |
func (DaemonSetNodeCurrentScheduled) Unit() string { |
| 1856 |
return "{node}" |
| 1857 |
} |
| 1858 |
|
| 1859 |
// Description returns the semantic convention description of the instrument |
| 1860 |
func (DaemonSetNodeCurrentScheduled) Description() string { |
| 1861 |
return "Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod." |
| 1862 |
} |
| 1863 |
|
| 1864 |
// Add adds incr to the existing count for attrs. |
| 1865 |
// |
| 1866 |
// This metric aligns with the `currentNumberScheduled` field of the |
| 1867 |
// [K8s DaemonSetStatus]. |
| 1868 |
// |
| 1869 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1870 |
func (m DaemonSetNodeCurrentScheduled) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1871 |
if len(attrs) == 0 { |
| 1872 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1873 |
return |
| 1874 |
} |
| 1875 |
|
| 1876 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1877 |
defer func() { |
| 1878 |
*o = (*o)[:0] |
| 1879 |
addOptPool.Put(o) |
| 1880 |
}() |
| 1881 |
|
| 1882 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1883 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1884 |
} |
| 1885 |
|
| 1886 |
// AddSet adds incr to the existing count for set. |
| 1887 |
// |
| 1888 |
// This metric aligns with the `currentNumberScheduled` field of the |
| 1889 |
// [K8s DaemonSetStatus]. |
| 1890 |
// |
| 1891 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1892 |
func (m DaemonSetNodeCurrentScheduled) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1893 |
if set.Len() == 0 { |
| 1894 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1895 |
return |
| 1896 |
} |
| 1897 |
|
| 1898 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1899 |
defer func() { |
| 1900 |
*o = (*o)[:0] |
| 1901 |
addOptPool.Put(o) |
| 1902 |
}() |
| 1903 |
|
| 1904 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1905 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1906 |
} |
| 1907 |
|
| 1908 |
// DaemonSetNodeDesiredScheduled is an instrument used to record metric values |
| 1909 |
// conforming to the "k8s.daemonset.node.desired_scheduled" semantic conventions. |
| 1910 |
// It represents the number of nodes that should be running the daemon pod |
| 1911 |
// (including nodes currently running the daemon pod). |
| 1912 |
type DaemonSetNodeDesiredScheduled struct { |
| 1913 |
metric.Int64UpDownCounter |
| 1914 |
} |
| 1915 |
|
| 1916 |
var newDaemonSetNodeDesiredScheduledOpts = []metric.Int64UpDownCounterOption{ |
| 1917 |
metric.WithDescription("Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)."), |
| 1918 |
metric.WithUnit("{node}"), |
| 1919 |
} |
| 1920 |
|
| 1921 |
// NewDaemonSetNodeDesiredScheduled returns a new DaemonSetNodeDesiredScheduled |
| 1922 |
// instrument. |
| 1923 |
func NewDaemonSetNodeDesiredScheduled( |
| 1924 |
m metric.Meter, |
| 1925 |
opt ...metric.Int64UpDownCounterOption, |
| 1926 |
) (DaemonSetNodeDesiredScheduled, error) { |
| 1927 |
// Check if the meter is nil. |
| 1928 |
if m == nil { |
| 1929 |
return DaemonSetNodeDesiredScheduled{noop.Int64UpDownCounter{}}, nil |
| 1930 |
} |
| 1931 |
|
| 1932 |
if len(opt) == 0 { |
| 1933 |
opt = newDaemonSetNodeDesiredScheduledOpts |
| 1934 |
} else { |
| 1935 |
opt = append(opt, newDaemonSetNodeDesiredScheduledOpts...) |
| 1936 |
} |
| 1937 |
|
| 1938 |
i, err := m.Int64UpDownCounter( |
| 1939 |
"k8s.daemonset.node.desired_scheduled", |
| 1940 |
opt..., |
| 1941 |
) |
| 1942 |
if err != nil { |
| 1943 |
return DaemonSetNodeDesiredScheduled{noop.Int64UpDownCounter{}}, err |
| 1944 |
} |
| 1945 |
return DaemonSetNodeDesiredScheduled{i}, nil |
| 1946 |
} |
| 1947 |
|
| 1948 |
// Inst returns the underlying metric instrument. |
| 1949 |
func (m DaemonSetNodeDesiredScheduled) Inst() metric.Int64UpDownCounter { |
| 1950 |
return m.Int64UpDownCounter |
| 1951 |
} |
| 1952 |
|
| 1953 |
// Name returns the semantic convention name of the instrument. |
| 1954 |
func (DaemonSetNodeDesiredScheduled) Name() string { |
| 1955 |
return "k8s.daemonset.node.desired_scheduled" |
| 1956 |
} |
| 1957 |
|
| 1958 |
// Unit returns the semantic convention unit of the instrument |
| 1959 |
func (DaemonSetNodeDesiredScheduled) Unit() string { |
| 1960 |
return "{node}" |
| 1961 |
} |
| 1962 |
|
| 1963 |
// Description returns the semantic convention description of the instrument |
| 1964 |
func (DaemonSetNodeDesiredScheduled) Description() string { |
| 1965 |
return "Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)." |
| 1966 |
} |
| 1967 |
|
| 1968 |
// Add adds incr to the existing count for attrs. |
| 1969 |
// |
| 1970 |
// This metric aligns with the `desiredNumberScheduled` field of the |
| 1971 |
// [K8s DaemonSetStatus]. |
| 1972 |
// |
| 1973 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1974 |
func (m DaemonSetNodeDesiredScheduled) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1975 |
if len(attrs) == 0 { |
| 1976 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1977 |
return |
| 1978 |
} |
| 1979 |
|
| 1980 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1981 |
defer func() { |
| 1982 |
*o = (*o)[:0] |
| 1983 |
addOptPool.Put(o) |
| 1984 |
}() |
| 1985 |
|
| 1986 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1987 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1988 |
} |
| 1989 |
|
| 1990 |
// AddSet adds incr to the existing count for set. |
| 1991 |
// |
| 1992 |
// This metric aligns with the `desiredNumberScheduled` field of the |
| 1993 |
// [K8s DaemonSetStatus]. |
| 1994 |
// |
| 1995 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1996 |
func (m DaemonSetNodeDesiredScheduled) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1997 |
if set.Len() == 0 { |
| 1998 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1999 |
return |
| 2000 |
} |
| 2001 |
|
| 2002 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2003 |
defer func() { |
| 2004 |
*o = (*o)[:0] |
| 2005 |
addOptPool.Put(o) |
| 2006 |
}() |
| 2007 |
|
| 2008 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2009 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2010 |
} |
| 2011 |
|
| 2012 |
// DaemonSetNodeMisscheduled is an instrument used to record metric values |
| 2013 |
// conforming to the "k8s.daemonset.node.misscheduled" semantic conventions. It |
| 2014 |
// represents the number of nodes that are running the daemon pod, but are not |
| 2015 |
// supposed to run the daemon pod. |
| 2016 |
type DaemonSetNodeMisscheduled struct { |
| 2017 |
metric.Int64UpDownCounter |
| 2018 |
} |
| 2019 |
|
| 2020 |
var newDaemonSetNodeMisscheduledOpts = []metric.Int64UpDownCounterOption{ |
| 2021 |
metric.WithDescription("Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod."), |
| 2022 |
metric.WithUnit("{node}"), |
| 2023 |
} |
| 2024 |
|
| 2025 |
// NewDaemonSetNodeMisscheduled returns a new DaemonSetNodeMisscheduled |
| 2026 |
// instrument. |
| 2027 |
func NewDaemonSetNodeMisscheduled( |
| 2028 |
m metric.Meter, |
| 2029 |
opt ...metric.Int64UpDownCounterOption, |
| 2030 |
) (DaemonSetNodeMisscheduled, error) { |
| 2031 |
// Check if the meter is nil. |
| 2032 |
if m == nil { |
| 2033 |
return DaemonSetNodeMisscheduled{noop.Int64UpDownCounter{}}, nil |
| 2034 |
} |
| 2035 |
|
| 2036 |
if len(opt) == 0 { |
| 2037 |
opt = newDaemonSetNodeMisscheduledOpts |
| 2038 |
} else { |
| 2039 |
opt = append(opt, newDaemonSetNodeMisscheduledOpts...) |
| 2040 |
} |
| 2041 |
|
| 2042 |
i, err := m.Int64UpDownCounter( |
| 2043 |
"k8s.daemonset.node.misscheduled", |
| 2044 |
opt..., |
| 2045 |
) |
| 2046 |
if err != nil { |
| 2047 |
return DaemonSetNodeMisscheduled{noop.Int64UpDownCounter{}}, err |
| 2048 |
} |
| 2049 |
return DaemonSetNodeMisscheduled{i}, nil |
| 2050 |
} |
| 2051 |
|
| 2052 |
// Inst returns the underlying metric instrument. |
| 2053 |
func (m DaemonSetNodeMisscheduled) Inst() metric.Int64UpDownCounter { |
| 2054 |
return m.Int64UpDownCounter |
| 2055 |
} |
| 2056 |
|
| 2057 |
// Name returns the semantic convention name of the instrument. |
| 2058 |
func (DaemonSetNodeMisscheduled) Name() string { |
| 2059 |
return "k8s.daemonset.node.misscheduled" |
| 2060 |
} |
| 2061 |
|
| 2062 |
// Unit returns the semantic convention unit of the instrument |
| 2063 |
func (DaemonSetNodeMisscheduled) Unit() string { |
| 2064 |
return "{node}" |
| 2065 |
} |
| 2066 |
|
| 2067 |
// Description returns the semantic convention description of the instrument |
| 2068 |
func (DaemonSetNodeMisscheduled) Description() string { |
| 2069 |
return "Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod." |
| 2070 |
} |
| 2071 |
|
| 2072 |
// Add adds incr to the existing count for attrs. |
| 2073 |
// |
| 2074 |
// This metric aligns with the `numberMisscheduled` field of the |
| 2075 |
// [K8s DaemonSetStatus]. |
| 2076 |
// |
| 2077 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 2078 |
func (m DaemonSetNodeMisscheduled) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2079 |
if len(attrs) == 0 { |
| 2080 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2081 |
return |
| 2082 |
} |
| 2083 |
|
| 2084 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2085 |
defer func() { |
| 2086 |
*o = (*o)[:0] |
| 2087 |
addOptPool.Put(o) |
| 2088 |
}() |
| 2089 |
|
| 2090 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2091 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2092 |
} |
| 2093 |
|
| 2094 |
// AddSet adds incr to the existing count for set. |
| 2095 |
// |
| 2096 |
// This metric aligns with the `numberMisscheduled` field of the |
| 2097 |
// [K8s DaemonSetStatus]. |
| 2098 |
// |
| 2099 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 2100 |
func (m DaemonSetNodeMisscheduled) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2101 |
if set.Len() == 0 { |
| 2102 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2103 |
return |
| 2104 |
} |
| 2105 |
|
| 2106 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2107 |
defer func() { |
| 2108 |
*o = (*o)[:0] |
| 2109 |
addOptPool.Put(o) |
| 2110 |
}() |
| 2111 |
|
| 2112 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2113 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2114 |
} |
| 2115 |
|
| 2116 |
// DaemonSetNodeReady is an instrument used to record metric values conforming to |
| 2117 |
// the "k8s.daemonset.node.ready" semantic conventions. It represents the number |
| 2118 |
// of nodes that should be running the daemon pod and have one or more of the |
| 2119 |
// daemon pod running and ready. |
| 2120 |
type DaemonSetNodeReady struct { |
| 2121 |
metric.Int64UpDownCounter |
| 2122 |
} |
| 2123 |
|
| 2124 |
var newDaemonSetNodeReadyOpts = []metric.Int64UpDownCounterOption{ |
| 2125 |
metric.WithDescription("Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready."), |
| 2126 |
metric.WithUnit("{node}"), |
| 2127 |
} |
| 2128 |
|
| 2129 |
// NewDaemonSetNodeReady returns a new DaemonSetNodeReady instrument. |
| 2130 |
func NewDaemonSetNodeReady( |
| 2131 |
m metric.Meter, |
| 2132 |
opt ...metric.Int64UpDownCounterOption, |
| 2133 |
) (DaemonSetNodeReady, error) { |
| 2134 |
// Check if the meter is nil. |
| 2135 |
if m == nil { |
| 2136 |
return DaemonSetNodeReady{noop.Int64UpDownCounter{}}, nil |
| 2137 |
} |
| 2138 |
|
| 2139 |
if len(opt) == 0 { |
| 2140 |
opt = newDaemonSetNodeReadyOpts |
| 2141 |
} else { |
| 2142 |
opt = append(opt, newDaemonSetNodeReadyOpts...) |
| 2143 |
} |
| 2144 |
|
| 2145 |
i, err := m.Int64UpDownCounter( |
| 2146 |
"k8s.daemonset.node.ready", |
| 2147 |
opt..., |
| 2148 |
) |
| 2149 |
if err != nil { |
| 2150 |
return DaemonSetNodeReady{noop.Int64UpDownCounter{}}, err |
| 2151 |
} |
| 2152 |
return DaemonSetNodeReady{i}, nil |
| 2153 |
} |
| 2154 |
|
| 2155 |
// Inst returns the underlying metric instrument. |
| 2156 |
func (m DaemonSetNodeReady) Inst() metric.Int64UpDownCounter { |
| 2157 |
return m.Int64UpDownCounter |
| 2158 |
} |
| 2159 |
|
| 2160 |
// Name returns the semantic convention name of the instrument. |
| 2161 |
func (DaemonSetNodeReady) Name() string { |
| 2162 |
return "k8s.daemonset.node.ready" |
| 2163 |
} |
| 2164 |
|
| 2165 |
// Unit returns the semantic convention unit of the instrument |
| 2166 |
func (DaemonSetNodeReady) Unit() string { |
| 2167 |
return "{node}" |
| 2168 |
} |
| 2169 |
|
| 2170 |
// Description returns the semantic convention description of the instrument |
| 2171 |
func (DaemonSetNodeReady) Description() string { |
| 2172 |
return "Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready." |
| 2173 |
} |
| 2174 |
|
| 2175 |
// Add adds incr to the existing count for attrs. |
| 2176 |
// |
| 2177 |
// This metric aligns with the `numberReady` field of the |
| 2178 |
// [K8s DaemonSetStatus]. |
| 2179 |
// |
| 2180 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 2181 |
func (m DaemonSetNodeReady) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2182 |
if len(attrs) == 0 { |
| 2183 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2184 |
return |
| 2185 |
} |
| 2186 |
|
| 2187 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2188 |
defer func() { |
| 2189 |
*o = (*o)[:0] |
| 2190 |
addOptPool.Put(o) |
| 2191 |
}() |
| 2192 |
|
| 2193 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2194 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2195 |
} |
| 2196 |
|
| 2197 |
// AddSet adds incr to the existing count for set. |
| 2198 |
// |
| 2199 |
// This metric aligns with the `numberReady` field of the |
| 2200 |
// [K8s DaemonSetStatus]. |
| 2201 |
// |
| 2202 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 2203 |
func (m DaemonSetNodeReady) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2204 |
if set.Len() == 0 { |
| 2205 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2206 |
return |
| 2207 |
} |
| 2208 |
|
| 2209 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2210 |
defer func() { |
| 2211 |
*o = (*o)[:0] |
| 2212 |
addOptPool.Put(o) |
| 2213 |
}() |
| 2214 |
|
| 2215 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2216 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2217 |
} |
| 2218 |
|
| 2219 |
// DeploymentPodAvailable is an instrument used to record metric values |
| 2220 |
// conforming to the "k8s.deployment.pod.available" semantic conventions. It |
| 2221 |
// represents the total number of available replica pods (ready for at least |
| 2222 |
// minReadySeconds) targeted by this deployment. |
| 2223 |
type DeploymentPodAvailable struct { |
| 2224 |
metric.Int64UpDownCounter |
| 2225 |
} |
| 2226 |
|
| 2227 |
var newDeploymentPodAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 2228 |
metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment."), |
| 2229 |
metric.WithUnit("{pod}"), |
| 2230 |
} |
| 2231 |
|
| 2232 |
// NewDeploymentPodAvailable returns a new DeploymentPodAvailable instrument. |
| 2233 |
func NewDeploymentPodAvailable( |
| 2234 |
m metric.Meter, |
| 2235 |
opt ...metric.Int64UpDownCounterOption, |
| 2236 |
) (DeploymentPodAvailable, error) { |
| 2237 |
// Check if the meter is nil. |
| 2238 |
if m == nil { |
| 2239 |
return DeploymentPodAvailable{noop.Int64UpDownCounter{}}, nil |
| 2240 |
} |
| 2241 |
|
| 2242 |
if len(opt) == 0 { |
| 2243 |
opt = newDeploymentPodAvailableOpts |
| 2244 |
} else { |
| 2245 |
opt = append(opt, newDeploymentPodAvailableOpts...) |
| 2246 |
} |
| 2247 |
|
| 2248 |
i, err := m.Int64UpDownCounter( |
| 2249 |
"k8s.deployment.pod.available", |
| 2250 |
opt..., |
| 2251 |
) |
| 2252 |
if err != nil { |
| 2253 |
return DeploymentPodAvailable{noop.Int64UpDownCounter{}}, err |
| 2254 |
} |
| 2255 |
return DeploymentPodAvailable{i}, nil |
| 2256 |
} |
| 2257 |
|
| 2258 |
// Inst returns the underlying metric instrument. |
| 2259 |
func (m DeploymentPodAvailable) Inst() metric.Int64UpDownCounter { |
| 2260 |
return m.Int64UpDownCounter |
| 2261 |
} |
| 2262 |
|
| 2263 |
// Name returns the semantic convention name of the instrument. |
| 2264 |
func (DeploymentPodAvailable) Name() string { |
| 2265 |
return "k8s.deployment.pod.available" |
| 2266 |
} |
| 2267 |
|
| 2268 |
// Unit returns the semantic convention unit of the instrument |
| 2269 |
func (DeploymentPodAvailable) Unit() string { |
| 2270 |
return "{pod}" |
| 2271 |
} |
| 2272 |
|
| 2273 |
// Description returns the semantic convention description of the instrument |
| 2274 |
func (DeploymentPodAvailable) Description() string { |
| 2275 |
return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment." |
| 2276 |
} |
| 2277 |
|
| 2278 |
// Add adds incr to the existing count for attrs. |
| 2279 |
// |
| 2280 |
// This metric aligns with the `availableReplicas` field of the |
| 2281 |
// [K8s DeploymentStatus]. |
| 2282 |
// |
| 2283 |
// [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps |
| 2284 |
func (m DeploymentPodAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2285 |
if len(attrs) == 0 { |
| 2286 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2287 |
return |
| 2288 |
} |
| 2289 |
|
| 2290 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2291 |
defer func() { |
| 2292 |
*o = (*o)[:0] |
| 2293 |
addOptPool.Put(o) |
| 2294 |
}() |
| 2295 |
|
| 2296 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2297 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2298 |
} |
| 2299 |
|
| 2300 |
// AddSet adds incr to the existing count for set. |
| 2301 |
// |
| 2302 |
// This metric aligns with the `availableReplicas` field of the |
| 2303 |
// [K8s DeploymentStatus]. |
| 2304 |
// |
| 2305 |
// [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps |
| 2306 |
func (m DeploymentPodAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2307 |
if set.Len() == 0 { |
| 2308 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2309 |
return |
| 2310 |
} |
| 2311 |
|
| 2312 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2313 |
defer func() { |
| 2314 |
*o = (*o)[:0] |
| 2315 |
addOptPool.Put(o) |
| 2316 |
}() |
| 2317 |
|
| 2318 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2319 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2320 |
} |
| 2321 |
|
| 2322 |
// DeploymentPodDesired is an instrument used to record metric values conforming |
| 2323 |
// to the "k8s.deployment.pod.desired" semantic conventions. It represents the |
| 2324 |
// number of desired replica pods in this deployment. |
| 2325 |
type DeploymentPodDesired struct { |
| 2326 |
metric.Int64UpDownCounter |
| 2327 |
} |
| 2328 |
|
| 2329 |
var newDeploymentPodDesiredOpts = []metric.Int64UpDownCounterOption{ |
| 2330 |
metric.WithDescription("Number of desired replica pods in this deployment."), |
| 2331 |
metric.WithUnit("{pod}"), |
| 2332 |
} |
| 2333 |
|
| 2334 |
// NewDeploymentPodDesired returns a new DeploymentPodDesired instrument. |
| 2335 |
func NewDeploymentPodDesired( |
| 2336 |
m metric.Meter, |
| 2337 |
opt ...metric.Int64UpDownCounterOption, |
| 2338 |
) (DeploymentPodDesired, error) { |
| 2339 |
// Check if the meter is nil. |
| 2340 |
if m == nil { |
| 2341 |
return DeploymentPodDesired{noop.Int64UpDownCounter{}}, nil |
| 2342 |
} |
| 2343 |
|
| 2344 |
if len(opt) == 0 { |
| 2345 |
opt = newDeploymentPodDesiredOpts |
| 2346 |
} else { |
| 2347 |
opt = append(opt, newDeploymentPodDesiredOpts...) |
| 2348 |
} |
| 2349 |
|
| 2350 |
i, err := m.Int64UpDownCounter( |
| 2351 |
"k8s.deployment.pod.desired", |
| 2352 |
opt..., |
| 2353 |
) |
| 2354 |
if err != nil { |
| 2355 |
return DeploymentPodDesired{noop.Int64UpDownCounter{}}, err |
| 2356 |
} |
| 2357 |
return DeploymentPodDesired{i}, nil |
| 2358 |
} |
| 2359 |
|
| 2360 |
// Inst returns the underlying metric instrument. |
| 2361 |
func (m DeploymentPodDesired) Inst() metric.Int64UpDownCounter { |
| 2362 |
return m.Int64UpDownCounter |
| 2363 |
} |
| 2364 |
|
| 2365 |
// Name returns the semantic convention name of the instrument. |
| 2366 |
func (DeploymentPodDesired) Name() string { |
| 2367 |
return "k8s.deployment.pod.desired" |
| 2368 |
} |
| 2369 |
|
| 2370 |
// Unit returns the semantic convention unit of the instrument |
| 2371 |
func (DeploymentPodDesired) Unit() string { |
| 2372 |
return "{pod}" |
| 2373 |
} |
| 2374 |
|
| 2375 |
// Description returns the semantic convention description of the instrument |
| 2376 |
func (DeploymentPodDesired) Description() string { |
| 2377 |
return "Number of desired replica pods in this deployment." |
| 2378 |
} |
| 2379 |
|
| 2380 |
// Add adds incr to the existing count for attrs. |
| 2381 |
// |
| 2382 |
// This metric aligns with the `replicas` field of the |
| 2383 |
// [K8s DeploymentSpec]. |
| 2384 |
// |
| 2385 |
// [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps |
| 2386 |
func (m DeploymentPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2387 |
if len(attrs) == 0 { |
| 2388 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2389 |
return |
| 2390 |
} |
| 2391 |
|
| 2392 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2393 |
defer func() { |
| 2394 |
*o = (*o)[:0] |
| 2395 |
addOptPool.Put(o) |
| 2396 |
}() |
| 2397 |
|
| 2398 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2399 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2400 |
} |
| 2401 |
|
| 2402 |
// AddSet adds incr to the existing count for set. |
| 2403 |
// |
| 2404 |
// This metric aligns with the `replicas` field of the |
| 2405 |
// [K8s DeploymentSpec]. |
| 2406 |
// |
| 2407 |
// [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps |
| 2408 |
func (m DeploymentPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2409 |
if set.Len() == 0 { |
| 2410 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2411 |
return |
| 2412 |
} |
| 2413 |
|
| 2414 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2415 |
defer func() { |
| 2416 |
*o = (*o)[:0] |
| 2417 |
addOptPool.Put(o) |
| 2418 |
}() |
| 2419 |
|
| 2420 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2421 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2422 |
} |
| 2423 |
|
| 2424 |
// HPAMetricTargetCPUAverageUtilization is an instrument used to record metric |
| 2425 |
// values conforming to the "k8s.hpa.metric.target.cpu.average_utilization" |
| 2426 |
// semantic conventions. It represents the target average utilization, in |
| 2427 |
// percentage, for CPU resource in HPA config. |
| 2428 |
type HPAMetricTargetCPUAverageUtilization struct { |
| 2429 |
metric.Int64Gauge |
| 2430 |
} |
| 2431 |
|
| 2432 |
var newHPAMetricTargetCPUAverageUtilizationOpts = []metric.Int64GaugeOption{ |
| 2433 |
metric.WithDescription("Target average utilization, in percentage, for CPU resource in HPA config."), |
| 2434 |
metric.WithUnit("1"), |
| 2435 |
} |
| 2436 |
|
| 2437 |
// NewHPAMetricTargetCPUAverageUtilization returns a new |
| 2438 |
// HPAMetricTargetCPUAverageUtilization instrument. |
| 2439 |
func NewHPAMetricTargetCPUAverageUtilization( |
| 2440 |
m metric.Meter, |
| 2441 |
opt ...metric.Int64GaugeOption, |
| 2442 |
) (HPAMetricTargetCPUAverageUtilization, error) { |
| 2443 |
// Check if the meter is nil. |
| 2444 |
if m == nil { |
| 2445 |
return HPAMetricTargetCPUAverageUtilization{noop.Int64Gauge{}}, nil |
| 2446 |
} |
| 2447 |
|
| 2448 |
if len(opt) == 0 { |
| 2449 |
opt = newHPAMetricTargetCPUAverageUtilizationOpts |
| 2450 |
} else { |
| 2451 |
opt = append(opt, newHPAMetricTargetCPUAverageUtilizationOpts...) |
| 2452 |
} |
| 2453 |
|
| 2454 |
i, err := m.Int64Gauge( |
| 2455 |
"k8s.hpa.metric.target.cpu.average_utilization", |
| 2456 |
opt..., |
| 2457 |
) |
| 2458 |
if err != nil { |
| 2459 |
return HPAMetricTargetCPUAverageUtilization{noop.Int64Gauge{}}, err |
| 2460 |
} |
| 2461 |
return HPAMetricTargetCPUAverageUtilization{i}, nil |
| 2462 |
} |
| 2463 |
|
| 2464 |
// Inst returns the underlying metric instrument. |
| 2465 |
func (m HPAMetricTargetCPUAverageUtilization) Inst() metric.Int64Gauge { |
| 2466 |
return m.Int64Gauge |
| 2467 |
} |
| 2468 |
|
| 2469 |
// Name returns the semantic convention name of the instrument. |
| 2470 |
func (HPAMetricTargetCPUAverageUtilization) Name() string { |
| 2471 |
return "k8s.hpa.metric.target.cpu.average_utilization" |
| 2472 |
} |
| 2473 |
|
| 2474 |
// Unit returns the semantic convention unit of the instrument |
| 2475 |
func (HPAMetricTargetCPUAverageUtilization) Unit() string { |
| 2476 |
return "1" |
| 2477 |
} |
| 2478 |
|
| 2479 |
// Description returns the semantic convention description of the instrument |
| 2480 |
func (HPAMetricTargetCPUAverageUtilization) Description() string { |
| 2481 |
return "Target average utilization, in percentage, for CPU resource in HPA config." |
| 2482 |
} |
| 2483 |
|
| 2484 |
// Record records val to the current distribution for attrs. |
| 2485 |
// |
| 2486 |
// All additional attrs passed are included in the recorded value. |
| 2487 |
// |
| 2488 |
// This metric aligns with the `averageUtilization` field of the |
| 2489 |
// [K8s HPA MetricTarget]. |
| 2490 |
// If the type of the metric is [`ContainerResource`], |
| 2491 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2492 |
// container within the pod to which the metric applies. |
| 2493 |
// |
| 2494 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2495 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2496 |
func (m HPAMetricTargetCPUAverageUtilization) Record( |
| 2497 |
ctx context.Context, |
| 2498 |
val int64, |
| 2499 |
attrs ...attribute.KeyValue, |
| 2500 |
) { |
| 2501 |
if len(attrs) == 0 { |
| 2502 |
m.Int64Gauge.Record(ctx, val) |
| 2503 |
return |
| 2504 |
} |
| 2505 |
|
| 2506 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2507 |
defer func() { |
| 2508 |
*o = (*o)[:0] |
| 2509 |
recOptPool.Put(o) |
| 2510 |
}() |
| 2511 |
|
| 2512 |
*o = append( |
| 2513 |
*o, |
| 2514 |
metric.WithAttributes( |
| 2515 |
attrs..., |
| 2516 |
), |
| 2517 |
) |
| 2518 |
|
| 2519 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2520 |
} |
| 2521 |
|
| 2522 |
// RecordSet records val to the current distribution for set. |
| 2523 |
// |
| 2524 |
// This metric aligns with the `averageUtilization` field of the |
| 2525 |
// [K8s HPA MetricTarget]. |
| 2526 |
// If the type of the metric is [`ContainerResource`], |
| 2527 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2528 |
// container within the pod to which the metric applies. |
| 2529 |
// |
| 2530 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2531 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2532 |
func (m HPAMetricTargetCPUAverageUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2533 |
if set.Len() == 0 { |
| 2534 |
m.Int64Gauge.Record(ctx, val) |
| 2535 |
return |
| 2536 |
} |
| 2537 |
|
| 2538 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2539 |
defer func() { |
| 2540 |
*o = (*o)[:0] |
| 2541 |
recOptPool.Put(o) |
| 2542 |
}() |
| 2543 |
|
| 2544 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2545 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2546 |
} |
| 2547 |
|
| 2548 |
// AttrContainerName returns an optional attribute for the "k8s.container.name" |
| 2549 |
// semantic convention. It represents the name of the Container from Pod |
| 2550 |
// specification, must be unique within a Pod. Container runtime usually uses |
| 2551 |
// different globally unique name (`container.name`). |
| 2552 |
func (HPAMetricTargetCPUAverageUtilization) AttrContainerName(val string) attribute.KeyValue { |
| 2553 |
return attribute.String("k8s.container.name", val) |
| 2554 |
} |
| 2555 |
|
| 2556 |
// AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type" |
| 2557 |
// semantic convention. It represents the type of metric source for the |
| 2558 |
// horizontal pod autoscaler. |
| 2559 |
func (HPAMetricTargetCPUAverageUtilization) AttrHPAMetricType(val string) attribute.KeyValue { |
| 2560 |
return attribute.String("k8s.hpa.metric.type", val) |
| 2561 |
} |
| 2562 |
|
| 2563 |
// HPAMetricTargetCPUAverageValue is an instrument used to record metric values |
| 2564 |
// conforming to the "k8s.hpa.metric.target.cpu.average_value" semantic |
| 2565 |
// conventions. It represents the target average value for CPU resource in HPA |
| 2566 |
// config. |
| 2567 |
type HPAMetricTargetCPUAverageValue struct { |
| 2568 |
metric.Int64Gauge |
| 2569 |
} |
| 2570 |
|
| 2571 |
var newHPAMetricTargetCPUAverageValueOpts = []metric.Int64GaugeOption{ |
| 2572 |
metric.WithDescription("Target average value for CPU resource in HPA config."), |
| 2573 |
metric.WithUnit("{cpu}"), |
| 2574 |
} |
| 2575 |
|
| 2576 |
// NewHPAMetricTargetCPUAverageValue returns a new HPAMetricTargetCPUAverageValue |
| 2577 |
// instrument. |
| 2578 |
func NewHPAMetricTargetCPUAverageValue( |
| 2579 |
m metric.Meter, |
| 2580 |
opt ...metric.Int64GaugeOption, |
| 2581 |
) (HPAMetricTargetCPUAverageValue, error) { |
| 2582 |
// Check if the meter is nil. |
| 2583 |
if m == nil { |
| 2584 |
return HPAMetricTargetCPUAverageValue{noop.Int64Gauge{}}, nil |
| 2585 |
} |
| 2586 |
|
| 2587 |
if len(opt) == 0 { |
| 2588 |
opt = newHPAMetricTargetCPUAverageValueOpts |
| 2589 |
} else { |
| 2590 |
opt = append(opt, newHPAMetricTargetCPUAverageValueOpts...) |
| 2591 |
} |
| 2592 |
|
| 2593 |
i, err := m.Int64Gauge( |
| 2594 |
"k8s.hpa.metric.target.cpu.average_value", |
| 2595 |
opt..., |
| 2596 |
) |
| 2597 |
if err != nil { |
| 2598 |
return HPAMetricTargetCPUAverageValue{noop.Int64Gauge{}}, err |
| 2599 |
} |
| 2600 |
return HPAMetricTargetCPUAverageValue{i}, nil |
| 2601 |
} |
| 2602 |
|
| 2603 |
// Inst returns the underlying metric instrument. |
| 2604 |
func (m HPAMetricTargetCPUAverageValue) Inst() metric.Int64Gauge { |
| 2605 |
return m.Int64Gauge |
| 2606 |
} |
| 2607 |
|
| 2608 |
// Name returns the semantic convention name of the instrument. |
| 2609 |
func (HPAMetricTargetCPUAverageValue) Name() string { |
| 2610 |
return "k8s.hpa.metric.target.cpu.average_value" |
| 2611 |
} |
| 2612 |
|
| 2613 |
// Unit returns the semantic convention unit of the instrument |
| 2614 |
func (HPAMetricTargetCPUAverageValue) Unit() string { |
| 2615 |
return "{cpu}" |
| 2616 |
} |
| 2617 |
|
| 2618 |
// Description returns the semantic convention description of the instrument |
| 2619 |
func (HPAMetricTargetCPUAverageValue) Description() string { |
| 2620 |
return "Target average value for CPU resource in HPA config." |
| 2621 |
} |
| 2622 |
|
| 2623 |
// Record records val to the current distribution for attrs. |
| 2624 |
// |
| 2625 |
// All additional attrs passed are included in the recorded value. |
| 2626 |
// |
| 2627 |
// This metric aligns with the `averageValue` field of the |
| 2628 |
// [K8s HPA MetricTarget]. |
| 2629 |
// If the type of the metric is [`ContainerResource`], |
| 2630 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2631 |
// container within the pod to which the metric applies. |
| 2632 |
// |
| 2633 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2634 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2635 |
func (m HPAMetricTargetCPUAverageValue) Record( |
| 2636 |
ctx context.Context, |
| 2637 |
val int64, |
| 2638 |
attrs ...attribute.KeyValue, |
| 2639 |
) { |
| 2640 |
if len(attrs) == 0 { |
| 2641 |
m.Int64Gauge.Record(ctx, val) |
| 2642 |
return |
| 2643 |
} |
| 2644 |
|
| 2645 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2646 |
defer func() { |
| 2647 |
*o = (*o)[:0] |
| 2648 |
recOptPool.Put(o) |
| 2649 |
}() |
| 2650 |
|
| 2651 |
*o = append( |
| 2652 |
*o, |
| 2653 |
metric.WithAttributes( |
| 2654 |
attrs..., |
| 2655 |
), |
| 2656 |
) |
| 2657 |
|
| 2658 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2659 |
} |
| 2660 |
|
| 2661 |
// RecordSet records val to the current distribution for set. |
| 2662 |
// |
| 2663 |
// This metric aligns with the `averageValue` field of the |
| 2664 |
// [K8s HPA MetricTarget]. |
| 2665 |
// If the type of the metric is [`ContainerResource`], |
| 2666 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2667 |
// container within the pod to which the metric applies. |
| 2668 |
// |
| 2669 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2670 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2671 |
func (m HPAMetricTargetCPUAverageValue) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2672 |
if set.Len() == 0 { |
| 2673 |
m.Int64Gauge.Record(ctx, val) |
| 2674 |
return |
| 2675 |
} |
| 2676 |
|
| 2677 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2678 |
defer func() { |
| 2679 |
*o = (*o)[:0] |
| 2680 |
recOptPool.Put(o) |
| 2681 |
}() |
| 2682 |
|
| 2683 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2684 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2685 |
} |
| 2686 |
|
| 2687 |
// AttrContainerName returns an optional attribute for the "k8s.container.name" |
| 2688 |
// semantic convention. It represents the name of the Container from Pod |
| 2689 |
// specification, must be unique within a Pod. Container runtime usually uses |
| 2690 |
// different globally unique name (`container.name`). |
| 2691 |
func (HPAMetricTargetCPUAverageValue) AttrContainerName(val string) attribute.KeyValue { |
| 2692 |
return attribute.String("k8s.container.name", val) |
| 2693 |
} |
| 2694 |
|
| 2695 |
// AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type" |
| 2696 |
// semantic convention. It represents the type of metric source for the |
| 2697 |
// horizontal pod autoscaler. |
| 2698 |
func (HPAMetricTargetCPUAverageValue) AttrHPAMetricType(val string) attribute.KeyValue { |
| 2699 |
return attribute.String("k8s.hpa.metric.type", val) |
| 2700 |
} |
| 2701 |
|
| 2702 |
// HPAMetricTargetCPUValue is an instrument used to record metric values |
| 2703 |
// conforming to the "k8s.hpa.metric.target.cpu.value" semantic conventions. It |
| 2704 |
// represents the target value for CPU resource in HPA config. |
| 2705 |
type HPAMetricTargetCPUValue struct { |
| 2706 |
metric.Int64Gauge |
| 2707 |
} |
| 2708 |
|
| 2709 |
var newHPAMetricTargetCPUValueOpts = []metric.Int64GaugeOption{ |
| 2710 |
metric.WithDescription("Target value for CPU resource in HPA config."), |
| 2711 |
metric.WithUnit("{cpu}"), |
| 2712 |
} |
| 2713 |
|
| 2714 |
// NewHPAMetricTargetCPUValue returns a new HPAMetricTargetCPUValue instrument. |
| 2715 |
func NewHPAMetricTargetCPUValue( |
| 2716 |
m metric.Meter, |
| 2717 |
opt ...metric.Int64GaugeOption, |
| 2718 |
) (HPAMetricTargetCPUValue, error) { |
| 2719 |
// Check if the meter is nil. |
| 2720 |
if m == nil { |
| 2721 |
return HPAMetricTargetCPUValue{noop.Int64Gauge{}}, nil |
| 2722 |
} |
| 2723 |
|
| 2724 |
if len(opt) == 0 { |
| 2725 |
opt = newHPAMetricTargetCPUValueOpts |
| 2726 |
} else { |
| 2727 |
opt = append(opt, newHPAMetricTargetCPUValueOpts...) |
| 2728 |
} |
| 2729 |
|
| 2730 |
i, err := m.Int64Gauge( |
| 2731 |
"k8s.hpa.metric.target.cpu.value", |
| 2732 |
opt..., |
| 2733 |
) |
| 2734 |
if err != nil { |
| 2735 |
return HPAMetricTargetCPUValue{noop.Int64Gauge{}}, err |
| 2736 |
} |
| 2737 |
return HPAMetricTargetCPUValue{i}, nil |
| 2738 |
} |
| 2739 |
|
| 2740 |
// Inst returns the underlying metric instrument. |
| 2741 |
func (m HPAMetricTargetCPUValue) Inst() metric.Int64Gauge { |
| 2742 |
return m.Int64Gauge |
| 2743 |
} |
| 2744 |
|
| 2745 |
// Name returns the semantic convention name of the instrument. |
| 2746 |
func (HPAMetricTargetCPUValue) Name() string { |
| 2747 |
return "k8s.hpa.metric.target.cpu.value" |
| 2748 |
} |
| 2749 |
|
| 2750 |
// Unit returns the semantic convention unit of the instrument |
| 2751 |
func (HPAMetricTargetCPUValue) Unit() string { |
| 2752 |
return "{cpu}" |
| 2753 |
} |
| 2754 |
|
| 2755 |
// Description returns the semantic convention description of the instrument |
| 2756 |
func (HPAMetricTargetCPUValue) Description() string { |
| 2757 |
return "Target value for CPU resource in HPA config." |
| 2758 |
} |
| 2759 |
|
| 2760 |
// Record records val to the current distribution for attrs. |
| 2761 |
// |
| 2762 |
// All additional attrs passed are included in the recorded value. |
| 2763 |
// |
| 2764 |
// This metric aligns with the `value` field of the |
| 2765 |
// [K8s HPA MetricTarget]. |
| 2766 |
// If the type of the metric is [`ContainerResource`], |
| 2767 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2768 |
// container within the pod to which the metric applies. |
| 2769 |
// |
| 2770 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2771 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2772 |
func (m HPAMetricTargetCPUValue) Record( |
| 2773 |
ctx context.Context, |
| 2774 |
val int64, |
| 2775 |
attrs ...attribute.KeyValue, |
| 2776 |
) { |
| 2777 |
if len(attrs) == 0 { |
| 2778 |
m.Int64Gauge.Record(ctx, val) |
| 2779 |
return |
| 2780 |
} |
| 2781 |
|
| 2782 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2783 |
defer func() { |
| 2784 |
*o = (*o)[:0] |
| 2785 |
recOptPool.Put(o) |
| 2786 |
}() |
| 2787 |
|
| 2788 |
*o = append( |
| 2789 |
*o, |
| 2790 |
metric.WithAttributes( |
| 2791 |
attrs..., |
| 2792 |
), |
| 2793 |
) |
| 2794 |
|
| 2795 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2796 |
} |
| 2797 |
|
| 2798 |
// RecordSet records val to the current distribution for set. |
| 2799 |
// |
| 2800 |
// This metric aligns with the `value` field of the |
| 2801 |
// [K8s HPA MetricTarget]. |
| 2802 |
// If the type of the metric is [`ContainerResource`], |
| 2803 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2804 |
// container within the pod to which the metric applies. |
| 2805 |
// |
| 2806 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2807 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2808 |
func (m HPAMetricTargetCPUValue) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2809 |
if set.Len() == 0 { |
| 2810 |
m.Int64Gauge.Record(ctx, val) |
| 2811 |
return |
| 2812 |
} |
| 2813 |
|
| 2814 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2815 |
defer func() { |
| 2816 |
*o = (*o)[:0] |
| 2817 |
recOptPool.Put(o) |
| 2818 |
}() |
| 2819 |
|
| 2820 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2821 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2822 |
} |
| 2823 |
|
| 2824 |
// AttrContainerName returns an optional attribute for the "k8s.container.name" |
| 2825 |
// semantic convention. It represents the name of the Container from Pod |
| 2826 |
// specification, must be unique within a Pod. Container runtime usually uses |
| 2827 |
// different globally unique name (`container.name`). |
| 2828 |
func (HPAMetricTargetCPUValue) AttrContainerName(val string) attribute.KeyValue { |
| 2829 |
return attribute.String("k8s.container.name", val) |
| 2830 |
} |
| 2831 |
|
| 2832 |
// AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type" |
| 2833 |
// semantic convention. It represents the type of metric source for the |
| 2834 |
// horizontal pod autoscaler. |
| 2835 |
func (HPAMetricTargetCPUValue) AttrHPAMetricType(val string) attribute.KeyValue { |
| 2836 |
return attribute.String("k8s.hpa.metric.type", val) |
| 2837 |
} |
| 2838 |
|
| 2839 |
// HPAPodCurrent is an instrument used to record metric values conforming to the |
| 2840 |
// "k8s.hpa.pod.current" semantic conventions. It represents the current number |
| 2841 |
// of replica pods managed by this horizontal pod autoscaler, as last seen by the |
| 2842 |
// autoscaler. |
| 2843 |
type HPAPodCurrent struct { |
| 2844 |
metric.Int64UpDownCounter |
| 2845 |
} |
| 2846 |
|
| 2847 |
var newHPAPodCurrentOpts = []metric.Int64UpDownCounterOption{ |
| 2848 |
metric.WithDescription("Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler."), |
| 2849 |
metric.WithUnit("{pod}"), |
| 2850 |
} |
| 2851 |
|
| 2852 |
// NewHPAPodCurrent returns a new HPAPodCurrent instrument. |
| 2853 |
func NewHPAPodCurrent( |
| 2854 |
m metric.Meter, |
| 2855 |
opt ...metric.Int64UpDownCounterOption, |
| 2856 |
) (HPAPodCurrent, error) { |
| 2857 |
// Check if the meter is nil. |
| 2858 |
if m == nil { |
| 2859 |
return HPAPodCurrent{noop.Int64UpDownCounter{}}, nil |
| 2860 |
} |
| 2861 |
|
| 2862 |
if len(opt) == 0 { |
| 2863 |
opt = newHPAPodCurrentOpts |
| 2864 |
} else { |
| 2865 |
opt = append(opt, newHPAPodCurrentOpts...) |
| 2866 |
} |
| 2867 |
|
| 2868 |
i, err := m.Int64UpDownCounter( |
| 2869 |
"k8s.hpa.pod.current", |
| 2870 |
opt..., |
| 2871 |
) |
| 2872 |
if err != nil { |
| 2873 |
return HPAPodCurrent{noop.Int64UpDownCounter{}}, err |
| 2874 |
} |
| 2875 |
return HPAPodCurrent{i}, nil |
| 2876 |
} |
| 2877 |
|
| 2878 |
// Inst returns the underlying metric instrument. |
| 2879 |
func (m HPAPodCurrent) Inst() metric.Int64UpDownCounter { |
| 2880 |
return m.Int64UpDownCounter |
| 2881 |
} |
| 2882 |
|
| 2883 |
// Name returns the semantic convention name of the instrument. |
| 2884 |
func (HPAPodCurrent) Name() string { |
| 2885 |
return "k8s.hpa.pod.current" |
| 2886 |
} |
| 2887 |
|
| 2888 |
// Unit returns the semantic convention unit of the instrument |
| 2889 |
func (HPAPodCurrent) Unit() string { |
| 2890 |
return "{pod}" |
| 2891 |
} |
| 2892 |
|
| 2893 |
// Description returns the semantic convention description of the instrument |
| 2894 |
func (HPAPodCurrent) Description() string { |
| 2895 |
return "Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler." |
| 2896 |
} |
| 2897 |
|
| 2898 |
// Add adds incr to the existing count for attrs. |
| 2899 |
// |
| 2900 |
// This metric aligns with the `currentReplicas` field of the |
| 2901 |
// [K8s HorizontalPodAutoscalerStatus] |
| 2902 |
// |
| 2903 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 2904 |
func (m HPAPodCurrent) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2905 |
if len(attrs) == 0 { |
| 2906 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2907 |
return |
| 2908 |
} |
| 2909 |
|
| 2910 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2911 |
defer func() { |
| 2912 |
*o = (*o)[:0] |
| 2913 |
addOptPool.Put(o) |
| 2914 |
}() |
| 2915 |
|
| 2916 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2917 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2918 |
} |
| 2919 |
|
| 2920 |
// AddSet adds incr to the existing count for set. |
| 2921 |
// |
| 2922 |
// This metric aligns with the `currentReplicas` field of the |
| 2923 |
// [K8s HorizontalPodAutoscalerStatus] |
| 2924 |
// |
| 2925 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 2926 |
func (m HPAPodCurrent) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2927 |
if set.Len() == 0 { |
| 2928 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2929 |
return |
| 2930 |
} |
| 2931 |
|
| 2932 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2933 |
defer func() { |
| 2934 |
*o = (*o)[:0] |
| 2935 |
addOptPool.Put(o) |
| 2936 |
}() |
| 2937 |
|
| 2938 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2939 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2940 |
} |
| 2941 |
|
| 2942 |
// HPAPodDesired is an instrument used to record metric values conforming to the |
| 2943 |
// "k8s.hpa.pod.desired" semantic conventions. It represents the desired number |
| 2944 |
// of replica pods managed by this horizontal pod autoscaler, as last calculated |
| 2945 |
// by the autoscaler. |
| 2946 |
type HPAPodDesired struct { |
| 2947 |
metric.Int64UpDownCounter |
| 2948 |
} |
| 2949 |
|
| 2950 |
var newHPAPodDesiredOpts = []metric.Int64UpDownCounterOption{ |
| 2951 |
metric.WithDescription("Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler."), |
| 2952 |
metric.WithUnit("{pod}"), |
| 2953 |
} |
| 2954 |
|
| 2955 |
// NewHPAPodDesired returns a new HPAPodDesired instrument. |
| 2956 |
func NewHPAPodDesired( |
| 2957 |
m metric.Meter, |
| 2958 |
opt ...metric.Int64UpDownCounterOption, |
| 2959 |
) (HPAPodDesired, error) { |
| 2960 |
// Check if the meter is nil. |
| 2961 |
if m == nil { |
| 2962 |
return HPAPodDesired{noop.Int64UpDownCounter{}}, nil |
| 2963 |
} |
| 2964 |
|
| 2965 |
if len(opt) == 0 { |
| 2966 |
opt = newHPAPodDesiredOpts |
| 2967 |
} else { |
| 2968 |
opt = append(opt, newHPAPodDesiredOpts...) |
| 2969 |
} |
| 2970 |
|
| 2971 |
i, err := m.Int64UpDownCounter( |
| 2972 |
"k8s.hpa.pod.desired", |
| 2973 |
opt..., |
| 2974 |
) |
| 2975 |
if err != nil { |
| 2976 |
return HPAPodDesired{noop.Int64UpDownCounter{}}, err |
| 2977 |
} |
| 2978 |
return HPAPodDesired{i}, nil |
| 2979 |
} |
| 2980 |
|
| 2981 |
// Inst returns the underlying metric instrument. |
| 2982 |
func (m HPAPodDesired) Inst() metric.Int64UpDownCounter { |
| 2983 |
return m.Int64UpDownCounter |
| 2984 |
} |
| 2985 |
|
| 2986 |
// Name returns the semantic convention name of the instrument. |
| 2987 |
func (HPAPodDesired) Name() string { |
| 2988 |
return "k8s.hpa.pod.desired" |
| 2989 |
} |
| 2990 |
|
| 2991 |
// Unit returns the semantic convention unit of the instrument |
| 2992 |
func (HPAPodDesired) Unit() string { |
| 2993 |
return "{pod}" |
| 2994 |
} |
| 2995 |
|
| 2996 |
// Description returns the semantic convention description of the instrument |
| 2997 |
func (HPAPodDesired) Description() string { |
| 2998 |
return "Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler." |
| 2999 |
} |
| 3000 |
|
| 3001 |
// Add adds incr to the existing count for attrs. |
| 3002 |
// |
| 3003 |
// This metric aligns with the `desiredReplicas` field of the |
| 3004 |
// [K8s HorizontalPodAutoscalerStatus] |
| 3005 |
// |
| 3006 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 3007 |
func (m HPAPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3008 |
if len(attrs) == 0 { |
| 3009 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3010 |
return |
| 3011 |
} |
| 3012 |
|
| 3013 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3014 |
defer func() { |
| 3015 |
*o = (*o)[:0] |
| 3016 |
addOptPool.Put(o) |
| 3017 |
}() |
| 3018 |
|
| 3019 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3020 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3021 |
} |
| 3022 |
|
| 3023 |
// AddSet adds incr to the existing count for set. |
| 3024 |
// |
| 3025 |
// This metric aligns with the `desiredReplicas` field of the |
| 3026 |
// [K8s HorizontalPodAutoscalerStatus] |
| 3027 |
// |
| 3028 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 3029 |
func (m HPAPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3030 |
if set.Len() == 0 { |
| 3031 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3032 |
return |
| 3033 |
} |
| 3034 |
|
| 3035 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3036 |
defer func() { |
| 3037 |
*o = (*o)[:0] |
| 3038 |
addOptPool.Put(o) |
| 3039 |
}() |
| 3040 |
|
| 3041 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3042 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3043 |
} |
| 3044 |
|
| 3045 |
// HPAPodMax is an instrument used to record metric values conforming to the |
| 3046 |
// "k8s.hpa.pod.max" semantic conventions. It represents the upper limit for the |
| 3047 |
// number of replica pods to which the autoscaler can scale up. |
| 3048 |
type HPAPodMax struct { |
| 3049 |
metric.Int64UpDownCounter |
| 3050 |
} |
| 3051 |
|
| 3052 |
var newHPAPodMaxOpts = []metric.Int64UpDownCounterOption{ |
| 3053 |
metric.WithDescription("The upper limit for the number of replica pods to which the autoscaler can scale up."), |
| 3054 |
metric.WithUnit("{pod}"), |
| 3055 |
} |
| 3056 |
|
| 3057 |
// NewHPAPodMax returns a new HPAPodMax instrument. |
| 3058 |
func NewHPAPodMax( |
| 3059 |
m metric.Meter, |
| 3060 |
opt ...metric.Int64UpDownCounterOption, |
| 3061 |
) (HPAPodMax, error) { |
| 3062 |
// Check if the meter is nil. |
| 3063 |
if m == nil { |
| 3064 |
return HPAPodMax{noop.Int64UpDownCounter{}}, nil |
| 3065 |
} |
| 3066 |
|
| 3067 |
if len(opt) == 0 { |
| 3068 |
opt = newHPAPodMaxOpts |
| 3069 |
} else { |
| 3070 |
opt = append(opt, newHPAPodMaxOpts...) |
| 3071 |
} |
| 3072 |
|
| 3073 |
i, err := m.Int64UpDownCounter( |
| 3074 |
"k8s.hpa.pod.max", |
| 3075 |
opt..., |
| 3076 |
) |
| 3077 |
if err != nil { |
| 3078 |
return HPAPodMax{noop.Int64UpDownCounter{}}, err |
| 3079 |
} |
| 3080 |
return HPAPodMax{i}, nil |
| 3081 |
} |
| 3082 |
|
| 3083 |
// Inst returns the underlying metric instrument. |
| 3084 |
func (m HPAPodMax) Inst() metric.Int64UpDownCounter { |
| 3085 |
return m.Int64UpDownCounter |
| 3086 |
} |
| 3087 |
|
| 3088 |
// Name returns the semantic convention name of the instrument. |
| 3089 |
func (HPAPodMax) Name() string { |
| 3090 |
return "k8s.hpa.pod.max" |
| 3091 |
} |
| 3092 |
|
| 3093 |
// Unit returns the semantic convention unit of the instrument |
| 3094 |
func (HPAPodMax) Unit() string { |
| 3095 |
return "{pod}" |
| 3096 |
} |
| 3097 |
|
| 3098 |
// Description returns the semantic convention description of the instrument |
| 3099 |
func (HPAPodMax) Description() string { |
| 3100 |
return "The upper limit for the number of replica pods to which the autoscaler can scale up." |
| 3101 |
} |
| 3102 |
|
| 3103 |
// Add adds incr to the existing count for attrs. |
| 3104 |
// |
| 3105 |
// This metric aligns with the `maxReplicas` field of the |
| 3106 |
// [K8s HorizontalPodAutoscalerSpec] |
| 3107 |
// |
| 3108 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 3109 |
func (m HPAPodMax) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3110 |
if len(attrs) == 0 { |
| 3111 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3112 |
return |
| 3113 |
} |
| 3114 |
|
| 3115 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3116 |
defer func() { |
| 3117 |
*o = (*o)[:0] |
| 3118 |
addOptPool.Put(o) |
| 3119 |
}() |
| 3120 |
|
| 3121 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3122 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3123 |
} |
| 3124 |
|
| 3125 |
// AddSet adds incr to the existing count for set. |
| 3126 |
// |
| 3127 |
// This metric aligns with the `maxReplicas` field of the |
| 3128 |
// [K8s HorizontalPodAutoscalerSpec] |
| 3129 |
// |
| 3130 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 3131 |
func (m HPAPodMax) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3132 |
if set.Len() == 0 { |
| 3133 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3134 |
return |
| 3135 |
} |
| 3136 |
|
| 3137 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3138 |
defer func() { |
| 3139 |
*o = (*o)[:0] |
| 3140 |
addOptPool.Put(o) |
| 3141 |
}() |
| 3142 |
|
| 3143 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3144 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3145 |
} |
| 3146 |
|
| 3147 |
// HPAPodMin is an instrument used to record metric values conforming to the |
| 3148 |
// "k8s.hpa.pod.min" semantic conventions. It represents the lower limit for the |
| 3149 |
// number of replica pods to which the autoscaler can scale down. |
| 3150 |
type HPAPodMin struct { |
| 3151 |
metric.Int64UpDownCounter |
| 3152 |
} |
| 3153 |
|
| 3154 |
var newHPAPodMinOpts = []metric.Int64UpDownCounterOption{ |
| 3155 |
metric.WithDescription("The lower limit for the number of replica pods to which the autoscaler can scale down."), |
| 3156 |
metric.WithUnit("{pod}"), |
| 3157 |
} |
| 3158 |
|
| 3159 |
// NewHPAPodMin returns a new HPAPodMin instrument. |
| 3160 |
func NewHPAPodMin( |
| 3161 |
m metric.Meter, |
| 3162 |
opt ...metric.Int64UpDownCounterOption, |
| 3163 |
) (HPAPodMin, error) { |
| 3164 |
// Check if the meter is nil. |
| 3165 |
if m == nil { |
| 3166 |
return HPAPodMin{noop.Int64UpDownCounter{}}, nil |
| 3167 |
} |
| 3168 |
|
| 3169 |
if len(opt) == 0 { |
| 3170 |
opt = newHPAPodMinOpts |
| 3171 |
} else { |
| 3172 |
opt = append(opt, newHPAPodMinOpts...) |
| 3173 |
} |
| 3174 |
|
| 3175 |
i, err := m.Int64UpDownCounter( |
| 3176 |
"k8s.hpa.pod.min", |
| 3177 |
opt..., |
| 3178 |
) |
| 3179 |
if err != nil { |
| 3180 |
return HPAPodMin{noop.Int64UpDownCounter{}}, err |
| 3181 |
} |
| 3182 |
return HPAPodMin{i}, nil |
| 3183 |
} |
| 3184 |
|
| 3185 |
// Inst returns the underlying metric instrument. |
| 3186 |
func (m HPAPodMin) Inst() metric.Int64UpDownCounter { |
| 3187 |
return m.Int64UpDownCounter |
| 3188 |
} |
| 3189 |
|
| 3190 |
// Name returns the semantic convention name of the instrument. |
| 3191 |
func (HPAPodMin) Name() string { |
| 3192 |
return "k8s.hpa.pod.min" |
| 3193 |
} |
| 3194 |
|
| 3195 |
// Unit returns the semantic convention unit of the instrument |
| 3196 |
func (HPAPodMin) Unit() string { |
| 3197 |
return "{pod}" |
| 3198 |
} |
| 3199 |
|
| 3200 |
// Description returns the semantic convention description of the instrument |
| 3201 |
func (HPAPodMin) Description() string { |
| 3202 |
return "The lower limit for the number of replica pods to which the autoscaler can scale down." |
| 3203 |
} |
| 3204 |
|
| 3205 |
// Add adds incr to the existing count for attrs. |
| 3206 |
// |
| 3207 |
// This metric aligns with the `minReplicas` field of the |
| 3208 |
// [K8s HorizontalPodAutoscalerSpec] |
| 3209 |
// |
| 3210 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 3211 |
func (m HPAPodMin) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3212 |
if len(attrs) == 0 { |
| 3213 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3214 |
return |
| 3215 |
} |
| 3216 |
|
| 3217 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3218 |
defer func() { |
| 3219 |
*o = (*o)[:0] |
| 3220 |
addOptPool.Put(o) |
| 3221 |
}() |
| 3222 |
|
| 3223 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3224 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3225 |
} |
| 3226 |
|
| 3227 |
// AddSet adds incr to the existing count for set. |
| 3228 |
// |
| 3229 |
// This metric aligns with the `minReplicas` field of the |
| 3230 |
// [K8s HorizontalPodAutoscalerSpec] |
| 3231 |
// |
| 3232 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 3233 |
func (m HPAPodMin) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3234 |
if set.Len() == 0 { |
| 3235 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3236 |
return |
| 3237 |
} |
| 3238 |
|
| 3239 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3240 |
defer func() { |
| 3241 |
*o = (*o)[:0] |
| 3242 |
addOptPool.Put(o) |
| 3243 |
}() |
| 3244 |
|
| 3245 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3246 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3247 |
} |
| 3248 |
|
| 3249 |
// JobPodActive is an instrument used to record metric values conforming to the |
| 3250 |
// "k8s.job.pod.active" semantic conventions. It represents the number of pending |
| 3251 |
// and actively running pods for a job. |
| 3252 |
type JobPodActive struct { |
| 3253 |
metric.Int64UpDownCounter |
| 3254 |
} |
| 3255 |
|
| 3256 |
var newJobPodActiveOpts = []metric.Int64UpDownCounterOption{ |
| 3257 |
metric.WithDescription("The number of pending and actively running pods for a job."), |
| 3258 |
metric.WithUnit("{pod}"), |
| 3259 |
} |
| 3260 |
|
| 3261 |
// NewJobPodActive returns a new JobPodActive instrument. |
| 3262 |
func NewJobPodActive( |
| 3263 |
m metric.Meter, |
| 3264 |
opt ...metric.Int64UpDownCounterOption, |
| 3265 |
) (JobPodActive, error) { |
| 3266 |
// Check if the meter is nil. |
| 3267 |
if m == nil { |
| 3268 |
return JobPodActive{noop.Int64UpDownCounter{}}, nil |
| 3269 |
} |
| 3270 |
|
| 3271 |
if len(opt) == 0 { |
| 3272 |
opt = newJobPodActiveOpts |
| 3273 |
} else { |
| 3274 |
opt = append(opt, newJobPodActiveOpts...) |
| 3275 |
} |
| 3276 |
|
| 3277 |
i, err := m.Int64UpDownCounter( |
| 3278 |
"k8s.job.pod.active", |
| 3279 |
opt..., |
| 3280 |
) |
| 3281 |
if err != nil { |
| 3282 |
return JobPodActive{noop.Int64UpDownCounter{}}, err |
| 3283 |
} |
| 3284 |
return JobPodActive{i}, nil |
| 3285 |
} |
| 3286 |
|
| 3287 |
// Inst returns the underlying metric instrument. |
| 3288 |
func (m JobPodActive) Inst() metric.Int64UpDownCounter { |
| 3289 |
return m.Int64UpDownCounter |
| 3290 |
} |
| 3291 |
|
| 3292 |
// Name returns the semantic convention name of the instrument. |
| 3293 |
func (JobPodActive) Name() string { |
| 3294 |
return "k8s.job.pod.active" |
| 3295 |
} |
| 3296 |
|
| 3297 |
// Unit returns the semantic convention unit of the instrument |
| 3298 |
func (JobPodActive) Unit() string { |
| 3299 |
return "{pod}" |
| 3300 |
} |
| 3301 |
|
| 3302 |
// Description returns the semantic convention description of the instrument |
| 3303 |
func (JobPodActive) Description() string { |
| 3304 |
return "The number of pending and actively running pods for a job." |
| 3305 |
} |
| 3306 |
|
| 3307 |
// Add adds incr to the existing count for attrs. |
| 3308 |
// |
| 3309 |
// This metric aligns with the `active` field of the |
| 3310 |
// [K8s JobStatus]. |
| 3311 |
// |
| 3312 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3313 |
func (m JobPodActive) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3314 |
if len(attrs) == 0 { |
| 3315 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3316 |
return |
| 3317 |
} |
| 3318 |
|
| 3319 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3320 |
defer func() { |
| 3321 |
*o = (*o)[:0] |
| 3322 |
addOptPool.Put(o) |
| 3323 |
}() |
| 3324 |
|
| 3325 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3326 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3327 |
} |
| 3328 |
|
| 3329 |
// AddSet adds incr to the existing count for set. |
| 3330 |
// |
| 3331 |
// This metric aligns with the `active` field of the |
| 3332 |
// [K8s JobStatus]. |
| 3333 |
// |
| 3334 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3335 |
func (m JobPodActive) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3336 |
if set.Len() == 0 { |
| 3337 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3338 |
return |
| 3339 |
} |
| 3340 |
|
| 3341 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3342 |
defer func() { |
| 3343 |
*o = (*o)[:0] |
| 3344 |
addOptPool.Put(o) |
| 3345 |
}() |
| 3346 |
|
| 3347 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3348 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3349 |
} |
| 3350 |
|
| 3351 |
// JobPodDesiredSuccessful is an instrument used to record metric values |
| 3352 |
// conforming to the "k8s.job.pod.desired_successful" semantic conventions. It |
| 3353 |
// represents the desired number of successfully finished pods the job should be |
| 3354 |
// run with. |
| 3355 |
type JobPodDesiredSuccessful struct { |
| 3356 |
metric.Int64UpDownCounter |
| 3357 |
} |
| 3358 |
|
| 3359 |
var newJobPodDesiredSuccessfulOpts = []metric.Int64UpDownCounterOption{ |
| 3360 |
metric.WithDescription("The desired number of successfully finished pods the job should be run with."), |
| 3361 |
metric.WithUnit("{pod}"), |
| 3362 |
} |
| 3363 |
|
| 3364 |
// NewJobPodDesiredSuccessful returns a new JobPodDesiredSuccessful instrument. |
| 3365 |
func NewJobPodDesiredSuccessful( |
| 3366 |
m metric.Meter, |
| 3367 |
opt ...metric.Int64UpDownCounterOption, |
| 3368 |
) (JobPodDesiredSuccessful, error) { |
| 3369 |
// Check if the meter is nil. |
| 3370 |
if m == nil { |
| 3371 |
return JobPodDesiredSuccessful{noop.Int64UpDownCounter{}}, nil |
| 3372 |
} |
| 3373 |
|
| 3374 |
if len(opt) == 0 { |
| 3375 |
opt = newJobPodDesiredSuccessfulOpts |
| 3376 |
} else { |
| 3377 |
opt = append(opt, newJobPodDesiredSuccessfulOpts...) |
| 3378 |
} |
| 3379 |
|
| 3380 |
i, err := m.Int64UpDownCounter( |
| 3381 |
"k8s.job.pod.desired_successful", |
| 3382 |
opt..., |
| 3383 |
) |
| 3384 |
if err != nil { |
| 3385 |
return JobPodDesiredSuccessful{noop.Int64UpDownCounter{}}, err |
| 3386 |
} |
| 3387 |
return JobPodDesiredSuccessful{i}, nil |
| 3388 |
} |
| 3389 |
|
| 3390 |
// Inst returns the underlying metric instrument. |
| 3391 |
func (m JobPodDesiredSuccessful) Inst() metric.Int64UpDownCounter { |
| 3392 |
return m.Int64UpDownCounter |
| 3393 |
} |
| 3394 |
|
| 3395 |
// Name returns the semantic convention name of the instrument. |
| 3396 |
func (JobPodDesiredSuccessful) Name() string { |
| 3397 |
return "k8s.job.pod.desired_successful" |
| 3398 |
} |
| 3399 |
|
| 3400 |
// Unit returns the semantic convention unit of the instrument |
| 3401 |
func (JobPodDesiredSuccessful) Unit() string { |
| 3402 |
return "{pod}" |
| 3403 |
} |
| 3404 |
|
| 3405 |
// Description returns the semantic convention description of the instrument |
| 3406 |
func (JobPodDesiredSuccessful) Description() string { |
| 3407 |
return "The desired number of successfully finished pods the job should be run with." |
| 3408 |
} |
| 3409 |
|
| 3410 |
// Add adds incr to the existing count for attrs. |
| 3411 |
// |
| 3412 |
// This metric aligns with the `completions` field of the |
| 3413 |
// [K8s JobSpec].. |
| 3414 |
// |
| 3415 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 3416 |
func (m JobPodDesiredSuccessful) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3417 |
if len(attrs) == 0 { |
| 3418 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3419 |
return |
| 3420 |
} |
| 3421 |
|
| 3422 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3423 |
defer func() { |
| 3424 |
*o = (*o)[:0] |
| 3425 |
addOptPool.Put(o) |
| 3426 |
}() |
| 3427 |
|
| 3428 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3429 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3430 |
} |
| 3431 |
|
| 3432 |
// AddSet adds incr to the existing count for set. |
| 3433 |
// |
| 3434 |
// This metric aligns with the `completions` field of the |
| 3435 |
// [K8s JobSpec].. |
| 3436 |
// |
| 3437 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 3438 |
func (m JobPodDesiredSuccessful) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3439 |
if set.Len() == 0 { |
| 3440 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3441 |
return |
| 3442 |
} |
| 3443 |
|
| 3444 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3445 |
defer func() { |
| 3446 |
*o = (*o)[:0] |
| 3447 |
addOptPool.Put(o) |
| 3448 |
}() |
| 3449 |
|
| 3450 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3451 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3452 |
} |
| 3453 |
|
| 3454 |
// JobPodFailed is an instrument used to record metric values conforming to the |
| 3455 |
// "k8s.job.pod.failed" semantic conventions. It represents the number of pods |
| 3456 |
// which reached phase Failed for a job. |
| 3457 |
type JobPodFailed struct { |
| 3458 |
metric.Int64UpDownCounter |
| 3459 |
} |
| 3460 |
|
| 3461 |
var newJobPodFailedOpts = []metric.Int64UpDownCounterOption{ |
| 3462 |
metric.WithDescription("The number of pods which reached phase Failed for a job."), |
| 3463 |
metric.WithUnit("{pod}"), |
| 3464 |
} |
| 3465 |
|
| 3466 |
// NewJobPodFailed returns a new JobPodFailed instrument. |
| 3467 |
func NewJobPodFailed( |
| 3468 |
m metric.Meter, |
| 3469 |
opt ...metric.Int64UpDownCounterOption, |
| 3470 |
) (JobPodFailed, error) { |
| 3471 |
// Check if the meter is nil. |
| 3472 |
if m == nil { |
| 3473 |
return JobPodFailed{noop.Int64UpDownCounter{}}, nil |
| 3474 |
} |
| 3475 |
|
| 3476 |
if len(opt) == 0 { |
| 3477 |
opt = newJobPodFailedOpts |
| 3478 |
} else { |
| 3479 |
opt = append(opt, newJobPodFailedOpts...) |
| 3480 |
} |
| 3481 |
|
| 3482 |
i, err := m.Int64UpDownCounter( |
| 3483 |
"k8s.job.pod.failed", |
| 3484 |
opt..., |
| 3485 |
) |
| 3486 |
if err != nil { |
| 3487 |
return JobPodFailed{noop.Int64UpDownCounter{}}, err |
| 3488 |
} |
| 3489 |
return JobPodFailed{i}, nil |
| 3490 |
} |
| 3491 |
|
| 3492 |
// Inst returns the underlying metric instrument. |
| 3493 |
func (m JobPodFailed) Inst() metric.Int64UpDownCounter { |
| 3494 |
return m.Int64UpDownCounter |
| 3495 |
} |
| 3496 |
|
| 3497 |
// Name returns the semantic convention name of the instrument. |
| 3498 |
func (JobPodFailed) Name() string { |
| 3499 |
return "k8s.job.pod.failed" |
| 3500 |
} |
| 3501 |
|
| 3502 |
// Unit returns the semantic convention unit of the instrument |
| 3503 |
func (JobPodFailed) Unit() string { |
| 3504 |
return "{pod}" |
| 3505 |
} |
| 3506 |
|
| 3507 |
// Description returns the semantic convention description of the instrument |
| 3508 |
func (JobPodFailed) Description() string { |
| 3509 |
return "The number of pods which reached phase Failed for a job." |
| 3510 |
} |
| 3511 |
|
| 3512 |
// Add adds incr to the existing count for attrs. |
| 3513 |
// |
| 3514 |
// This metric aligns with the `failed` field of the |
| 3515 |
// [K8s JobStatus]. |
| 3516 |
// |
| 3517 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3518 |
func (m JobPodFailed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3519 |
if len(attrs) == 0 { |
| 3520 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3521 |
return |
| 3522 |
} |
| 3523 |
|
| 3524 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3525 |
defer func() { |
| 3526 |
*o = (*o)[:0] |
| 3527 |
addOptPool.Put(o) |
| 3528 |
}() |
| 3529 |
|
| 3530 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3531 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3532 |
} |
| 3533 |
|
| 3534 |
// AddSet adds incr to the existing count for set. |
| 3535 |
// |
| 3536 |
// This metric aligns with the `failed` field of the |
| 3537 |
// [K8s JobStatus]. |
| 3538 |
// |
| 3539 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3540 |
func (m JobPodFailed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3541 |
if set.Len() == 0 { |
| 3542 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3543 |
return |
| 3544 |
} |
| 3545 |
|
| 3546 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3547 |
defer func() { |
| 3548 |
*o = (*o)[:0] |
| 3549 |
addOptPool.Put(o) |
| 3550 |
}() |
| 3551 |
|
| 3552 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3553 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3554 |
} |
| 3555 |
|
| 3556 |
// JobPodMaxParallel is an instrument used to record metric values conforming to |
| 3557 |
// the "k8s.job.pod.max_parallel" semantic conventions. It represents the max |
| 3558 |
// desired number of pods the job should run at any given time. |
| 3559 |
type JobPodMaxParallel struct { |
| 3560 |
metric.Int64UpDownCounter |
| 3561 |
} |
| 3562 |
|
| 3563 |
var newJobPodMaxParallelOpts = []metric.Int64UpDownCounterOption{ |
| 3564 |
metric.WithDescription("The max desired number of pods the job should run at any given time."), |
| 3565 |
metric.WithUnit("{pod}"), |
| 3566 |
} |
| 3567 |
|
| 3568 |
// NewJobPodMaxParallel returns a new JobPodMaxParallel instrument. |
| 3569 |
func NewJobPodMaxParallel( |
| 3570 |
m metric.Meter, |
| 3571 |
opt ...metric.Int64UpDownCounterOption, |
| 3572 |
) (JobPodMaxParallel, error) { |
| 3573 |
// Check if the meter is nil. |
| 3574 |
if m == nil { |
| 3575 |
return JobPodMaxParallel{noop.Int64UpDownCounter{}}, nil |
| 3576 |
} |
| 3577 |
|
| 3578 |
if len(opt) == 0 { |
| 3579 |
opt = newJobPodMaxParallelOpts |
| 3580 |
} else { |
| 3581 |
opt = append(opt, newJobPodMaxParallelOpts...) |
| 3582 |
} |
| 3583 |
|
| 3584 |
i, err := m.Int64UpDownCounter( |
| 3585 |
"k8s.job.pod.max_parallel", |
| 3586 |
opt..., |
| 3587 |
) |
| 3588 |
if err != nil { |
| 3589 |
return JobPodMaxParallel{noop.Int64UpDownCounter{}}, err |
| 3590 |
} |
| 3591 |
return JobPodMaxParallel{i}, nil |
| 3592 |
} |
| 3593 |
|
| 3594 |
// Inst returns the underlying metric instrument. |
| 3595 |
func (m JobPodMaxParallel) Inst() metric.Int64UpDownCounter { |
| 3596 |
return m.Int64UpDownCounter |
| 3597 |
} |
| 3598 |
|
| 3599 |
// Name returns the semantic convention name of the instrument. |
| 3600 |
func (JobPodMaxParallel) Name() string { |
| 3601 |
return "k8s.job.pod.max_parallel" |
| 3602 |
} |
| 3603 |
|
| 3604 |
// Unit returns the semantic convention unit of the instrument |
| 3605 |
func (JobPodMaxParallel) Unit() string { |
| 3606 |
return "{pod}" |
| 3607 |
} |
| 3608 |
|
| 3609 |
// Description returns the semantic convention description of the instrument |
| 3610 |
func (JobPodMaxParallel) Description() string { |
| 3611 |
return "The max desired number of pods the job should run at any given time." |
| 3612 |
} |
| 3613 |
|
| 3614 |
// Add adds incr to the existing count for attrs. |
| 3615 |
// |
| 3616 |
// This metric aligns with the `parallelism` field of the |
| 3617 |
// [K8s JobSpec]. |
| 3618 |
// |
| 3619 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 3620 |
func (m JobPodMaxParallel) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3621 |
if len(attrs) == 0 { |
| 3622 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3623 |
return |
| 3624 |
} |
| 3625 |
|
| 3626 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3627 |
defer func() { |
| 3628 |
*o = (*o)[:0] |
| 3629 |
addOptPool.Put(o) |
| 3630 |
}() |
| 3631 |
|
| 3632 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3633 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3634 |
} |
| 3635 |
|
| 3636 |
// AddSet adds incr to the existing count for set. |
| 3637 |
// |
| 3638 |
// This metric aligns with the `parallelism` field of the |
| 3639 |
// [K8s JobSpec]. |
| 3640 |
// |
| 3641 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 3642 |
func (m JobPodMaxParallel) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3643 |
if set.Len() == 0 { |
| 3644 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3645 |
return |
| 3646 |
} |
| 3647 |
|
| 3648 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3649 |
defer func() { |
| 3650 |
*o = (*o)[:0] |
| 3651 |
addOptPool.Put(o) |
| 3652 |
}() |
| 3653 |
|
| 3654 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3655 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3656 |
} |
| 3657 |
|
| 3658 |
// JobPodSuccessful is an instrument used to record metric values conforming to |
| 3659 |
// the "k8s.job.pod.successful" semantic conventions. It represents the number of |
| 3660 |
// pods which reached phase Succeeded for a job. |
| 3661 |
type JobPodSuccessful struct { |
| 3662 |
metric.Int64UpDownCounter |
| 3663 |
} |
| 3664 |
|
| 3665 |
var newJobPodSuccessfulOpts = []metric.Int64UpDownCounterOption{ |
| 3666 |
metric.WithDescription("The number of pods which reached phase Succeeded for a job."), |
| 3667 |
metric.WithUnit("{pod}"), |
| 3668 |
} |
| 3669 |
|
| 3670 |
// NewJobPodSuccessful returns a new JobPodSuccessful instrument. |
| 3671 |
func NewJobPodSuccessful( |
| 3672 |
m metric.Meter, |
| 3673 |
opt ...metric.Int64UpDownCounterOption, |
| 3674 |
) (JobPodSuccessful, error) { |
| 3675 |
// Check if the meter is nil. |
| 3676 |
if m == nil { |
| 3677 |
return JobPodSuccessful{noop.Int64UpDownCounter{}}, nil |
| 3678 |
} |
| 3679 |
|
| 3680 |
if len(opt) == 0 { |
| 3681 |
opt = newJobPodSuccessfulOpts |
| 3682 |
} else { |
| 3683 |
opt = append(opt, newJobPodSuccessfulOpts...) |
| 3684 |
} |
| 3685 |
|
| 3686 |
i, err := m.Int64UpDownCounter( |
| 3687 |
"k8s.job.pod.successful", |
| 3688 |
opt..., |
| 3689 |
) |
| 3690 |
if err != nil { |
| 3691 |
return JobPodSuccessful{noop.Int64UpDownCounter{}}, err |
| 3692 |
} |
| 3693 |
return JobPodSuccessful{i}, nil |
| 3694 |
} |
| 3695 |
|
| 3696 |
// Inst returns the underlying metric instrument. |
| 3697 |
func (m JobPodSuccessful) Inst() metric.Int64UpDownCounter { |
| 3698 |
return m.Int64UpDownCounter |
| 3699 |
} |
| 3700 |
|
| 3701 |
// Name returns the semantic convention name of the instrument. |
| 3702 |
func (JobPodSuccessful) Name() string { |
| 3703 |
return "k8s.job.pod.successful" |
| 3704 |
} |
| 3705 |
|
| 3706 |
// Unit returns the semantic convention unit of the instrument |
| 3707 |
func (JobPodSuccessful) Unit() string { |
| 3708 |
return "{pod}" |
| 3709 |
} |
| 3710 |
|
| 3711 |
// Description returns the semantic convention description of the instrument |
| 3712 |
func (JobPodSuccessful) Description() string { |
| 3713 |
return "The number of pods which reached phase Succeeded for a job." |
| 3714 |
} |
| 3715 |
|
| 3716 |
// Add adds incr to the existing count for attrs. |
| 3717 |
// |
| 3718 |
// This metric aligns with the `succeeded` field of the |
| 3719 |
// [K8s JobStatus]. |
| 3720 |
// |
| 3721 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3722 |
func (m JobPodSuccessful) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3723 |
if len(attrs) == 0 { |
| 3724 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3725 |
return |
| 3726 |
} |
| 3727 |
|
| 3728 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3729 |
defer func() { |
| 3730 |
*o = (*o)[:0] |
| 3731 |
addOptPool.Put(o) |
| 3732 |
}() |
| 3733 |
|
| 3734 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3735 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3736 |
} |
| 3737 |
|
| 3738 |
// AddSet adds incr to the existing count for set. |
| 3739 |
// |
| 3740 |
// This metric aligns with the `succeeded` field of the |
| 3741 |
// [K8s JobStatus]. |
| 3742 |
// |
| 3743 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3744 |
func (m JobPodSuccessful) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3745 |
if set.Len() == 0 { |
| 3746 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3747 |
return |
| 3748 |
} |
| 3749 |
|
| 3750 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3751 |
defer func() { |
| 3752 |
*o = (*o)[:0] |
| 3753 |
addOptPool.Put(o) |
| 3754 |
}() |
| 3755 |
|
| 3756 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3757 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3758 |
} |
| 3759 |
|
| 3760 |
// NamespacePhase is an instrument used to record metric values conforming to the |
| 3761 |
// "k8s.namespace.phase" semantic conventions. It represents the describes number |
| 3762 |
// of K8s namespaces that are currently in a given phase. |
| 3763 |
type NamespacePhase struct { |
| 3764 |
metric.Int64UpDownCounter |
| 3765 |
} |
| 3766 |
|
| 3767 |
var newNamespacePhaseOpts = []metric.Int64UpDownCounterOption{ |
| 3768 |
metric.WithDescription("Describes number of K8s namespaces that are currently in a given phase."), |
| 3769 |
metric.WithUnit("{namespace}"), |
| 3770 |
} |
| 3771 |
|
| 3772 |
// NewNamespacePhase returns a new NamespacePhase instrument. |
| 3773 |
func NewNamespacePhase( |
| 3774 |
m metric.Meter, |
| 3775 |
opt ...metric.Int64UpDownCounterOption, |
| 3776 |
) (NamespacePhase, error) { |
| 3777 |
// Check if the meter is nil. |
| 3778 |
if m == nil { |
| 3779 |
return NamespacePhase{noop.Int64UpDownCounter{}}, nil |
| 3780 |
} |
| 3781 |
|
| 3782 |
if len(opt) == 0 { |
| 3783 |
opt = newNamespacePhaseOpts |
| 3784 |
} else { |
| 3785 |
opt = append(opt, newNamespacePhaseOpts...) |
| 3786 |
} |
| 3787 |
|
| 3788 |
i, err := m.Int64UpDownCounter( |
| 3789 |
"k8s.namespace.phase", |
| 3790 |
opt..., |
| 3791 |
) |
| 3792 |
if err != nil { |
| 3793 |
return NamespacePhase{noop.Int64UpDownCounter{}}, err |
| 3794 |
} |
| 3795 |
return NamespacePhase{i}, nil |
| 3796 |
} |
| 3797 |
|
| 3798 |
// Inst returns the underlying metric instrument. |
| 3799 |
func (m NamespacePhase) Inst() metric.Int64UpDownCounter { |
| 3800 |
return m.Int64UpDownCounter |
| 3801 |
} |
| 3802 |
|
| 3803 |
// Name returns the semantic convention name of the instrument. |
| 3804 |
func (NamespacePhase) Name() string { |
| 3805 |
return "k8s.namespace.phase" |
| 3806 |
} |
| 3807 |
|
| 3808 |
// Unit returns the semantic convention unit of the instrument |
| 3809 |
func (NamespacePhase) Unit() string { |
| 3810 |
return "{namespace}" |
| 3811 |
} |
| 3812 |
|
| 3813 |
// Description returns the semantic convention description of the instrument |
| 3814 |
func (NamespacePhase) Description() string { |
| 3815 |
return "Describes number of K8s namespaces that are currently in a given phase." |
| 3816 |
} |
| 3817 |
|
| 3818 |
// Add adds incr to the existing count for attrs. |
| 3819 |
// |
| 3820 |
// The namespacePhase is the the phase of the K8s namespace. |
| 3821 |
func (m NamespacePhase) Add( |
| 3822 |
ctx context.Context, |
| 3823 |
incr int64, |
| 3824 |
namespacePhase NamespacePhaseAttr, |
| 3825 |
attrs ...attribute.KeyValue, |
| 3826 |
) { |
| 3827 |
if len(attrs) == 0 { |
| 3828 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 3829 |
attribute.String("k8s.namespace.phase", string(namespacePhase)), |
| 3830 |
)) |
| 3831 |
return |
| 3832 |
} |
| 3833 |
|
| 3834 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3835 |
defer func() { |
| 3836 |
*o = (*o)[:0] |
| 3837 |
addOptPool.Put(o) |
| 3838 |
}() |
| 3839 |
|
| 3840 |
*o = append( |
| 3841 |
*o, |
| 3842 |
metric.WithAttributes( |
| 3843 |
append( |
| 3844 |
attrs, |
| 3845 |
attribute.String("k8s.namespace.phase", string(namespacePhase)), |
| 3846 |
)..., |
| 3847 |
), |
| 3848 |
) |
| 3849 |
|
| 3850 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3851 |
} |
| 3852 |
|
| 3853 |
// AddSet adds incr to the existing count for set. |
| 3854 |
func (m NamespacePhase) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3855 |
if set.Len() == 0 { |
| 3856 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3857 |
return |
| 3858 |
} |
| 3859 |
|
| 3860 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3861 |
defer func() { |
| 3862 |
*o = (*o)[:0] |
| 3863 |
addOptPool.Put(o) |
| 3864 |
}() |
| 3865 |
|
| 3866 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3867 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3868 |
} |
| 3869 |
|
| 3870 |
// NodeConditionStatus is an instrument used to record metric values conforming |
| 3871 |
// to the "k8s.node.condition.status" semantic conventions. It represents the |
| 3872 |
// describes the condition of a particular Node. |
| 3873 |
type NodeConditionStatus struct { |
| 3874 |
metric.Int64UpDownCounter |
| 3875 |
} |
| 3876 |
|
| 3877 |
var newNodeConditionStatusOpts = []metric.Int64UpDownCounterOption{ |
| 3878 |
metric.WithDescription("Describes the condition of a particular Node."), |
| 3879 |
metric.WithUnit("{node}"), |
| 3880 |
} |
| 3881 |
|
| 3882 |
// NewNodeConditionStatus returns a new NodeConditionStatus instrument. |
| 3883 |
func NewNodeConditionStatus( |
| 3884 |
m metric.Meter, |
| 3885 |
opt ...metric.Int64UpDownCounterOption, |
| 3886 |
) (NodeConditionStatus, error) { |
| 3887 |
// Check if the meter is nil. |
| 3888 |
if m == nil { |
| 3889 |
return NodeConditionStatus{noop.Int64UpDownCounter{}}, nil |
| 3890 |
} |
| 3891 |
|
| 3892 |
if len(opt) == 0 { |
| 3893 |
opt = newNodeConditionStatusOpts |
| 3894 |
} else { |
| 3895 |
opt = append(opt, newNodeConditionStatusOpts...) |
| 3896 |
} |
| 3897 |
|
| 3898 |
i, err := m.Int64UpDownCounter( |
| 3899 |
"k8s.node.condition.status", |
| 3900 |
opt..., |
| 3901 |
) |
| 3902 |
if err != nil { |
| 3903 |
return NodeConditionStatus{noop.Int64UpDownCounter{}}, err |
| 3904 |
} |
| 3905 |
return NodeConditionStatus{i}, nil |
| 3906 |
} |
| 3907 |
|
| 3908 |
// Inst returns the underlying metric instrument. |
| 3909 |
func (m NodeConditionStatus) Inst() metric.Int64UpDownCounter { |
| 3910 |
return m.Int64UpDownCounter |
| 3911 |
} |
| 3912 |
|
| 3913 |
// Name returns the semantic convention name of the instrument. |
| 3914 |
func (NodeConditionStatus) Name() string { |
| 3915 |
return "k8s.node.condition.status" |
| 3916 |
} |
| 3917 |
|
| 3918 |
// Unit returns the semantic convention unit of the instrument |
| 3919 |
func (NodeConditionStatus) Unit() string { |
| 3920 |
return "{node}" |
| 3921 |
} |
| 3922 |
|
| 3923 |
// Description returns the semantic convention description of the instrument |
| 3924 |
func (NodeConditionStatus) Description() string { |
| 3925 |
return "Describes the condition of a particular Node." |
| 3926 |
} |
| 3927 |
|
| 3928 |
// Add adds incr to the existing count for attrs. |
| 3929 |
// |
| 3930 |
// The nodeConditionStatus is the the status of the condition, one of True, |
| 3931 |
// False, Unknown. |
| 3932 |
// |
| 3933 |
// The nodeConditionType is the the condition type of a K8s Node. |
| 3934 |
// |
| 3935 |
// All possible node condition pairs (type and status) will be reported at each |
| 3936 |
// time interval to avoid missing metrics. Condition pairs corresponding to the |
| 3937 |
// current conditions' statuses will be non-zero. |
| 3938 |
func (m NodeConditionStatus) Add( |
| 3939 |
ctx context.Context, |
| 3940 |
incr int64, |
| 3941 |
nodeConditionStatus NodeConditionStatusAttr, |
| 3942 |
nodeConditionType NodeConditionTypeAttr, |
| 3943 |
attrs ...attribute.KeyValue, |
| 3944 |
) { |
| 3945 |
if len(attrs) == 0 { |
| 3946 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 3947 |
attribute.String("k8s.node.condition.status", string(nodeConditionStatus)), |
| 3948 |
attribute.String("k8s.node.condition.type", string(nodeConditionType)), |
| 3949 |
)) |
| 3950 |
return |
| 3951 |
} |
| 3952 |
|
| 3953 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3954 |
defer func() { |
| 3955 |
*o = (*o)[:0] |
| 3956 |
addOptPool.Put(o) |
| 3957 |
}() |
| 3958 |
|
| 3959 |
*o = append( |
| 3960 |
*o, |
| 3961 |
metric.WithAttributes( |
| 3962 |
append( |
| 3963 |
attrs, |
| 3964 |
attribute.String("k8s.node.condition.status", string(nodeConditionStatus)), |
| 3965 |
attribute.String("k8s.node.condition.type", string(nodeConditionType)), |
| 3966 |
)..., |
| 3967 |
), |
| 3968 |
) |
| 3969 |
|
| 3970 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3971 |
} |
| 3972 |
|
| 3973 |
// AddSet adds incr to the existing count for set. |
| 3974 |
// |
| 3975 |
// All possible node condition pairs (type and status) will be reported at each |
| 3976 |
// time interval to avoid missing metrics. Condition pairs corresponding to the |
| 3977 |
// current conditions' statuses will be non-zero. |
| 3978 |
func (m NodeConditionStatus) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3979 |
if set.Len() == 0 { |
| 3980 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 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(*o, metric.WithAttributeSet(set)) |
| 3991 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3992 |
} |
| 3993 |
|
| 3994 |
// NodeCPUAllocatable is an instrument used to record metric values conforming to |
| 3995 |
// the "k8s.node.cpu.allocatable" semantic conventions. It represents the amount |
| 3996 |
// of cpu allocatable on the node. |
| 3997 |
type NodeCPUAllocatable struct { |
| 3998 |
metric.Int64UpDownCounter |
| 3999 |
} |
| 4000 |
|
| 4001 |
var newNodeCPUAllocatableOpts = []metric.Int64UpDownCounterOption{ |
| 4002 |
metric.WithDescription("Amount of cpu allocatable on the node."), |
| 4003 |
metric.WithUnit("{cpu}"), |
| 4004 |
} |
| 4005 |
|
| 4006 |
// NewNodeCPUAllocatable returns a new NodeCPUAllocatable instrument. |
| 4007 |
func NewNodeCPUAllocatable( |
| 4008 |
m metric.Meter, |
| 4009 |
opt ...metric.Int64UpDownCounterOption, |
| 4010 |
) (NodeCPUAllocatable, error) { |
| 4011 |
// Check if the meter is nil. |
| 4012 |
if m == nil { |
| 4013 |
return NodeCPUAllocatable{noop.Int64UpDownCounter{}}, nil |
| 4014 |
} |
| 4015 |
|
| 4016 |
if len(opt) == 0 { |
| 4017 |
opt = newNodeCPUAllocatableOpts |
| 4018 |
} else { |
| 4019 |
opt = append(opt, newNodeCPUAllocatableOpts...) |
| 4020 |
} |
| 4021 |
|
| 4022 |
i, err := m.Int64UpDownCounter( |
| 4023 |
"k8s.node.cpu.allocatable", |
| 4024 |
opt..., |
| 4025 |
) |
| 4026 |
if err != nil { |
| 4027 |
return NodeCPUAllocatable{noop.Int64UpDownCounter{}}, err |
| 4028 |
} |
| 4029 |
return NodeCPUAllocatable{i}, nil |
| 4030 |
} |
| 4031 |
|
| 4032 |
// Inst returns the underlying metric instrument. |
| 4033 |
func (m NodeCPUAllocatable) Inst() metric.Int64UpDownCounter { |
| 4034 |
return m.Int64UpDownCounter |
| 4035 |
} |
| 4036 |
|
| 4037 |
// Name returns the semantic convention name of the instrument. |
| 4038 |
func (NodeCPUAllocatable) Name() string { |
| 4039 |
return "k8s.node.cpu.allocatable" |
| 4040 |
} |
| 4041 |
|
| 4042 |
// Unit returns the semantic convention unit of the instrument |
| 4043 |
func (NodeCPUAllocatable) Unit() string { |
| 4044 |
return "{cpu}" |
| 4045 |
} |
| 4046 |
|
| 4047 |
// Description returns the semantic convention description of the instrument |
| 4048 |
func (NodeCPUAllocatable) Description() string { |
| 4049 |
return "Amount of cpu allocatable on the node." |
| 4050 |
} |
| 4051 |
|
| 4052 |
// Add adds incr to the existing count for attrs. |
| 4053 |
func (m NodeCPUAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4054 |
if len(attrs) == 0 { |
| 4055 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4056 |
return |
| 4057 |
} |
| 4058 |
|
| 4059 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4060 |
defer func() { |
| 4061 |
*o = (*o)[:0] |
| 4062 |
addOptPool.Put(o) |
| 4063 |
}() |
| 4064 |
|
| 4065 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4066 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4067 |
} |
| 4068 |
|
| 4069 |
// AddSet adds incr to the existing count for set. |
| 4070 |
func (m NodeCPUAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4071 |
if set.Len() == 0 { |
| 4072 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4073 |
return |
| 4074 |
} |
| 4075 |
|
| 4076 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4077 |
defer func() { |
| 4078 |
*o = (*o)[:0] |
| 4079 |
addOptPool.Put(o) |
| 4080 |
}() |
| 4081 |
|
| 4082 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4083 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4084 |
} |
| 4085 |
|
| 4086 |
// NodeCPUTime is an instrument used to record metric values conforming to the |
| 4087 |
// "k8s.node.cpu.time" semantic conventions. It represents the total CPU time |
| 4088 |
// consumed. |
| 4089 |
type NodeCPUTime struct { |
| 4090 |
metric.Float64Counter |
| 4091 |
} |
| 4092 |
|
| 4093 |
var newNodeCPUTimeOpts = []metric.Float64CounterOption{ |
| 4094 |
metric.WithDescription("Total CPU time consumed."), |
| 4095 |
metric.WithUnit("s"), |
| 4096 |
} |
| 4097 |
|
| 4098 |
// NewNodeCPUTime returns a new NodeCPUTime instrument. |
| 4099 |
func NewNodeCPUTime( |
| 4100 |
m metric.Meter, |
| 4101 |
opt ...metric.Float64CounterOption, |
| 4102 |
) (NodeCPUTime, error) { |
| 4103 |
// Check if the meter is nil. |
| 4104 |
if m == nil { |
| 4105 |
return NodeCPUTime{noop.Float64Counter{}}, nil |
| 4106 |
} |
| 4107 |
|
| 4108 |
if len(opt) == 0 { |
| 4109 |
opt = newNodeCPUTimeOpts |
| 4110 |
} else { |
| 4111 |
opt = append(opt, newNodeCPUTimeOpts...) |
| 4112 |
} |
| 4113 |
|
| 4114 |
i, err := m.Float64Counter( |
| 4115 |
"k8s.node.cpu.time", |
| 4116 |
opt..., |
| 4117 |
) |
| 4118 |
if err != nil { |
| 4119 |
return NodeCPUTime{noop.Float64Counter{}}, err |
| 4120 |
} |
| 4121 |
return NodeCPUTime{i}, nil |
| 4122 |
} |
| 4123 |
|
| 4124 |
// Inst returns the underlying metric instrument. |
| 4125 |
func (m NodeCPUTime) Inst() metric.Float64Counter { |
| 4126 |
return m.Float64Counter |
| 4127 |
} |
| 4128 |
|
| 4129 |
// Name returns the semantic convention name of the instrument. |
| 4130 |
func (NodeCPUTime) Name() string { |
| 4131 |
return "k8s.node.cpu.time" |
| 4132 |
} |
| 4133 |
|
| 4134 |
// Unit returns the semantic convention unit of the instrument |
| 4135 |
func (NodeCPUTime) Unit() string { |
| 4136 |
return "s" |
| 4137 |
} |
| 4138 |
|
| 4139 |
// Description returns the semantic convention description of the instrument |
| 4140 |
func (NodeCPUTime) Description() string { |
| 4141 |
return "Total CPU time consumed." |
| 4142 |
} |
| 4143 |
|
| 4144 |
// Add adds incr to the existing count for attrs. |
| 4145 |
// |
| 4146 |
// Total CPU time consumed by the specific Node on all available CPU cores |
| 4147 |
func (m NodeCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { |
| 4148 |
if len(attrs) == 0 { |
| 4149 |
m.Float64Counter.Add(ctx, incr) |
| 4150 |
return |
| 4151 |
} |
| 4152 |
|
| 4153 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4154 |
defer func() { |
| 4155 |
*o = (*o)[:0] |
| 4156 |
addOptPool.Put(o) |
| 4157 |
}() |
| 4158 |
|
| 4159 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4160 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 4161 |
} |
| 4162 |
|
| 4163 |
// AddSet adds incr to the existing count for set. |
| 4164 |
// |
| 4165 |
// Total CPU time consumed by the specific Node on all available CPU cores |
| 4166 |
func (m NodeCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { |
| 4167 |
if set.Len() == 0 { |
| 4168 |
m.Float64Counter.Add(ctx, incr) |
| 4169 |
return |
| 4170 |
} |
| 4171 |
|
| 4172 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4173 |
defer func() { |
| 4174 |
*o = (*o)[:0] |
| 4175 |
addOptPool.Put(o) |
| 4176 |
}() |
| 4177 |
|
| 4178 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4179 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 4180 |
} |
| 4181 |
|
| 4182 |
// NodeCPUUsage is an instrument used to record metric values conforming to the |
| 4183 |
// "k8s.node.cpu.usage" semantic conventions. It represents the node's CPU usage, |
| 4184 |
// measured in cpus. Range from 0 to the number of allocatable CPUs. |
| 4185 |
type NodeCPUUsage struct { |
| 4186 |
metric.Int64Gauge |
| 4187 |
} |
| 4188 |
|
| 4189 |
var newNodeCPUUsageOpts = []metric.Int64GaugeOption{ |
| 4190 |
metric.WithDescription("Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."), |
| 4191 |
metric.WithUnit("{cpu}"), |
| 4192 |
} |
| 4193 |
|
| 4194 |
// NewNodeCPUUsage returns a new NodeCPUUsage instrument. |
| 4195 |
func NewNodeCPUUsage( |
| 4196 |
m metric.Meter, |
| 4197 |
opt ...metric.Int64GaugeOption, |
| 4198 |
) (NodeCPUUsage, error) { |
| 4199 |
// Check if the meter is nil. |
| 4200 |
if m == nil { |
| 4201 |
return NodeCPUUsage{noop.Int64Gauge{}}, nil |
| 4202 |
} |
| 4203 |
|
| 4204 |
if len(opt) == 0 { |
| 4205 |
opt = newNodeCPUUsageOpts |
| 4206 |
} else { |
| 4207 |
opt = append(opt, newNodeCPUUsageOpts...) |
| 4208 |
} |
| 4209 |
|
| 4210 |
i, err := m.Int64Gauge( |
| 4211 |
"k8s.node.cpu.usage", |
| 4212 |
opt..., |
| 4213 |
) |
| 4214 |
if err != nil { |
| 4215 |
return NodeCPUUsage{noop.Int64Gauge{}}, err |
| 4216 |
} |
| 4217 |
return NodeCPUUsage{i}, nil |
| 4218 |
} |
| 4219 |
|
| 4220 |
// Inst returns the underlying metric instrument. |
| 4221 |
func (m NodeCPUUsage) Inst() metric.Int64Gauge { |
| 4222 |
return m.Int64Gauge |
| 4223 |
} |
| 4224 |
|
| 4225 |
// Name returns the semantic convention name of the instrument. |
| 4226 |
func (NodeCPUUsage) Name() string { |
| 4227 |
return "k8s.node.cpu.usage" |
| 4228 |
} |
| 4229 |
|
| 4230 |
// Unit returns the semantic convention unit of the instrument |
| 4231 |
func (NodeCPUUsage) Unit() string { |
| 4232 |
return "{cpu}" |
| 4233 |
} |
| 4234 |
|
| 4235 |
// Description returns the semantic convention description of the instrument |
| 4236 |
func (NodeCPUUsage) Description() string { |
| 4237 |
return "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs." |
| 4238 |
} |
| 4239 |
|
| 4240 |
// Record records val to the current distribution for attrs. |
| 4241 |
// |
| 4242 |
// CPU usage of the specific Node on all available CPU cores, averaged over the |
| 4243 |
// sample window |
| 4244 |
func (m NodeCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 4245 |
if len(attrs) == 0 { |
| 4246 |
m.Int64Gauge.Record(ctx, val) |
| 4247 |
return |
| 4248 |
} |
| 4249 |
|
| 4250 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4251 |
defer func() { |
| 4252 |
*o = (*o)[:0] |
| 4253 |
recOptPool.Put(o) |
| 4254 |
}() |
| 4255 |
|
| 4256 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4257 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4258 |
} |
| 4259 |
|
| 4260 |
// RecordSet records val to the current distribution for set. |
| 4261 |
// |
| 4262 |
// CPU usage of the specific Node on all available CPU cores, averaged over the |
| 4263 |
// sample window |
| 4264 |
func (m NodeCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 4265 |
if set.Len() == 0 { |
| 4266 |
m.Int64Gauge.Record(ctx, val) |
| 4267 |
return |
| 4268 |
} |
| 4269 |
|
| 4270 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4271 |
defer func() { |
| 4272 |
*o = (*o)[:0] |
| 4273 |
recOptPool.Put(o) |
| 4274 |
}() |
| 4275 |
|
| 4276 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4277 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4278 |
} |
| 4279 |
|
| 4280 |
// NodeEphemeralStorageAllocatable is an instrument used to record metric values |
| 4281 |
// conforming to the "k8s.node.ephemeral_storage.allocatable" semantic |
| 4282 |
// conventions. It represents the amount of ephemeral-storage allocatable on the |
| 4283 |
// node. |
| 4284 |
type NodeEphemeralStorageAllocatable struct { |
| 4285 |
metric.Int64UpDownCounter |
| 4286 |
} |
| 4287 |
|
| 4288 |
var newNodeEphemeralStorageAllocatableOpts = []metric.Int64UpDownCounterOption{ |
| 4289 |
metric.WithDescription("Amount of ephemeral-storage allocatable on the node."), |
| 4290 |
metric.WithUnit("By"), |
| 4291 |
} |
| 4292 |
|
| 4293 |
// NewNodeEphemeralStorageAllocatable returns a new |
| 4294 |
// NodeEphemeralStorageAllocatable instrument. |
| 4295 |
func NewNodeEphemeralStorageAllocatable( |
| 4296 |
m metric.Meter, |
| 4297 |
opt ...metric.Int64UpDownCounterOption, |
| 4298 |
) (NodeEphemeralStorageAllocatable, error) { |
| 4299 |
// Check if the meter is nil. |
| 4300 |
if m == nil { |
| 4301 |
return NodeEphemeralStorageAllocatable{noop.Int64UpDownCounter{}}, nil |
| 4302 |
} |
| 4303 |
|
| 4304 |
if len(opt) == 0 { |
| 4305 |
opt = newNodeEphemeralStorageAllocatableOpts |
| 4306 |
} else { |
| 4307 |
opt = append(opt, newNodeEphemeralStorageAllocatableOpts...) |
| 4308 |
} |
| 4309 |
|
| 4310 |
i, err := m.Int64UpDownCounter( |
| 4311 |
"k8s.node.ephemeral_storage.allocatable", |
| 4312 |
opt..., |
| 4313 |
) |
| 4314 |
if err != nil { |
| 4315 |
return NodeEphemeralStorageAllocatable{noop.Int64UpDownCounter{}}, err |
| 4316 |
} |
| 4317 |
return NodeEphemeralStorageAllocatable{i}, nil |
| 4318 |
} |
| 4319 |
|
| 4320 |
// Inst returns the underlying metric instrument. |
| 4321 |
func (m NodeEphemeralStorageAllocatable) Inst() metric.Int64UpDownCounter { |
| 4322 |
return m.Int64UpDownCounter |
| 4323 |
} |
| 4324 |
|
| 4325 |
// Name returns the semantic convention name of the instrument. |
| 4326 |
func (NodeEphemeralStorageAllocatable) Name() string { |
| 4327 |
return "k8s.node.ephemeral_storage.allocatable" |
| 4328 |
} |
| 4329 |
|
| 4330 |
// Unit returns the semantic convention unit of the instrument |
| 4331 |
func (NodeEphemeralStorageAllocatable) Unit() string { |
| 4332 |
return "By" |
| 4333 |
} |
| 4334 |
|
| 4335 |
// Description returns the semantic convention description of the instrument |
| 4336 |
func (NodeEphemeralStorageAllocatable) Description() string { |
| 4337 |
return "Amount of ephemeral-storage allocatable on the node." |
| 4338 |
} |
| 4339 |
|
| 4340 |
// Add adds incr to the existing count for attrs. |
| 4341 |
func (m NodeEphemeralStorageAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4342 |
if len(attrs) == 0 { |
| 4343 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4344 |
return |
| 4345 |
} |
| 4346 |
|
| 4347 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4348 |
defer func() { |
| 4349 |
*o = (*o)[:0] |
| 4350 |
addOptPool.Put(o) |
| 4351 |
}() |
| 4352 |
|
| 4353 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4354 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4355 |
} |
| 4356 |
|
| 4357 |
// AddSet adds incr to the existing count for set. |
| 4358 |
func (m NodeEphemeralStorageAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4359 |
if set.Len() == 0 { |
| 4360 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4361 |
return |
| 4362 |
} |
| 4363 |
|
| 4364 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4365 |
defer func() { |
| 4366 |
*o = (*o)[:0] |
| 4367 |
addOptPool.Put(o) |
| 4368 |
}() |
| 4369 |
|
| 4370 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4371 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4372 |
} |
| 4373 |
|
| 4374 |
// NodeFilesystemAvailable is an instrument used to record metric values |
| 4375 |
// conforming to the "k8s.node.filesystem.available" semantic conventions. It |
| 4376 |
// represents the node filesystem available bytes. |
| 4377 |
type NodeFilesystemAvailable struct { |
| 4378 |
metric.Int64UpDownCounter |
| 4379 |
} |
| 4380 |
|
| 4381 |
var newNodeFilesystemAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 4382 |
metric.WithDescription("Node filesystem available bytes."), |
| 4383 |
metric.WithUnit("By"), |
| 4384 |
} |
| 4385 |
|
| 4386 |
// NewNodeFilesystemAvailable returns a new NodeFilesystemAvailable instrument. |
| 4387 |
func NewNodeFilesystemAvailable( |
| 4388 |
m metric.Meter, |
| 4389 |
opt ...metric.Int64UpDownCounterOption, |
| 4390 |
) (NodeFilesystemAvailable, error) { |
| 4391 |
// Check if the meter is nil. |
| 4392 |
if m == nil { |
| 4393 |
return NodeFilesystemAvailable{noop.Int64UpDownCounter{}}, nil |
| 4394 |
} |
| 4395 |
|
| 4396 |
if len(opt) == 0 { |
| 4397 |
opt = newNodeFilesystemAvailableOpts |
| 4398 |
} else { |
| 4399 |
opt = append(opt, newNodeFilesystemAvailableOpts...) |
| 4400 |
} |
| 4401 |
|
| 4402 |
i, err := m.Int64UpDownCounter( |
| 4403 |
"k8s.node.filesystem.available", |
| 4404 |
opt..., |
| 4405 |
) |
| 4406 |
if err != nil { |
| 4407 |
return NodeFilesystemAvailable{noop.Int64UpDownCounter{}}, err |
| 4408 |
} |
| 4409 |
return NodeFilesystemAvailable{i}, nil |
| 4410 |
} |
| 4411 |
|
| 4412 |
// Inst returns the underlying metric instrument. |
| 4413 |
func (m NodeFilesystemAvailable) Inst() metric.Int64UpDownCounter { |
| 4414 |
return m.Int64UpDownCounter |
| 4415 |
} |
| 4416 |
|
| 4417 |
// Name returns the semantic convention name of the instrument. |
| 4418 |
func (NodeFilesystemAvailable) Name() string { |
| 4419 |
return "k8s.node.filesystem.available" |
| 4420 |
} |
| 4421 |
|
| 4422 |
// Unit returns the semantic convention unit of the instrument |
| 4423 |
func (NodeFilesystemAvailable) Unit() string { |
| 4424 |
return "By" |
| 4425 |
} |
| 4426 |
|
| 4427 |
// Description returns the semantic convention description of the instrument |
| 4428 |
func (NodeFilesystemAvailable) Description() string { |
| 4429 |
return "Node filesystem available bytes." |
| 4430 |
} |
| 4431 |
|
| 4432 |
// Add adds incr to the existing count for attrs. |
| 4433 |
// |
| 4434 |
// This metric is derived from the |
| 4435 |
// [FsStats.AvailableBytes] field |
| 4436 |
// of the [NodeStats.Fs] |
| 4437 |
// of the Kubelet's stats API. |
| 4438 |
// |
| 4439 |
// [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 4440 |
// [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4441 |
func (m NodeFilesystemAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4442 |
if len(attrs) == 0 { |
| 4443 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4444 |
return |
| 4445 |
} |
| 4446 |
|
| 4447 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4448 |
defer func() { |
| 4449 |
*o = (*o)[:0] |
| 4450 |
addOptPool.Put(o) |
| 4451 |
}() |
| 4452 |
|
| 4453 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4454 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4455 |
} |
| 4456 |
|
| 4457 |
// AddSet adds incr to the existing count for set. |
| 4458 |
// |
| 4459 |
// This metric is derived from the |
| 4460 |
// [FsStats.AvailableBytes] field |
| 4461 |
// of the [NodeStats.Fs] |
| 4462 |
// of the Kubelet's stats API. |
| 4463 |
// |
| 4464 |
// [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 4465 |
// [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4466 |
func (m NodeFilesystemAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4467 |
if set.Len() == 0 { |
| 4468 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4469 |
return |
| 4470 |
} |
| 4471 |
|
| 4472 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4473 |
defer func() { |
| 4474 |
*o = (*o)[:0] |
| 4475 |
addOptPool.Put(o) |
| 4476 |
}() |
| 4477 |
|
| 4478 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4479 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4480 |
} |
| 4481 |
|
| 4482 |
// NodeFilesystemCapacity is an instrument used to record metric values |
| 4483 |
// conforming to the "k8s.node.filesystem.capacity" semantic conventions. It |
| 4484 |
// represents the node filesystem capacity. |
| 4485 |
type NodeFilesystemCapacity struct { |
| 4486 |
metric.Int64UpDownCounter |
| 4487 |
} |
| 4488 |
|
| 4489 |
var newNodeFilesystemCapacityOpts = []metric.Int64UpDownCounterOption{ |
| 4490 |
metric.WithDescription("Node filesystem capacity."), |
| 4491 |
metric.WithUnit("By"), |
| 4492 |
} |
| 4493 |
|
| 4494 |
// NewNodeFilesystemCapacity returns a new NodeFilesystemCapacity instrument. |
| 4495 |
func NewNodeFilesystemCapacity( |
| 4496 |
m metric.Meter, |
| 4497 |
opt ...metric.Int64UpDownCounterOption, |
| 4498 |
) (NodeFilesystemCapacity, error) { |
| 4499 |
// Check if the meter is nil. |
| 4500 |
if m == nil { |
| 4501 |
return NodeFilesystemCapacity{noop.Int64UpDownCounter{}}, nil |
| 4502 |
} |
| 4503 |
|
| 4504 |
if len(opt) == 0 { |
| 4505 |
opt = newNodeFilesystemCapacityOpts |
| 4506 |
} else { |
| 4507 |
opt = append(opt, newNodeFilesystemCapacityOpts...) |
| 4508 |
} |
| 4509 |
|
| 4510 |
i, err := m.Int64UpDownCounter( |
| 4511 |
"k8s.node.filesystem.capacity", |
| 4512 |
opt..., |
| 4513 |
) |
| 4514 |
if err != nil { |
| 4515 |
return NodeFilesystemCapacity{noop.Int64UpDownCounter{}}, err |
| 4516 |
} |
| 4517 |
return NodeFilesystemCapacity{i}, nil |
| 4518 |
} |
| 4519 |
|
| 4520 |
// Inst returns the underlying metric instrument. |
| 4521 |
func (m NodeFilesystemCapacity) Inst() metric.Int64UpDownCounter { |
| 4522 |
return m.Int64UpDownCounter |
| 4523 |
} |
| 4524 |
|
| 4525 |
// Name returns the semantic convention name of the instrument. |
| 4526 |
func (NodeFilesystemCapacity) Name() string { |
| 4527 |
return "k8s.node.filesystem.capacity" |
| 4528 |
} |
| 4529 |
|
| 4530 |
// Unit returns the semantic convention unit of the instrument |
| 4531 |
func (NodeFilesystemCapacity) Unit() string { |
| 4532 |
return "By" |
| 4533 |
} |
| 4534 |
|
| 4535 |
// Description returns the semantic convention description of the instrument |
| 4536 |
func (NodeFilesystemCapacity) Description() string { |
| 4537 |
return "Node filesystem capacity." |
| 4538 |
} |
| 4539 |
|
| 4540 |
// Add adds incr to the existing count for attrs. |
| 4541 |
// |
| 4542 |
// This metric is derived from the |
| 4543 |
// [FsStats.CapacityBytes] field |
| 4544 |
// of the [NodeStats.Fs] |
| 4545 |
// of the Kubelet's stats API. |
| 4546 |
// |
| 4547 |
// [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 4548 |
// [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4549 |
func (m NodeFilesystemCapacity) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4550 |
if len(attrs) == 0 { |
| 4551 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4552 |
return |
| 4553 |
} |
| 4554 |
|
| 4555 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4556 |
defer func() { |
| 4557 |
*o = (*o)[:0] |
| 4558 |
addOptPool.Put(o) |
| 4559 |
}() |
| 4560 |
|
| 4561 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4562 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4563 |
} |
| 4564 |
|
| 4565 |
// AddSet adds incr to the existing count for set. |
| 4566 |
// |
| 4567 |
// This metric is derived from the |
| 4568 |
// [FsStats.CapacityBytes] field |
| 4569 |
// of the [NodeStats.Fs] |
| 4570 |
// of the Kubelet's stats API. |
| 4571 |
// |
| 4572 |
// [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 4573 |
// [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4574 |
func (m NodeFilesystemCapacity) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4575 |
if set.Len() == 0 { |
| 4576 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4577 |
return |
| 4578 |
} |
| 4579 |
|
| 4580 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4581 |
defer func() { |
| 4582 |
*o = (*o)[:0] |
| 4583 |
addOptPool.Put(o) |
| 4584 |
}() |
| 4585 |
|
| 4586 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4587 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4588 |
} |
| 4589 |
|
| 4590 |
// NodeFilesystemUsage is an instrument used to record metric values conforming |
| 4591 |
// to the "k8s.node.filesystem.usage" semantic conventions. It represents the |
| 4592 |
// node filesystem usage. |
| 4593 |
type NodeFilesystemUsage struct { |
| 4594 |
metric.Int64UpDownCounter |
| 4595 |
} |
| 4596 |
|
| 4597 |
var newNodeFilesystemUsageOpts = []metric.Int64UpDownCounterOption{ |
| 4598 |
metric.WithDescription("Node filesystem usage."), |
| 4599 |
metric.WithUnit("By"), |
| 4600 |
} |
| 4601 |
|
| 4602 |
// NewNodeFilesystemUsage returns a new NodeFilesystemUsage instrument. |
| 4603 |
func NewNodeFilesystemUsage( |
| 4604 |
m metric.Meter, |
| 4605 |
opt ...metric.Int64UpDownCounterOption, |
| 4606 |
) (NodeFilesystemUsage, error) { |
| 4607 |
// Check if the meter is nil. |
| 4608 |
if m == nil { |
| 4609 |
return NodeFilesystemUsage{noop.Int64UpDownCounter{}}, nil |
| 4610 |
} |
| 4611 |
|
| 4612 |
if len(opt) == 0 { |
| 4613 |
opt = newNodeFilesystemUsageOpts |
| 4614 |
} else { |
| 4615 |
opt = append(opt, newNodeFilesystemUsageOpts...) |
| 4616 |
} |
| 4617 |
|
| 4618 |
i, err := m.Int64UpDownCounter( |
| 4619 |
"k8s.node.filesystem.usage", |
| 4620 |
opt..., |
| 4621 |
) |
| 4622 |
if err != nil { |
| 4623 |
return NodeFilesystemUsage{noop.Int64UpDownCounter{}}, err |
| 4624 |
} |
| 4625 |
return NodeFilesystemUsage{i}, nil |
| 4626 |
} |
| 4627 |
|
| 4628 |
// Inst returns the underlying metric instrument. |
| 4629 |
func (m NodeFilesystemUsage) Inst() metric.Int64UpDownCounter { |
| 4630 |
return m.Int64UpDownCounter |
| 4631 |
} |
| 4632 |
|
| 4633 |
// Name returns the semantic convention name of the instrument. |
| 4634 |
func (NodeFilesystemUsage) Name() string { |
| 4635 |
return "k8s.node.filesystem.usage" |
| 4636 |
} |
| 4637 |
|
| 4638 |
// Unit returns the semantic convention unit of the instrument |
| 4639 |
func (NodeFilesystemUsage) Unit() string { |
| 4640 |
return "By" |
| 4641 |
} |
| 4642 |
|
| 4643 |
// Description returns the semantic convention description of the instrument |
| 4644 |
func (NodeFilesystemUsage) Description() string { |
| 4645 |
return "Node filesystem usage." |
| 4646 |
} |
| 4647 |
|
| 4648 |
// Add adds incr to the existing count for attrs. |
| 4649 |
// |
| 4650 |
// This may not equal capacity - available. |
| 4651 |
// |
| 4652 |
// This metric is derived from the |
| 4653 |
// [FsStats.UsedBytes] field |
| 4654 |
// of the [NodeStats.Fs] |
| 4655 |
// of the Kubelet's stats API. |
| 4656 |
// |
| 4657 |
// [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 4658 |
// [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4659 |
func (m NodeFilesystemUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4660 |
if len(attrs) == 0 { |
| 4661 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4662 |
return |
| 4663 |
} |
| 4664 |
|
| 4665 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4666 |
defer func() { |
| 4667 |
*o = (*o)[:0] |
| 4668 |
addOptPool.Put(o) |
| 4669 |
}() |
| 4670 |
|
| 4671 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4672 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4673 |
} |
| 4674 |
|
| 4675 |
// AddSet adds incr to the existing count for set. |
| 4676 |
// |
| 4677 |
// This may not equal capacity - available. |
| 4678 |
// |
| 4679 |
// This metric is derived from the |
| 4680 |
// [FsStats.UsedBytes] field |
| 4681 |
// of the [NodeStats.Fs] |
| 4682 |
// of the Kubelet's stats API. |
| 4683 |
// |
| 4684 |
// [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 4685 |
// [NodeStats.Fs]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4686 |
func (m NodeFilesystemUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4687 |
if set.Len() == 0 { |
| 4688 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4689 |
return |
| 4690 |
} |
| 4691 |
|
| 4692 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4693 |
defer func() { |
| 4694 |
*o = (*o)[:0] |
| 4695 |
addOptPool.Put(o) |
| 4696 |
}() |
| 4697 |
|
| 4698 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4699 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4700 |
} |
| 4701 |
|
| 4702 |
// NodeMemoryAllocatable is an instrument used to record metric values conforming |
| 4703 |
// to the "k8s.node.memory.allocatable" semantic conventions. It represents the |
| 4704 |
// amount of memory allocatable on the node. |
| 4705 |
type NodeMemoryAllocatable struct { |
| 4706 |
metric.Int64UpDownCounter |
| 4707 |
} |
| 4708 |
|
| 4709 |
var newNodeMemoryAllocatableOpts = []metric.Int64UpDownCounterOption{ |
| 4710 |
metric.WithDescription("Amount of memory allocatable on the node."), |
| 4711 |
metric.WithUnit("By"), |
| 4712 |
} |
| 4713 |
|
| 4714 |
// NewNodeMemoryAllocatable returns a new NodeMemoryAllocatable instrument. |
| 4715 |
func NewNodeMemoryAllocatable( |
| 4716 |
m metric.Meter, |
| 4717 |
opt ...metric.Int64UpDownCounterOption, |
| 4718 |
) (NodeMemoryAllocatable, error) { |
| 4719 |
// Check if the meter is nil. |
| 4720 |
if m == nil { |
| 4721 |
return NodeMemoryAllocatable{noop.Int64UpDownCounter{}}, nil |
| 4722 |
} |
| 4723 |
|
| 4724 |
if len(opt) == 0 { |
| 4725 |
opt = newNodeMemoryAllocatableOpts |
| 4726 |
} else { |
| 4727 |
opt = append(opt, newNodeMemoryAllocatableOpts...) |
| 4728 |
} |
| 4729 |
|
| 4730 |
i, err := m.Int64UpDownCounter( |
| 4731 |
"k8s.node.memory.allocatable", |
| 4732 |
opt..., |
| 4733 |
) |
| 4734 |
if err != nil { |
| 4735 |
return NodeMemoryAllocatable{noop.Int64UpDownCounter{}}, err |
| 4736 |
} |
| 4737 |
return NodeMemoryAllocatable{i}, nil |
| 4738 |
} |
| 4739 |
|
| 4740 |
// Inst returns the underlying metric instrument. |
| 4741 |
func (m NodeMemoryAllocatable) Inst() metric.Int64UpDownCounter { |
| 4742 |
return m.Int64UpDownCounter |
| 4743 |
} |
| 4744 |
|
| 4745 |
// Name returns the semantic convention name of the instrument. |
| 4746 |
func (NodeMemoryAllocatable) Name() string { |
| 4747 |
return "k8s.node.memory.allocatable" |
| 4748 |
} |
| 4749 |
|
| 4750 |
// Unit returns the semantic convention unit of the instrument |
| 4751 |
func (NodeMemoryAllocatable) Unit() string { |
| 4752 |
return "By" |
| 4753 |
} |
| 4754 |
|
| 4755 |
// Description returns the semantic convention description of the instrument |
| 4756 |
func (NodeMemoryAllocatable) Description() string { |
| 4757 |
return "Amount of memory allocatable on the node." |
| 4758 |
} |
| 4759 |
|
| 4760 |
// Add adds incr to the existing count for attrs. |
| 4761 |
func (m NodeMemoryAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4762 |
if len(attrs) == 0 { |
| 4763 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4764 |
return |
| 4765 |
} |
| 4766 |
|
| 4767 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4768 |
defer func() { |
| 4769 |
*o = (*o)[:0] |
| 4770 |
addOptPool.Put(o) |
| 4771 |
}() |
| 4772 |
|
| 4773 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4774 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4775 |
} |
| 4776 |
|
| 4777 |
// AddSet adds incr to the existing count for set. |
| 4778 |
func (m NodeMemoryAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4779 |
if set.Len() == 0 { |
| 4780 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4781 |
return |
| 4782 |
} |
| 4783 |
|
| 4784 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4785 |
defer func() { |
| 4786 |
*o = (*o)[:0] |
| 4787 |
addOptPool.Put(o) |
| 4788 |
}() |
| 4789 |
|
| 4790 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4791 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4792 |
} |
| 4793 |
|
| 4794 |
// NodeMemoryAvailable is an instrument used to record metric values conforming |
| 4795 |
// to the "k8s.node.memory.available" semantic conventions. It represents the |
| 4796 |
// node memory available. |
| 4797 |
type NodeMemoryAvailable struct { |
| 4798 |
metric.Int64UpDownCounter |
| 4799 |
} |
| 4800 |
|
| 4801 |
var newNodeMemoryAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 4802 |
metric.WithDescription("Node memory available."), |
| 4803 |
metric.WithUnit("By"), |
| 4804 |
} |
| 4805 |
|
| 4806 |
// NewNodeMemoryAvailable returns a new NodeMemoryAvailable instrument. |
| 4807 |
func NewNodeMemoryAvailable( |
| 4808 |
m metric.Meter, |
| 4809 |
opt ...metric.Int64UpDownCounterOption, |
| 4810 |
) (NodeMemoryAvailable, error) { |
| 4811 |
// Check if the meter is nil. |
| 4812 |
if m == nil { |
| 4813 |
return NodeMemoryAvailable{noop.Int64UpDownCounter{}}, nil |
| 4814 |
} |
| 4815 |
|
| 4816 |
if len(opt) == 0 { |
| 4817 |
opt = newNodeMemoryAvailableOpts |
| 4818 |
} else { |
| 4819 |
opt = append(opt, newNodeMemoryAvailableOpts...) |
| 4820 |
} |
| 4821 |
|
| 4822 |
i, err := m.Int64UpDownCounter( |
| 4823 |
"k8s.node.memory.available", |
| 4824 |
opt..., |
| 4825 |
) |
| 4826 |
if err != nil { |
| 4827 |
return NodeMemoryAvailable{noop.Int64UpDownCounter{}}, err |
| 4828 |
} |
| 4829 |
return NodeMemoryAvailable{i}, nil |
| 4830 |
} |
| 4831 |
|
| 4832 |
// Inst returns the underlying metric instrument. |
| 4833 |
func (m NodeMemoryAvailable) Inst() metric.Int64UpDownCounter { |
| 4834 |
return m.Int64UpDownCounter |
| 4835 |
} |
| 4836 |
|
| 4837 |
// Name returns the semantic convention name of the instrument. |
| 4838 |
func (NodeMemoryAvailable) Name() string { |
| 4839 |
return "k8s.node.memory.available" |
| 4840 |
} |
| 4841 |
|
| 4842 |
// Unit returns the semantic convention unit of the instrument |
| 4843 |
func (NodeMemoryAvailable) Unit() string { |
| 4844 |
return "By" |
| 4845 |
} |
| 4846 |
|
| 4847 |
// Description returns the semantic convention description of the instrument |
| 4848 |
func (NodeMemoryAvailable) Description() string { |
| 4849 |
return "Node memory available." |
| 4850 |
} |
| 4851 |
|
| 4852 |
// Add adds incr to the existing count for attrs. |
| 4853 |
// |
| 4854 |
// Available memory for use. This is defined as the memory limit - |
| 4855 |
// workingSetBytes. If memory limit is undefined, the available bytes is omitted. |
| 4856 |
// This metric is derived from the [MemoryStats.AvailableBytes] field of the |
| 4857 |
// [NodeStats.Memory] of the Kubelet's stats API. |
| 4858 |
// |
| 4859 |
// [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 4860 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4861 |
func (m NodeMemoryAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4862 |
if len(attrs) == 0 { |
| 4863 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4864 |
return |
| 4865 |
} |
| 4866 |
|
| 4867 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4868 |
defer func() { |
| 4869 |
*o = (*o)[:0] |
| 4870 |
addOptPool.Put(o) |
| 4871 |
}() |
| 4872 |
|
| 4873 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4874 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4875 |
} |
| 4876 |
|
| 4877 |
// AddSet adds incr to the existing count for set. |
| 4878 |
// |
| 4879 |
// Available memory for use. This is defined as the memory limit - |
| 4880 |
// workingSetBytes. If memory limit is undefined, the available bytes is omitted. |
| 4881 |
// This metric is derived from the [MemoryStats.AvailableBytes] field of the |
| 4882 |
// [NodeStats.Memory] of the Kubelet's stats API. |
| 4883 |
// |
| 4884 |
// [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 4885 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4886 |
func (m NodeMemoryAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4887 |
if set.Len() == 0 { |
| 4888 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4889 |
return |
| 4890 |
} |
| 4891 |
|
| 4892 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4893 |
defer func() { |
| 4894 |
*o = (*o)[:0] |
| 4895 |
addOptPool.Put(o) |
| 4896 |
}() |
| 4897 |
|
| 4898 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4899 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4900 |
} |
| 4901 |
|
| 4902 |
// NodeMemoryPagingFaults is an instrument used to record metric values |
| 4903 |
// conforming to the "k8s.node.memory.paging.faults" semantic conventions. It |
| 4904 |
// represents the node memory paging faults. |
| 4905 |
type NodeMemoryPagingFaults struct { |
| 4906 |
metric.Int64Counter |
| 4907 |
} |
| 4908 |
|
| 4909 |
var newNodeMemoryPagingFaultsOpts = []metric.Int64CounterOption{ |
| 4910 |
metric.WithDescription("Node memory paging faults."), |
| 4911 |
metric.WithUnit("{fault}"), |
| 4912 |
} |
| 4913 |
|
| 4914 |
// NewNodeMemoryPagingFaults returns a new NodeMemoryPagingFaults instrument. |
| 4915 |
func NewNodeMemoryPagingFaults( |
| 4916 |
m metric.Meter, |
| 4917 |
opt ...metric.Int64CounterOption, |
| 4918 |
) (NodeMemoryPagingFaults, error) { |
| 4919 |
// Check if the meter is nil. |
| 4920 |
if m == nil { |
| 4921 |
return NodeMemoryPagingFaults{noop.Int64Counter{}}, nil |
| 4922 |
} |
| 4923 |
|
| 4924 |
if len(opt) == 0 { |
| 4925 |
opt = newNodeMemoryPagingFaultsOpts |
| 4926 |
} else { |
| 4927 |
opt = append(opt, newNodeMemoryPagingFaultsOpts...) |
| 4928 |
} |
| 4929 |
|
| 4930 |
i, err := m.Int64Counter( |
| 4931 |
"k8s.node.memory.paging.faults", |
| 4932 |
opt..., |
| 4933 |
) |
| 4934 |
if err != nil { |
| 4935 |
return NodeMemoryPagingFaults{noop.Int64Counter{}}, err |
| 4936 |
} |
| 4937 |
return NodeMemoryPagingFaults{i}, nil |
| 4938 |
} |
| 4939 |
|
| 4940 |
// Inst returns the underlying metric instrument. |
| 4941 |
func (m NodeMemoryPagingFaults) Inst() metric.Int64Counter { |
| 4942 |
return m.Int64Counter |
| 4943 |
} |
| 4944 |
|
| 4945 |
// Name returns the semantic convention name of the instrument. |
| 4946 |
func (NodeMemoryPagingFaults) Name() string { |
| 4947 |
return "k8s.node.memory.paging.faults" |
| 4948 |
} |
| 4949 |
|
| 4950 |
// Unit returns the semantic convention unit of the instrument |
| 4951 |
func (NodeMemoryPagingFaults) Unit() string { |
| 4952 |
return "{fault}" |
| 4953 |
} |
| 4954 |
|
| 4955 |
// Description returns the semantic convention description of the instrument |
| 4956 |
func (NodeMemoryPagingFaults) Description() string { |
| 4957 |
return "Node memory paging faults." |
| 4958 |
} |
| 4959 |
|
| 4960 |
// Add adds incr to the existing count for attrs. |
| 4961 |
// |
| 4962 |
// All additional attrs passed are included in the recorded value. |
| 4963 |
// |
| 4964 |
// Cumulative number of major/minor page faults. |
| 4965 |
// This metric is derived from the [MemoryStats.PageFaults] and |
| 4966 |
// [MemoryStats.MajorPageFaults] fields of the [NodeStats.Memory] of the |
| 4967 |
// Kubelet's stats API. |
| 4968 |
// |
| 4969 |
// [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 4970 |
// [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 4971 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 4972 |
func (m NodeMemoryPagingFaults) Add( |
| 4973 |
ctx context.Context, |
| 4974 |
incr int64, |
| 4975 |
attrs ...attribute.KeyValue, |
| 4976 |
) { |
| 4977 |
if len(attrs) == 0 { |
| 4978 |
m.Int64Counter.Add(ctx, incr) |
| 4979 |
return |
| 4980 |
} |
| 4981 |
|
| 4982 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4983 |
defer func() { |
| 4984 |
*o = (*o)[:0] |
| 4985 |
addOptPool.Put(o) |
| 4986 |
}() |
| 4987 |
|
| 4988 |
*o = append( |
| 4989 |
*o, |
| 4990 |
metric.WithAttributes( |
| 4991 |
attrs..., |
| 4992 |
), |
| 4993 |
) |
| 4994 |
|
| 4995 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4996 |
} |
| 4997 |
|
| 4998 |
// AddSet adds incr to the existing count for set. |
| 4999 |
// |
| 5000 |
// Cumulative number of major/minor page faults. |
| 5001 |
// This metric is derived from the [MemoryStats.PageFaults] and |
| 5002 |
// [MemoryStats.MajorPageFaults] fields of the [NodeStats.Memory] of the |
| 5003 |
// Kubelet's stats API. |
| 5004 |
// |
| 5005 |
// [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 5006 |
// [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 5007 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 5008 |
func (m NodeMemoryPagingFaults) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5009 |
if set.Len() == 0 { |
| 5010 |
m.Int64Counter.Add(ctx, incr) |
| 5011 |
return |
| 5012 |
} |
| 5013 |
|
| 5014 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5015 |
defer func() { |
| 5016 |
*o = (*o)[:0] |
| 5017 |
addOptPool.Put(o) |
| 5018 |
}() |
| 5019 |
|
| 5020 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5021 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 5022 |
} |
| 5023 |
|
| 5024 |
// AttrSystemPagingFaultType returns an optional attribute for the |
| 5025 |
// "system.paging.fault.type" semantic convention. It represents the paging fault |
| 5026 |
// type. |
| 5027 |
func (NodeMemoryPagingFaults) AttrSystemPagingFaultType(val SystemPagingFaultTypeAttr) attribute.KeyValue { |
| 5028 |
return attribute.String("system.paging.fault.type", string(val)) |
| 5029 |
} |
| 5030 |
|
| 5031 |
// NodeMemoryRss is an instrument used to record metric values conforming to the |
| 5032 |
// "k8s.node.memory.rss" semantic conventions. It represents the node memory RSS. |
| 5033 |
type NodeMemoryRss struct { |
| 5034 |
metric.Int64UpDownCounter |
| 5035 |
} |
| 5036 |
|
| 5037 |
var newNodeMemoryRssOpts = []metric.Int64UpDownCounterOption{ |
| 5038 |
metric.WithDescription("Node memory RSS."), |
| 5039 |
metric.WithUnit("By"), |
| 5040 |
} |
| 5041 |
|
| 5042 |
// NewNodeMemoryRss returns a new NodeMemoryRss instrument. |
| 5043 |
func NewNodeMemoryRss( |
| 5044 |
m metric.Meter, |
| 5045 |
opt ...metric.Int64UpDownCounterOption, |
| 5046 |
) (NodeMemoryRss, error) { |
| 5047 |
// Check if the meter is nil. |
| 5048 |
if m == nil { |
| 5049 |
return NodeMemoryRss{noop.Int64UpDownCounter{}}, nil |
| 5050 |
} |
| 5051 |
|
| 5052 |
if len(opt) == 0 { |
| 5053 |
opt = newNodeMemoryRssOpts |
| 5054 |
} else { |
| 5055 |
opt = append(opt, newNodeMemoryRssOpts...) |
| 5056 |
} |
| 5057 |
|
| 5058 |
i, err := m.Int64UpDownCounter( |
| 5059 |
"k8s.node.memory.rss", |
| 5060 |
opt..., |
| 5061 |
) |
| 5062 |
if err != nil { |
| 5063 |
return NodeMemoryRss{noop.Int64UpDownCounter{}}, err |
| 5064 |
} |
| 5065 |
return NodeMemoryRss{i}, nil |
| 5066 |
} |
| 5067 |
|
| 5068 |
// Inst returns the underlying metric instrument. |
| 5069 |
func (m NodeMemoryRss) Inst() metric.Int64UpDownCounter { |
| 5070 |
return m.Int64UpDownCounter |
| 5071 |
} |
| 5072 |
|
| 5073 |
// Name returns the semantic convention name of the instrument. |
| 5074 |
func (NodeMemoryRss) Name() string { |
| 5075 |
return "k8s.node.memory.rss" |
| 5076 |
} |
| 5077 |
|
| 5078 |
// Unit returns the semantic convention unit of the instrument |
| 5079 |
func (NodeMemoryRss) Unit() string { |
| 5080 |
return "By" |
| 5081 |
} |
| 5082 |
|
| 5083 |
// Description returns the semantic convention description of the instrument |
| 5084 |
func (NodeMemoryRss) Description() string { |
| 5085 |
return "Node memory RSS." |
| 5086 |
} |
| 5087 |
|
| 5088 |
// Add adds incr to the existing count for attrs. |
| 5089 |
// |
| 5090 |
// The amount of anonymous and swap cache memory (includes transparent |
| 5091 |
// hugepages). |
| 5092 |
// This metric is derived from the [MemoryStats.RSSBytes] field of the |
| 5093 |
// [NodeStats.Memory] of the Kubelet's stats API. |
| 5094 |
// |
| 5095 |
// [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 5096 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 5097 |
func (m NodeMemoryRss) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5098 |
if len(attrs) == 0 { |
| 5099 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5100 |
return |
| 5101 |
} |
| 5102 |
|
| 5103 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5104 |
defer func() { |
| 5105 |
*o = (*o)[:0] |
| 5106 |
addOptPool.Put(o) |
| 5107 |
}() |
| 5108 |
|
| 5109 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5110 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5111 |
} |
| 5112 |
|
| 5113 |
// AddSet adds incr to the existing count for set. |
| 5114 |
// |
| 5115 |
// The amount of anonymous and swap cache memory (includes transparent |
| 5116 |
// hugepages). |
| 5117 |
// This metric is derived from the [MemoryStats.RSSBytes] field of the |
| 5118 |
// [NodeStats.Memory] of the Kubelet's stats API. |
| 5119 |
// |
| 5120 |
// [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 5121 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 5122 |
func (m NodeMemoryRss) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5123 |
if set.Len() == 0 { |
| 5124 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5125 |
return |
| 5126 |
} |
| 5127 |
|
| 5128 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5129 |
defer func() { |
| 5130 |
*o = (*o)[:0] |
| 5131 |
addOptPool.Put(o) |
| 5132 |
}() |
| 5133 |
|
| 5134 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5135 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5136 |
} |
| 5137 |
|
| 5138 |
// NodeMemoryUsage is an instrument used to record metric values conforming to |
| 5139 |
// the "k8s.node.memory.usage" semantic conventions. It represents the memory |
| 5140 |
// usage of the Node. |
| 5141 |
type NodeMemoryUsage struct { |
| 5142 |
metric.Int64Gauge |
| 5143 |
} |
| 5144 |
|
| 5145 |
var newNodeMemoryUsageOpts = []metric.Int64GaugeOption{ |
| 5146 |
metric.WithDescription("Memory usage of the Node."), |
| 5147 |
metric.WithUnit("By"), |
| 5148 |
} |
| 5149 |
|
| 5150 |
// NewNodeMemoryUsage returns a new NodeMemoryUsage instrument. |
| 5151 |
func NewNodeMemoryUsage( |
| 5152 |
m metric.Meter, |
| 5153 |
opt ...metric.Int64GaugeOption, |
| 5154 |
) (NodeMemoryUsage, error) { |
| 5155 |
// Check if the meter is nil. |
| 5156 |
if m == nil { |
| 5157 |
return NodeMemoryUsage{noop.Int64Gauge{}}, nil |
| 5158 |
} |
| 5159 |
|
| 5160 |
if len(opt) == 0 { |
| 5161 |
opt = newNodeMemoryUsageOpts |
| 5162 |
} else { |
| 5163 |
opt = append(opt, newNodeMemoryUsageOpts...) |
| 5164 |
} |
| 5165 |
|
| 5166 |
i, err := m.Int64Gauge( |
| 5167 |
"k8s.node.memory.usage", |
| 5168 |
opt..., |
| 5169 |
) |
| 5170 |
if err != nil { |
| 5171 |
return NodeMemoryUsage{noop.Int64Gauge{}}, err |
| 5172 |
} |
| 5173 |
return NodeMemoryUsage{i}, nil |
| 5174 |
} |
| 5175 |
|
| 5176 |
// Inst returns the underlying metric instrument. |
| 5177 |
func (m NodeMemoryUsage) Inst() metric.Int64Gauge { |
| 5178 |
return m.Int64Gauge |
| 5179 |
} |
| 5180 |
|
| 5181 |
// Name returns the semantic convention name of the instrument. |
| 5182 |
func (NodeMemoryUsage) Name() string { |
| 5183 |
return "k8s.node.memory.usage" |
| 5184 |
} |
| 5185 |
|
| 5186 |
// Unit returns the semantic convention unit of the instrument |
| 5187 |
func (NodeMemoryUsage) Unit() string { |
| 5188 |
return "By" |
| 5189 |
} |
| 5190 |
|
| 5191 |
// Description returns the semantic convention description of the instrument |
| 5192 |
func (NodeMemoryUsage) Description() string { |
| 5193 |
return "Memory usage of the Node." |
| 5194 |
} |
| 5195 |
|
| 5196 |
// Record records val to the current distribution for attrs. |
| 5197 |
// |
| 5198 |
// Total memory usage of the Node |
| 5199 |
func (m NodeMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 5200 |
if len(attrs) == 0 { |
| 5201 |
m.Int64Gauge.Record(ctx, val) |
| 5202 |
return |
| 5203 |
} |
| 5204 |
|
| 5205 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5206 |
defer func() { |
| 5207 |
*o = (*o)[:0] |
| 5208 |
recOptPool.Put(o) |
| 5209 |
}() |
| 5210 |
|
| 5211 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5212 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5213 |
} |
| 5214 |
|
| 5215 |
// RecordSet records val to the current distribution for set. |
| 5216 |
// |
| 5217 |
// Total memory usage of the Node |
| 5218 |
func (m NodeMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 5219 |
if set.Len() == 0 { |
| 5220 |
m.Int64Gauge.Record(ctx, val) |
| 5221 |
return |
| 5222 |
} |
| 5223 |
|
| 5224 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5225 |
defer func() { |
| 5226 |
*o = (*o)[:0] |
| 5227 |
recOptPool.Put(o) |
| 5228 |
}() |
| 5229 |
|
| 5230 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5231 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5232 |
} |
| 5233 |
|
| 5234 |
// NodeMemoryWorkingSet is an instrument used to record metric values conforming |
| 5235 |
// to the "k8s.node.memory.working_set" semantic conventions. It represents the |
| 5236 |
// node memory working set. |
| 5237 |
type NodeMemoryWorkingSet struct { |
| 5238 |
metric.Int64UpDownCounter |
| 5239 |
} |
| 5240 |
|
| 5241 |
var newNodeMemoryWorkingSetOpts = []metric.Int64UpDownCounterOption{ |
| 5242 |
metric.WithDescription("Node memory working set."), |
| 5243 |
metric.WithUnit("By"), |
| 5244 |
} |
| 5245 |
|
| 5246 |
// NewNodeMemoryWorkingSet returns a new NodeMemoryWorkingSet instrument. |
| 5247 |
func NewNodeMemoryWorkingSet( |
| 5248 |
m metric.Meter, |
| 5249 |
opt ...metric.Int64UpDownCounterOption, |
| 5250 |
) (NodeMemoryWorkingSet, error) { |
| 5251 |
// Check if the meter is nil. |
| 5252 |
if m == nil { |
| 5253 |
return NodeMemoryWorkingSet{noop.Int64UpDownCounter{}}, nil |
| 5254 |
} |
| 5255 |
|
| 5256 |
if len(opt) == 0 { |
| 5257 |
opt = newNodeMemoryWorkingSetOpts |
| 5258 |
} else { |
| 5259 |
opt = append(opt, newNodeMemoryWorkingSetOpts...) |
| 5260 |
} |
| 5261 |
|
| 5262 |
i, err := m.Int64UpDownCounter( |
| 5263 |
"k8s.node.memory.working_set", |
| 5264 |
opt..., |
| 5265 |
) |
| 5266 |
if err != nil { |
| 5267 |
return NodeMemoryWorkingSet{noop.Int64UpDownCounter{}}, err |
| 5268 |
} |
| 5269 |
return NodeMemoryWorkingSet{i}, nil |
| 5270 |
} |
| 5271 |
|
| 5272 |
// Inst returns the underlying metric instrument. |
| 5273 |
func (m NodeMemoryWorkingSet) Inst() metric.Int64UpDownCounter { |
| 5274 |
return m.Int64UpDownCounter |
| 5275 |
} |
| 5276 |
|
| 5277 |
// Name returns the semantic convention name of the instrument. |
| 5278 |
func (NodeMemoryWorkingSet) Name() string { |
| 5279 |
return "k8s.node.memory.working_set" |
| 5280 |
} |
| 5281 |
|
| 5282 |
// Unit returns the semantic convention unit of the instrument |
| 5283 |
func (NodeMemoryWorkingSet) Unit() string { |
| 5284 |
return "By" |
| 5285 |
} |
| 5286 |
|
| 5287 |
// Description returns the semantic convention description of the instrument |
| 5288 |
func (NodeMemoryWorkingSet) Description() string { |
| 5289 |
return "Node memory working set." |
| 5290 |
} |
| 5291 |
|
| 5292 |
// Add adds incr to the existing count for attrs. |
| 5293 |
// |
| 5294 |
// The amount of working set memory. This includes recently accessed memory, |
| 5295 |
// dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes. |
| 5296 |
// This metric is derived from the [MemoryStats.WorkingSetBytes] field of the |
| 5297 |
// [NodeStats.Memory] of the Kubelet's stats API. |
| 5298 |
// |
| 5299 |
// [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 5300 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 5301 |
func (m NodeMemoryWorkingSet) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5302 |
if len(attrs) == 0 { |
| 5303 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5304 |
return |
| 5305 |
} |
| 5306 |
|
| 5307 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5308 |
defer func() { |
| 5309 |
*o = (*o)[:0] |
| 5310 |
addOptPool.Put(o) |
| 5311 |
}() |
| 5312 |
|
| 5313 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5314 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5315 |
} |
| 5316 |
|
| 5317 |
// AddSet adds incr to the existing count for set. |
| 5318 |
// |
| 5319 |
// The amount of working set memory. This includes recently accessed memory, |
| 5320 |
// dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes. |
| 5321 |
// This metric is derived from the [MemoryStats.WorkingSetBytes] field of the |
| 5322 |
// [NodeStats.Memory] of the Kubelet's stats API. |
| 5323 |
// |
| 5324 |
// [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 5325 |
// [NodeStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#NodeStats |
| 5326 |
func (m NodeMemoryWorkingSet) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5327 |
if set.Len() == 0 { |
| 5328 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5329 |
return |
| 5330 |
} |
| 5331 |
|
| 5332 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5333 |
defer func() { |
| 5334 |
*o = (*o)[:0] |
| 5335 |
addOptPool.Put(o) |
| 5336 |
}() |
| 5337 |
|
| 5338 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5339 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5340 |
} |
| 5341 |
|
| 5342 |
// NodeNetworkErrors is an instrument used to record metric values conforming to |
| 5343 |
// the "k8s.node.network.errors" semantic conventions. It represents the node |
| 5344 |
// network errors. |
| 5345 |
type NodeNetworkErrors struct { |
| 5346 |
metric.Int64Counter |
| 5347 |
} |
| 5348 |
|
| 5349 |
var newNodeNetworkErrorsOpts = []metric.Int64CounterOption{ |
| 5350 |
metric.WithDescription("Node network errors."), |
| 5351 |
metric.WithUnit("{error}"), |
| 5352 |
} |
| 5353 |
|
| 5354 |
// NewNodeNetworkErrors returns a new NodeNetworkErrors instrument. |
| 5355 |
func NewNodeNetworkErrors( |
| 5356 |
m metric.Meter, |
| 5357 |
opt ...metric.Int64CounterOption, |
| 5358 |
) (NodeNetworkErrors, error) { |
| 5359 |
// Check if the meter is nil. |
| 5360 |
if m == nil { |
| 5361 |
return NodeNetworkErrors{noop.Int64Counter{}}, nil |
| 5362 |
} |
| 5363 |
|
| 5364 |
if len(opt) == 0 { |
| 5365 |
opt = newNodeNetworkErrorsOpts |
| 5366 |
} else { |
| 5367 |
opt = append(opt, newNodeNetworkErrorsOpts...) |
| 5368 |
} |
| 5369 |
|
| 5370 |
i, err := m.Int64Counter( |
| 5371 |
"k8s.node.network.errors", |
| 5372 |
opt..., |
| 5373 |
) |
| 5374 |
if err != nil { |
| 5375 |
return NodeNetworkErrors{noop.Int64Counter{}}, err |
| 5376 |
} |
| 5377 |
return NodeNetworkErrors{i}, nil |
| 5378 |
} |
| 5379 |
|
| 5380 |
// Inst returns the underlying metric instrument. |
| 5381 |
func (m NodeNetworkErrors) Inst() metric.Int64Counter { |
| 5382 |
return m.Int64Counter |
| 5383 |
} |
| 5384 |
|
| 5385 |
// Name returns the semantic convention name of the instrument. |
| 5386 |
func (NodeNetworkErrors) Name() string { |
| 5387 |
return "k8s.node.network.errors" |
| 5388 |
} |
| 5389 |
|
| 5390 |
// Unit returns the semantic convention unit of the instrument |
| 5391 |
func (NodeNetworkErrors) Unit() string { |
| 5392 |
return "{error}" |
| 5393 |
} |
| 5394 |
|
| 5395 |
// Description returns the semantic convention description of the instrument |
| 5396 |
func (NodeNetworkErrors) Description() string { |
| 5397 |
return "Node network errors." |
| 5398 |
} |
| 5399 |
|
| 5400 |
// Add adds incr to the existing count for attrs. |
| 5401 |
// |
| 5402 |
// All additional attrs passed are included in the recorded value. |
| 5403 |
func (m NodeNetworkErrors) Add( |
| 5404 |
ctx context.Context, |
| 5405 |
incr int64, |
| 5406 |
attrs ...attribute.KeyValue, |
| 5407 |
) { |
| 5408 |
if len(attrs) == 0 { |
| 5409 |
m.Int64Counter.Add(ctx, incr) |
| 5410 |
return |
| 5411 |
} |
| 5412 |
|
| 5413 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5414 |
defer func() { |
| 5415 |
*o = (*o)[:0] |
| 5416 |
addOptPool.Put(o) |
| 5417 |
}() |
| 5418 |
|
| 5419 |
*o = append( |
| 5420 |
*o, |
| 5421 |
metric.WithAttributes( |
| 5422 |
attrs..., |
| 5423 |
), |
| 5424 |
) |
| 5425 |
|
| 5426 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 5427 |
} |
| 5428 |
|
| 5429 |
// AddSet adds incr to the existing count for set. |
| 5430 |
func (m NodeNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5431 |
if set.Len() == 0 { |
| 5432 |
m.Int64Counter.Add(ctx, incr) |
| 5433 |
return |
| 5434 |
} |
| 5435 |
|
| 5436 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5437 |
defer func() { |
| 5438 |
*o = (*o)[:0] |
| 5439 |
addOptPool.Put(o) |
| 5440 |
}() |
| 5441 |
|
| 5442 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5443 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 5444 |
} |
| 5445 |
|
| 5446 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 5447 |
// "network.interface.name" semantic convention. It represents the network |
| 5448 |
// interface name. |
| 5449 |
func (NodeNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 5450 |
return attribute.String("network.interface.name", val) |
| 5451 |
} |
| 5452 |
|
| 5453 |
// AttrNetworkIODirection returns an optional attribute for the |
| 5454 |
// "network.io.direction" semantic convention. It represents the network IO |
| 5455 |
// operation direction. |
| 5456 |
func (NodeNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 5457 |
return attribute.String("network.io.direction", string(val)) |
| 5458 |
} |
| 5459 |
|
| 5460 |
// NodeNetworkIO is an instrument used to record metric values conforming to the |
| 5461 |
// "k8s.node.network.io" semantic conventions. It represents the network bytes |
| 5462 |
// for the Node. |
| 5463 |
type NodeNetworkIO struct { |
| 5464 |
metric.Int64Counter |
| 5465 |
} |
| 5466 |
|
| 5467 |
var newNodeNetworkIOOpts = []metric.Int64CounterOption{ |
| 5468 |
metric.WithDescription("Network bytes for the Node."), |
| 5469 |
metric.WithUnit("By"), |
| 5470 |
} |
| 5471 |
|
| 5472 |
// NewNodeNetworkIO returns a new NodeNetworkIO instrument. |
| 5473 |
func NewNodeNetworkIO( |
| 5474 |
m metric.Meter, |
| 5475 |
opt ...metric.Int64CounterOption, |
| 5476 |
) (NodeNetworkIO, error) { |
| 5477 |
// Check if the meter is nil. |
| 5478 |
if m == nil { |
| 5479 |
return NodeNetworkIO{noop.Int64Counter{}}, nil |
| 5480 |
} |
| 5481 |
|
| 5482 |
if len(opt) == 0 { |
| 5483 |
opt = newNodeNetworkIOOpts |
| 5484 |
} else { |
| 5485 |
opt = append(opt, newNodeNetworkIOOpts...) |
| 5486 |
} |
| 5487 |
|
| 5488 |
i, err := m.Int64Counter( |
| 5489 |
"k8s.node.network.io", |
| 5490 |
opt..., |
| 5491 |
) |
| 5492 |
if err != nil { |
| 5493 |
return NodeNetworkIO{noop.Int64Counter{}}, err |
| 5494 |
} |
| 5495 |
return NodeNetworkIO{i}, nil |
| 5496 |
} |
| 5497 |
|
| 5498 |
// Inst returns the underlying metric instrument. |
| 5499 |
func (m NodeNetworkIO) Inst() metric.Int64Counter { |
| 5500 |
return m.Int64Counter |
| 5501 |
} |
| 5502 |
|
| 5503 |
// Name returns the semantic convention name of the instrument. |
| 5504 |
func (NodeNetworkIO) Name() string { |
| 5505 |
return "k8s.node.network.io" |
| 5506 |
} |
| 5507 |
|
| 5508 |
// Unit returns the semantic convention unit of the instrument |
| 5509 |
func (NodeNetworkIO) Unit() string { |
| 5510 |
return "By" |
| 5511 |
} |
| 5512 |
|
| 5513 |
// Description returns the semantic convention description of the instrument |
| 5514 |
func (NodeNetworkIO) Description() string { |
| 5515 |
return "Network bytes for the Node." |
| 5516 |
} |
| 5517 |
|
| 5518 |
// Add adds incr to the existing count for attrs. |
| 5519 |
// |
| 5520 |
// All additional attrs passed are included in the recorded value. |
| 5521 |
func (m NodeNetworkIO) Add( |
| 5522 |
ctx context.Context, |
| 5523 |
incr int64, |
| 5524 |
attrs ...attribute.KeyValue, |
| 5525 |
) { |
| 5526 |
if len(attrs) == 0 { |
| 5527 |
m.Int64Counter.Add(ctx, incr) |
| 5528 |
return |
| 5529 |
} |
| 5530 |
|
| 5531 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5532 |
defer func() { |
| 5533 |
*o = (*o)[:0] |
| 5534 |
addOptPool.Put(o) |
| 5535 |
}() |
| 5536 |
|
| 5537 |
*o = append( |
| 5538 |
*o, |
| 5539 |
metric.WithAttributes( |
| 5540 |
attrs..., |
| 5541 |
), |
| 5542 |
) |
| 5543 |
|
| 5544 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 5545 |
} |
| 5546 |
|
| 5547 |
// AddSet adds incr to the existing count for set. |
| 5548 |
func (m NodeNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5549 |
if set.Len() == 0 { |
| 5550 |
m.Int64Counter.Add(ctx, incr) |
| 5551 |
return |
| 5552 |
} |
| 5553 |
|
| 5554 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5555 |
defer func() { |
| 5556 |
*o = (*o)[:0] |
| 5557 |
addOptPool.Put(o) |
| 5558 |
}() |
| 5559 |
|
| 5560 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5561 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 5562 |
} |
| 5563 |
|
| 5564 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 5565 |
// "network.interface.name" semantic convention. It represents the network |
| 5566 |
// interface name. |
| 5567 |
func (NodeNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 5568 |
return attribute.String("network.interface.name", val) |
| 5569 |
} |
| 5570 |
|
| 5571 |
// AttrNetworkIODirection returns an optional attribute for the |
| 5572 |
// "network.io.direction" semantic convention. It represents the network IO |
| 5573 |
// operation direction. |
| 5574 |
func (NodeNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 5575 |
return attribute.String("network.io.direction", string(val)) |
| 5576 |
} |
| 5577 |
|
| 5578 |
// NodePodAllocatable is an instrument used to record metric values conforming to |
| 5579 |
// the "k8s.node.pod.allocatable" semantic conventions. It represents the amount |
| 5580 |
// of pods allocatable on the node. |
| 5581 |
type NodePodAllocatable struct { |
| 5582 |
metric.Int64UpDownCounter |
| 5583 |
} |
| 5584 |
|
| 5585 |
var newNodePodAllocatableOpts = []metric.Int64UpDownCounterOption{ |
| 5586 |
metric.WithDescription("Amount of pods allocatable on the node."), |
| 5587 |
metric.WithUnit("{pod}"), |
| 5588 |
} |
| 5589 |
|
| 5590 |
// NewNodePodAllocatable returns a new NodePodAllocatable instrument. |
| 5591 |
func NewNodePodAllocatable( |
| 5592 |
m metric.Meter, |
| 5593 |
opt ...metric.Int64UpDownCounterOption, |
| 5594 |
) (NodePodAllocatable, error) { |
| 5595 |
// Check if the meter is nil. |
| 5596 |
if m == nil { |
| 5597 |
return NodePodAllocatable{noop.Int64UpDownCounter{}}, nil |
| 5598 |
} |
| 5599 |
|
| 5600 |
if len(opt) == 0 { |
| 5601 |
opt = newNodePodAllocatableOpts |
| 5602 |
} else { |
| 5603 |
opt = append(opt, newNodePodAllocatableOpts...) |
| 5604 |
} |
| 5605 |
|
| 5606 |
i, err := m.Int64UpDownCounter( |
| 5607 |
"k8s.node.pod.allocatable", |
| 5608 |
opt..., |
| 5609 |
) |
| 5610 |
if err != nil { |
| 5611 |
return NodePodAllocatable{noop.Int64UpDownCounter{}}, err |
| 5612 |
} |
| 5613 |
return NodePodAllocatable{i}, nil |
| 5614 |
} |
| 5615 |
|
| 5616 |
// Inst returns the underlying metric instrument. |
| 5617 |
func (m NodePodAllocatable) Inst() metric.Int64UpDownCounter { |
| 5618 |
return m.Int64UpDownCounter |
| 5619 |
} |
| 5620 |
|
| 5621 |
// Name returns the semantic convention name of the instrument. |
| 5622 |
func (NodePodAllocatable) Name() string { |
| 5623 |
return "k8s.node.pod.allocatable" |
| 5624 |
} |
| 5625 |
|
| 5626 |
// Unit returns the semantic convention unit of the instrument |
| 5627 |
func (NodePodAllocatable) Unit() string { |
| 5628 |
return "{pod}" |
| 5629 |
} |
| 5630 |
|
| 5631 |
// Description returns the semantic convention description of the instrument |
| 5632 |
func (NodePodAllocatable) Description() string { |
| 5633 |
return "Amount of pods allocatable on the node." |
| 5634 |
} |
| 5635 |
|
| 5636 |
// Add adds incr to the existing count for attrs. |
| 5637 |
func (m NodePodAllocatable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5638 |
if len(attrs) == 0 { |
| 5639 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5640 |
return |
| 5641 |
} |
| 5642 |
|
| 5643 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5644 |
defer func() { |
| 5645 |
*o = (*o)[:0] |
| 5646 |
addOptPool.Put(o) |
| 5647 |
}() |
| 5648 |
|
| 5649 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5650 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5651 |
} |
| 5652 |
|
| 5653 |
// AddSet adds incr to the existing count for set. |
| 5654 |
func (m NodePodAllocatable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5655 |
if set.Len() == 0 { |
| 5656 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5657 |
return |
| 5658 |
} |
| 5659 |
|
| 5660 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5661 |
defer func() { |
| 5662 |
*o = (*o)[:0] |
| 5663 |
addOptPool.Put(o) |
| 5664 |
}() |
| 5665 |
|
| 5666 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5667 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5668 |
} |
| 5669 |
|
| 5670 |
// NodeUptime is an instrument used to record metric values conforming to the |
| 5671 |
// "k8s.node.uptime" semantic conventions. It represents the time the Node has |
| 5672 |
// been running. |
| 5673 |
type NodeUptime struct { |
| 5674 |
metric.Float64Gauge |
| 5675 |
} |
| 5676 |
|
| 5677 |
var newNodeUptimeOpts = []metric.Float64GaugeOption{ |
| 5678 |
metric.WithDescription("The time the Node has been running."), |
| 5679 |
metric.WithUnit("s"), |
| 5680 |
} |
| 5681 |
|
| 5682 |
// NewNodeUptime returns a new NodeUptime instrument. |
| 5683 |
func NewNodeUptime( |
| 5684 |
m metric.Meter, |
| 5685 |
opt ...metric.Float64GaugeOption, |
| 5686 |
) (NodeUptime, error) { |
| 5687 |
// Check if the meter is nil. |
| 5688 |
if m == nil { |
| 5689 |
return NodeUptime{noop.Float64Gauge{}}, nil |
| 5690 |
} |
| 5691 |
|
| 5692 |
if len(opt) == 0 { |
| 5693 |
opt = newNodeUptimeOpts |
| 5694 |
} else { |
| 5695 |
opt = append(opt, newNodeUptimeOpts...) |
| 5696 |
} |
| 5697 |
|
| 5698 |
i, err := m.Float64Gauge( |
| 5699 |
"k8s.node.uptime", |
| 5700 |
opt..., |
| 5701 |
) |
| 5702 |
if err != nil { |
| 5703 |
return NodeUptime{noop.Float64Gauge{}}, err |
| 5704 |
} |
| 5705 |
return NodeUptime{i}, nil |
| 5706 |
} |
| 5707 |
|
| 5708 |
// Inst returns the underlying metric instrument. |
| 5709 |
func (m NodeUptime) Inst() metric.Float64Gauge { |
| 5710 |
return m.Float64Gauge |
| 5711 |
} |
| 5712 |
|
| 5713 |
// Name returns the semantic convention name of the instrument. |
| 5714 |
func (NodeUptime) Name() string { |
| 5715 |
return "k8s.node.uptime" |
| 5716 |
} |
| 5717 |
|
| 5718 |
// Unit returns the semantic convention unit of the instrument |
| 5719 |
func (NodeUptime) Unit() string { |
| 5720 |
return "s" |
| 5721 |
} |
| 5722 |
|
| 5723 |
// Description returns the semantic convention description of the instrument |
| 5724 |
func (NodeUptime) Description() string { |
| 5725 |
return "The time the Node has been running." |
| 5726 |
} |
| 5727 |
|
| 5728 |
// Record records val to the current distribution for attrs. |
| 5729 |
// |
| 5730 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 5731 |
// seconds as a floating point number with the highest precision available. |
| 5732 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 5733 |
func (m NodeUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) { |
| 5734 |
if len(attrs) == 0 { |
| 5735 |
m.Float64Gauge.Record(ctx, val) |
| 5736 |
return |
| 5737 |
} |
| 5738 |
|
| 5739 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5740 |
defer func() { |
| 5741 |
*o = (*o)[:0] |
| 5742 |
recOptPool.Put(o) |
| 5743 |
}() |
| 5744 |
|
| 5745 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5746 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 5747 |
} |
| 5748 |
|
| 5749 |
// RecordSet records val to the current distribution for set. |
| 5750 |
// |
| 5751 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 5752 |
// seconds as a floating point number with the highest precision available. |
| 5753 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 5754 |
func (m NodeUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { |
| 5755 |
if set.Len() == 0 { |
| 5756 |
m.Float64Gauge.Record(ctx, val) |
| 5757 |
return |
| 5758 |
} |
| 5759 |
|
| 5760 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5761 |
defer func() { |
| 5762 |
*o = (*o)[:0] |
| 5763 |
recOptPool.Put(o) |
| 5764 |
}() |
| 5765 |
|
| 5766 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5767 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 5768 |
} |
| 5769 |
|
| 5770 |
// PodCPUTime is an instrument used to record metric values conforming to the |
| 5771 |
// "k8s.pod.cpu.time" semantic conventions. It represents the total CPU time |
| 5772 |
// consumed. |
| 5773 |
type PodCPUTime struct { |
| 5774 |
metric.Float64Counter |
| 5775 |
} |
| 5776 |
|
| 5777 |
var newPodCPUTimeOpts = []metric.Float64CounterOption{ |
| 5778 |
metric.WithDescription("Total CPU time consumed."), |
| 5779 |
metric.WithUnit("s"), |
| 5780 |
} |
| 5781 |
|
| 5782 |
// NewPodCPUTime returns a new PodCPUTime instrument. |
| 5783 |
func NewPodCPUTime( |
| 5784 |
m metric.Meter, |
| 5785 |
opt ...metric.Float64CounterOption, |
| 5786 |
) (PodCPUTime, error) { |
| 5787 |
// Check if the meter is nil. |
| 5788 |
if m == nil { |
| 5789 |
return PodCPUTime{noop.Float64Counter{}}, nil |
| 5790 |
} |
| 5791 |
|
| 5792 |
if len(opt) == 0 { |
| 5793 |
opt = newPodCPUTimeOpts |
| 5794 |
} else { |
| 5795 |
opt = append(opt, newPodCPUTimeOpts...) |
| 5796 |
} |
| 5797 |
|
| 5798 |
i, err := m.Float64Counter( |
| 5799 |
"k8s.pod.cpu.time", |
| 5800 |
opt..., |
| 5801 |
) |
| 5802 |
if err != nil { |
| 5803 |
return PodCPUTime{noop.Float64Counter{}}, err |
| 5804 |
} |
| 5805 |
return PodCPUTime{i}, nil |
| 5806 |
} |
| 5807 |
|
| 5808 |
// Inst returns the underlying metric instrument. |
| 5809 |
func (m PodCPUTime) Inst() metric.Float64Counter { |
| 5810 |
return m.Float64Counter |
| 5811 |
} |
| 5812 |
|
| 5813 |
// Name returns the semantic convention name of the instrument. |
| 5814 |
func (PodCPUTime) Name() string { |
| 5815 |
return "k8s.pod.cpu.time" |
| 5816 |
} |
| 5817 |
|
| 5818 |
// Unit returns the semantic convention unit of the instrument |
| 5819 |
func (PodCPUTime) Unit() string { |
| 5820 |
return "s" |
| 5821 |
} |
| 5822 |
|
| 5823 |
// Description returns the semantic convention description of the instrument |
| 5824 |
func (PodCPUTime) Description() string { |
| 5825 |
return "Total CPU time consumed." |
| 5826 |
} |
| 5827 |
|
| 5828 |
// Add adds incr to the existing count for attrs. |
| 5829 |
// |
| 5830 |
// Total CPU time consumed by the specific Pod on all available CPU cores |
| 5831 |
func (m PodCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { |
| 5832 |
if len(attrs) == 0 { |
| 5833 |
m.Float64Counter.Add(ctx, incr) |
| 5834 |
return |
| 5835 |
} |
| 5836 |
|
| 5837 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5838 |
defer func() { |
| 5839 |
*o = (*o)[:0] |
| 5840 |
addOptPool.Put(o) |
| 5841 |
}() |
| 5842 |
|
| 5843 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5844 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 5845 |
} |
| 5846 |
|
| 5847 |
// AddSet adds incr to the existing count for set. |
| 5848 |
// |
| 5849 |
// Total CPU time consumed by the specific Pod on all available CPU cores |
| 5850 |
func (m PodCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { |
| 5851 |
if set.Len() == 0 { |
| 5852 |
m.Float64Counter.Add(ctx, incr) |
| 5853 |
return |
| 5854 |
} |
| 5855 |
|
| 5856 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5857 |
defer func() { |
| 5858 |
*o = (*o)[:0] |
| 5859 |
addOptPool.Put(o) |
| 5860 |
}() |
| 5861 |
|
| 5862 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5863 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 5864 |
} |
| 5865 |
|
| 5866 |
// PodCPUUsage is an instrument used to record metric values conforming to the |
| 5867 |
// "k8s.pod.cpu.usage" semantic conventions. It represents the pod's CPU usage, |
| 5868 |
// measured in cpus. Range from 0 to the number of allocatable CPUs. |
| 5869 |
type PodCPUUsage struct { |
| 5870 |
metric.Int64Gauge |
| 5871 |
} |
| 5872 |
|
| 5873 |
var newPodCPUUsageOpts = []metric.Int64GaugeOption{ |
| 5874 |
metric.WithDescription("Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."), |
| 5875 |
metric.WithUnit("{cpu}"), |
| 5876 |
} |
| 5877 |
|
| 5878 |
// NewPodCPUUsage returns a new PodCPUUsage instrument. |
| 5879 |
func NewPodCPUUsage( |
| 5880 |
m metric.Meter, |
| 5881 |
opt ...metric.Int64GaugeOption, |
| 5882 |
) (PodCPUUsage, error) { |
| 5883 |
// Check if the meter is nil. |
| 5884 |
if m == nil { |
| 5885 |
return PodCPUUsage{noop.Int64Gauge{}}, nil |
| 5886 |
} |
| 5887 |
|
| 5888 |
if len(opt) == 0 { |
| 5889 |
opt = newPodCPUUsageOpts |
| 5890 |
} else { |
| 5891 |
opt = append(opt, newPodCPUUsageOpts...) |
| 5892 |
} |
| 5893 |
|
| 5894 |
i, err := m.Int64Gauge( |
| 5895 |
"k8s.pod.cpu.usage", |
| 5896 |
opt..., |
| 5897 |
) |
| 5898 |
if err != nil { |
| 5899 |
return PodCPUUsage{noop.Int64Gauge{}}, err |
| 5900 |
} |
| 5901 |
return PodCPUUsage{i}, nil |
| 5902 |
} |
| 5903 |
|
| 5904 |
// Inst returns the underlying metric instrument. |
| 5905 |
func (m PodCPUUsage) Inst() metric.Int64Gauge { |
| 5906 |
return m.Int64Gauge |
| 5907 |
} |
| 5908 |
|
| 5909 |
// Name returns the semantic convention name of the instrument. |
| 5910 |
func (PodCPUUsage) Name() string { |
| 5911 |
return "k8s.pod.cpu.usage" |
| 5912 |
} |
| 5913 |
|
| 5914 |
// Unit returns the semantic convention unit of the instrument |
| 5915 |
func (PodCPUUsage) Unit() string { |
| 5916 |
return "{cpu}" |
| 5917 |
} |
| 5918 |
|
| 5919 |
// Description returns the semantic convention description of the instrument |
| 5920 |
func (PodCPUUsage) Description() string { |
| 5921 |
return "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs." |
| 5922 |
} |
| 5923 |
|
| 5924 |
// Record records val to the current distribution for attrs. |
| 5925 |
// |
| 5926 |
// CPU usage of the specific Pod on all available CPU cores, averaged over the |
| 5927 |
// sample window |
| 5928 |
func (m PodCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 5929 |
if len(attrs) == 0 { |
| 5930 |
m.Int64Gauge.Record(ctx, val) |
| 5931 |
return |
| 5932 |
} |
| 5933 |
|
| 5934 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5935 |
defer func() { |
| 5936 |
*o = (*o)[:0] |
| 5937 |
recOptPool.Put(o) |
| 5938 |
}() |
| 5939 |
|
| 5940 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5941 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5942 |
} |
| 5943 |
|
| 5944 |
// RecordSet records val to the current distribution for set. |
| 5945 |
// |
| 5946 |
// CPU usage of the specific Pod on all available CPU cores, averaged over the |
| 5947 |
// sample window |
| 5948 |
func (m PodCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 5949 |
if set.Len() == 0 { |
| 5950 |
m.Int64Gauge.Record(ctx, val) |
| 5951 |
return |
| 5952 |
} |
| 5953 |
|
| 5954 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5955 |
defer func() { |
| 5956 |
*o = (*o)[:0] |
| 5957 |
recOptPool.Put(o) |
| 5958 |
}() |
| 5959 |
|
| 5960 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5961 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5962 |
} |
| 5963 |
|
| 5964 |
// PodFilesystemAvailable is an instrument used to record metric values |
| 5965 |
// conforming to the "k8s.pod.filesystem.available" semantic conventions. It |
| 5966 |
// represents the pod filesystem available bytes. |
| 5967 |
type PodFilesystemAvailable struct { |
| 5968 |
metric.Int64UpDownCounter |
| 5969 |
} |
| 5970 |
|
| 5971 |
var newPodFilesystemAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 5972 |
metric.WithDescription("Pod filesystem available bytes."), |
| 5973 |
metric.WithUnit("By"), |
| 5974 |
} |
| 5975 |
|
| 5976 |
// NewPodFilesystemAvailable returns a new PodFilesystemAvailable instrument. |
| 5977 |
func NewPodFilesystemAvailable( |
| 5978 |
m metric.Meter, |
| 5979 |
opt ...metric.Int64UpDownCounterOption, |
| 5980 |
) (PodFilesystemAvailable, error) { |
| 5981 |
// Check if the meter is nil. |
| 5982 |
if m == nil { |
| 5983 |
return PodFilesystemAvailable{noop.Int64UpDownCounter{}}, nil |
| 5984 |
} |
| 5985 |
|
| 5986 |
if len(opt) == 0 { |
| 5987 |
opt = newPodFilesystemAvailableOpts |
| 5988 |
} else { |
| 5989 |
opt = append(opt, newPodFilesystemAvailableOpts...) |
| 5990 |
} |
| 5991 |
|
| 5992 |
i, err := m.Int64UpDownCounter( |
| 5993 |
"k8s.pod.filesystem.available", |
| 5994 |
opt..., |
| 5995 |
) |
| 5996 |
if err != nil { |
| 5997 |
return PodFilesystemAvailable{noop.Int64UpDownCounter{}}, err |
| 5998 |
} |
| 5999 |
return PodFilesystemAvailable{i}, nil |
| 6000 |
} |
| 6001 |
|
| 6002 |
// Inst returns the underlying metric instrument. |
| 6003 |
func (m PodFilesystemAvailable) Inst() metric.Int64UpDownCounter { |
| 6004 |
return m.Int64UpDownCounter |
| 6005 |
} |
| 6006 |
|
| 6007 |
// Name returns the semantic convention name of the instrument. |
| 6008 |
func (PodFilesystemAvailable) Name() string { |
| 6009 |
return "k8s.pod.filesystem.available" |
| 6010 |
} |
| 6011 |
|
| 6012 |
// Unit returns the semantic convention unit of the instrument |
| 6013 |
func (PodFilesystemAvailable) Unit() string { |
| 6014 |
return "By" |
| 6015 |
} |
| 6016 |
|
| 6017 |
// Description returns the semantic convention description of the instrument |
| 6018 |
func (PodFilesystemAvailable) Description() string { |
| 6019 |
return "Pod filesystem available bytes." |
| 6020 |
} |
| 6021 |
|
| 6022 |
// Add adds incr to the existing count for attrs. |
| 6023 |
// |
| 6024 |
// This metric is derived from the |
| 6025 |
// [FsStats.AvailableBytes] field |
| 6026 |
// of the [PodStats.EphemeralStorage] |
| 6027 |
// of the Kubelet's stats API. |
| 6028 |
// |
| 6029 |
// [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 6030 |
// [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6031 |
func (m PodFilesystemAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6032 |
if len(attrs) == 0 { |
| 6033 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6034 |
return |
| 6035 |
} |
| 6036 |
|
| 6037 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6038 |
defer func() { |
| 6039 |
*o = (*o)[:0] |
| 6040 |
addOptPool.Put(o) |
| 6041 |
}() |
| 6042 |
|
| 6043 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6044 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6045 |
} |
| 6046 |
|
| 6047 |
// AddSet adds incr to the existing count for set. |
| 6048 |
// |
| 6049 |
// This metric is derived from the |
| 6050 |
// [FsStats.AvailableBytes] field |
| 6051 |
// of the [PodStats.EphemeralStorage] |
| 6052 |
// of the Kubelet's stats API. |
| 6053 |
// |
| 6054 |
// [FsStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 6055 |
// [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6056 |
func (m PodFilesystemAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6057 |
if set.Len() == 0 { |
| 6058 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6059 |
return |
| 6060 |
} |
| 6061 |
|
| 6062 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6063 |
defer func() { |
| 6064 |
*o = (*o)[:0] |
| 6065 |
addOptPool.Put(o) |
| 6066 |
}() |
| 6067 |
|
| 6068 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6069 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6070 |
} |
| 6071 |
|
| 6072 |
// PodFilesystemCapacity is an instrument used to record metric values conforming |
| 6073 |
// to the "k8s.pod.filesystem.capacity" semantic conventions. It represents the |
| 6074 |
// pod filesystem capacity. |
| 6075 |
type PodFilesystemCapacity struct { |
| 6076 |
metric.Int64UpDownCounter |
| 6077 |
} |
| 6078 |
|
| 6079 |
var newPodFilesystemCapacityOpts = []metric.Int64UpDownCounterOption{ |
| 6080 |
metric.WithDescription("Pod filesystem capacity."), |
| 6081 |
metric.WithUnit("By"), |
| 6082 |
} |
| 6083 |
|
| 6084 |
// NewPodFilesystemCapacity returns a new PodFilesystemCapacity instrument. |
| 6085 |
func NewPodFilesystemCapacity( |
| 6086 |
m metric.Meter, |
| 6087 |
opt ...metric.Int64UpDownCounterOption, |
| 6088 |
) (PodFilesystemCapacity, error) { |
| 6089 |
// Check if the meter is nil. |
| 6090 |
if m == nil { |
| 6091 |
return PodFilesystemCapacity{noop.Int64UpDownCounter{}}, nil |
| 6092 |
} |
| 6093 |
|
| 6094 |
if len(opt) == 0 { |
| 6095 |
opt = newPodFilesystemCapacityOpts |
| 6096 |
} else { |
| 6097 |
opt = append(opt, newPodFilesystemCapacityOpts...) |
| 6098 |
} |
| 6099 |
|
| 6100 |
i, err := m.Int64UpDownCounter( |
| 6101 |
"k8s.pod.filesystem.capacity", |
| 6102 |
opt..., |
| 6103 |
) |
| 6104 |
if err != nil { |
| 6105 |
return PodFilesystemCapacity{noop.Int64UpDownCounter{}}, err |
| 6106 |
} |
| 6107 |
return PodFilesystemCapacity{i}, nil |
| 6108 |
} |
| 6109 |
|
| 6110 |
// Inst returns the underlying metric instrument. |
| 6111 |
func (m PodFilesystemCapacity) Inst() metric.Int64UpDownCounter { |
| 6112 |
return m.Int64UpDownCounter |
| 6113 |
} |
| 6114 |
|
| 6115 |
// Name returns the semantic convention name of the instrument. |
| 6116 |
func (PodFilesystemCapacity) Name() string { |
| 6117 |
return "k8s.pod.filesystem.capacity" |
| 6118 |
} |
| 6119 |
|
| 6120 |
// Unit returns the semantic convention unit of the instrument |
| 6121 |
func (PodFilesystemCapacity) Unit() string { |
| 6122 |
return "By" |
| 6123 |
} |
| 6124 |
|
| 6125 |
// Description returns the semantic convention description of the instrument |
| 6126 |
func (PodFilesystemCapacity) Description() string { |
| 6127 |
return "Pod filesystem capacity." |
| 6128 |
} |
| 6129 |
|
| 6130 |
// Add adds incr to the existing count for attrs. |
| 6131 |
// |
| 6132 |
// This metric is derived from the |
| 6133 |
// [FsStats.CapacityBytes] field |
| 6134 |
// of the [PodStats.EphemeralStorage] |
| 6135 |
// of the Kubelet's stats API. |
| 6136 |
// |
| 6137 |
// [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 6138 |
// [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6139 |
func (m PodFilesystemCapacity) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6140 |
if len(attrs) == 0 { |
| 6141 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6142 |
return |
| 6143 |
} |
| 6144 |
|
| 6145 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6146 |
defer func() { |
| 6147 |
*o = (*o)[:0] |
| 6148 |
addOptPool.Put(o) |
| 6149 |
}() |
| 6150 |
|
| 6151 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6152 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6153 |
} |
| 6154 |
|
| 6155 |
// AddSet adds incr to the existing count for set. |
| 6156 |
// |
| 6157 |
// This metric is derived from the |
| 6158 |
// [FsStats.CapacityBytes] field |
| 6159 |
// of the [PodStats.EphemeralStorage] |
| 6160 |
// of the Kubelet's stats API. |
| 6161 |
// |
| 6162 |
// [FsStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 6163 |
// [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6164 |
func (m PodFilesystemCapacity) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6165 |
if set.Len() == 0 { |
| 6166 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6167 |
return |
| 6168 |
} |
| 6169 |
|
| 6170 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6171 |
defer func() { |
| 6172 |
*o = (*o)[:0] |
| 6173 |
addOptPool.Put(o) |
| 6174 |
}() |
| 6175 |
|
| 6176 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6177 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6178 |
} |
| 6179 |
|
| 6180 |
// PodFilesystemUsage is an instrument used to record metric values conforming to |
| 6181 |
// the "k8s.pod.filesystem.usage" semantic conventions. It represents the pod |
| 6182 |
// filesystem usage. |
| 6183 |
type PodFilesystemUsage struct { |
| 6184 |
metric.Int64UpDownCounter |
| 6185 |
} |
| 6186 |
|
| 6187 |
var newPodFilesystemUsageOpts = []metric.Int64UpDownCounterOption{ |
| 6188 |
metric.WithDescription("Pod filesystem usage."), |
| 6189 |
metric.WithUnit("By"), |
| 6190 |
} |
| 6191 |
|
| 6192 |
// NewPodFilesystemUsage returns a new PodFilesystemUsage instrument. |
| 6193 |
func NewPodFilesystemUsage( |
| 6194 |
m metric.Meter, |
| 6195 |
opt ...metric.Int64UpDownCounterOption, |
| 6196 |
) (PodFilesystemUsage, error) { |
| 6197 |
// Check if the meter is nil. |
| 6198 |
if m == nil { |
| 6199 |
return PodFilesystemUsage{noop.Int64UpDownCounter{}}, nil |
| 6200 |
} |
| 6201 |
|
| 6202 |
if len(opt) == 0 { |
| 6203 |
opt = newPodFilesystemUsageOpts |
| 6204 |
} else { |
| 6205 |
opt = append(opt, newPodFilesystemUsageOpts...) |
| 6206 |
} |
| 6207 |
|
| 6208 |
i, err := m.Int64UpDownCounter( |
| 6209 |
"k8s.pod.filesystem.usage", |
| 6210 |
opt..., |
| 6211 |
) |
| 6212 |
if err != nil { |
| 6213 |
return PodFilesystemUsage{noop.Int64UpDownCounter{}}, err |
| 6214 |
} |
| 6215 |
return PodFilesystemUsage{i}, nil |
| 6216 |
} |
| 6217 |
|
| 6218 |
// Inst returns the underlying metric instrument. |
| 6219 |
func (m PodFilesystemUsage) Inst() metric.Int64UpDownCounter { |
| 6220 |
return m.Int64UpDownCounter |
| 6221 |
} |
| 6222 |
|
| 6223 |
// Name returns the semantic convention name of the instrument. |
| 6224 |
func (PodFilesystemUsage) Name() string { |
| 6225 |
return "k8s.pod.filesystem.usage" |
| 6226 |
} |
| 6227 |
|
| 6228 |
// Unit returns the semantic convention unit of the instrument |
| 6229 |
func (PodFilesystemUsage) Unit() string { |
| 6230 |
return "By" |
| 6231 |
} |
| 6232 |
|
| 6233 |
// Description returns the semantic convention description of the instrument |
| 6234 |
func (PodFilesystemUsage) Description() string { |
| 6235 |
return "Pod filesystem usage." |
| 6236 |
} |
| 6237 |
|
| 6238 |
// Add adds incr to the existing count for attrs. |
| 6239 |
// |
| 6240 |
// This may not equal capacity - available. |
| 6241 |
// |
| 6242 |
// This metric is derived from the |
| 6243 |
// [FsStats.UsedBytes] field |
| 6244 |
// of the [PodStats.EphemeralStorage] |
| 6245 |
// of the Kubelet's stats API. |
| 6246 |
// |
| 6247 |
// [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 6248 |
// [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6249 |
func (m PodFilesystemUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6250 |
if len(attrs) == 0 { |
| 6251 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6252 |
return |
| 6253 |
} |
| 6254 |
|
| 6255 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6256 |
defer func() { |
| 6257 |
*o = (*o)[:0] |
| 6258 |
addOptPool.Put(o) |
| 6259 |
}() |
| 6260 |
|
| 6261 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6262 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6263 |
} |
| 6264 |
|
| 6265 |
// AddSet adds incr to the existing count for set. |
| 6266 |
// |
| 6267 |
// This may not equal capacity - available. |
| 6268 |
// |
| 6269 |
// This metric is derived from the |
| 6270 |
// [FsStats.UsedBytes] field |
| 6271 |
// of the [PodStats.EphemeralStorage] |
| 6272 |
// of the Kubelet's stats API. |
| 6273 |
// |
| 6274 |
// [FsStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#FsStats |
| 6275 |
// [PodStats.EphemeralStorage]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6276 |
func (m PodFilesystemUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6277 |
if set.Len() == 0 { |
| 6278 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6279 |
return |
| 6280 |
} |
| 6281 |
|
| 6282 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6283 |
defer func() { |
| 6284 |
*o = (*o)[:0] |
| 6285 |
addOptPool.Put(o) |
| 6286 |
}() |
| 6287 |
|
| 6288 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6289 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6290 |
} |
| 6291 |
|
| 6292 |
// PodMemoryAvailable is an instrument used to record metric values conforming to |
| 6293 |
// the "k8s.pod.memory.available" semantic conventions. It represents the pod |
| 6294 |
// memory available. |
| 6295 |
type PodMemoryAvailable struct { |
| 6296 |
metric.Int64UpDownCounter |
| 6297 |
} |
| 6298 |
|
| 6299 |
var newPodMemoryAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 6300 |
metric.WithDescription("Pod memory available."), |
| 6301 |
metric.WithUnit("By"), |
| 6302 |
} |
| 6303 |
|
| 6304 |
// NewPodMemoryAvailable returns a new PodMemoryAvailable instrument. |
| 6305 |
func NewPodMemoryAvailable( |
| 6306 |
m metric.Meter, |
| 6307 |
opt ...metric.Int64UpDownCounterOption, |
| 6308 |
) (PodMemoryAvailable, error) { |
| 6309 |
// Check if the meter is nil. |
| 6310 |
if m == nil { |
| 6311 |
return PodMemoryAvailable{noop.Int64UpDownCounter{}}, nil |
| 6312 |
} |
| 6313 |
|
| 6314 |
if len(opt) == 0 { |
| 6315 |
opt = newPodMemoryAvailableOpts |
| 6316 |
} else { |
| 6317 |
opt = append(opt, newPodMemoryAvailableOpts...) |
| 6318 |
} |
| 6319 |
|
| 6320 |
i, err := m.Int64UpDownCounter( |
| 6321 |
"k8s.pod.memory.available", |
| 6322 |
opt..., |
| 6323 |
) |
| 6324 |
if err != nil { |
| 6325 |
return PodMemoryAvailable{noop.Int64UpDownCounter{}}, err |
| 6326 |
} |
| 6327 |
return PodMemoryAvailable{i}, nil |
| 6328 |
} |
| 6329 |
|
| 6330 |
// Inst returns the underlying metric instrument. |
| 6331 |
func (m PodMemoryAvailable) Inst() metric.Int64UpDownCounter { |
| 6332 |
return m.Int64UpDownCounter |
| 6333 |
} |
| 6334 |
|
| 6335 |
// Name returns the semantic convention name of the instrument. |
| 6336 |
func (PodMemoryAvailable) Name() string { |
| 6337 |
return "k8s.pod.memory.available" |
| 6338 |
} |
| 6339 |
|
| 6340 |
// Unit returns the semantic convention unit of the instrument |
| 6341 |
func (PodMemoryAvailable) Unit() string { |
| 6342 |
return "By" |
| 6343 |
} |
| 6344 |
|
| 6345 |
// Description returns the semantic convention description of the instrument |
| 6346 |
func (PodMemoryAvailable) Description() string { |
| 6347 |
return "Pod memory available." |
| 6348 |
} |
| 6349 |
|
| 6350 |
// Add adds incr to the existing count for attrs. |
| 6351 |
// |
| 6352 |
// Available memory for use. This is defined as the memory limit - |
| 6353 |
// workingSetBytes. If memory limit is undefined, the available bytes is omitted. |
| 6354 |
// This metric is derived from the [MemoryStats.AvailableBytes] field of the |
| 6355 |
// [PodStats.Memory] of the Kubelet's stats API. |
| 6356 |
// |
| 6357 |
// [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6358 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6359 |
func (m PodMemoryAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6360 |
if len(attrs) == 0 { |
| 6361 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6362 |
return |
| 6363 |
} |
| 6364 |
|
| 6365 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6366 |
defer func() { |
| 6367 |
*o = (*o)[:0] |
| 6368 |
addOptPool.Put(o) |
| 6369 |
}() |
| 6370 |
|
| 6371 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6372 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6373 |
} |
| 6374 |
|
| 6375 |
// AddSet adds incr to the existing count for set. |
| 6376 |
// |
| 6377 |
// Available memory for use. This is defined as the memory limit - |
| 6378 |
// workingSetBytes. If memory limit is undefined, the available bytes is omitted. |
| 6379 |
// This metric is derived from the [MemoryStats.AvailableBytes] field of the |
| 6380 |
// [PodStats.Memory] of the Kubelet's stats API. |
| 6381 |
// |
| 6382 |
// [MemoryStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6383 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6384 |
func (m PodMemoryAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6385 |
if set.Len() == 0 { |
| 6386 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6387 |
return |
| 6388 |
} |
| 6389 |
|
| 6390 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6391 |
defer func() { |
| 6392 |
*o = (*o)[:0] |
| 6393 |
addOptPool.Put(o) |
| 6394 |
}() |
| 6395 |
|
| 6396 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6397 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6398 |
} |
| 6399 |
|
| 6400 |
// PodMemoryPagingFaults is an instrument used to record metric values conforming |
| 6401 |
// to the "k8s.pod.memory.paging.faults" semantic conventions. It represents the |
| 6402 |
// pod memory paging faults. |
| 6403 |
type PodMemoryPagingFaults struct { |
| 6404 |
metric.Int64Counter |
| 6405 |
} |
| 6406 |
|
| 6407 |
var newPodMemoryPagingFaultsOpts = []metric.Int64CounterOption{ |
| 6408 |
metric.WithDescription("Pod memory paging faults."), |
| 6409 |
metric.WithUnit("{fault}"), |
| 6410 |
} |
| 6411 |
|
| 6412 |
// NewPodMemoryPagingFaults returns a new PodMemoryPagingFaults instrument. |
| 6413 |
func NewPodMemoryPagingFaults( |
| 6414 |
m metric.Meter, |
| 6415 |
opt ...metric.Int64CounterOption, |
| 6416 |
) (PodMemoryPagingFaults, error) { |
| 6417 |
// Check if the meter is nil. |
| 6418 |
if m == nil { |
| 6419 |
return PodMemoryPagingFaults{noop.Int64Counter{}}, nil |
| 6420 |
} |
| 6421 |
|
| 6422 |
if len(opt) == 0 { |
| 6423 |
opt = newPodMemoryPagingFaultsOpts |
| 6424 |
} else { |
| 6425 |
opt = append(opt, newPodMemoryPagingFaultsOpts...) |
| 6426 |
} |
| 6427 |
|
| 6428 |
i, err := m.Int64Counter( |
| 6429 |
"k8s.pod.memory.paging.faults", |
| 6430 |
opt..., |
| 6431 |
) |
| 6432 |
if err != nil { |
| 6433 |
return PodMemoryPagingFaults{noop.Int64Counter{}}, err |
| 6434 |
} |
| 6435 |
return PodMemoryPagingFaults{i}, nil |
| 6436 |
} |
| 6437 |
|
| 6438 |
// Inst returns the underlying metric instrument. |
| 6439 |
func (m PodMemoryPagingFaults) Inst() metric.Int64Counter { |
| 6440 |
return m.Int64Counter |
| 6441 |
} |
| 6442 |
|
| 6443 |
// Name returns the semantic convention name of the instrument. |
| 6444 |
func (PodMemoryPagingFaults) Name() string { |
| 6445 |
return "k8s.pod.memory.paging.faults" |
| 6446 |
} |
| 6447 |
|
| 6448 |
// Unit returns the semantic convention unit of the instrument |
| 6449 |
func (PodMemoryPagingFaults) Unit() string { |
| 6450 |
return "{fault}" |
| 6451 |
} |
| 6452 |
|
| 6453 |
// Description returns the semantic convention description of the instrument |
| 6454 |
func (PodMemoryPagingFaults) Description() string { |
| 6455 |
return "Pod memory paging faults." |
| 6456 |
} |
| 6457 |
|
| 6458 |
// Add adds incr to the existing count for attrs. |
| 6459 |
// |
| 6460 |
// All additional attrs passed are included in the recorded value. |
| 6461 |
// |
| 6462 |
// Cumulative number of major/minor page faults. |
| 6463 |
// This metric is derived from the [MemoryStats.PageFaults] and |
| 6464 |
// [MemoryStats.MajorPageFaults] field of the [PodStats.Memory] of the Kubelet's |
| 6465 |
// stats API. |
| 6466 |
// |
| 6467 |
// [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6468 |
// [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6469 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6470 |
func (m PodMemoryPagingFaults) Add( |
| 6471 |
ctx context.Context, |
| 6472 |
incr int64, |
| 6473 |
attrs ...attribute.KeyValue, |
| 6474 |
) { |
| 6475 |
if len(attrs) == 0 { |
| 6476 |
m.Int64Counter.Add(ctx, incr) |
| 6477 |
return |
| 6478 |
} |
| 6479 |
|
| 6480 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6481 |
defer func() { |
| 6482 |
*o = (*o)[:0] |
| 6483 |
addOptPool.Put(o) |
| 6484 |
}() |
| 6485 |
|
| 6486 |
*o = append( |
| 6487 |
*o, |
| 6488 |
metric.WithAttributes( |
| 6489 |
attrs..., |
| 6490 |
), |
| 6491 |
) |
| 6492 |
|
| 6493 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 6494 |
} |
| 6495 |
|
| 6496 |
// AddSet adds incr to the existing count for set. |
| 6497 |
// |
| 6498 |
// Cumulative number of major/minor page faults. |
| 6499 |
// This metric is derived from the [MemoryStats.PageFaults] and |
| 6500 |
// [MemoryStats.MajorPageFaults] field of the [PodStats.Memory] of the Kubelet's |
| 6501 |
// stats API. |
| 6502 |
// |
| 6503 |
// [MemoryStats.PageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6504 |
// [MemoryStats.MajorPageFaults]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6505 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6506 |
func (m PodMemoryPagingFaults) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6507 |
if set.Len() == 0 { |
| 6508 |
m.Int64Counter.Add(ctx, incr) |
| 6509 |
return |
| 6510 |
} |
| 6511 |
|
| 6512 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6513 |
defer func() { |
| 6514 |
*o = (*o)[:0] |
| 6515 |
addOptPool.Put(o) |
| 6516 |
}() |
| 6517 |
|
| 6518 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6519 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 6520 |
} |
| 6521 |
|
| 6522 |
// AttrSystemPagingFaultType returns an optional attribute for the |
| 6523 |
// "system.paging.fault.type" semantic convention. It represents the paging fault |
| 6524 |
// type. |
| 6525 |
func (PodMemoryPagingFaults) AttrSystemPagingFaultType(val SystemPagingFaultTypeAttr) attribute.KeyValue { |
| 6526 |
return attribute.String("system.paging.fault.type", string(val)) |
| 6527 |
} |
| 6528 |
|
| 6529 |
// PodMemoryRss is an instrument used to record metric values conforming to the |
| 6530 |
// "k8s.pod.memory.rss" semantic conventions. It represents the pod memory RSS. |
| 6531 |
type PodMemoryRss struct { |
| 6532 |
metric.Int64UpDownCounter |
| 6533 |
} |
| 6534 |
|
| 6535 |
var newPodMemoryRssOpts = []metric.Int64UpDownCounterOption{ |
| 6536 |
metric.WithDescription("Pod memory RSS."), |
| 6537 |
metric.WithUnit("By"), |
| 6538 |
} |
| 6539 |
|
| 6540 |
// NewPodMemoryRss returns a new PodMemoryRss instrument. |
| 6541 |
func NewPodMemoryRss( |
| 6542 |
m metric.Meter, |
| 6543 |
opt ...metric.Int64UpDownCounterOption, |
| 6544 |
) (PodMemoryRss, error) { |
| 6545 |
// Check if the meter is nil. |
| 6546 |
if m == nil { |
| 6547 |
return PodMemoryRss{noop.Int64UpDownCounter{}}, nil |
| 6548 |
} |
| 6549 |
|
| 6550 |
if len(opt) == 0 { |
| 6551 |
opt = newPodMemoryRssOpts |
| 6552 |
} else { |
| 6553 |
opt = append(opt, newPodMemoryRssOpts...) |
| 6554 |
} |
| 6555 |
|
| 6556 |
i, err := m.Int64UpDownCounter( |
| 6557 |
"k8s.pod.memory.rss", |
| 6558 |
opt..., |
| 6559 |
) |
| 6560 |
if err != nil { |
| 6561 |
return PodMemoryRss{noop.Int64UpDownCounter{}}, err |
| 6562 |
} |
| 6563 |
return PodMemoryRss{i}, nil |
| 6564 |
} |
| 6565 |
|
| 6566 |
// Inst returns the underlying metric instrument. |
| 6567 |
func (m PodMemoryRss) Inst() metric.Int64UpDownCounter { |
| 6568 |
return m.Int64UpDownCounter |
| 6569 |
} |
| 6570 |
|
| 6571 |
// Name returns the semantic convention name of the instrument. |
| 6572 |
func (PodMemoryRss) Name() string { |
| 6573 |
return "k8s.pod.memory.rss" |
| 6574 |
} |
| 6575 |
|
| 6576 |
// Unit returns the semantic convention unit of the instrument |
| 6577 |
func (PodMemoryRss) Unit() string { |
| 6578 |
return "By" |
| 6579 |
} |
| 6580 |
|
| 6581 |
// Description returns the semantic convention description of the instrument |
| 6582 |
func (PodMemoryRss) Description() string { |
| 6583 |
return "Pod memory RSS." |
| 6584 |
} |
| 6585 |
|
| 6586 |
// Add adds incr to the existing count for attrs. |
| 6587 |
// |
| 6588 |
// The amount of anonymous and swap cache memory (includes transparent |
| 6589 |
// hugepages). |
| 6590 |
// This metric is derived from the [MemoryStats.RSSBytes] field of the |
| 6591 |
// [PodStats.Memory] of the Kubelet's stats API. |
| 6592 |
// |
| 6593 |
// [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6594 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6595 |
func (m PodMemoryRss) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6596 |
if len(attrs) == 0 { |
| 6597 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6598 |
return |
| 6599 |
} |
| 6600 |
|
| 6601 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6602 |
defer func() { |
| 6603 |
*o = (*o)[:0] |
| 6604 |
addOptPool.Put(o) |
| 6605 |
}() |
| 6606 |
|
| 6607 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6608 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6609 |
} |
| 6610 |
|
| 6611 |
// AddSet adds incr to the existing count for set. |
| 6612 |
// |
| 6613 |
// The amount of anonymous and swap cache memory (includes transparent |
| 6614 |
// hugepages). |
| 6615 |
// This metric is derived from the [MemoryStats.RSSBytes] field of the |
| 6616 |
// [PodStats.Memory] of the Kubelet's stats API. |
| 6617 |
// |
| 6618 |
// [MemoryStats.RSSBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6619 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6620 |
func (m PodMemoryRss) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6621 |
if set.Len() == 0 { |
| 6622 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6623 |
return |
| 6624 |
} |
| 6625 |
|
| 6626 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6627 |
defer func() { |
| 6628 |
*o = (*o)[:0] |
| 6629 |
addOptPool.Put(o) |
| 6630 |
}() |
| 6631 |
|
| 6632 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6633 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6634 |
} |
| 6635 |
|
| 6636 |
// PodMemoryUsage is an instrument used to record metric values conforming to the |
| 6637 |
// "k8s.pod.memory.usage" semantic conventions. It represents the memory usage of |
| 6638 |
// the Pod. |
| 6639 |
type PodMemoryUsage struct { |
| 6640 |
metric.Int64Gauge |
| 6641 |
} |
| 6642 |
|
| 6643 |
var newPodMemoryUsageOpts = []metric.Int64GaugeOption{ |
| 6644 |
metric.WithDescription("Memory usage of the Pod."), |
| 6645 |
metric.WithUnit("By"), |
| 6646 |
} |
| 6647 |
|
| 6648 |
// NewPodMemoryUsage returns a new PodMemoryUsage instrument. |
| 6649 |
func NewPodMemoryUsage( |
| 6650 |
m metric.Meter, |
| 6651 |
opt ...metric.Int64GaugeOption, |
| 6652 |
) (PodMemoryUsage, error) { |
| 6653 |
// Check if the meter is nil. |
| 6654 |
if m == nil { |
| 6655 |
return PodMemoryUsage{noop.Int64Gauge{}}, nil |
| 6656 |
} |
| 6657 |
|
| 6658 |
if len(opt) == 0 { |
| 6659 |
opt = newPodMemoryUsageOpts |
| 6660 |
} else { |
| 6661 |
opt = append(opt, newPodMemoryUsageOpts...) |
| 6662 |
} |
| 6663 |
|
| 6664 |
i, err := m.Int64Gauge( |
| 6665 |
"k8s.pod.memory.usage", |
| 6666 |
opt..., |
| 6667 |
) |
| 6668 |
if err != nil { |
| 6669 |
return PodMemoryUsage{noop.Int64Gauge{}}, err |
| 6670 |
} |
| 6671 |
return PodMemoryUsage{i}, nil |
| 6672 |
} |
| 6673 |
|
| 6674 |
// Inst returns the underlying metric instrument. |
| 6675 |
func (m PodMemoryUsage) Inst() metric.Int64Gauge { |
| 6676 |
return m.Int64Gauge |
| 6677 |
} |
| 6678 |
|
| 6679 |
// Name returns the semantic convention name of the instrument. |
| 6680 |
func (PodMemoryUsage) Name() string { |
| 6681 |
return "k8s.pod.memory.usage" |
| 6682 |
} |
| 6683 |
|
| 6684 |
// Unit returns the semantic convention unit of the instrument |
| 6685 |
func (PodMemoryUsage) Unit() string { |
| 6686 |
return "By" |
| 6687 |
} |
| 6688 |
|
| 6689 |
// Description returns the semantic convention description of the instrument |
| 6690 |
func (PodMemoryUsage) Description() string { |
| 6691 |
return "Memory usage of the Pod." |
| 6692 |
} |
| 6693 |
|
| 6694 |
// Record records val to the current distribution for attrs. |
| 6695 |
// |
| 6696 |
// Total memory usage of the Pod |
| 6697 |
func (m PodMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 6698 |
if len(attrs) == 0 { |
| 6699 |
m.Int64Gauge.Record(ctx, val) |
| 6700 |
return |
| 6701 |
} |
| 6702 |
|
| 6703 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 6704 |
defer func() { |
| 6705 |
*o = (*o)[:0] |
| 6706 |
recOptPool.Put(o) |
| 6707 |
}() |
| 6708 |
|
| 6709 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6710 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 6711 |
} |
| 6712 |
|
| 6713 |
// RecordSet records val to the current distribution for set. |
| 6714 |
// |
| 6715 |
// Total memory usage of the Pod |
| 6716 |
func (m PodMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 6717 |
if set.Len() == 0 { |
| 6718 |
m.Int64Gauge.Record(ctx, val) |
| 6719 |
return |
| 6720 |
} |
| 6721 |
|
| 6722 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 6723 |
defer func() { |
| 6724 |
*o = (*o)[:0] |
| 6725 |
recOptPool.Put(o) |
| 6726 |
}() |
| 6727 |
|
| 6728 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6729 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 6730 |
} |
| 6731 |
|
| 6732 |
// PodMemoryWorkingSet is an instrument used to record metric values conforming |
| 6733 |
// to the "k8s.pod.memory.working_set" semantic conventions. It represents the |
| 6734 |
// pod memory working set. |
| 6735 |
type PodMemoryWorkingSet struct { |
| 6736 |
metric.Int64UpDownCounter |
| 6737 |
} |
| 6738 |
|
| 6739 |
var newPodMemoryWorkingSetOpts = []metric.Int64UpDownCounterOption{ |
| 6740 |
metric.WithDescription("Pod memory working set."), |
| 6741 |
metric.WithUnit("By"), |
| 6742 |
} |
| 6743 |
|
| 6744 |
// NewPodMemoryWorkingSet returns a new PodMemoryWorkingSet instrument. |
| 6745 |
func NewPodMemoryWorkingSet( |
| 6746 |
m metric.Meter, |
| 6747 |
opt ...metric.Int64UpDownCounterOption, |
| 6748 |
) (PodMemoryWorkingSet, error) { |
| 6749 |
// Check if the meter is nil. |
| 6750 |
if m == nil { |
| 6751 |
return PodMemoryWorkingSet{noop.Int64UpDownCounter{}}, nil |
| 6752 |
} |
| 6753 |
|
| 6754 |
if len(opt) == 0 { |
| 6755 |
opt = newPodMemoryWorkingSetOpts |
| 6756 |
} else { |
| 6757 |
opt = append(opt, newPodMemoryWorkingSetOpts...) |
| 6758 |
} |
| 6759 |
|
| 6760 |
i, err := m.Int64UpDownCounter( |
| 6761 |
"k8s.pod.memory.working_set", |
| 6762 |
opt..., |
| 6763 |
) |
| 6764 |
if err != nil { |
| 6765 |
return PodMemoryWorkingSet{noop.Int64UpDownCounter{}}, err |
| 6766 |
} |
| 6767 |
return PodMemoryWorkingSet{i}, nil |
| 6768 |
} |
| 6769 |
|
| 6770 |
// Inst returns the underlying metric instrument. |
| 6771 |
func (m PodMemoryWorkingSet) Inst() metric.Int64UpDownCounter { |
| 6772 |
return m.Int64UpDownCounter |
| 6773 |
} |
| 6774 |
|
| 6775 |
// Name returns the semantic convention name of the instrument. |
| 6776 |
func (PodMemoryWorkingSet) Name() string { |
| 6777 |
return "k8s.pod.memory.working_set" |
| 6778 |
} |
| 6779 |
|
| 6780 |
// Unit returns the semantic convention unit of the instrument |
| 6781 |
func (PodMemoryWorkingSet) Unit() string { |
| 6782 |
return "By" |
| 6783 |
} |
| 6784 |
|
| 6785 |
// Description returns the semantic convention description of the instrument |
| 6786 |
func (PodMemoryWorkingSet) Description() string { |
| 6787 |
return "Pod memory working set." |
| 6788 |
} |
| 6789 |
|
| 6790 |
// Add adds incr to the existing count for attrs. |
| 6791 |
// |
| 6792 |
// The amount of working set memory. This includes recently accessed memory, |
| 6793 |
// dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes. |
| 6794 |
// This metric is derived from the [MemoryStats.WorkingSetBytes] field of the |
| 6795 |
// [PodStats.Memory] of the Kubelet's stats API. |
| 6796 |
// |
| 6797 |
// [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6798 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6799 |
func (m PodMemoryWorkingSet) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6800 |
if len(attrs) == 0 { |
| 6801 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6802 |
return |
| 6803 |
} |
| 6804 |
|
| 6805 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6806 |
defer func() { |
| 6807 |
*o = (*o)[:0] |
| 6808 |
addOptPool.Put(o) |
| 6809 |
}() |
| 6810 |
|
| 6811 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6812 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6813 |
} |
| 6814 |
|
| 6815 |
// AddSet adds incr to the existing count for set. |
| 6816 |
// |
| 6817 |
// The amount of working set memory. This includes recently accessed memory, |
| 6818 |
// dirty memory, and kernel memory. WorkingSetBytes is <= UsageBytes. |
| 6819 |
// This metric is derived from the [MemoryStats.WorkingSetBytes] field of the |
| 6820 |
// [PodStats.Memory] of the Kubelet's stats API. |
| 6821 |
// |
| 6822 |
// [MemoryStats.WorkingSetBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats |
| 6823 |
// [PodStats.Memory]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 6824 |
func (m PodMemoryWorkingSet) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6825 |
if set.Len() == 0 { |
| 6826 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6827 |
return |
| 6828 |
} |
| 6829 |
|
| 6830 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6831 |
defer func() { |
| 6832 |
*o = (*o)[:0] |
| 6833 |
addOptPool.Put(o) |
| 6834 |
}() |
| 6835 |
|
| 6836 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6837 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6838 |
} |
| 6839 |
|
| 6840 |
// PodNetworkErrors is an instrument used to record metric values conforming to |
| 6841 |
// the "k8s.pod.network.errors" semantic conventions. It represents the pod |
| 6842 |
// network errors. |
| 6843 |
type PodNetworkErrors struct { |
| 6844 |
metric.Int64Counter |
| 6845 |
} |
| 6846 |
|
| 6847 |
var newPodNetworkErrorsOpts = []metric.Int64CounterOption{ |
| 6848 |
metric.WithDescription("Pod network errors."), |
| 6849 |
metric.WithUnit("{error}"), |
| 6850 |
} |
| 6851 |
|
| 6852 |
// NewPodNetworkErrors returns a new PodNetworkErrors instrument. |
| 6853 |
func NewPodNetworkErrors( |
| 6854 |
m metric.Meter, |
| 6855 |
opt ...metric.Int64CounterOption, |
| 6856 |
) (PodNetworkErrors, error) { |
| 6857 |
// Check if the meter is nil. |
| 6858 |
if m == nil { |
| 6859 |
return PodNetworkErrors{noop.Int64Counter{}}, nil |
| 6860 |
} |
| 6861 |
|
| 6862 |
if len(opt) == 0 { |
| 6863 |
opt = newPodNetworkErrorsOpts |
| 6864 |
} else { |
| 6865 |
opt = append(opt, newPodNetworkErrorsOpts...) |
| 6866 |
} |
| 6867 |
|
| 6868 |
i, err := m.Int64Counter( |
| 6869 |
"k8s.pod.network.errors", |
| 6870 |
opt..., |
| 6871 |
) |
| 6872 |
if err != nil { |
| 6873 |
return PodNetworkErrors{noop.Int64Counter{}}, err |
| 6874 |
} |
| 6875 |
return PodNetworkErrors{i}, nil |
| 6876 |
} |
| 6877 |
|
| 6878 |
// Inst returns the underlying metric instrument. |
| 6879 |
func (m PodNetworkErrors) Inst() metric.Int64Counter { |
| 6880 |
return m.Int64Counter |
| 6881 |
} |
| 6882 |
|
| 6883 |
// Name returns the semantic convention name of the instrument. |
| 6884 |
func (PodNetworkErrors) Name() string { |
| 6885 |
return "k8s.pod.network.errors" |
| 6886 |
} |
| 6887 |
|
| 6888 |
// Unit returns the semantic convention unit of the instrument |
| 6889 |
func (PodNetworkErrors) Unit() string { |
| 6890 |
return "{error}" |
| 6891 |
} |
| 6892 |
|
| 6893 |
// Description returns the semantic convention description of the instrument |
| 6894 |
func (PodNetworkErrors) Description() string { |
| 6895 |
return "Pod network errors." |
| 6896 |
} |
| 6897 |
|
| 6898 |
// Add adds incr to the existing count for attrs. |
| 6899 |
// |
| 6900 |
// All additional attrs passed are included in the recorded value. |
| 6901 |
func (m PodNetworkErrors) Add( |
| 6902 |
ctx context.Context, |
| 6903 |
incr int64, |
| 6904 |
attrs ...attribute.KeyValue, |
| 6905 |
) { |
| 6906 |
if len(attrs) == 0 { |
| 6907 |
m.Int64Counter.Add(ctx, incr) |
| 6908 |
return |
| 6909 |
} |
| 6910 |
|
| 6911 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6912 |
defer func() { |
| 6913 |
*o = (*o)[:0] |
| 6914 |
addOptPool.Put(o) |
| 6915 |
}() |
| 6916 |
|
| 6917 |
*o = append( |
| 6918 |
*o, |
| 6919 |
metric.WithAttributes( |
| 6920 |
attrs..., |
| 6921 |
), |
| 6922 |
) |
| 6923 |
|
| 6924 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 6925 |
} |
| 6926 |
|
| 6927 |
// AddSet adds incr to the existing count for set. |
| 6928 |
func (m PodNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6929 |
if set.Len() == 0 { |
| 6930 |
m.Int64Counter.Add(ctx, incr) |
| 6931 |
return |
| 6932 |
} |
| 6933 |
|
| 6934 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6935 |
defer func() { |
| 6936 |
*o = (*o)[:0] |
| 6937 |
addOptPool.Put(o) |
| 6938 |
}() |
| 6939 |
|
| 6940 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6941 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 6942 |
} |
| 6943 |
|
| 6944 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 6945 |
// "network.interface.name" semantic convention. It represents the network |
| 6946 |
// interface name. |
| 6947 |
func (PodNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 6948 |
return attribute.String("network.interface.name", val) |
| 6949 |
} |
| 6950 |
|
| 6951 |
// AttrNetworkIODirection returns an optional attribute for the |
| 6952 |
// "network.io.direction" semantic convention. It represents the network IO |
| 6953 |
// operation direction. |
| 6954 |
func (PodNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 6955 |
return attribute.String("network.io.direction", string(val)) |
| 6956 |
} |
| 6957 |
|
| 6958 |
// PodNetworkIO is an instrument used to record metric values conforming to the |
| 6959 |
// "k8s.pod.network.io" semantic conventions. It represents the network bytes for |
| 6960 |
// the Pod. |
| 6961 |
type PodNetworkIO struct { |
| 6962 |
metric.Int64Counter |
| 6963 |
} |
| 6964 |
|
| 6965 |
var newPodNetworkIOOpts = []metric.Int64CounterOption{ |
| 6966 |
metric.WithDescription("Network bytes for the Pod."), |
| 6967 |
metric.WithUnit("By"), |
| 6968 |
} |
| 6969 |
|
| 6970 |
// NewPodNetworkIO returns a new PodNetworkIO instrument. |
| 6971 |
func NewPodNetworkIO( |
| 6972 |
m metric.Meter, |
| 6973 |
opt ...metric.Int64CounterOption, |
| 6974 |
) (PodNetworkIO, error) { |
| 6975 |
// Check if the meter is nil. |
| 6976 |
if m == nil { |
| 6977 |
return PodNetworkIO{noop.Int64Counter{}}, nil |
| 6978 |
} |
| 6979 |
|
| 6980 |
if len(opt) == 0 { |
| 6981 |
opt = newPodNetworkIOOpts |
| 6982 |
} else { |
| 6983 |
opt = append(opt, newPodNetworkIOOpts...) |
| 6984 |
} |
| 6985 |
|
| 6986 |
i, err := m.Int64Counter( |
| 6987 |
"k8s.pod.network.io", |
| 6988 |
opt..., |
| 6989 |
) |
| 6990 |
if err != nil { |
| 6991 |
return PodNetworkIO{noop.Int64Counter{}}, err |
| 6992 |
} |
| 6993 |
return PodNetworkIO{i}, nil |
| 6994 |
} |
| 6995 |
|
| 6996 |
// Inst returns the underlying metric instrument. |
| 6997 |
func (m PodNetworkIO) Inst() metric.Int64Counter { |
| 6998 |
return m.Int64Counter |
| 6999 |
} |
| 7000 |
|
| 7001 |
// Name returns the semantic convention name of the instrument. |
| 7002 |
func (PodNetworkIO) Name() string { |
| 7003 |
return "k8s.pod.network.io" |
| 7004 |
} |
| 7005 |
|
| 7006 |
// Unit returns the semantic convention unit of the instrument |
| 7007 |
func (PodNetworkIO) Unit() string { |
| 7008 |
return "By" |
| 7009 |
} |
| 7010 |
|
| 7011 |
// Description returns the semantic convention description of the instrument |
| 7012 |
func (PodNetworkIO) Description() string { |
| 7013 |
return "Network bytes for the Pod." |
| 7014 |
} |
| 7015 |
|
| 7016 |
// Add adds incr to the existing count for attrs. |
| 7017 |
// |
| 7018 |
// All additional attrs passed are included in the recorded value. |
| 7019 |
func (m PodNetworkIO) Add( |
| 7020 |
ctx context.Context, |
| 7021 |
incr int64, |
| 7022 |
attrs ...attribute.KeyValue, |
| 7023 |
) { |
| 7024 |
if len(attrs) == 0 { |
| 7025 |
m.Int64Counter.Add(ctx, incr) |
| 7026 |
return |
| 7027 |
} |
| 7028 |
|
| 7029 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7030 |
defer func() { |
| 7031 |
*o = (*o)[:0] |
| 7032 |
addOptPool.Put(o) |
| 7033 |
}() |
| 7034 |
|
| 7035 |
*o = append( |
| 7036 |
*o, |
| 7037 |
metric.WithAttributes( |
| 7038 |
attrs..., |
| 7039 |
), |
| 7040 |
) |
| 7041 |
|
| 7042 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 7043 |
} |
| 7044 |
|
| 7045 |
// AddSet adds incr to the existing count for set. |
| 7046 |
func (m PodNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7047 |
if set.Len() == 0 { |
| 7048 |
m.Int64Counter.Add(ctx, incr) |
| 7049 |
return |
| 7050 |
} |
| 7051 |
|
| 7052 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7053 |
defer func() { |
| 7054 |
*o = (*o)[:0] |
| 7055 |
addOptPool.Put(o) |
| 7056 |
}() |
| 7057 |
|
| 7058 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7059 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 7060 |
} |
| 7061 |
|
| 7062 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 7063 |
// "network.interface.name" semantic convention. It represents the network |
| 7064 |
// interface name. |
| 7065 |
func (PodNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 7066 |
return attribute.String("network.interface.name", val) |
| 7067 |
} |
| 7068 |
|
| 7069 |
// AttrNetworkIODirection returns an optional attribute for the |
| 7070 |
// "network.io.direction" semantic convention. It represents the network IO |
| 7071 |
// operation direction. |
| 7072 |
func (PodNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 7073 |
return attribute.String("network.io.direction", string(val)) |
| 7074 |
} |
| 7075 |
|
| 7076 |
// PodStatusPhase is an instrument used to record metric values conforming to the |
| 7077 |
// "k8s.pod.status.phase" semantic conventions. It represents the describes |
| 7078 |
// number of K8s Pods that are currently in a given phase. |
| 7079 |
type PodStatusPhase struct { |
| 7080 |
metric.Int64UpDownCounter |
| 7081 |
} |
| 7082 |
|
| 7083 |
var newPodStatusPhaseOpts = []metric.Int64UpDownCounterOption{ |
| 7084 |
metric.WithDescription("Describes number of K8s Pods that are currently in a given phase."), |
| 7085 |
metric.WithUnit("{pod}"), |
| 7086 |
} |
| 7087 |
|
| 7088 |
// NewPodStatusPhase returns a new PodStatusPhase instrument. |
| 7089 |
func NewPodStatusPhase( |
| 7090 |
m metric.Meter, |
| 7091 |
opt ...metric.Int64UpDownCounterOption, |
| 7092 |
) (PodStatusPhase, error) { |
| 7093 |
// Check if the meter is nil. |
| 7094 |
if m == nil { |
| 7095 |
return PodStatusPhase{noop.Int64UpDownCounter{}}, nil |
| 7096 |
} |
| 7097 |
|
| 7098 |
if len(opt) == 0 { |
| 7099 |
opt = newPodStatusPhaseOpts |
| 7100 |
} else { |
| 7101 |
opt = append(opt, newPodStatusPhaseOpts...) |
| 7102 |
} |
| 7103 |
|
| 7104 |
i, err := m.Int64UpDownCounter( |
| 7105 |
"k8s.pod.status.phase", |
| 7106 |
opt..., |
| 7107 |
) |
| 7108 |
if err != nil { |
| 7109 |
return PodStatusPhase{noop.Int64UpDownCounter{}}, err |
| 7110 |
} |
| 7111 |
return PodStatusPhase{i}, nil |
| 7112 |
} |
| 7113 |
|
| 7114 |
// Inst returns the underlying metric instrument. |
| 7115 |
func (m PodStatusPhase) Inst() metric.Int64UpDownCounter { |
| 7116 |
return m.Int64UpDownCounter |
| 7117 |
} |
| 7118 |
|
| 7119 |
// Name returns the semantic convention name of the instrument. |
| 7120 |
func (PodStatusPhase) Name() string { |
| 7121 |
return "k8s.pod.status.phase" |
| 7122 |
} |
| 7123 |
|
| 7124 |
// Unit returns the semantic convention unit of the instrument |
| 7125 |
func (PodStatusPhase) Unit() string { |
| 7126 |
return "{pod}" |
| 7127 |
} |
| 7128 |
|
| 7129 |
// Description returns the semantic convention description of the instrument |
| 7130 |
func (PodStatusPhase) Description() string { |
| 7131 |
return "Describes number of K8s Pods that are currently in a given phase." |
| 7132 |
} |
| 7133 |
|
| 7134 |
// Add adds incr to the existing count for attrs. |
| 7135 |
// |
| 7136 |
// The podStatusPhase is the the phase for the pod. Corresponds to the `phase` |
| 7137 |
// field of the: [K8s PodStatus] |
| 7138 |
// |
| 7139 |
// [K8s PodStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.33/#podstatus-v1-core |
| 7140 |
// |
| 7141 |
// All possible pod phases will be reported at each time interval to avoid |
| 7142 |
// missing metrics. |
| 7143 |
// Only the value corresponding to the current phase will be non-zero. |
| 7144 |
func (m PodStatusPhase) Add( |
| 7145 |
ctx context.Context, |
| 7146 |
incr int64, |
| 7147 |
podStatusPhase PodStatusPhaseAttr, |
| 7148 |
attrs ...attribute.KeyValue, |
| 7149 |
) { |
| 7150 |
if len(attrs) == 0 { |
| 7151 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 7152 |
attribute.String("k8s.pod.status.phase", string(podStatusPhase)), |
| 7153 |
)) |
| 7154 |
return |
| 7155 |
} |
| 7156 |
|
| 7157 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7158 |
defer func() { |
| 7159 |
*o = (*o)[:0] |
| 7160 |
addOptPool.Put(o) |
| 7161 |
}() |
| 7162 |
|
| 7163 |
*o = append( |
| 7164 |
*o, |
| 7165 |
metric.WithAttributes( |
| 7166 |
append( |
| 7167 |
attrs, |
| 7168 |
attribute.String("k8s.pod.status.phase", string(podStatusPhase)), |
| 7169 |
)..., |
| 7170 |
), |
| 7171 |
) |
| 7172 |
|
| 7173 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7174 |
} |
| 7175 |
|
| 7176 |
// AddSet adds incr to the existing count for set. |
| 7177 |
// |
| 7178 |
// All possible pod phases will be reported at each time interval to avoid |
| 7179 |
// missing metrics. |
| 7180 |
// Only the value corresponding to the current phase will be non-zero. |
| 7181 |
func (m PodStatusPhase) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7182 |
if set.Len() == 0 { |
| 7183 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7184 |
return |
| 7185 |
} |
| 7186 |
|
| 7187 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7188 |
defer func() { |
| 7189 |
*o = (*o)[:0] |
| 7190 |
addOptPool.Put(o) |
| 7191 |
}() |
| 7192 |
|
| 7193 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7194 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7195 |
} |
| 7196 |
|
| 7197 |
// PodStatusReason is an instrument used to record metric values conforming to |
| 7198 |
// the "k8s.pod.status.reason" semantic conventions. It represents the describes |
| 7199 |
// the number of K8s Pods that are currently in a state for a given reason. |
| 7200 |
type PodStatusReason struct { |
| 7201 |
metric.Int64UpDownCounter |
| 7202 |
} |
| 7203 |
|
| 7204 |
var newPodStatusReasonOpts = []metric.Int64UpDownCounterOption{ |
| 7205 |
metric.WithDescription("Describes the number of K8s Pods that are currently in a state for a given reason."), |
| 7206 |
metric.WithUnit("{pod}"), |
| 7207 |
} |
| 7208 |
|
| 7209 |
// NewPodStatusReason returns a new PodStatusReason instrument. |
| 7210 |
func NewPodStatusReason( |
| 7211 |
m metric.Meter, |
| 7212 |
opt ...metric.Int64UpDownCounterOption, |
| 7213 |
) (PodStatusReason, error) { |
| 7214 |
// Check if the meter is nil. |
| 7215 |
if m == nil { |
| 7216 |
return PodStatusReason{noop.Int64UpDownCounter{}}, nil |
| 7217 |
} |
| 7218 |
|
| 7219 |
if len(opt) == 0 { |
| 7220 |
opt = newPodStatusReasonOpts |
| 7221 |
} else { |
| 7222 |
opt = append(opt, newPodStatusReasonOpts...) |
| 7223 |
} |
| 7224 |
|
| 7225 |
i, err := m.Int64UpDownCounter( |
| 7226 |
"k8s.pod.status.reason", |
| 7227 |
opt..., |
| 7228 |
) |
| 7229 |
if err != nil { |
| 7230 |
return PodStatusReason{noop.Int64UpDownCounter{}}, err |
| 7231 |
} |
| 7232 |
return PodStatusReason{i}, nil |
| 7233 |
} |
| 7234 |
|
| 7235 |
// Inst returns the underlying metric instrument. |
| 7236 |
func (m PodStatusReason) Inst() metric.Int64UpDownCounter { |
| 7237 |
return m.Int64UpDownCounter |
| 7238 |
} |
| 7239 |
|
| 7240 |
// Name returns the semantic convention name of the instrument. |
| 7241 |
func (PodStatusReason) Name() string { |
| 7242 |
return "k8s.pod.status.reason" |
| 7243 |
} |
| 7244 |
|
| 7245 |
// Unit returns the semantic convention unit of the instrument |
| 7246 |
func (PodStatusReason) Unit() string { |
| 7247 |
return "{pod}" |
| 7248 |
} |
| 7249 |
|
| 7250 |
// Description returns the semantic convention description of the instrument |
| 7251 |
func (PodStatusReason) Description() string { |
| 7252 |
return "Describes the number of K8s Pods that are currently in a state for a given reason." |
| 7253 |
} |
| 7254 |
|
| 7255 |
// Add adds incr to the existing count for attrs. |
| 7256 |
// |
| 7257 |
// The podStatusReason is the the reason for the pod state. Corresponds to the |
| 7258 |
// `reason` field of the: [K8s PodStatus] |
| 7259 |
// |
| 7260 |
// [K8s PodStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.33/#podstatus-v1-core |
| 7261 |
// |
| 7262 |
// All possible pod status reasons will be reported at each time interval to |
| 7263 |
// avoid missing metrics. |
| 7264 |
// Only the value corresponding to the current reason will be non-zero. |
| 7265 |
func (m PodStatusReason) Add( |
| 7266 |
ctx context.Context, |
| 7267 |
incr int64, |
| 7268 |
podStatusReason PodStatusReasonAttr, |
| 7269 |
attrs ...attribute.KeyValue, |
| 7270 |
) { |
| 7271 |
if len(attrs) == 0 { |
| 7272 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 7273 |
attribute.String("k8s.pod.status.reason", string(podStatusReason)), |
| 7274 |
)) |
| 7275 |
return |
| 7276 |
} |
| 7277 |
|
| 7278 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7279 |
defer func() { |
| 7280 |
*o = (*o)[:0] |
| 7281 |
addOptPool.Put(o) |
| 7282 |
}() |
| 7283 |
|
| 7284 |
*o = append( |
| 7285 |
*o, |
| 7286 |
metric.WithAttributes( |
| 7287 |
append( |
| 7288 |
attrs, |
| 7289 |
attribute.String("k8s.pod.status.reason", string(podStatusReason)), |
| 7290 |
)..., |
| 7291 |
), |
| 7292 |
) |
| 7293 |
|
| 7294 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7295 |
} |
| 7296 |
|
| 7297 |
// AddSet adds incr to the existing count for set. |
| 7298 |
// |
| 7299 |
// All possible pod status reasons will be reported at each time interval to |
| 7300 |
// avoid missing metrics. |
| 7301 |
// Only the value corresponding to the current reason will be non-zero. |
| 7302 |
func (m PodStatusReason) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7303 |
if set.Len() == 0 { |
| 7304 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7305 |
return |
| 7306 |
} |
| 7307 |
|
| 7308 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7309 |
defer func() { |
| 7310 |
*o = (*o)[:0] |
| 7311 |
addOptPool.Put(o) |
| 7312 |
}() |
| 7313 |
|
| 7314 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7315 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7316 |
} |
| 7317 |
|
| 7318 |
// PodUptime is an instrument used to record metric values conforming to the |
| 7319 |
// "k8s.pod.uptime" semantic conventions. It represents the time the Pod has been |
| 7320 |
// running. |
| 7321 |
type PodUptime struct { |
| 7322 |
metric.Float64Gauge |
| 7323 |
} |
| 7324 |
|
| 7325 |
var newPodUptimeOpts = []metric.Float64GaugeOption{ |
| 7326 |
metric.WithDescription("The time the Pod has been running."), |
| 7327 |
metric.WithUnit("s"), |
| 7328 |
} |
| 7329 |
|
| 7330 |
// NewPodUptime returns a new PodUptime instrument. |
| 7331 |
func NewPodUptime( |
| 7332 |
m metric.Meter, |
| 7333 |
opt ...metric.Float64GaugeOption, |
| 7334 |
) (PodUptime, error) { |
| 7335 |
// Check if the meter is nil. |
| 7336 |
if m == nil { |
| 7337 |
return PodUptime{noop.Float64Gauge{}}, nil |
| 7338 |
} |
| 7339 |
|
| 7340 |
if len(opt) == 0 { |
| 7341 |
opt = newPodUptimeOpts |
| 7342 |
} else { |
| 7343 |
opt = append(opt, newPodUptimeOpts...) |
| 7344 |
} |
| 7345 |
|
| 7346 |
i, err := m.Float64Gauge( |
| 7347 |
"k8s.pod.uptime", |
| 7348 |
opt..., |
| 7349 |
) |
| 7350 |
if err != nil { |
| 7351 |
return PodUptime{noop.Float64Gauge{}}, err |
| 7352 |
} |
| 7353 |
return PodUptime{i}, nil |
| 7354 |
} |
| 7355 |
|
| 7356 |
// Inst returns the underlying metric instrument. |
| 7357 |
func (m PodUptime) Inst() metric.Float64Gauge { |
| 7358 |
return m.Float64Gauge |
| 7359 |
} |
| 7360 |
|
| 7361 |
// Name returns the semantic convention name of the instrument. |
| 7362 |
func (PodUptime) Name() string { |
| 7363 |
return "k8s.pod.uptime" |
| 7364 |
} |
| 7365 |
|
| 7366 |
// Unit returns the semantic convention unit of the instrument |
| 7367 |
func (PodUptime) Unit() string { |
| 7368 |
return "s" |
| 7369 |
} |
| 7370 |
|
| 7371 |
// Description returns the semantic convention description of the instrument |
| 7372 |
func (PodUptime) Description() string { |
| 7373 |
return "The time the Pod has been running." |
| 7374 |
} |
| 7375 |
|
| 7376 |
// Record records val to the current distribution for attrs. |
| 7377 |
// |
| 7378 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 7379 |
// seconds as a floating point number with the highest precision available. |
| 7380 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 7381 |
func (m PodUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) { |
| 7382 |
if len(attrs) == 0 { |
| 7383 |
m.Float64Gauge.Record(ctx, val) |
| 7384 |
return |
| 7385 |
} |
| 7386 |
|
| 7387 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 7388 |
defer func() { |
| 7389 |
*o = (*o)[:0] |
| 7390 |
recOptPool.Put(o) |
| 7391 |
}() |
| 7392 |
|
| 7393 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 7394 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 7395 |
} |
| 7396 |
|
| 7397 |
// RecordSet records val to the current distribution for set. |
| 7398 |
// |
| 7399 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 7400 |
// seconds as a floating point number with the highest precision available. |
| 7401 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 7402 |
func (m PodUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { |
| 7403 |
if set.Len() == 0 { |
| 7404 |
m.Float64Gauge.Record(ctx, val) |
| 7405 |
return |
| 7406 |
} |
| 7407 |
|
| 7408 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 7409 |
defer func() { |
| 7410 |
*o = (*o)[:0] |
| 7411 |
recOptPool.Put(o) |
| 7412 |
}() |
| 7413 |
|
| 7414 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7415 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 7416 |
} |
| 7417 |
|
| 7418 |
// PodVolumeAvailable is an instrument used to record metric values conforming to |
| 7419 |
// the "k8s.pod.volume.available" semantic conventions. It represents the pod |
| 7420 |
// volume storage space available. |
| 7421 |
type PodVolumeAvailable struct { |
| 7422 |
metric.Int64UpDownCounter |
| 7423 |
} |
| 7424 |
|
| 7425 |
var newPodVolumeAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 7426 |
metric.WithDescription("Pod volume storage space available."), |
| 7427 |
metric.WithUnit("By"), |
| 7428 |
} |
| 7429 |
|
| 7430 |
// NewPodVolumeAvailable returns a new PodVolumeAvailable instrument. |
| 7431 |
func NewPodVolumeAvailable( |
| 7432 |
m metric.Meter, |
| 7433 |
opt ...metric.Int64UpDownCounterOption, |
| 7434 |
) (PodVolumeAvailable, error) { |
| 7435 |
// Check if the meter is nil. |
| 7436 |
if m == nil { |
| 7437 |
return PodVolumeAvailable{noop.Int64UpDownCounter{}}, nil |
| 7438 |
} |
| 7439 |
|
| 7440 |
if len(opt) == 0 { |
| 7441 |
opt = newPodVolumeAvailableOpts |
| 7442 |
} else { |
| 7443 |
opt = append(opt, newPodVolumeAvailableOpts...) |
| 7444 |
} |
| 7445 |
|
| 7446 |
i, err := m.Int64UpDownCounter( |
| 7447 |
"k8s.pod.volume.available", |
| 7448 |
opt..., |
| 7449 |
) |
| 7450 |
if err != nil { |
| 7451 |
return PodVolumeAvailable{noop.Int64UpDownCounter{}}, err |
| 7452 |
} |
| 7453 |
return PodVolumeAvailable{i}, nil |
| 7454 |
} |
| 7455 |
|
| 7456 |
// Inst returns the underlying metric instrument. |
| 7457 |
func (m PodVolumeAvailable) Inst() metric.Int64UpDownCounter { |
| 7458 |
return m.Int64UpDownCounter |
| 7459 |
} |
| 7460 |
|
| 7461 |
// Name returns the semantic convention name of the instrument. |
| 7462 |
func (PodVolumeAvailable) Name() string { |
| 7463 |
return "k8s.pod.volume.available" |
| 7464 |
} |
| 7465 |
|
| 7466 |
// Unit returns the semantic convention unit of the instrument |
| 7467 |
func (PodVolumeAvailable) Unit() string { |
| 7468 |
return "By" |
| 7469 |
} |
| 7470 |
|
| 7471 |
// Description returns the semantic convention description of the instrument |
| 7472 |
func (PodVolumeAvailable) Description() string { |
| 7473 |
return "Pod volume storage space available." |
| 7474 |
} |
| 7475 |
|
| 7476 |
// Add adds incr to the existing count for attrs. |
| 7477 |
// |
| 7478 |
// The volumeName is the the name of the K8s volume. |
| 7479 |
// |
| 7480 |
// All additional attrs passed are included in the recorded value. |
| 7481 |
// |
| 7482 |
// This metric is derived from the |
| 7483 |
// [VolumeStats.AvailableBytes] field |
| 7484 |
// of the [PodStats] of the |
| 7485 |
// Kubelet's stats API. |
| 7486 |
// |
| 7487 |
// [VolumeStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7488 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7489 |
func (m PodVolumeAvailable) Add( |
| 7490 |
ctx context.Context, |
| 7491 |
incr int64, |
| 7492 |
volumeName string, |
| 7493 |
attrs ...attribute.KeyValue, |
| 7494 |
) { |
| 7495 |
if len(attrs) == 0 { |
| 7496 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 7497 |
attribute.String("k8s.volume.name", volumeName), |
| 7498 |
)) |
| 7499 |
return |
| 7500 |
} |
| 7501 |
|
| 7502 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7503 |
defer func() { |
| 7504 |
*o = (*o)[:0] |
| 7505 |
addOptPool.Put(o) |
| 7506 |
}() |
| 7507 |
|
| 7508 |
*o = append( |
| 7509 |
*o, |
| 7510 |
metric.WithAttributes( |
| 7511 |
append( |
| 7512 |
attrs, |
| 7513 |
attribute.String("k8s.volume.name", volumeName), |
| 7514 |
)..., |
| 7515 |
), |
| 7516 |
) |
| 7517 |
|
| 7518 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7519 |
} |
| 7520 |
|
| 7521 |
// AddSet adds incr to the existing count for set. |
| 7522 |
// |
| 7523 |
// This metric is derived from the |
| 7524 |
// [VolumeStats.AvailableBytes] field |
| 7525 |
// of the [PodStats] of the |
| 7526 |
// Kubelet's stats API. |
| 7527 |
// |
| 7528 |
// [VolumeStats.AvailableBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7529 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7530 |
func (m PodVolumeAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7531 |
if set.Len() == 0 { |
| 7532 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7533 |
return |
| 7534 |
} |
| 7535 |
|
| 7536 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7537 |
defer func() { |
| 7538 |
*o = (*o)[:0] |
| 7539 |
addOptPool.Put(o) |
| 7540 |
}() |
| 7541 |
|
| 7542 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7543 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7544 |
} |
| 7545 |
|
| 7546 |
// AttrVolumeType returns an optional attribute for the "k8s.volume.type" |
| 7547 |
// semantic convention. It represents the type of the K8s volume. |
| 7548 |
func (PodVolumeAvailable) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue { |
| 7549 |
return attribute.String("k8s.volume.type", string(val)) |
| 7550 |
} |
| 7551 |
|
| 7552 |
// PodVolumeCapacity is an instrument used to record metric values conforming to |
| 7553 |
// the "k8s.pod.volume.capacity" semantic conventions. It represents the pod |
| 7554 |
// volume total capacity. |
| 7555 |
type PodVolumeCapacity struct { |
| 7556 |
metric.Int64UpDownCounter |
| 7557 |
} |
| 7558 |
|
| 7559 |
var newPodVolumeCapacityOpts = []metric.Int64UpDownCounterOption{ |
| 7560 |
metric.WithDescription("Pod volume total capacity."), |
| 7561 |
metric.WithUnit("By"), |
| 7562 |
} |
| 7563 |
|
| 7564 |
// NewPodVolumeCapacity returns a new PodVolumeCapacity instrument. |
| 7565 |
func NewPodVolumeCapacity( |
| 7566 |
m metric.Meter, |
| 7567 |
opt ...metric.Int64UpDownCounterOption, |
| 7568 |
) (PodVolumeCapacity, error) { |
| 7569 |
// Check if the meter is nil. |
| 7570 |
if m == nil { |
| 7571 |
return PodVolumeCapacity{noop.Int64UpDownCounter{}}, nil |
| 7572 |
} |
| 7573 |
|
| 7574 |
if len(opt) == 0 { |
| 7575 |
opt = newPodVolumeCapacityOpts |
| 7576 |
} else { |
| 7577 |
opt = append(opt, newPodVolumeCapacityOpts...) |
| 7578 |
} |
| 7579 |
|
| 7580 |
i, err := m.Int64UpDownCounter( |
| 7581 |
"k8s.pod.volume.capacity", |
| 7582 |
opt..., |
| 7583 |
) |
| 7584 |
if err != nil { |
| 7585 |
return PodVolumeCapacity{noop.Int64UpDownCounter{}}, err |
| 7586 |
} |
| 7587 |
return PodVolumeCapacity{i}, nil |
| 7588 |
} |
| 7589 |
|
| 7590 |
// Inst returns the underlying metric instrument. |
| 7591 |
func (m PodVolumeCapacity) Inst() metric.Int64UpDownCounter { |
| 7592 |
return m.Int64UpDownCounter |
| 7593 |
} |
| 7594 |
|
| 7595 |
// Name returns the semantic convention name of the instrument. |
| 7596 |
func (PodVolumeCapacity) Name() string { |
| 7597 |
return "k8s.pod.volume.capacity" |
| 7598 |
} |
| 7599 |
|
| 7600 |
// Unit returns the semantic convention unit of the instrument |
| 7601 |
func (PodVolumeCapacity) Unit() string { |
| 7602 |
return "By" |
| 7603 |
} |
| 7604 |
|
| 7605 |
// Description returns the semantic convention description of the instrument |
| 7606 |
func (PodVolumeCapacity) Description() string { |
| 7607 |
return "Pod volume total capacity." |
| 7608 |
} |
| 7609 |
|
| 7610 |
// Add adds incr to the existing count for attrs. |
| 7611 |
// |
| 7612 |
// The volumeName is the the name of the K8s volume. |
| 7613 |
// |
| 7614 |
// All additional attrs passed are included in the recorded value. |
| 7615 |
// |
| 7616 |
// This metric is derived from the |
| 7617 |
// [VolumeStats.CapacityBytes] field |
| 7618 |
// of the [PodStats] of the |
| 7619 |
// Kubelet's stats API. |
| 7620 |
// |
| 7621 |
// [VolumeStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7622 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7623 |
func (m PodVolumeCapacity) Add( |
| 7624 |
ctx context.Context, |
| 7625 |
incr int64, |
| 7626 |
volumeName string, |
| 7627 |
attrs ...attribute.KeyValue, |
| 7628 |
) { |
| 7629 |
if len(attrs) == 0 { |
| 7630 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 7631 |
attribute.String("k8s.volume.name", volumeName), |
| 7632 |
)) |
| 7633 |
return |
| 7634 |
} |
| 7635 |
|
| 7636 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7637 |
defer func() { |
| 7638 |
*o = (*o)[:0] |
| 7639 |
addOptPool.Put(o) |
| 7640 |
}() |
| 7641 |
|
| 7642 |
*o = append( |
| 7643 |
*o, |
| 7644 |
metric.WithAttributes( |
| 7645 |
append( |
| 7646 |
attrs, |
| 7647 |
attribute.String("k8s.volume.name", volumeName), |
| 7648 |
)..., |
| 7649 |
), |
| 7650 |
) |
| 7651 |
|
| 7652 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7653 |
} |
| 7654 |
|
| 7655 |
// AddSet adds incr to the existing count for set. |
| 7656 |
// |
| 7657 |
// This metric is derived from the |
| 7658 |
// [VolumeStats.CapacityBytes] field |
| 7659 |
// of the [PodStats] of the |
| 7660 |
// Kubelet's stats API. |
| 7661 |
// |
| 7662 |
// [VolumeStats.CapacityBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7663 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7664 |
func (m PodVolumeCapacity) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7665 |
if set.Len() == 0 { |
| 7666 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7667 |
return |
| 7668 |
} |
| 7669 |
|
| 7670 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7671 |
defer func() { |
| 7672 |
*o = (*o)[:0] |
| 7673 |
addOptPool.Put(o) |
| 7674 |
}() |
| 7675 |
|
| 7676 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7677 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7678 |
} |
| 7679 |
|
| 7680 |
// AttrVolumeType returns an optional attribute for the "k8s.volume.type" |
| 7681 |
// semantic convention. It represents the type of the K8s volume. |
| 7682 |
func (PodVolumeCapacity) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue { |
| 7683 |
return attribute.String("k8s.volume.type", string(val)) |
| 7684 |
} |
| 7685 |
|
| 7686 |
// PodVolumeInodeCount is an instrument used to record metric values conforming |
| 7687 |
// to the "k8s.pod.volume.inode.count" semantic conventions. It represents the |
| 7688 |
// total inodes in the filesystem of the Pod's volume. |
| 7689 |
type PodVolumeInodeCount struct { |
| 7690 |
metric.Int64UpDownCounter |
| 7691 |
} |
| 7692 |
|
| 7693 |
var newPodVolumeInodeCountOpts = []metric.Int64UpDownCounterOption{ |
| 7694 |
metric.WithDescription("The total inodes in the filesystem of the Pod's volume."), |
| 7695 |
metric.WithUnit("{inode}"), |
| 7696 |
} |
| 7697 |
|
| 7698 |
// NewPodVolumeInodeCount returns a new PodVolumeInodeCount instrument. |
| 7699 |
func NewPodVolumeInodeCount( |
| 7700 |
m metric.Meter, |
| 7701 |
opt ...metric.Int64UpDownCounterOption, |
| 7702 |
) (PodVolumeInodeCount, error) { |
| 7703 |
// Check if the meter is nil. |
| 7704 |
if m == nil { |
| 7705 |
return PodVolumeInodeCount{noop.Int64UpDownCounter{}}, nil |
| 7706 |
} |
| 7707 |
|
| 7708 |
if len(opt) == 0 { |
| 7709 |
opt = newPodVolumeInodeCountOpts |
| 7710 |
} else { |
| 7711 |
opt = append(opt, newPodVolumeInodeCountOpts...) |
| 7712 |
} |
| 7713 |
|
| 7714 |
i, err := m.Int64UpDownCounter( |
| 7715 |
"k8s.pod.volume.inode.count", |
| 7716 |
opt..., |
| 7717 |
) |
| 7718 |
if err != nil { |
| 7719 |
return PodVolumeInodeCount{noop.Int64UpDownCounter{}}, err |
| 7720 |
} |
| 7721 |
return PodVolumeInodeCount{i}, nil |
| 7722 |
} |
| 7723 |
|
| 7724 |
// Inst returns the underlying metric instrument. |
| 7725 |
func (m PodVolumeInodeCount) Inst() metric.Int64UpDownCounter { |
| 7726 |
return m.Int64UpDownCounter |
| 7727 |
} |
| 7728 |
|
| 7729 |
// Name returns the semantic convention name of the instrument. |
| 7730 |
func (PodVolumeInodeCount) Name() string { |
| 7731 |
return "k8s.pod.volume.inode.count" |
| 7732 |
} |
| 7733 |
|
| 7734 |
// Unit returns the semantic convention unit of the instrument |
| 7735 |
func (PodVolumeInodeCount) Unit() string { |
| 7736 |
return "{inode}" |
| 7737 |
} |
| 7738 |
|
| 7739 |
// Description returns the semantic convention description of the instrument |
| 7740 |
func (PodVolumeInodeCount) Description() string { |
| 7741 |
return "The total inodes in the filesystem of the Pod's volume." |
| 7742 |
} |
| 7743 |
|
| 7744 |
// Add adds incr to the existing count for attrs. |
| 7745 |
// |
| 7746 |
// The volumeName is the the name of the K8s volume. |
| 7747 |
// |
| 7748 |
// All additional attrs passed are included in the recorded value. |
| 7749 |
// |
| 7750 |
// This metric is derived from the |
| 7751 |
// [VolumeStats.Inodes] field |
| 7752 |
// of the [PodStats] of the |
| 7753 |
// Kubelet's stats API. |
| 7754 |
// |
| 7755 |
// [VolumeStats.Inodes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7756 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7757 |
func (m PodVolumeInodeCount) Add( |
| 7758 |
ctx context.Context, |
| 7759 |
incr int64, |
| 7760 |
volumeName string, |
| 7761 |
attrs ...attribute.KeyValue, |
| 7762 |
) { |
| 7763 |
if len(attrs) == 0 { |
| 7764 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 7765 |
attribute.String("k8s.volume.name", volumeName), |
| 7766 |
)) |
| 7767 |
return |
| 7768 |
} |
| 7769 |
|
| 7770 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7771 |
defer func() { |
| 7772 |
*o = (*o)[:0] |
| 7773 |
addOptPool.Put(o) |
| 7774 |
}() |
| 7775 |
|
| 7776 |
*o = append( |
| 7777 |
*o, |
| 7778 |
metric.WithAttributes( |
| 7779 |
append( |
| 7780 |
attrs, |
| 7781 |
attribute.String("k8s.volume.name", volumeName), |
| 7782 |
)..., |
| 7783 |
), |
| 7784 |
) |
| 7785 |
|
| 7786 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7787 |
} |
| 7788 |
|
| 7789 |
// AddSet adds incr to the existing count for set. |
| 7790 |
// |
| 7791 |
// This metric is derived from the |
| 7792 |
// [VolumeStats.Inodes] field |
| 7793 |
// of the [PodStats] of the |
| 7794 |
// Kubelet's stats API. |
| 7795 |
// |
| 7796 |
// [VolumeStats.Inodes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7797 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7798 |
func (m PodVolumeInodeCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7799 |
if set.Len() == 0 { |
| 7800 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7801 |
return |
| 7802 |
} |
| 7803 |
|
| 7804 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7805 |
defer func() { |
| 7806 |
*o = (*o)[:0] |
| 7807 |
addOptPool.Put(o) |
| 7808 |
}() |
| 7809 |
|
| 7810 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7811 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7812 |
} |
| 7813 |
|
| 7814 |
// AttrVolumeType returns an optional attribute for the "k8s.volume.type" |
| 7815 |
// semantic convention. It represents the type of the K8s volume. |
| 7816 |
func (PodVolumeInodeCount) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue { |
| 7817 |
return attribute.String("k8s.volume.type", string(val)) |
| 7818 |
} |
| 7819 |
|
| 7820 |
// PodVolumeInodeFree is an instrument used to record metric values conforming to |
| 7821 |
// the "k8s.pod.volume.inode.free" semantic conventions. It represents the free |
| 7822 |
// inodes in the filesystem of the Pod's volume. |
| 7823 |
type PodVolumeInodeFree struct { |
| 7824 |
metric.Int64UpDownCounter |
| 7825 |
} |
| 7826 |
|
| 7827 |
var newPodVolumeInodeFreeOpts = []metric.Int64UpDownCounterOption{ |
| 7828 |
metric.WithDescription("The free inodes in the filesystem of the Pod's volume."), |
| 7829 |
metric.WithUnit("{inode}"), |
| 7830 |
} |
| 7831 |
|
| 7832 |
// NewPodVolumeInodeFree returns a new PodVolumeInodeFree instrument. |
| 7833 |
func NewPodVolumeInodeFree( |
| 7834 |
m metric.Meter, |
| 7835 |
opt ...metric.Int64UpDownCounterOption, |
| 7836 |
) (PodVolumeInodeFree, error) { |
| 7837 |
// Check if the meter is nil. |
| 7838 |
if m == nil { |
| 7839 |
return PodVolumeInodeFree{noop.Int64UpDownCounter{}}, nil |
| 7840 |
} |
| 7841 |
|
| 7842 |
if len(opt) == 0 { |
| 7843 |
opt = newPodVolumeInodeFreeOpts |
| 7844 |
} else { |
| 7845 |
opt = append(opt, newPodVolumeInodeFreeOpts...) |
| 7846 |
} |
| 7847 |
|
| 7848 |
i, err := m.Int64UpDownCounter( |
| 7849 |
"k8s.pod.volume.inode.free", |
| 7850 |
opt..., |
| 7851 |
) |
| 7852 |
if err != nil { |
| 7853 |
return PodVolumeInodeFree{noop.Int64UpDownCounter{}}, err |
| 7854 |
} |
| 7855 |
return PodVolumeInodeFree{i}, nil |
| 7856 |
} |
| 7857 |
|
| 7858 |
// Inst returns the underlying metric instrument. |
| 7859 |
func (m PodVolumeInodeFree) Inst() metric.Int64UpDownCounter { |
| 7860 |
return m.Int64UpDownCounter |
| 7861 |
} |
| 7862 |
|
| 7863 |
// Name returns the semantic convention name of the instrument. |
| 7864 |
func (PodVolumeInodeFree) Name() string { |
| 7865 |
return "k8s.pod.volume.inode.free" |
| 7866 |
} |
| 7867 |
|
| 7868 |
// Unit returns the semantic convention unit of the instrument |
| 7869 |
func (PodVolumeInodeFree) Unit() string { |
| 7870 |
return "{inode}" |
| 7871 |
} |
| 7872 |
|
| 7873 |
// Description returns the semantic convention description of the instrument |
| 7874 |
func (PodVolumeInodeFree) Description() string { |
| 7875 |
return "The free inodes in the filesystem of the Pod's volume." |
| 7876 |
} |
| 7877 |
|
| 7878 |
// Add adds incr to the existing count for attrs. |
| 7879 |
// |
| 7880 |
// The volumeName is the the name of the K8s volume. |
| 7881 |
// |
| 7882 |
// All additional attrs passed are included in the recorded value. |
| 7883 |
// |
| 7884 |
// This metric is derived from the |
| 7885 |
// [VolumeStats.InodesFree] field |
| 7886 |
// of the [PodStats] of the |
| 7887 |
// Kubelet's stats API. |
| 7888 |
// |
| 7889 |
// [VolumeStats.InodesFree]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7890 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7891 |
func (m PodVolumeInodeFree) Add( |
| 7892 |
ctx context.Context, |
| 7893 |
incr int64, |
| 7894 |
volumeName string, |
| 7895 |
attrs ...attribute.KeyValue, |
| 7896 |
) { |
| 7897 |
if len(attrs) == 0 { |
| 7898 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 7899 |
attribute.String("k8s.volume.name", volumeName), |
| 7900 |
)) |
| 7901 |
return |
| 7902 |
} |
| 7903 |
|
| 7904 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7905 |
defer func() { |
| 7906 |
*o = (*o)[:0] |
| 7907 |
addOptPool.Put(o) |
| 7908 |
}() |
| 7909 |
|
| 7910 |
*o = append( |
| 7911 |
*o, |
| 7912 |
metric.WithAttributes( |
| 7913 |
append( |
| 7914 |
attrs, |
| 7915 |
attribute.String("k8s.volume.name", volumeName), |
| 7916 |
)..., |
| 7917 |
), |
| 7918 |
) |
| 7919 |
|
| 7920 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7921 |
} |
| 7922 |
|
| 7923 |
// AddSet adds incr to the existing count for set. |
| 7924 |
// |
| 7925 |
// This metric is derived from the |
| 7926 |
// [VolumeStats.InodesFree] field |
| 7927 |
// of the [PodStats] of the |
| 7928 |
// Kubelet's stats API. |
| 7929 |
// |
| 7930 |
// [VolumeStats.InodesFree]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 7931 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 7932 |
func (m PodVolumeInodeFree) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7933 |
if set.Len() == 0 { |
| 7934 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7935 |
return |
| 7936 |
} |
| 7937 |
|
| 7938 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7939 |
defer func() { |
| 7940 |
*o = (*o)[:0] |
| 7941 |
addOptPool.Put(o) |
| 7942 |
}() |
| 7943 |
|
| 7944 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7945 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7946 |
} |
| 7947 |
|
| 7948 |
// AttrVolumeType returns an optional attribute for the "k8s.volume.type" |
| 7949 |
// semantic convention. It represents the type of the K8s volume. |
| 7950 |
func (PodVolumeInodeFree) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue { |
| 7951 |
return attribute.String("k8s.volume.type", string(val)) |
| 7952 |
} |
| 7953 |
|
| 7954 |
// PodVolumeInodeUsed is an instrument used to record metric values conforming to |
| 7955 |
// the "k8s.pod.volume.inode.used" semantic conventions. It represents the inodes |
| 7956 |
// used by the filesystem of the Pod's volume. |
| 7957 |
type PodVolumeInodeUsed struct { |
| 7958 |
metric.Int64UpDownCounter |
| 7959 |
} |
| 7960 |
|
| 7961 |
var newPodVolumeInodeUsedOpts = []metric.Int64UpDownCounterOption{ |
| 7962 |
metric.WithDescription("The inodes used by the filesystem of the Pod's volume."), |
| 7963 |
metric.WithUnit("{inode}"), |
| 7964 |
} |
| 7965 |
|
| 7966 |
// NewPodVolumeInodeUsed returns a new PodVolumeInodeUsed instrument. |
| 7967 |
func NewPodVolumeInodeUsed( |
| 7968 |
m metric.Meter, |
| 7969 |
opt ...metric.Int64UpDownCounterOption, |
| 7970 |
) (PodVolumeInodeUsed, error) { |
| 7971 |
// Check if the meter is nil. |
| 7972 |
if m == nil { |
| 7973 |
return PodVolumeInodeUsed{noop.Int64UpDownCounter{}}, nil |
| 7974 |
} |
| 7975 |
|
| 7976 |
if len(opt) == 0 { |
| 7977 |
opt = newPodVolumeInodeUsedOpts |
| 7978 |
} else { |
| 7979 |
opt = append(opt, newPodVolumeInodeUsedOpts...) |
| 7980 |
} |
| 7981 |
|
| 7982 |
i, err := m.Int64UpDownCounter( |
| 7983 |
"k8s.pod.volume.inode.used", |
| 7984 |
opt..., |
| 7985 |
) |
| 7986 |
if err != nil { |
| 7987 |
return PodVolumeInodeUsed{noop.Int64UpDownCounter{}}, err |
| 7988 |
} |
| 7989 |
return PodVolumeInodeUsed{i}, nil |
| 7990 |
} |
| 7991 |
|
| 7992 |
// Inst returns the underlying metric instrument. |
| 7993 |
func (m PodVolumeInodeUsed) Inst() metric.Int64UpDownCounter { |
| 7994 |
return m.Int64UpDownCounter |
| 7995 |
} |
| 7996 |
|
| 7997 |
// Name returns the semantic convention name of the instrument. |
| 7998 |
func (PodVolumeInodeUsed) Name() string { |
| 7999 |
return "k8s.pod.volume.inode.used" |
| 8000 |
} |
| 8001 |
|
| 8002 |
// Unit returns the semantic convention unit of the instrument |
| 8003 |
func (PodVolumeInodeUsed) Unit() string { |
| 8004 |
return "{inode}" |
| 8005 |
} |
| 8006 |
|
| 8007 |
// Description returns the semantic convention description of the instrument |
| 8008 |
func (PodVolumeInodeUsed) Description() string { |
| 8009 |
return "The inodes used by the filesystem of the Pod's volume." |
| 8010 |
} |
| 8011 |
|
| 8012 |
// Add adds incr to the existing count for attrs. |
| 8013 |
// |
| 8014 |
// The volumeName is the the name of the K8s volume. |
| 8015 |
// |
| 8016 |
// All additional attrs passed are included in the recorded value. |
| 8017 |
// |
| 8018 |
// This metric is derived from the |
| 8019 |
// [VolumeStats.InodesUsed] field |
| 8020 |
// of the [PodStats] of the |
| 8021 |
// Kubelet's stats API. |
| 8022 |
// |
| 8023 |
// This may not be equal to `inodes - free` because filesystem may share inodes |
| 8024 |
// with other filesystems. |
| 8025 |
// |
| 8026 |
// [VolumeStats.InodesUsed]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 8027 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 8028 |
func (m PodVolumeInodeUsed) Add( |
| 8029 |
ctx context.Context, |
| 8030 |
incr int64, |
| 8031 |
volumeName string, |
| 8032 |
attrs ...attribute.KeyValue, |
| 8033 |
) { |
| 8034 |
if len(attrs) == 0 { |
| 8035 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 8036 |
attribute.String("k8s.volume.name", volumeName), |
| 8037 |
)) |
| 8038 |
return |
| 8039 |
} |
| 8040 |
|
| 8041 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8042 |
defer func() { |
| 8043 |
*o = (*o)[:0] |
| 8044 |
addOptPool.Put(o) |
| 8045 |
}() |
| 8046 |
|
| 8047 |
*o = append( |
| 8048 |
*o, |
| 8049 |
metric.WithAttributes( |
| 8050 |
append( |
| 8051 |
attrs, |
| 8052 |
attribute.String("k8s.volume.name", volumeName), |
| 8053 |
)..., |
| 8054 |
), |
| 8055 |
) |
| 8056 |
|
| 8057 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8058 |
} |
| 8059 |
|
| 8060 |
// AddSet adds incr to the existing count for set. |
| 8061 |
// |
| 8062 |
// This metric is derived from the |
| 8063 |
// [VolumeStats.InodesUsed] field |
| 8064 |
// of the [PodStats] of the |
| 8065 |
// Kubelet's stats API. |
| 8066 |
// |
| 8067 |
// This may not be equal to `inodes - free` because filesystem may share inodes |
| 8068 |
// with other filesystems. |
| 8069 |
// |
| 8070 |
// [VolumeStats.InodesUsed]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 8071 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 8072 |
func (m PodVolumeInodeUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8073 |
if set.Len() == 0 { |
| 8074 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8075 |
return |
| 8076 |
} |
| 8077 |
|
| 8078 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8079 |
defer func() { |
| 8080 |
*o = (*o)[:0] |
| 8081 |
addOptPool.Put(o) |
| 8082 |
}() |
| 8083 |
|
| 8084 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8085 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8086 |
} |
| 8087 |
|
| 8088 |
// AttrVolumeType returns an optional attribute for the "k8s.volume.type" |
| 8089 |
// semantic convention. It represents the type of the K8s volume. |
| 8090 |
func (PodVolumeInodeUsed) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue { |
| 8091 |
return attribute.String("k8s.volume.type", string(val)) |
| 8092 |
} |
| 8093 |
|
| 8094 |
// PodVolumeUsage is an instrument used to record metric values conforming to the |
| 8095 |
// "k8s.pod.volume.usage" semantic conventions. It represents the pod volume |
| 8096 |
// usage. |
| 8097 |
type PodVolumeUsage struct { |
| 8098 |
metric.Int64UpDownCounter |
| 8099 |
} |
| 8100 |
|
| 8101 |
var newPodVolumeUsageOpts = []metric.Int64UpDownCounterOption{ |
| 8102 |
metric.WithDescription("Pod volume usage."), |
| 8103 |
metric.WithUnit("By"), |
| 8104 |
} |
| 8105 |
|
| 8106 |
// NewPodVolumeUsage returns a new PodVolumeUsage instrument. |
| 8107 |
func NewPodVolumeUsage( |
| 8108 |
m metric.Meter, |
| 8109 |
opt ...metric.Int64UpDownCounterOption, |
| 8110 |
) (PodVolumeUsage, error) { |
| 8111 |
// Check if the meter is nil. |
| 8112 |
if m == nil { |
| 8113 |
return PodVolumeUsage{noop.Int64UpDownCounter{}}, nil |
| 8114 |
} |
| 8115 |
|
| 8116 |
if len(opt) == 0 { |
| 8117 |
opt = newPodVolumeUsageOpts |
| 8118 |
} else { |
| 8119 |
opt = append(opt, newPodVolumeUsageOpts...) |
| 8120 |
} |
| 8121 |
|
| 8122 |
i, err := m.Int64UpDownCounter( |
| 8123 |
"k8s.pod.volume.usage", |
| 8124 |
opt..., |
| 8125 |
) |
| 8126 |
if err != nil { |
| 8127 |
return PodVolumeUsage{noop.Int64UpDownCounter{}}, err |
| 8128 |
} |
| 8129 |
return PodVolumeUsage{i}, nil |
| 8130 |
} |
| 8131 |
|
| 8132 |
// Inst returns the underlying metric instrument. |
| 8133 |
func (m PodVolumeUsage) Inst() metric.Int64UpDownCounter { |
| 8134 |
return m.Int64UpDownCounter |
| 8135 |
} |
| 8136 |
|
| 8137 |
// Name returns the semantic convention name of the instrument. |
| 8138 |
func (PodVolumeUsage) Name() string { |
| 8139 |
return "k8s.pod.volume.usage" |
| 8140 |
} |
| 8141 |
|
| 8142 |
// Unit returns the semantic convention unit of the instrument |
| 8143 |
func (PodVolumeUsage) Unit() string { |
| 8144 |
return "By" |
| 8145 |
} |
| 8146 |
|
| 8147 |
// Description returns the semantic convention description of the instrument |
| 8148 |
func (PodVolumeUsage) Description() string { |
| 8149 |
return "Pod volume usage." |
| 8150 |
} |
| 8151 |
|
| 8152 |
// Add adds incr to the existing count for attrs. |
| 8153 |
// |
| 8154 |
// The volumeName is the the name of the K8s volume. |
| 8155 |
// |
| 8156 |
// All additional attrs passed are included in the recorded value. |
| 8157 |
// |
| 8158 |
// This may not equal capacity - available. |
| 8159 |
// |
| 8160 |
// This metric is derived from the |
| 8161 |
// [VolumeStats.UsedBytes] field |
| 8162 |
// of the [PodStats] of the |
| 8163 |
// Kubelet's stats API. |
| 8164 |
// |
| 8165 |
// [VolumeStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 8166 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 8167 |
func (m PodVolumeUsage) Add( |
| 8168 |
ctx context.Context, |
| 8169 |
incr int64, |
| 8170 |
volumeName string, |
| 8171 |
attrs ...attribute.KeyValue, |
| 8172 |
) { |
| 8173 |
if len(attrs) == 0 { |
| 8174 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 8175 |
attribute.String("k8s.volume.name", volumeName), |
| 8176 |
)) |
| 8177 |
return |
| 8178 |
} |
| 8179 |
|
| 8180 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8181 |
defer func() { |
| 8182 |
*o = (*o)[:0] |
| 8183 |
addOptPool.Put(o) |
| 8184 |
}() |
| 8185 |
|
| 8186 |
*o = append( |
| 8187 |
*o, |
| 8188 |
metric.WithAttributes( |
| 8189 |
append( |
| 8190 |
attrs, |
| 8191 |
attribute.String("k8s.volume.name", volumeName), |
| 8192 |
)..., |
| 8193 |
), |
| 8194 |
) |
| 8195 |
|
| 8196 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8197 |
} |
| 8198 |
|
| 8199 |
// AddSet adds incr to the existing count for set. |
| 8200 |
// |
| 8201 |
// This may not equal capacity - available. |
| 8202 |
// |
| 8203 |
// This metric is derived from the |
| 8204 |
// [VolumeStats.UsedBytes] field |
| 8205 |
// of the [PodStats] of the |
| 8206 |
// Kubelet's stats API. |
| 8207 |
// |
| 8208 |
// [VolumeStats.UsedBytes]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#VolumeStats |
| 8209 |
// [PodStats]: https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats |
| 8210 |
func (m PodVolumeUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8211 |
if set.Len() == 0 { |
| 8212 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8213 |
return |
| 8214 |
} |
| 8215 |
|
| 8216 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8217 |
defer func() { |
| 8218 |
*o = (*o)[:0] |
| 8219 |
addOptPool.Put(o) |
| 8220 |
}() |
| 8221 |
|
| 8222 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8223 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8224 |
} |
| 8225 |
|
| 8226 |
// AttrVolumeType returns an optional attribute for the "k8s.volume.type" |
| 8227 |
// semantic convention. It represents the type of the K8s volume. |
| 8228 |
func (PodVolumeUsage) AttrVolumeType(val VolumeTypeAttr) attribute.KeyValue { |
| 8229 |
return attribute.String("k8s.volume.type", string(val)) |
| 8230 |
} |
| 8231 |
|
| 8232 |
// ReplicaSetPodAvailable is an instrument used to record metric values |
| 8233 |
// conforming to the "k8s.replicaset.pod.available" semantic conventions. It |
| 8234 |
// represents the total number of available replica pods (ready for at least |
| 8235 |
// minReadySeconds) targeted by this replicaset. |
| 8236 |
type ReplicaSetPodAvailable struct { |
| 8237 |
metric.Int64UpDownCounter |
| 8238 |
} |
| 8239 |
|
| 8240 |
var newReplicaSetPodAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 8241 |
metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset."), |
| 8242 |
metric.WithUnit("{pod}"), |
| 8243 |
} |
| 8244 |
|
| 8245 |
// NewReplicaSetPodAvailable returns a new ReplicaSetPodAvailable instrument. |
| 8246 |
func NewReplicaSetPodAvailable( |
| 8247 |
m metric.Meter, |
| 8248 |
opt ...metric.Int64UpDownCounterOption, |
| 8249 |
) (ReplicaSetPodAvailable, error) { |
| 8250 |
// Check if the meter is nil. |
| 8251 |
if m == nil { |
| 8252 |
return ReplicaSetPodAvailable{noop.Int64UpDownCounter{}}, nil |
| 8253 |
} |
| 8254 |
|
| 8255 |
if len(opt) == 0 { |
| 8256 |
opt = newReplicaSetPodAvailableOpts |
| 8257 |
} else { |
| 8258 |
opt = append(opt, newReplicaSetPodAvailableOpts...) |
| 8259 |
} |
| 8260 |
|
| 8261 |
i, err := m.Int64UpDownCounter( |
| 8262 |
"k8s.replicaset.pod.available", |
| 8263 |
opt..., |
| 8264 |
) |
| 8265 |
if err != nil { |
| 8266 |
return ReplicaSetPodAvailable{noop.Int64UpDownCounter{}}, err |
| 8267 |
} |
| 8268 |
return ReplicaSetPodAvailable{i}, nil |
| 8269 |
} |
| 8270 |
|
| 8271 |
// Inst returns the underlying metric instrument. |
| 8272 |
func (m ReplicaSetPodAvailable) Inst() metric.Int64UpDownCounter { |
| 8273 |
return m.Int64UpDownCounter |
| 8274 |
} |
| 8275 |
|
| 8276 |
// Name returns the semantic convention name of the instrument. |
| 8277 |
func (ReplicaSetPodAvailable) Name() string { |
| 8278 |
return "k8s.replicaset.pod.available" |
| 8279 |
} |
| 8280 |
|
| 8281 |
// Unit returns the semantic convention unit of the instrument |
| 8282 |
func (ReplicaSetPodAvailable) Unit() string { |
| 8283 |
return "{pod}" |
| 8284 |
} |
| 8285 |
|
| 8286 |
// Description returns the semantic convention description of the instrument |
| 8287 |
func (ReplicaSetPodAvailable) Description() string { |
| 8288 |
return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset." |
| 8289 |
} |
| 8290 |
|
| 8291 |
// Add adds incr to the existing count for attrs. |
| 8292 |
// |
| 8293 |
// This metric aligns with the `availableReplicas` field of the |
| 8294 |
// [K8s ReplicaSetStatus]. |
| 8295 |
// |
| 8296 |
// [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps |
| 8297 |
func (m ReplicaSetPodAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 8298 |
if len(attrs) == 0 { |
| 8299 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8300 |
return |
| 8301 |
} |
| 8302 |
|
| 8303 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8304 |
defer func() { |
| 8305 |
*o = (*o)[:0] |
| 8306 |
addOptPool.Put(o) |
| 8307 |
}() |
| 8308 |
|
| 8309 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 8310 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8311 |
} |
| 8312 |
|
| 8313 |
// AddSet adds incr to the existing count for set. |
| 8314 |
// |
| 8315 |
// This metric aligns with the `availableReplicas` field of the |
| 8316 |
// [K8s ReplicaSetStatus]. |
| 8317 |
// |
| 8318 |
// [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps |
| 8319 |
func (m ReplicaSetPodAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8320 |
if set.Len() == 0 { |
| 8321 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8322 |
return |
| 8323 |
} |
| 8324 |
|
| 8325 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8326 |
defer func() { |
| 8327 |
*o = (*o)[:0] |
| 8328 |
addOptPool.Put(o) |
| 8329 |
}() |
| 8330 |
|
| 8331 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8332 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8333 |
} |
| 8334 |
|
| 8335 |
// ReplicaSetPodDesired is an instrument used to record metric values conforming |
| 8336 |
// to the "k8s.replicaset.pod.desired" semantic conventions. It represents the |
| 8337 |
// number of desired replica pods in this replicaset. |
| 8338 |
type ReplicaSetPodDesired struct { |
| 8339 |
metric.Int64UpDownCounter |
| 8340 |
} |
| 8341 |
|
| 8342 |
var newReplicaSetPodDesiredOpts = []metric.Int64UpDownCounterOption{ |
| 8343 |
metric.WithDescription("Number of desired replica pods in this replicaset."), |
| 8344 |
metric.WithUnit("{pod}"), |
| 8345 |
} |
| 8346 |
|
| 8347 |
// NewReplicaSetPodDesired returns a new ReplicaSetPodDesired instrument. |
| 8348 |
func NewReplicaSetPodDesired( |
| 8349 |
m metric.Meter, |
| 8350 |
opt ...metric.Int64UpDownCounterOption, |
| 8351 |
) (ReplicaSetPodDesired, error) { |
| 8352 |
// Check if the meter is nil. |
| 8353 |
if m == nil { |
| 8354 |
return ReplicaSetPodDesired{noop.Int64UpDownCounter{}}, nil |
| 8355 |
} |
| 8356 |
|
| 8357 |
if len(opt) == 0 { |
| 8358 |
opt = newReplicaSetPodDesiredOpts |
| 8359 |
} else { |
| 8360 |
opt = append(opt, newReplicaSetPodDesiredOpts...) |
| 8361 |
} |
| 8362 |
|
| 8363 |
i, err := m.Int64UpDownCounter( |
| 8364 |
"k8s.replicaset.pod.desired", |
| 8365 |
opt..., |
| 8366 |
) |
| 8367 |
if err != nil { |
| 8368 |
return ReplicaSetPodDesired{noop.Int64UpDownCounter{}}, err |
| 8369 |
} |
| 8370 |
return ReplicaSetPodDesired{i}, nil |
| 8371 |
} |
| 8372 |
|
| 8373 |
// Inst returns the underlying metric instrument. |
| 8374 |
func (m ReplicaSetPodDesired) Inst() metric.Int64UpDownCounter { |
| 8375 |
return m.Int64UpDownCounter |
| 8376 |
} |
| 8377 |
|
| 8378 |
// Name returns the semantic convention name of the instrument. |
| 8379 |
func (ReplicaSetPodDesired) Name() string { |
| 8380 |
return "k8s.replicaset.pod.desired" |
| 8381 |
} |
| 8382 |
|
| 8383 |
// Unit returns the semantic convention unit of the instrument |
| 8384 |
func (ReplicaSetPodDesired) Unit() string { |
| 8385 |
return "{pod}" |
| 8386 |
} |
| 8387 |
|
| 8388 |
// Description returns the semantic convention description of the instrument |
| 8389 |
func (ReplicaSetPodDesired) Description() string { |
| 8390 |
return "Number of desired replica pods in this replicaset." |
| 8391 |
} |
| 8392 |
|
| 8393 |
// Add adds incr to the existing count for attrs. |
| 8394 |
// |
| 8395 |
// This metric aligns with the `replicas` field of the |
| 8396 |
// [K8s ReplicaSetSpec]. |
| 8397 |
// |
| 8398 |
// [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps |
| 8399 |
func (m ReplicaSetPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 8400 |
if len(attrs) == 0 { |
| 8401 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8402 |
return |
| 8403 |
} |
| 8404 |
|
| 8405 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8406 |
defer func() { |
| 8407 |
*o = (*o)[:0] |
| 8408 |
addOptPool.Put(o) |
| 8409 |
}() |
| 8410 |
|
| 8411 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 8412 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8413 |
} |
| 8414 |
|
| 8415 |
// AddSet adds incr to the existing count for set. |
| 8416 |
// |
| 8417 |
// This metric aligns with the `replicas` field of the |
| 8418 |
// [K8s ReplicaSetSpec]. |
| 8419 |
// |
| 8420 |
// [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps |
| 8421 |
func (m ReplicaSetPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8422 |
if set.Len() == 0 { |
| 8423 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8424 |
return |
| 8425 |
} |
| 8426 |
|
| 8427 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8428 |
defer func() { |
| 8429 |
*o = (*o)[:0] |
| 8430 |
addOptPool.Put(o) |
| 8431 |
}() |
| 8432 |
|
| 8433 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8434 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8435 |
} |
| 8436 |
|
| 8437 |
// ReplicationControllerPodAvailable is an instrument used to record metric |
| 8438 |
// values conforming to the "k8s.replicationcontroller.pod.available" semantic |
| 8439 |
// conventions. It represents the total number of available replica pods (ready |
| 8440 |
// for at least minReadySeconds) targeted by this replication controller. |
| 8441 |
type ReplicationControllerPodAvailable struct { |
| 8442 |
metric.Int64UpDownCounter |
| 8443 |
} |
| 8444 |
|
| 8445 |
var newReplicationControllerPodAvailableOpts = []metric.Int64UpDownCounterOption{ |
| 8446 |
metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller."), |
| 8447 |
metric.WithUnit("{pod}"), |
| 8448 |
} |
| 8449 |
|
| 8450 |
// NewReplicationControllerPodAvailable returns a new |
| 8451 |
// ReplicationControllerPodAvailable instrument. |
| 8452 |
func NewReplicationControllerPodAvailable( |
| 8453 |
m metric.Meter, |
| 8454 |
opt ...metric.Int64UpDownCounterOption, |
| 8455 |
) (ReplicationControllerPodAvailable, error) { |
| 8456 |
// Check if the meter is nil. |
| 8457 |
if m == nil { |
| 8458 |
return ReplicationControllerPodAvailable{noop.Int64UpDownCounter{}}, nil |
| 8459 |
} |
| 8460 |
|
| 8461 |
if len(opt) == 0 { |
| 8462 |
opt = newReplicationControllerPodAvailableOpts |
| 8463 |
} else { |
| 8464 |
opt = append(opt, newReplicationControllerPodAvailableOpts...) |
| 8465 |
} |
| 8466 |
|
| 8467 |
i, err := m.Int64UpDownCounter( |
| 8468 |
"k8s.replicationcontroller.pod.available", |
| 8469 |
opt..., |
| 8470 |
) |
| 8471 |
if err != nil { |
| 8472 |
return ReplicationControllerPodAvailable{noop.Int64UpDownCounter{}}, err |
| 8473 |
} |
| 8474 |
return ReplicationControllerPodAvailable{i}, nil |
| 8475 |
} |
| 8476 |
|
| 8477 |
// Inst returns the underlying metric instrument. |
| 8478 |
func (m ReplicationControllerPodAvailable) Inst() metric.Int64UpDownCounter { |
| 8479 |
return m.Int64UpDownCounter |
| 8480 |
} |
| 8481 |
|
| 8482 |
// Name returns the semantic convention name of the instrument. |
| 8483 |
func (ReplicationControllerPodAvailable) Name() string { |
| 8484 |
return "k8s.replicationcontroller.pod.available" |
| 8485 |
} |
| 8486 |
|
| 8487 |
// Unit returns the semantic convention unit of the instrument |
| 8488 |
func (ReplicationControllerPodAvailable) Unit() string { |
| 8489 |
return "{pod}" |
| 8490 |
} |
| 8491 |
|
| 8492 |
// Description returns the semantic convention description of the instrument |
| 8493 |
func (ReplicationControllerPodAvailable) Description() string { |
| 8494 |
return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller." |
| 8495 |
} |
| 8496 |
|
| 8497 |
// Add adds incr to the existing count for attrs. |
| 8498 |
// |
| 8499 |
// This metric aligns with the `availableReplicas` field of the |
| 8500 |
// [K8s ReplicationControllerStatus] |
| 8501 |
// |
| 8502 |
// [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core |
| 8503 |
func (m ReplicationControllerPodAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 8504 |
if len(attrs) == 0 { |
| 8505 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8506 |
return |
| 8507 |
} |
| 8508 |
|
| 8509 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8510 |
defer func() { |
| 8511 |
*o = (*o)[:0] |
| 8512 |
addOptPool.Put(o) |
| 8513 |
}() |
| 8514 |
|
| 8515 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 8516 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8517 |
} |
| 8518 |
|
| 8519 |
// AddSet adds incr to the existing count for set. |
| 8520 |
// |
| 8521 |
// This metric aligns with the `availableReplicas` field of the |
| 8522 |
// [K8s ReplicationControllerStatus] |
| 8523 |
// |
| 8524 |
// [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core |
| 8525 |
func (m ReplicationControllerPodAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8526 |
if set.Len() == 0 { |
| 8527 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8528 |
return |
| 8529 |
} |
| 8530 |
|
| 8531 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8532 |
defer func() { |
| 8533 |
*o = (*o)[:0] |
| 8534 |
addOptPool.Put(o) |
| 8535 |
}() |
| 8536 |
|
| 8537 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8538 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8539 |
} |
| 8540 |
|
| 8541 |
// ReplicationControllerPodDesired is an instrument used to record metric values |
| 8542 |
// conforming to the "k8s.replicationcontroller.pod.desired" semantic |
| 8543 |
// conventions. It represents the number of desired replica pods in this |
| 8544 |
// replication controller. |
| 8545 |
type ReplicationControllerPodDesired struct { |
| 8546 |
metric.Int64UpDownCounter |
| 8547 |
} |
| 8548 |
|
| 8549 |
var newReplicationControllerPodDesiredOpts = []metric.Int64UpDownCounterOption{ |
| 8550 |
metric.WithDescription("Number of desired replica pods in this replication controller."), |
| 8551 |
metric.WithUnit("{pod}"), |
| 8552 |
} |
| 8553 |
|
| 8554 |
// NewReplicationControllerPodDesired returns a new |
| 8555 |
// ReplicationControllerPodDesired instrument. |
| 8556 |
func NewReplicationControllerPodDesired( |
| 8557 |
m metric.Meter, |
| 8558 |
opt ...metric.Int64UpDownCounterOption, |
| 8559 |
) (ReplicationControllerPodDesired, error) { |
| 8560 |
// Check if the meter is nil. |
| 8561 |
if m == nil { |
| 8562 |
return ReplicationControllerPodDesired{noop.Int64UpDownCounter{}}, nil |
| 8563 |
} |
| 8564 |
|
| 8565 |
if len(opt) == 0 { |
| 8566 |
opt = newReplicationControllerPodDesiredOpts |
| 8567 |
} else { |
| 8568 |
opt = append(opt, newReplicationControllerPodDesiredOpts...) |
| 8569 |
} |
| 8570 |
|
| 8571 |
i, err := m.Int64UpDownCounter( |
| 8572 |
"k8s.replicationcontroller.pod.desired", |
| 8573 |
opt..., |
| 8574 |
) |
| 8575 |
if err != nil { |
| 8576 |
return ReplicationControllerPodDesired{noop.Int64UpDownCounter{}}, err |
| 8577 |
} |
| 8578 |
return ReplicationControllerPodDesired{i}, nil |
| 8579 |
} |
| 8580 |
|
| 8581 |
// Inst returns the underlying metric instrument. |
| 8582 |
func (m ReplicationControllerPodDesired) Inst() metric.Int64UpDownCounter { |
| 8583 |
return m.Int64UpDownCounter |
| 8584 |
} |
| 8585 |
|
| 8586 |
// Name returns the semantic convention name of the instrument. |
| 8587 |
func (ReplicationControllerPodDesired) Name() string { |
| 8588 |
return "k8s.replicationcontroller.pod.desired" |
| 8589 |
} |
| 8590 |
|
| 8591 |
// Unit returns the semantic convention unit of the instrument |
| 8592 |
func (ReplicationControllerPodDesired) Unit() string { |
| 8593 |
return "{pod}" |
| 8594 |
} |
| 8595 |
|
| 8596 |
// Description returns the semantic convention description of the instrument |
| 8597 |
func (ReplicationControllerPodDesired) Description() string { |
| 8598 |
return "Number of desired replica pods in this replication controller." |
| 8599 |
} |
| 8600 |
|
| 8601 |
// Add adds incr to the existing count for attrs. |
| 8602 |
// |
| 8603 |
// This metric aligns with the `replicas` field of the |
| 8604 |
// [K8s ReplicationControllerSpec] |
| 8605 |
// |
| 8606 |
// [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core |
| 8607 |
func (m ReplicationControllerPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 8608 |
if len(attrs) == 0 { |
| 8609 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8610 |
return |
| 8611 |
} |
| 8612 |
|
| 8613 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8614 |
defer func() { |
| 8615 |
*o = (*o)[:0] |
| 8616 |
addOptPool.Put(o) |
| 8617 |
}() |
| 8618 |
|
| 8619 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 8620 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8621 |
} |
| 8622 |
|
| 8623 |
// AddSet adds incr to the existing count for set. |
| 8624 |
// |
| 8625 |
// This metric aligns with the `replicas` field of the |
| 8626 |
// [K8s ReplicationControllerSpec] |
| 8627 |
// |
| 8628 |
// [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core |
| 8629 |
func (m ReplicationControllerPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8630 |
if set.Len() == 0 { |
| 8631 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8632 |
return |
| 8633 |
} |
| 8634 |
|
| 8635 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8636 |
defer func() { |
| 8637 |
*o = (*o)[:0] |
| 8638 |
addOptPool.Put(o) |
| 8639 |
}() |
| 8640 |
|
| 8641 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8642 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8643 |
} |
| 8644 |
|
| 8645 |
// ResourceQuotaCPULimitHard is an instrument used to record metric values |
| 8646 |
// conforming to the "k8s.resourcequota.cpu.limit.hard" semantic conventions. It |
| 8647 |
// represents the CPU limits in a specific namespace. |
| 8648 |
// The value represents the configured quota limit of the resource in the |
| 8649 |
// namespace. |
| 8650 |
type ResourceQuotaCPULimitHard struct { |
| 8651 |
metric.Int64UpDownCounter |
| 8652 |
} |
| 8653 |
|
| 8654 |
var newResourceQuotaCPULimitHardOpts = []metric.Int64UpDownCounterOption{ |
| 8655 |
metric.WithDescription("The CPU limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 8656 |
metric.WithUnit("{cpu}"), |
| 8657 |
} |
| 8658 |
|
| 8659 |
// NewResourceQuotaCPULimitHard returns a new ResourceQuotaCPULimitHard |
| 8660 |
// instrument. |
| 8661 |
func NewResourceQuotaCPULimitHard( |
| 8662 |
m metric.Meter, |
| 8663 |
opt ...metric.Int64UpDownCounterOption, |
| 8664 |
) (ResourceQuotaCPULimitHard, error) { |
| 8665 |
// Check if the meter is nil. |
| 8666 |
if m == nil { |
| 8667 |
return ResourceQuotaCPULimitHard{noop.Int64UpDownCounter{}}, nil |
| 8668 |
} |
| 8669 |
|
| 8670 |
if len(opt) == 0 { |
| 8671 |
opt = newResourceQuotaCPULimitHardOpts |
| 8672 |
} else { |
| 8673 |
opt = append(opt, newResourceQuotaCPULimitHardOpts...) |
| 8674 |
} |
| 8675 |
|
| 8676 |
i, err := m.Int64UpDownCounter( |
| 8677 |
"k8s.resourcequota.cpu.limit.hard", |
| 8678 |
opt..., |
| 8679 |
) |
| 8680 |
if err != nil { |
| 8681 |
return ResourceQuotaCPULimitHard{noop.Int64UpDownCounter{}}, err |
| 8682 |
} |
| 8683 |
return ResourceQuotaCPULimitHard{i}, nil |
| 8684 |
} |
| 8685 |
|
| 8686 |
// Inst returns the underlying metric instrument. |
| 8687 |
func (m ResourceQuotaCPULimitHard) Inst() metric.Int64UpDownCounter { |
| 8688 |
return m.Int64UpDownCounter |
| 8689 |
} |
| 8690 |
|
| 8691 |
// Name returns the semantic convention name of the instrument. |
| 8692 |
func (ResourceQuotaCPULimitHard) Name() string { |
| 8693 |
return "k8s.resourcequota.cpu.limit.hard" |
| 8694 |
} |
| 8695 |
|
| 8696 |
// Unit returns the semantic convention unit of the instrument |
| 8697 |
func (ResourceQuotaCPULimitHard) Unit() string { |
| 8698 |
return "{cpu}" |
| 8699 |
} |
| 8700 |
|
| 8701 |
// Description returns the semantic convention description of the instrument |
| 8702 |
func (ResourceQuotaCPULimitHard) Description() string { |
| 8703 |
return "The CPU limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 8704 |
} |
| 8705 |
|
| 8706 |
// Add adds incr to the existing count for attrs. |
| 8707 |
// |
| 8708 |
// This metric is retrieved from the `hard` field of the |
| 8709 |
// [K8s ResourceQuotaStatus]. |
| 8710 |
// |
| 8711 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 8712 |
func (m ResourceQuotaCPULimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 8713 |
if len(attrs) == 0 { |
| 8714 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8715 |
return |
| 8716 |
} |
| 8717 |
|
| 8718 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8719 |
defer func() { |
| 8720 |
*o = (*o)[:0] |
| 8721 |
addOptPool.Put(o) |
| 8722 |
}() |
| 8723 |
|
| 8724 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 8725 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8726 |
} |
| 8727 |
|
| 8728 |
// AddSet adds incr to the existing count for set. |
| 8729 |
// |
| 8730 |
// This metric is retrieved from the `hard` field of the |
| 8731 |
// [K8s ResourceQuotaStatus]. |
| 8732 |
// |
| 8733 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 8734 |
func (m ResourceQuotaCPULimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8735 |
if set.Len() == 0 { |
| 8736 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8737 |
return |
| 8738 |
} |
| 8739 |
|
| 8740 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8741 |
defer func() { |
| 8742 |
*o = (*o)[:0] |
| 8743 |
addOptPool.Put(o) |
| 8744 |
}() |
| 8745 |
|
| 8746 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8747 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8748 |
} |
| 8749 |
|
| 8750 |
// ResourceQuotaCPULimitUsed is an instrument used to record metric values |
| 8751 |
// conforming to the "k8s.resourcequota.cpu.limit.used" semantic conventions. It |
| 8752 |
// represents the CPU limits in a specific namespace. |
| 8753 |
// The value represents the current observed total usage of the resource in the |
| 8754 |
// namespace. |
| 8755 |
type ResourceQuotaCPULimitUsed struct { |
| 8756 |
metric.Int64UpDownCounter |
| 8757 |
} |
| 8758 |
|
| 8759 |
var newResourceQuotaCPULimitUsedOpts = []metric.Int64UpDownCounterOption{ |
| 8760 |
metric.WithDescription("The CPU limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 8761 |
metric.WithUnit("{cpu}"), |
| 8762 |
} |
| 8763 |
|
| 8764 |
// NewResourceQuotaCPULimitUsed returns a new ResourceQuotaCPULimitUsed |
| 8765 |
// instrument. |
| 8766 |
func NewResourceQuotaCPULimitUsed( |
| 8767 |
m metric.Meter, |
| 8768 |
opt ...metric.Int64UpDownCounterOption, |
| 8769 |
) (ResourceQuotaCPULimitUsed, error) { |
| 8770 |
// Check if the meter is nil. |
| 8771 |
if m == nil { |
| 8772 |
return ResourceQuotaCPULimitUsed{noop.Int64UpDownCounter{}}, nil |
| 8773 |
} |
| 8774 |
|
| 8775 |
if len(opt) == 0 { |
| 8776 |
opt = newResourceQuotaCPULimitUsedOpts |
| 8777 |
} else { |
| 8778 |
opt = append(opt, newResourceQuotaCPULimitUsedOpts...) |
| 8779 |
} |
| 8780 |
|
| 8781 |
i, err := m.Int64UpDownCounter( |
| 8782 |
"k8s.resourcequota.cpu.limit.used", |
| 8783 |
opt..., |
| 8784 |
) |
| 8785 |
if err != nil { |
| 8786 |
return ResourceQuotaCPULimitUsed{noop.Int64UpDownCounter{}}, err |
| 8787 |
} |
| 8788 |
return ResourceQuotaCPULimitUsed{i}, nil |
| 8789 |
} |
| 8790 |
|
| 8791 |
// Inst returns the underlying metric instrument. |
| 8792 |
func (m ResourceQuotaCPULimitUsed) Inst() metric.Int64UpDownCounter { |
| 8793 |
return m.Int64UpDownCounter |
| 8794 |
} |
| 8795 |
|
| 8796 |
// Name returns the semantic convention name of the instrument. |
| 8797 |
func (ResourceQuotaCPULimitUsed) Name() string { |
| 8798 |
return "k8s.resourcequota.cpu.limit.used" |
| 8799 |
} |
| 8800 |
|
| 8801 |
// Unit returns the semantic convention unit of the instrument |
| 8802 |
func (ResourceQuotaCPULimitUsed) Unit() string { |
| 8803 |
return "{cpu}" |
| 8804 |
} |
| 8805 |
|
| 8806 |
// Description returns the semantic convention description of the instrument |
| 8807 |
func (ResourceQuotaCPULimitUsed) Description() string { |
| 8808 |
return "The CPU limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 8809 |
} |
| 8810 |
|
| 8811 |
// Add adds incr to the existing count for attrs. |
| 8812 |
// |
| 8813 |
// This metric is retrieved from the `used` field of the |
| 8814 |
// [K8s ResourceQuotaStatus]. |
| 8815 |
// |
| 8816 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 8817 |
func (m ResourceQuotaCPULimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 8818 |
if len(attrs) == 0 { |
| 8819 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8820 |
return |
| 8821 |
} |
| 8822 |
|
| 8823 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8824 |
defer func() { |
| 8825 |
*o = (*o)[:0] |
| 8826 |
addOptPool.Put(o) |
| 8827 |
}() |
| 8828 |
|
| 8829 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 8830 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8831 |
} |
| 8832 |
|
| 8833 |
// AddSet adds incr to the existing count for set. |
| 8834 |
// |
| 8835 |
// This metric is retrieved from the `used` field of the |
| 8836 |
// [K8s ResourceQuotaStatus]. |
| 8837 |
// |
| 8838 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 8839 |
func (m ResourceQuotaCPULimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8840 |
if set.Len() == 0 { |
| 8841 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8842 |
return |
| 8843 |
} |
| 8844 |
|
| 8845 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8846 |
defer func() { |
| 8847 |
*o = (*o)[:0] |
| 8848 |
addOptPool.Put(o) |
| 8849 |
}() |
| 8850 |
|
| 8851 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8852 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8853 |
} |
| 8854 |
|
| 8855 |
// ResourceQuotaCPURequestHard is an instrument used to record metric values |
| 8856 |
// conforming to the "k8s.resourcequota.cpu.request.hard" semantic conventions. |
| 8857 |
// It represents the CPU requests in a specific namespace. |
| 8858 |
// The value represents the configured quota limit of the resource in the |
| 8859 |
// namespace. |
| 8860 |
type ResourceQuotaCPURequestHard struct { |
| 8861 |
metric.Int64UpDownCounter |
| 8862 |
} |
| 8863 |
|
| 8864 |
var newResourceQuotaCPURequestHardOpts = []metric.Int64UpDownCounterOption{ |
| 8865 |
metric.WithDescription("The CPU requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 8866 |
metric.WithUnit("{cpu}"), |
| 8867 |
} |
| 8868 |
|
| 8869 |
// NewResourceQuotaCPURequestHard returns a new ResourceQuotaCPURequestHard |
| 8870 |
// instrument. |
| 8871 |
func NewResourceQuotaCPURequestHard( |
| 8872 |
m metric.Meter, |
| 8873 |
opt ...metric.Int64UpDownCounterOption, |
| 8874 |
) (ResourceQuotaCPURequestHard, error) { |
| 8875 |
// Check if the meter is nil. |
| 8876 |
if m == nil { |
| 8877 |
return ResourceQuotaCPURequestHard{noop.Int64UpDownCounter{}}, nil |
| 8878 |
} |
| 8879 |
|
| 8880 |
if len(opt) == 0 { |
| 8881 |
opt = newResourceQuotaCPURequestHardOpts |
| 8882 |
} else { |
| 8883 |
opt = append(opt, newResourceQuotaCPURequestHardOpts...) |
| 8884 |
} |
| 8885 |
|
| 8886 |
i, err := m.Int64UpDownCounter( |
| 8887 |
"k8s.resourcequota.cpu.request.hard", |
| 8888 |
opt..., |
| 8889 |
) |
| 8890 |
if err != nil { |
| 8891 |
return ResourceQuotaCPURequestHard{noop.Int64UpDownCounter{}}, err |
| 8892 |
} |
| 8893 |
return ResourceQuotaCPURequestHard{i}, nil |
| 8894 |
} |
| 8895 |
|
| 8896 |
// Inst returns the underlying metric instrument. |
| 8897 |
func (m ResourceQuotaCPURequestHard) Inst() metric.Int64UpDownCounter { |
| 8898 |
return m.Int64UpDownCounter |
| 8899 |
} |
| 8900 |
|
| 8901 |
// Name returns the semantic convention name of the instrument. |
| 8902 |
func (ResourceQuotaCPURequestHard) Name() string { |
| 8903 |
return "k8s.resourcequota.cpu.request.hard" |
| 8904 |
} |
| 8905 |
|
| 8906 |
// Unit returns the semantic convention unit of the instrument |
| 8907 |
func (ResourceQuotaCPURequestHard) Unit() string { |
| 8908 |
return "{cpu}" |
| 8909 |
} |
| 8910 |
|
| 8911 |
// Description returns the semantic convention description of the instrument |
| 8912 |
func (ResourceQuotaCPURequestHard) Description() string { |
| 8913 |
return "The CPU requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 8914 |
} |
| 8915 |
|
| 8916 |
// Add adds incr to the existing count for attrs. |
| 8917 |
// |
| 8918 |
// This metric is retrieved from the `hard` field of the |
| 8919 |
// [K8s ResourceQuotaStatus]. |
| 8920 |
// |
| 8921 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 8922 |
func (m ResourceQuotaCPURequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 8923 |
if len(attrs) == 0 { |
| 8924 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8925 |
return |
| 8926 |
} |
| 8927 |
|
| 8928 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8929 |
defer func() { |
| 8930 |
*o = (*o)[:0] |
| 8931 |
addOptPool.Put(o) |
| 8932 |
}() |
| 8933 |
|
| 8934 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 8935 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8936 |
} |
| 8937 |
|
| 8938 |
// AddSet adds incr to the existing count for set. |
| 8939 |
// |
| 8940 |
// This metric is retrieved from the `hard` field of the |
| 8941 |
// [K8s ResourceQuotaStatus]. |
| 8942 |
// |
| 8943 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 8944 |
func (m ResourceQuotaCPURequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 8945 |
if set.Len() == 0 { |
| 8946 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 8947 |
return |
| 8948 |
} |
| 8949 |
|
| 8950 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 8951 |
defer func() { |
| 8952 |
*o = (*o)[:0] |
| 8953 |
addOptPool.Put(o) |
| 8954 |
}() |
| 8955 |
|
| 8956 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 8957 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 8958 |
} |
| 8959 |
|
| 8960 |
// ResourceQuotaCPURequestUsed is an instrument used to record metric values |
| 8961 |
// conforming to the "k8s.resourcequota.cpu.request.used" semantic conventions. |
| 8962 |
// It represents the CPU requests in a specific namespace. |
| 8963 |
// The value represents the current observed total usage of the resource in the |
| 8964 |
// namespace. |
| 8965 |
type ResourceQuotaCPURequestUsed struct { |
| 8966 |
metric.Int64UpDownCounter |
| 8967 |
} |
| 8968 |
|
| 8969 |
var newResourceQuotaCPURequestUsedOpts = []metric.Int64UpDownCounterOption{ |
| 8970 |
metric.WithDescription("The CPU requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 8971 |
metric.WithUnit("{cpu}"), |
| 8972 |
} |
| 8973 |
|
| 8974 |
// NewResourceQuotaCPURequestUsed returns a new ResourceQuotaCPURequestUsed |
| 8975 |
// instrument. |
| 8976 |
func NewResourceQuotaCPURequestUsed( |
| 8977 |
m metric.Meter, |
| 8978 |
opt ...metric.Int64UpDownCounterOption, |
| 8979 |
) (ResourceQuotaCPURequestUsed, error) { |
| 8980 |
// Check if the meter is nil. |
| 8981 |
if m == nil { |
| 8982 |
return ResourceQuotaCPURequestUsed{noop.Int64UpDownCounter{}}, nil |
| 8983 |
} |
| 8984 |
|
| 8985 |
if len(opt) == 0 { |
| 8986 |
opt = newResourceQuotaCPURequestUsedOpts |
| 8987 |
} else { |
| 8988 |
opt = append(opt, newResourceQuotaCPURequestUsedOpts...) |
| 8989 |
} |
| 8990 |
|
| 8991 |
i, err := m.Int64UpDownCounter( |
| 8992 |
"k8s.resourcequota.cpu.request.used", |
| 8993 |
opt..., |
| 8994 |
) |
| 8995 |
if err != nil { |
| 8996 |
return ResourceQuotaCPURequestUsed{noop.Int64UpDownCounter{}}, err |
| 8997 |
} |
| 8998 |
return ResourceQuotaCPURequestUsed{i}, nil |
| 8999 |
} |
| 9000 |
|
| 9001 |
// Inst returns the underlying metric instrument. |
| 9002 |
func (m ResourceQuotaCPURequestUsed) Inst() metric.Int64UpDownCounter { |
| 9003 |
return m.Int64UpDownCounter |
| 9004 |
} |
| 9005 |
|
| 9006 |
// Name returns the semantic convention name of the instrument. |
| 9007 |
func (ResourceQuotaCPURequestUsed) Name() string { |
| 9008 |
return "k8s.resourcequota.cpu.request.used" |
| 9009 |
} |
| 9010 |
|
| 9011 |
// Unit returns the semantic convention unit of the instrument |
| 9012 |
func (ResourceQuotaCPURequestUsed) Unit() string { |
| 9013 |
return "{cpu}" |
| 9014 |
} |
| 9015 |
|
| 9016 |
// Description returns the semantic convention description of the instrument |
| 9017 |
func (ResourceQuotaCPURequestUsed) Description() string { |
| 9018 |
return "The CPU requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 9019 |
} |
| 9020 |
|
| 9021 |
// Add adds incr to the existing count for attrs. |
| 9022 |
// |
| 9023 |
// This metric is retrieved from the `used` field of the |
| 9024 |
// [K8s ResourceQuotaStatus]. |
| 9025 |
// |
| 9026 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9027 |
func (m ResourceQuotaCPURequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 9028 |
if len(attrs) == 0 { |
| 9029 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9030 |
return |
| 9031 |
} |
| 9032 |
|
| 9033 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9034 |
defer func() { |
| 9035 |
*o = (*o)[:0] |
| 9036 |
addOptPool.Put(o) |
| 9037 |
}() |
| 9038 |
|
| 9039 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 9040 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9041 |
} |
| 9042 |
|
| 9043 |
// AddSet adds incr to the existing count for set. |
| 9044 |
// |
| 9045 |
// This metric is retrieved from the `used` field of the |
| 9046 |
// [K8s ResourceQuotaStatus]. |
| 9047 |
// |
| 9048 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9049 |
func (m ResourceQuotaCPURequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9050 |
if set.Len() == 0 { |
| 9051 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9052 |
return |
| 9053 |
} |
| 9054 |
|
| 9055 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9056 |
defer func() { |
| 9057 |
*o = (*o)[:0] |
| 9058 |
addOptPool.Put(o) |
| 9059 |
}() |
| 9060 |
|
| 9061 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 9062 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9063 |
} |
| 9064 |
|
| 9065 |
// ResourceQuotaEphemeralStorageLimitHard is an instrument used to record metric |
| 9066 |
// values conforming to the "k8s.resourcequota.ephemeral_storage.limit.hard" |
| 9067 |
// semantic conventions. It represents the sum of local ephemeral storage limits |
| 9068 |
// in the namespace. |
| 9069 |
// The value represents the configured quota limit of the resource in the |
| 9070 |
// namespace. |
| 9071 |
type ResourceQuotaEphemeralStorageLimitHard struct { |
| 9072 |
metric.Int64UpDownCounter |
| 9073 |
} |
| 9074 |
|
| 9075 |
var newResourceQuotaEphemeralStorageLimitHardOpts = []metric.Int64UpDownCounterOption{ |
| 9076 |
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."), |
| 9077 |
metric.WithUnit("By"), |
| 9078 |
} |
| 9079 |
|
| 9080 |
// NewResourceQuotaEphemeralStorageLimitHard returns a new |
| 9081 |
// ResourceQuotaEphemeralStorageLimitHard instrument. |
| 9082 |
func NewResourceQuotaEphemeralStorageLimitHard( |
| 9083 |
m metric.Meter, |
| 9084 |
opt ...metric.Int64UpDownCounterOption, |
| 9085 |
) (ResourceQuotaEphemeralStorageLimitHard, error) { |
| 9086 |
// Check if the meter is nil. |
| 9087 |
if m == nil { |
| 9088 |
return ResourceQuotaEphemeralStorageLimitHard{noop.Int64UpDownCounter{}}, nil |
| 9089 |
} |
| 9090 |
|
| 9091 |
if len(opt) == 0 { |
| 9092 |
opt = newResourceQuotaEphemeralStorageLimitHardOpts |
| 9093 |
} else { |
| 9094 |
opt = append(opt, newResourceQuotaEphemeralStorageLimitHardOpts...) |
| 9095 |
} |
| 9096 |
|
| 9097 |
i, err := m.Int64UpDownCounter( |
| 9098 |
"k8s.resourcequota.ephemeral_storage.limit.hard", |
| 9099 |
opt..., |
| 9100 |
) |
| 9101 |
if err != nil { |
| 9102 |
return ResourceQuotaEphemeralStorageLimitHard{noop.Int64UpDownCounter{}}, err |
| 9103 |
} |
| 9104 |
return ResourceQuotaEphemeralStorageLimitHard{i}, nil |
| 9105 |
} |
| 9106 |
|
| 9107 |
// Inst returns the underlying metric instrument. |
| 9108 |
func (m ResourceQuotaEphemeralStorageLimitHard) Inst() metric.Int64UpDownCounter { |
| 9109 |
return m.Int64UpDownCounter |
| 9110 |
} |
| 9111 |
|
| 9112 |
// Name returns the semantic convention name of the instrument. |
| 9113 |
func (ResourceQuotaEphemeralStorageLimitHard) Name() string { |
| 9114 |
return "k8s.resourcequota.ephemeral_storage.limit.hard" |
| 9115 |
} |
| 9116 |
|
| 9117 |
// Unit returns the semantic convention unit of the instrument |
| 9118 |
func (ResourceQuotaEphemeralStorageLimitHard) Unit() string { |
| 9119 |
return "By" |
| 9120 |
} |
| 9121 |
|
| 9122 |
// Description returns the semantic convention description of the instrument |
| 9123 |
func (ResourceQuotaEphemeralStorageLimitHard) Description() string { |
| 9124 |
return "The sum of local ephemeral storage limits in the namespace. The value represents the configured quota limit of the resource in the namespace." |
| 9125 |
} |
| 9126 |
|
| 9127 |
// Add adds incr to the existing count for attrs. |
| 9128 |
// |
| 9129 |
// This metric is retrieved from the `hard` field of the |
| 9130 |
// [K8s ResourceQuotaStatus]. |
| 9131 |
// |
| 9132 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9133 |
func (m ResourceQuotaEphemeralStorageLimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 9134 |
if len(attrs) == 0 { |
| 9135 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9136 |
return |
| 9137 |
} |
| 9138 |
|
| 9139 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9140 |
defer func() { |
| 9141 |
*o = (*o)[:0] |
| 9142 |
addOptPool.Put(o) |
| 9143 |
}() |
| 9144 |
|
| 9145 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 9146 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9147 |
} |
| 9148 |
|
| 9149 |
// AddSet adds incr to the existing count for set. |
| 9150 |
// |
| 9151 |
// This metric is retrieved from the `hard` field of the |
| 9152 |
// [K8s ResourceQuotaStatus]. |
| 9153 |
// |
| 9154 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9155 |
func (m ResourceQuotaEphemeralStorageLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9156 |
if set.Len() == 0 { |
| 9157 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9158 |
return |
| 9159 |
} |
| 9160 |
|
| 9161 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9162 |
defer func() { |
| 9163 |
*o = (*o)[:0] |
| 9164 |
addOptPool.Put(o) |
| 9165 |
}() |
| 9166 |
|
| 9167 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 9168 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9169 |
} |
| 9170 |
|
| 9171 |
// ResourceQuotaEphemeralStorageLimitUsed is an instrument used to record metric |
| 9172 |
// values conforming to the "k8s.resourcequota.ephemeral_storage.limit.used" |
| 9173 |
// semantic conventions. It represents the sum of local ephemeral storage limits |
| 9174 |
// in the namespace. |
| 9175 |
// The value represents the current observed total usage of the resource in the |
| 9176 |
// namespace. |
| 9177 |
type ResourceQuotaEphemeralStorageLimitUsed struct { |
| 9178 |
metric.Int64UpDownCounter |
| 9179 |
} |
| 9180 |
|
| 9181 |
var newResourceQuotaEphemeralStorageLimitUsedOpts = []metric.Int64UpDownCounterOption{ |
| 9182 |
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."), |
| 9183 |
metric.WithUnit("By"), |
| 9184 |
} |
| 9185 |
|
| 9186 |
// NewResourceQuotaEphemeralStorageLimitUsed returns a new |
| 9187 |
// ResourceQuotaEphemeralStorageLimitUsed instrument. |
| 9188 |
func NewResourceQuotaEphemeralStorageLimitUsed( |
| 9189 |
m metric.Meter, |
| 9190 |
opt ...metric.Int64UpDownCounterOption, |
| 9191 |
) (ResourceQuotaEphemeralStorageLimitUsed, error) { |
| 9192 |
// Check if the meter is nil. |
| 9193 |
if m == nil { |
| 9194 |
return ResourceQuotaEphemeralStorageLimitUsed{noop.Int64UpDownCounter{}}, nil |
| 9195 |
} |
| 9196 |
|
| 9197 |
if len(opt) == 0 { |
| 9198 |
opt = newResourceQuotaEphemeralStorageLimitUsedOpts |
| 9199 |
} else { |
| 9200 |
opt = append(opt, newResourceQuotaEphemeralStorageLimitUsedOpts...) |
| 9201 |
} |
| 9202 |
|
| 9203 |
i, err := m.Int64UpDownCounter( |
| 9204 |
"k8s.resourcequota.ephemeral_storage.limit.used", |
| 9205 |
opt..., |
| 9206 |
) |
| 9207 |
if err != nil { |
| 9208 |
return ResourceQuotaEphemeralStorageLimitUsed{noop.Int64UpDownCounter{}}, err |
| 9209 |
} |
| 9210 |
return ResourceQuotaEphemeralStorageLimitUsed{i}, nil |
| 9211 |
} |
| 9212 |
|
| 9213 |
// Inst returns the underlying metric instrument. |
| 9214 |
func (m ResourceQuotaEphemeralStorageLimitUsed) Inst() metric.Int64UpDownCounter { |
| 9215 |
return m.Int64UpDownCounter |
| 9216 |
} |
| 9217 |
|
| 9218 |
// Name returns the semantic convention name of the instrument. |
| 9219 |
func (ResourceQuotaEphemeralStorageLimitUsed) Name() string { |
| 9220 |
return "k8s.resourcequota.ephemeral_storage.limit.used" |
| 9221 |
} |
| 9222 |
|
| 9223 |
// Unit returns the semantic convention unit of the instrument |
| 9224 |
func (ResourceQuotaEphemeralStorageLimitUsed) Unit() string { |
| 9225 |
return "By" |
| 9226 |
} |
| 9227 |
|
| 9228 |
// Description returns the semantic convention description of the instrument |
| 9229 |
func (ResourceQuotaEphemeralStorageLimitUsed) Description() string { |
| 9230 |
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." |
| 9231 |
} |
| 9232 |
|
| 9233 |
// Add adds incr to the existing count for attrs. |
| 9234 |
// |
| 9235 |
// This metric is retrieved from the `used` field of the |
| 9236 |
// [K8s ResourceQuotaStatus]. |
| 9237 |
// |
| 9238 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9239 |
func (m ResourceQuotaEphemeralStorageLimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 9240 |
if len(attrs) == 0 { |
| 9241 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9242 |
return |
| 9243 |
} |
| 9244 |
|
| 9245 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9246 |
defer func() { |
| 9247 |
*o = (*o)[:0] |
| 9248 |
addOptPool.Put(o) |
| 9249 |
}() |
| 9250 |
|
| 9251 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 9252 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9253 |
} |
| 9254 |
|
| 9255 |
// AddSet adds incr to the existing count for set. |
| 9256 |
// |
| 9257 |
// This metric is retrieved from the `used` field of the |
| 9258 |
// [K8s ResourceQuotaStatus]. |
| 9259 |
// |
| 9260 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9261 |
func (m ResourceQuotaEphemeralStorageLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9262 |
if set.Len() == 0 { |
| 9263 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9264 |
return |
| 9265 |
} |
| 9266 |
|
| 9267 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9268 |
defer func() { |
| 9269 |
*o = (*o)[:0] |
| 9270 |
addOptPool.Put(o) |
| 9271 |
}() |
| 9272 |
|
| 9273 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 9274 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9275 |
} |
| 9276 |
|
| 9277 |
// ResourceQuotaEphemeralStorageRequestHard is an instrument used to record |
| 9278 |
// metric values conforming to the |
| 9279 |
// "k8s.resourcequota.ephemeral_storage.request.hard" semantic conventions. It |
| 9280 |
// represents the sum of local ephemeral storage requests in the namespace. |
| 9281 |
// The value represents the configured quota limit of the resource in the |
| 9282 |
// namespace. |
| 9283 |
type ResourceQuotaEphemeralStorageRequestHard struct { |
| 9284 |
metric.Int64UpDownCounter |
| 9285 |
} |
| 9286 |
|
| 9287 |
var newResourceQuotaEphemeralStorageRequestHardOpts = []metric.Int64UpDownCounterOption{ |
| 9288 |
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."), |
| 9289 |
metric.WithUnit("By"), |
| 9290 |
} |
| 9291 |
|
| 9292 |
// NewResourceQuotaEphemeralStorageRequestHard returns a new |
| 9293 |
// ResourceQuotaEphemeralStorageRequestHard instrument. |
| 9294 |
func NewResourceQuotaEphemeralStorageRequestHard( |
| 9295 |
m metric.Meter, |
| 9296 |
opt ...metric.Int64UpDownCounterOption, |
| 9297 |
) (ResourceQuotaEphemeralStorageRequestHard, error) { |
| 9298 |
// Check if the meter is nil. |
| 9299 |
if m == nil { |
| 9300 |
return ResourceQuotaEphemeralStorageRequestHard{noop.Int64UpDownCounter{}}, nil |
| 9301 |
} |
| 9302 |
|
| 9303 |
if len(opt) == 0 { |
| 9304 |
opt = newResourceQuotaEphemeralStorageRequestHardOpts |
| 9305 |
} else { |
| 9306 |
opt = append(opt, newResourceQuotaEphemeralStorageRequestHardOpts...) |
| 9307 |
} |
| 9308 |
|
| 9309 |
i, err := m.Int64UpDownCounter( |
| 9310 |
"k8s.resourcequota.ephemeral_storage.request.hard", |
| 9311 |
opt..., |
| 9312 |
) |
| 9313 |
if err != nil { |
| 9314 |
return ResourceQuotaEphemeralStorageRequestHard{noop.Int64UpDownCounter{}}, err |
| 9315 |
} |
| 9316 |
return ResourceQuotaEphemeralStorageRequestHard{i}, nil |
| 9317 |
} |
| 9318 |
|
| 9319 |
// Inst returns the underlying metric instrument. |
| 9320 |
func (m ResourceQuotaEphemeralStorageRequestHard) Inst() metric.Int64UpDownCounter { |
| 9321 |
return m.Int64UpDownCounter |
| 9322 |
} |
| 9323 |
|
| 9324 |
// Name returns the semantic convention name of the instrument. |
| 9325 |
func (ResourceQuotaEphemeralStorageRequestHard) Name() string { |
| 9326 |
return "k8s.resourcequota.ephemeral_storage.request.hard" |
| 9327 |
} |
| 9328 |
|
| 9329 |
// Unit returns the semantic convention unit of the instrument |
| 9330 |
func (ResourceQuotaEphemeralStorageRequestHard) Unit() string { |
| 9331 |
return "By" |
| 9332 |
} |
| 9333 |
|
| 9334 |
// Description returns the semantic convention description of the instrument |
| 9335 |
func (ResourceQuotaEphemeralStorageRequestHard) Description() string { |
| 9336 |
return "The sum of local ephemeral storage requests in the namespace. The value represents the configured quota limit of the resource in the namespace." |
| 9337 |
} |
| 9338 |
|
| 9339 |
// Add adds incr to the existing count for attrs. |
| 9340 |
// |
| 9341 |
// This metric is retrieved from the `hard` field of the |
| 9342 |
// [K8s ResourceQuotaStatus]. |
| 9343 |
// |
| 9344 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9345 |
func (m ResourceQuotaEphemeralStorageRequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 9346 |
if len(attrs) == 0 { |
| 9347 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9348 |
return |
| 9349 |
} |
| 9350 |
|
| 9351 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9352 |
defer func() { |
| 9353 |
*o = (*o)[:0] |
| 9354 |
addOptPool.Put(o) |
| 9355 |
}() |
| 9356 |
|
| 9357 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 9358 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9359 |
} |
| 9360 |
|
| 9361 |
// AddSet adds incr to the existing count for set. |
| 9362 |
// |
| 9363 |
// This metric is retrieved from the `hard` field of the |
| 9364 |
// [K8s ResourceQuotaStatus]. |
| 9365 |
// |
| 9366 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9367 |
func (m ResourceQuotaEphemeralStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9368 |
if set.Len() == 0 { |
| 9369 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9370 |
return |
| 9371 |
} |
| 9372 |
|
| 9373 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9374 |
defer func() { |
| 9375 |
*o = (*o)[:0] |
| 9376 |
addOptPool.Put(o) |
| 9377 |
}() |
| 9378 |
|
| 9379 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 9380 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9381 |
} |
| 9382 |
|
| 9383 |
// ResourceQuotaEphemeralStorageRequestUsed is an instrument used to record |
| 9384 |
// metric values conforming to the |
| 9385 |
// "k8s.resourcequota.ephemeral_storage.request.used" semantic conventions. It |
| 9386 |
// represents the sum of local ephemeral storage requests in the namespace. |
| 9387 |
// The value represents the current observed total usage of the resource in the |
| 9388 |
// namespace. |
| 9389 |
type ResourceQuotaEphemeralStorageRequestUsed struct { |
| 9390 |
metric.Int64UpDownCounter |
| 9391 |
} |
| 9392 |
|
| 9393 |
var newResourceQuotaEphemeralStorageRequestUsedOpts = []metric.Int64UpDownCounterOption{ |
| 9394 |
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."), |
| 9395 |
metric.WithUnit("By"), |
| 9396 |
} |
| 9397 |
|
| 9398 |
// NewResourceQuotaEphemeralStorageRequestUsed returns a new |
| 9399 |
// ResourceQuotaEphemeralStorageRequestUsed instrument. |
| 9400 |
func NewResourceQuotaEphemeralStorageRequestUsed( |
| 9401 |
m metric.Meter, |
| 9402 |
opt ...metric.Int64UpDownCounterOption, |
| 9403 |
) (ResourceQuotaEphemeralStorageRequestUsed, error) { |
| 9404 |
// Check if the meter is nil. |
| 9405 |
if m == nil { |
| 9406 |
return ResourceQuotaEphemeralStorageRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 9407 |
} |
| 9408 |
|
| 9409 |
if len(opt) == 0 { |
| 9410 |
opt = newResourceQuotaEphemeralStorageRequestUsedOpts |
| 9411 |
} else { |
| 9412 |
opt = append(opt, newResourceQuotaEphemeralStorageRequestUsedOpts...) |
| 9413 |
} |
| 9414 |
|
| 9415 |
i, err := m.Int64UpDownCounter( |
| 9416 |
"k8s.resourcequota.ephemeral_storage.request.used", |
| 9417 |
opt..., |
| 9418 |
) |
| 9419 |
if err != nil { |
| 9420 |
return ResourceQuotaEphemeralStorageRequestUsed{noop.Int64UpDownCounter{}}, err |
| 9421 |
} |
| 9422 |
return ResourceQuotaEphemeralStorageRequestUsed{i}, nil |
| 9423 |
} |
| 9424 |
|
| 9425 |
// Inst returns the underlying metric instrument. |
| 9426 |
func (m ResourceQuotaEphemeralStorageRequestUsed) Inst() metric.Int64UpDownCounter { |
| 9427 |
return m.Int64UpDownCounter |
| 9428 |
} |
| 9429 |
|
| 9430 |
// Name returns the semantic convention name of the instrument. |
| 9431 |
func (ResourceQuotaEphemeralStorageRequestUsed) Name() string { |
| 9432 |
return "k8s.resourcequota.ephemeral_storage.request.used" |
| 9433 |
} |
| 9434 |
|
| 9435 |
// Unit returns the semantic convention unit of the instrument |
| 9436 |
func (ResourceQuotaEphemeralStorageRequestUsed) Unit() string { |
| 9437 |
return "By" |
| 9438 |
} |
| 9439 |
|
| 9440 |
// Description returns the semantic convention description of the instrument |
| 9441 |
func (ResourceQuotaEphemeralStorageRequestUsed) Description() string { |
| 9442 |
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." |
| 9443 |
} |
| 9444 |
|
| 9445 |
// Add adds incr to the existing count for attrs. |
| 9446 |
// |
| 9447 |
// This metric is retrieved from the `used` field of the |
| 9448 |
// [K8s ResourceQuotaStatus]. |
| 9449 |
// |
| 9450 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9451 |
func (m ResourceQuotaEphemeralStorageRequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 9452 |
if len(attrs) == 0 { |
| 9453 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9454 |
return |
| 9455 |
} |
| 9456 |
|
| 9457 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9458 |
defer func() { |
| 9459 |
*o = (*o)[:0] |
| 9460 |
addOptPool.Put(o) |
| 9461 |
}() |
| 9462 |
|
| 9463 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 9464 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9465 |
} |
| 9466 |
|
| 9467 |
// AddSet adds incr to the existing count for set. |
| 9468 |
// |
| 9469 |
// This metric is retrieved from the `used` field of the |
| 9470 |
// [K8s ResourceQuotaStatus]. |
| 9471 |
// |
| 9472 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9473 |
func (m ResourceQuotaEphemeralStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9474 |
if set.Len() == 0 { |
| 9475 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9476 |
return |
| 9477 |
} |
| 9478 |
|
| 9479 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9480 |
defer func() { |
| 9481 |
*o = (*o)[:0] |
| 9482 |
addOptPool.Put(o) |
| 9483 |
}() |
| 9484 |
|
| 9485 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 9486 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9487 |
} |
| 9488 |
|
| 9489 |
// ResourceQuotaHugepageCountRequestHard is an instrument used to record metric |
| 9490 |
// values conforming to the "k8s.resourcequota.hugepage_count.request.hard" |
| 9491 |
// semantic conventions. It represents the huge page requests in a specific |
| 9492 |
// namespace. |
| 9493 |
// The value represents the configured quota limit of the resource in the |
| 9494 |
// namespace. |
| 9495 |
type ResourceQuotaHugepageCountRequestHard struct { |
| 9496 |
metric.Int64UpDownCounter |
| 9497 |
} |
| 9498 |
|
| 9499 |
var newResourceQuotaHugepageCountRequestHardOpts = []metric.Int64UpDownCounterOption{ |
| 9500 |
metric.WithDescription("The huge page requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 9501 |
metric.WithUnit("{hugepage}"), |
| 9502 |
} |
| 9503 |
|
| 9504 |
// NewResourceQuotaHugepageCountRequestHard returns a new |
| 9505 |
// ResourceQuotaHugepageCountRequestHard instrument. |
| 9506 |
func NewResourceQuotaHugepageCountRequestHard( |
| 9507 |
m metric.Meter, |
| 9508 |
opt ...metric.Int64UpDownCounterOption, |
| 9509 |
) (ResourceQuotaHugepageCountRequestHard, error) { |
| 9510 |
// Check if the meter is nil. |
| 9511 |
if m == nil { |
| 9512 |
return ResourceQuotaHugepageCountRequestHard{noop.Int64UpDownCounter{}}, nil |
| 9513 |
} |
| 9514 |
|
| 9515 |
if len(opt) == 0 { |
| 9516 |
opt = newResourceQuotaHugepageCountRequestHardOpts |
| 9517 |
} else { |
| 9518 |
opt = append(opt, newResourceQuotaHugepageCountRequestHardOpts...) |
| 9519 |
} |
| 9520 |
|
| 9521 |
i, err := m.Int64UpDownCounter( |
| 9522 |
"k8s.resourcequota.hugepage_count.request.hard", |
| 9523 |
opt..., |
| 9524 |
) |
| 9525 |
if err != nil { |
| 9526 |
return ResourceQuotaHugepageCountRequestHard{noop.Int64UpDownCounter{}}, err |
| 9527 |
} |
| 9528 |
return ResourceQuotaHugepageCountRequestHard{i}, nil |
| 9529 |
} |
| 9530 |
|
| 9531 |
// Inst returns the underlying metric instrument. |
| 9532 |
func (m ResourceQuotaHugepageCountRequestHard) Inst() metric.Int64UpDownCounter { |
| 9533 |
return m.Int64UpDownCounter |
| 9534 |
} |
| 9535 |
|
| 9536 |
// Name returns the semantic convention name of the instrument. |
| 9537 |
func (ResourceQuotaHugepageCountRequestHard) Name() string { |
| 9538 |
return "k8s.resourcequota.hugepage_count.request.hard" |
| 9539 |
} |
| 9540 |
|
| 9541 |
// Unit returns the semantic convention unit of the instrument |
| 9542 |
func (ResourceQuotaHugepageCountRequestHard) Unit() string { |
| 9543 |
return "{hugepage}" |
| 9544 |
} |
| 9545 |
|
| 9546 |
// Description returns the semantic convention description of the instrument |
| 9547 |
func (ResourceQuotaHugepageCountRequestHard) Description() string { |
| 9548 |
return "The huge page requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 9549 |
} |
| 9550 |
|
| 9551 |
// Add adds incr to the existing count for attrs. |
| 9552 |
// |
| 9553 |
// The hugepageSize is the the size (identifier) of the K8s huge page. |
| 9554 |
// |
| 9555 |
// This metric is retrieved from the `hard` field of the |
| 9556 |
// [K8s ResourceQuotaStatus]. |
| 9557 |
// |
| 9558 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9559 |
func (m ResourceQuotaHugepageCountRequestHard) Add( |
| 9560 |
ctx context.Context, |
| 9561 |
incr int64, |
| 9562 |
hugepageSize string, |
| 9563 |
attrs ...attribute.KeyValue, |
| 9564 |
) { |
| 9565 |
if len(attrs) == 0 { |
| 9566 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 9567 |
attribute.String("k8s.hugepage.size", hugepageSize), |
| 9568 |
)) |
| 9569 |
return |
| 9570 |
} |
| 9571 |
|
| 9572 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9573 |
defer func() { |
| 9574 |
*o = (*o)[:0] |
| 9575 |
addOptPool.Put(o) |
| 9576 |
}() |
| 9577 |
|
| 9578 |
*o = append( |
| 9579 |
*o, |
| 9580 |
metric.WithAttributes( |
| 9581 |
append( |
| 9582 |
attrs, |
| 9583 |
attribute.String("k8s.hugepage.size", hugepageSize), |
| 9584 |
)..., |
| 9585 |
), |
| 9586 |
) |
| 9587 |
|
| 9588 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9589 |
} |
| 9590 |
|
| 9591 |
// AddSet adds incr to the existing count for set. |
| 9592 |
// |
| 9593 |
// This metric is retrieved from the `hard` field of the |
| 9594 |
// [K8s ResourceQuotaStatus]. |
| 9595 |
// |
| 9596 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9597 |
func (m ResourceQuotaHugepageCountRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9598 |
if set.Len() == 0 { |
| 9599 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 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(*o, metric.WithAttributeSet(set)) |
| 9610 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9611 |
} |
| 9612 |
|
| 9613 |
// ResourceQuotaHugepageCountRequestUsed is an instrument used to record metric |
| 9614 |
// values conforming to the "k8s.resourcequota.hugepage_count.request.used" |
| 9615 |
// semantic conventions. It represents the huge page requests in a specific |
| 9616 |
// namespace. |
| 9617 |
// The value represents the current observed total usage of the resource in the |
| 9618 |
// namespace. |
| 9619 |
type ResourceQuotaHugepageCountRequestUsed struct { |
| 9620 |
metric.Int64UpDownCounter |
| 9621 |
} |
| 9622 |
|
| 9623 |
var newResourceQuotaHugepageCountRequestUsedOpts = []metric.Int64UpDownCounterOption{ |
| 9624 |
metric.WithDescription("The huge page requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 9625 |
metric.WithUnit("{hugepage}"), |
| 9626 |
} |
| 9627 |
|
| 9628 |
// NewResourceQuotaHugepageCountRequestUsed returns a new |
| 9629 |
// ResourceQuotaHugepageCountRequestUsed instrument. |
| 9630 |
func NewResourceQuotaHugepageCountRequestUsed( |
| 9631 |
m metric.Meter, |
| 9632 |
opt ...metric.Int64UpDownCounterOption, |
| 9633 |
) (ResourceQuotaHugepageCountRequestUsed, error) { |
| 9634 |
// Check if the meter is nil. |
| 9635 |
if m == nil { |
| 9636 |
return ResourceQuotaHugepageCountRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 9637 |
} |
| 9638 |
|
| 9639 |
if len(opt) == 0 { |
| 9640 |
opt = newResourceQuotaHugepageCountRequestUsedOpts |
| 9641 |
} else { |
| 9642 |
opt = append(opt, newResourceQuotaHugepageCountRequestUsedOpts...) |
| 9643 |
} |
| 9644 |
|
| 9645 |
i, err := m.Int64UpDownCounter( |
| 9646 |
"k8s.resourcequota.hugepage_count.request.used", |
| 9647 |
opt..., |
| 9648 |
) |
| 9649 |
if err != nil { |
| 9650 |
return ResourceQuotaHugepageCountRequestUsed{noop.Int64UpDownCounter{}}, err |
| 9651 |
} |
| 9652 |
return ResourceQuotaHugepageCountRequestUsed{i}, nil |
| 9653 |
} |
| 9654 |
|
| 9655 |
// Inst returns the underlying metric instrument. |
| 9656 |
func (m ResourceQuotaHugepageCountRequestUsed) Inst() metric.Int64UpDownCounter { |
| 9657 |
return m.Int64UpDownCounter |
| 9658 |
} |
| 9659 |
|
| 9660 |
// Name returns the semantic convention name of the instrument. |
| 9661 |
func (ResourceQuotaHugepageCountRequestUsed) Name() string { |
| 9662 |
return "k8s.resourcequota.hugepage_count.request.used" |
| 9663 |
} |
| 9664 |
|
| 9665 |
// Unit returns the semantic convention unit of the instrument |
| 9666 |
func (ResourceQuotaHugepageCountRequestUsed) Unit() string { |
| 9667 |
return "{hugepage}" |
| 9668 |
} |
| 9669 |
|
| 9670 |
// Description returns the semantic convention description of the instrument |
| 9671 |
func (ResourceQuotaHugepageCountRequestUsed) Description() string { |
| 9672 |
return "The huge page requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 9673 |
} |
| 9674 |
|
| 9675 |
// Add adds incr to the existing count for attrs. |
| 9676 |
// |
| 9677 |
// The hugepageSize is the the size (identifier) of the K8s huge page. |
| 9678 |
// |
| 9679 |
// This metric is retrieved from the `used` field of the |
| 9680 |
// [K8s ResourceQuotaStatus]. |
| 9681 |
// |
| 9682 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9683 |
func (m ResourceQuotaHugepageCountRequestUsed) Add( |
| 9684 |
ctx context.Context, |
| 9685 |
incr int64, |
| 9686 |
hugepageSize string, |
| 9687 |
attrs ...attribute.KeyValue, |
| 9688 |
) { |
| 9689 |
if len(attrs) == 0 { |
| 9690 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 9691 |
attribute.String("k8s.hugepage.size", hugepageSize), |
| 9692 |
)) |
| 9693 |
return |
| 9694 |
} |
| 9695 |
|
| 9696 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9697 |
defer func() { |
| 9698 |
*o = (*o)[:0] |
| 9699 |
addOptPool.Put(o) |
| 9700 |
}() |
| 9701 |
|
| 9702 |
*o = append( |
| 9703 |
*o, |
| 9704 |
metric.WithAttributes( |
| 9705 |
append( |
| 9706 |
attrs, |
| 9707 |
attribute.String("k8s.hugepage.size", hugepageSize), |
| 9708 |
)..., |
| 9709 |
), |
| 9710 |
) |
| 9711 |
|
| 9712 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9713 |
} |
| 9714 |
|
| 9715 |
// AddSet adds incr to the existing count for set. |
| 9716 |
// |
| 9717 |
// This metric is retrieved from the `used` field of the |
| 9718 |
// [K8s ResourceQuotaStatus]. |
| 9719 |
// |
| 9720 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9721 |
func (m ResourceQuotaHugepageCountRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9722 |
if set.Len() == 0 { |
| 9723 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 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(*o, metric.WithAttributeSet(set)) |
| 9734 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9735 |
} |
| 9736 |
|
| 9737 |
// ResourceQuotaMemoryLimitHard is an instrument used to record metric values |
| 9738 |
// conforming to the "k8s.resourcequota.memory.limit.hard" semantic conventions. |
| 9739 |
// It represents the memory limits in a specific namespace. |
| 9740 |
// The value represents the configured quota limit of the resource in the |
| 9741 |
// namespace. |
| 9742 |
type ResourceQuotaMemoryLimitHard struct { |
| 9743 |
metric.Int64UpDownCounter |
| 9744 |
} |
| 9745 |
|
| 9746 |
var newResourceQuotaMemoryLimitHardOpts = []metric.Int64UpDownCounterOption{ |
| 9747 |
metric.WithDescription("The memory limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 9748 |
metric.WithUnit("By"), |
| 9749 |
} |
| 9750 |
|
| 9751 |
// NewResourceQuotaMemoryLimitHard returns a new ResourceQuotaMemoryLimitHard |
| 9752 |
// instrument. |
| 9753 |
func NewResourceQuotaMemoryLimitHard( |
| 9754 |
m metric.Meter, |
| 9755 |
opt ...metric.Int64UpDownCounterOption, |
| 9756 |
) (ResourceQuotaMemoryLimitHard, error) { |
| 9757 |
// Check if the meter is nil. |
| 9758 |
if m == nil { |
| 9759 |
return ResourceQuotaMemoryLimitHard{noop.Int64UpDownCounter{}}, nil |
| 9760 |
} |
| 9761 |
|
| 9762 |
if len(opt) == 0 { |
| 9763 |
opt = newResourceQuotaMemoryLimitHardOpts |
| 9764 |
} else { |
| 9765 |
opt = append(opt, newResourceQuotaMemoryLimitHardOpts...) |
| 9766 |
} |
| 9767 |
|
| 9768 |
i, err := m.Int64UpDownCounter( |
| 9769 |
"k8s.resourcequota.memory.limit.hard", |
| 9770 |
opt..., |
| 9771 |
) |
| 9772 |
if err != nil { |
| 9773 |
return ResourceQuotaMemoryLimitHard{noop.Int64UpDownCounter{}}, err |
| 9774 |
} |
| 9775 |
return ResourceQuotaMemoryLimitHard{i}, nil |
| 9776 |
} |
| 9777 |
|
| 9778 |
// Inst returns the underlying metric instrument. |
| 9779 |
func (m ResourceQuotaMemoryLimitHard) Inst() metric.Int64UpDownCounter { |
| 9780 |
return m.Int64UpDownCounter |
| 9781 |
} |
| 9782 |
|
| 9783 |
// Name returns the semantic convention name of the instrument. |
| 9784 |
func (ResourceQuotaMemoryLimitHard) Name() string { |
| 9785 |
return "k8s.resourcequota.memory.limit.hard" |
| 9786 |
} |
| 9787 |
|
| 9788 |
// Unit returns the semantic convention unit of the instrument |
| 9789 |
func (ResourceQuotaMemoryLimitHard) Unit() string { |
| 9790 |
return "By" |
| 9791 |
} |
| 9792 |
|
| 9793 |
// Description returns the semantic convention description of the instrument |
| 9794 |
func (ResourceQuotaMemoryLimitHard) Description() string { |
| 9795 |
return "The memory limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 9796 |
} |
| 9797 |
|
| 9798 |
// Add adds incr to the existing count for attrs. |
| 9799 |
// |
| 9800 |
// This metric is retrieved from the `hard` field of the |
| 9801 |
// [K8s ResourceQuotaStatus]. |
| 9802 |
// |
| 9803 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9804 |
func (m ResourceQuotaMemoryLimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 9805 |
if len(attrs) == 0 { |
| 9806 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9807 |
return |
| 9808 |
} |
| 9809 |
|
| 9810 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9811 |
defer func() { |
| 9812 |
*o = (*o)[:0] |
| 9813 |
addOptPool.Put(o) |
| 9814 |
}() |
| 9815 |
|
| 9816 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 9817 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9818 |
} |
| 9819 |
|
| 9820 |
// AddSet adds incr to the existing count for set. |
| 9821 |
// |
| 9822 |
// This metric is retrieved from the `hard` field of the |
| 9823 |
// [K8s ResourceQuotaStatus]. |
| 9824 |
// |
| 9825 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9826 |
func (m ResourceQuotaMemoryLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9827 |
if set.Len() == 0 { |
| 9828 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9829 |
return |
| 9830 |
} |
| 9831 |
|
| 9832 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9833 |
defer func() { |
| 9834 |
*o = (*o)[:0] |
| 9835 |
addOptPool.Put(o) |
| 9836 |
}() |
| 9837 |
|
| 9838 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 9839 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9840 |
} |
| 9841 |
|
| 9842 |
// ResourceQuotaMemoryLimitUsed is an instrument used to record metric values |
| 9843 |
// conforming to the "k8s.resourcequota.memory.limit.used" semantic conventions. |
| 9844 |
// It represents the memory limits in a specific namespace. |
| 9845 |
// The value represents the current observed total usage of the resource in the |
| 9846 |
// namespace. |
| 9847 |
type ResourceQuotaMemoryLimitUsed struct { |
| 9848 |
metric.Int64UpDownCounter |
| 9849 |
} |
| 9850 |
|
| 9851 |
var newResourceQuotaMemoryLimitUsedOpts = []metric.Int64UpDownCounterOption{ |
| 9852 |
metric.WithDescription("The memory limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 9853 |
metric.WithUnit("By"), |
| 9854 |
} |
| 9855 |
|
| 9856 |
// NewResourceQuotaMemoryLimitUsed returns a new ResourceQuotaMemoryLimitUsed |
| 9857 |
// instrument. |
| 9858 |
func NewResourceQuotaMemoryLimitUsed( |
| 9859 |
m metric.Meter, |
| 9860 |
opt ...metric.Int64UpDownCounterOption, |
| 9861 |
) (ResourceQuotaMemoryLimitUsed, error) { |
| 9862 |
// Check if the meter is nil. |
| 9863 |
if m == nil { |
| 9864 |
return ResourceQuotaMemoryLimitUsed{noop.Int64UpDownCounter{}}, nil |
| 9865 |
} |
| 9866 |
|
| 9867 |
if len(opt) == 0 { |
| 9868 |
opt = newResourceQuotaMemoryLimitUsedOpts |
| 9869 |
} else { |
| 9870 |
opt = append(opt, newResourceQuotaMemoryLimitUsedOpts...) |
| 9871 |
} |
| 9872 |
|
| 9873 |
i, err := m.Int64UpDownCounter( |
| 9874 |
"k8s.resourcequota.memory.limit.used", |
| 9875 |
opt..., |
| 9876 |
) |
| 9877 |
if err != nil { |
| 9878 |
return ResourceQuotaMemoryLimitUsed{noop.Int64UpDownCounter{}}, err |
| 9879 |
} |
| 9880 |
return ResourceQuotaMemoryLimitUsed{i}, nil |
| 9881 |
} |
| 9882 |
|
| 9883 |
// Inst returns the underlying metric instrument. |
| 9884 |
func (m ResourceQuotaMemoryLimitUsed) Inst() metric.Int64UpDownCounter { |
| 9885 |
return m.Int64UpDownCounter |
| 9886 |
} |
| 9887 |
|
| 9888 |
// Name returns the semantic convention name of the instrument. |
| 9889 |
func (ResourceQuotaMemoryLimitUsed) Name() string { |
| 9890 |
return "k8s.resourcequota.memory.limit.used" |
| 9891 |
} |
| 9892 |
|
| 9893 |
// Unit returns the semantic convention unit of the instrument |
| 9894 |
func (ResourceQuotaMemoryLimitUsed) Unit() string { |
| 9895 |
return "By" |
| 9896 |
} |
| 9897 |
|
| 9898 |
// Description returns the semantic convention description of the instrument |
| 9899 |
func (ResourceQuotaMemoryLimitUsed) Description() string { |
| 9900 |
return "The memory limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 9901 |
} |
| 9902 |
|
| 9903 |
// Add adds incr to the existing count for attrs. |
| 9904 |
// |
| 9905 |
// This metric is retrieved from the `used` field of the |
| 9906 |
// [K8s ResourceQuotaStatus]. |
| 9907 |
// |
| 9908 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9909 |
func (m ResourceQuotaMemoryLimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 9910 |
if len(attrs) == 0 { |
| 9911 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9912 |
return |
| 9913 |
} |
| 9914 |
|
| 9915 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9916 |
defer func() { |
| 9917 |
*o = (*o)[:0] |
| 9918 |
addOptPool.Put(o) |
| 9919 |
}() |
| 9920 |
|
| 9921 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 9922 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9923 |
} |
| 9924 |
|
| 9925 |
// AddSet adds incr to the existing count for set. |
| 9926 |
// |
| 9927 |
// This metric is retrieved from the `used` field of the |
| 9928 |
// [K8s ResourceQuotaStatus]. |
| 9929 |
// |
| 9930 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 9931 |
func (m ResourceQuotaMemoryLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 9932 |
if set.Len() == 0 { |
| 9933 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 9934 |
return |
| 9935 |
} |
| 9936 |
|
| 9937 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 9938 |
defer func() { |
| 9939 |
*o = (*o)[:0] |
| 9940 |
addOptPool.Put(o) |
| 9941 |
}() |
| 9942 |
|
| 9943 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 9944 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 9945 |
} |
| 9946 |
|
| 9947 |
// ResourceQuotaMemoryRequestHard is an instrument used to record metric values |
| 9948 |
// conforming to the "k8s.resourcequota.memory.request.hard" semantic |
| 9949 |
// conventions. It represents the memory requests in a specific namespace. |
| 9950 |
// The value represents the configured quota limit of the resource in the |
| 9951 |
// namespace. |
| 9952 |
type ResourceQuotaMemoryRequestHard struct { |
| 9953 |
metric.Int64UpDownCounter |
| 9954 |
} |
| 9955 |
|
| 9956 |
var newResourceQuotaMemoryRequestHardOpts = []metric.Int64UpDownCounterOption{ |
| 9957 |
metric.WithDescription("The memory requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 9958 |
metric.WithUnit("By"), |
| 9959 |
} |
| 9960 |
|
| 9961 |
// NewResourceQuotaMemoryRequestHard returns a new ResourceQuotaMemoryRequestHard |
| 9962 |
// instrument. |
| 9963 |
func NewResourceQuotaMemoryRequestHard( |
| 9964 |
m metric.Meter, |
| 9965 |
opt ...metric.Int64UpDownCounterOption, |
| 9966 |
) (ResourceQuotaMemoryRequestHard, error) { |
| 9967 |
// Check if the meter is nil. |
| 9968 |
if m == nil { |
| 9969 |
return ResourceQuotaMemoryRequestHard{noop.Int64UpDownCounter{}}, nil |
| 9970 |
} |
| 9971 |
|
| 9972 |
if len(opt) == 0 { |
| 9973 |
opt = newResourceQuotaMemoryRequestHardOpts |
| 9974 |
} else { |
| 9975 |
opt = append(opt, newResourceQuotaMemoryRequestHardOpts...) |
| 9976 |
} |
| 9977 |
|
| 9978 |
i, err := m.Int64UpDownCounter( |
| 9979 |
"k8s.resourcequota.memory.request.hard", |
| 9980 |
opt..., |
| 9981 |
) |
| 9982 |
if err != nil { |
| 9983 |
return ResourceQuotaMemoryRequestHard{noop.Int64UpDownCounter{}}, err |
| 9984 |
} |
| 9985 |
return ResourceQuotaMemoryRequestHard{i}, nil |
| 9986 |
} |
| 9987 |
|
| 9988 |
// Inst returns the underlying metric instrument. |
| 9989 |
func (m ResourceQuotaMemoryRequestHard) Inst() metric.Int64UpDownCounter { |
| 9990 |
return m.Int64UpDownCounter |
| 9991 |
} |
| 9992 |
|
| 9993 |
// Name returns the semantic convention name of the instrument. |
| 9994 |
func (ResourceQuotaMemoryRequestHard) Name() string { |
| 9995 |
return "k8s.resourcequota.memory.request.hard" |
| 9996 |
} |
| 9997 |
|
| 9998 |
// Unit returns the semantic convention unit of the instrument |
| 9999 |
func (ResourceQuotaMemoryRequestHard) Unit() string { |
| 10000 |
return "By" |
| 10001 |
} |
| 10002 |
|
| 10003 |
// Description returns the semantic convention description of the instrument |
| 10004 |
func (ResourceQuotaMemoryRequestHard) Description() string { |
| 10005 |
return "The memory requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 10006 |
} |
| 10007 |
|
| 10008 |
// Add adds incr to the existing count for attrs. |
| 10009 |
// |
| 10010 |
// This metric is retrieved from the `hard` field of the |
| 10011 |
// [K8s ResourceQuotaStatus]. |
| 10012 |
// |
| 10013 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10014 |
func (m ResourceQuotaMemoryRequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 10015 |
if len(attrs) == 0 { |
| 10016 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10017 |
return |
| 10018 |
} |
| 10019 |
|
| 10020 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10021 |
defer func() { |
| 10022 |
*o = (*o)[:0] |
| 10023 |
addOptPool.Put(o) |
| 10024 |
}() |
| 10025 |
|
| 10026 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 10027 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10028 |
} |
| 10029 |
|
| 10030 |
// AddSet adds incr to the existing count for set. |
| 10031 |
// |
| 10032 |
// This metric is retrieved from the `hard` field of the |
| 10033 |
// [K8s ResourceQuotaStatus]. |
| 10034 |
// |
| 10035 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10036 |
func (m ResourceQuotaMemoryRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10037 |
if set.Len() == 0 { |
| 10038 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10039 |
return |
| 10040 |
} |
| 10041 |
|
| 10042 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10043 |
defer func() { |
| 10044 |
*o = (*o)[:0] |
| 10045 |
addOptPool.Put(o) |
| 10046 |
}() |
| 10047 |
|
| 10048 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 10049 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10050 |
} |
| 10051 |
|
| 10052 |
// ResourceQuotaMemoryRequestUsed is an instrument used to record metric values |
| 10053 |
// conforming to the "k8s.resourcequota.memory.request.used" semantic |
| 10054 |
// conventions. It represents the memory requests in a specific namespace. |
| 10055 |
// The value represents the current observed total usage of the resource in the |
| 10056 |
// namespace. |
| 10057 |
type ResourceQuotaMemoryRequestUsed struct { |
| 10058 |
metric.Int64UpDownCounter |
| 10059 |
} |
| 10060 |
|
| 10061 |
var newResourceQuotaMemoryRequestUsedOpts = []metric.Int64UpDownCounterOption{ |
| 10062 |
metric.WithDescription("The memory requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 10063 |
metric.WithUnit("By"), |
| 10064 |
} |
| 10065 |
|
| 10066 |
// NewResourceQuotaMemoryRequestUsed returns a new ResourceQuotaMemoryRequestUsed |
| 10067 |
// instrument. |
| 10068 |
func NewResourceQuotaMemoryRequestUsed( |
| 10069 |
m metric.Meter, |
| 10070 |
opt ...metric.Int64UpDownCounterOption, |
| 10071 |
) (ResourceQuotaMemoryRequestUsed, error) { |
| 10072 |
// Check if the meter is nil. |
| 10073 |
if m == nil { |
| 10074 |
return ResourceQuotaMemoryRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 10075 |
} |
| 10076 |
|
| 10077 |
if len(opt) == 0 { |
| 10078 |
opt = newResourceQuotaMemoryRequestUsedOpts |
| 10079 |
} else { |
| 10080 |
opt = append(opt, newResourceQuotaMemoryRequestUsedOpts...) |
| 10081 |
} |
| 10082 |
|
| 10083 |
i, err := m.Int64UpDownCounter( |
| 10084 |
"k8s.resourcequota.memory.request.used", |
| 10085 |
opt..., |
| 10086 |
) |
| 10087 |
if err != nil { |
| 10088 |
return ResourceQuotaMemoryRequestUsed{noop.Int64UpDownCounter{}}, err |
| 10089 |
} |
| 10090 |
return ResourceQuotaMemoryRequestUsed{i}, nil |
| 10091 |
} |
| 10092 |
|
| 10093 |
// Inst returns the underlying metric instrument. |
| 10094 |
func (m ResourceQuotaMemoryRequestUsed) Inst() metric.Int64UpDownCounter { |
| 10095 |
return m.Int64UpDownCounter |
| 10096 |
} |
| 10097 |
|
| 10098 |
// Name returns the semantic convention name of the instrument. |
| 10099 |
func (ResourceQuotaMemoryRequestUsed) Name() string { |
| 10100 |
return "k8s.resourcequota.memory.request.used" |
| 10101 |
} |
| 10102 |
|
| 10103 |
// Unit returns the semantic convention unit of the instrument |
| 10104 |
func (ResourceQuotaMemoryRequestUsed) Unit() string { |
| 10105 |
return "By" |
| 10106 |
} |
| 10107 |
|
| 10108 |
// Description returns the semantic convention description of the instrument |
| 10109 |
func (ResourceQuotaMemoryRequestUsed) Description() string { |
| 10110 |
return "The memory requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 10111 |
} |
| 10112 |
|
| 10113 |
// Add adds incr to the existing count for attrs. |
| 10114 |
// |
| 10115 |
// This metric is retrieved from the `used` field of the |
| 10116 |
// [K8s ResourceQuotaStatus]. |
| 10117 |
// |
| 10118 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10119 |
func (m ResourceQuotaMemoryRequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 10120 |
if len(attrs) == 0 { |
| 10121 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10122 |
return |
| 10123 |
} |
| 10124 |
|
| 10125 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10126 |
defer func() { |
| 10127 |
*o = (*o)[:0] |
| 10128 |
addOptPool.Put(o) |
| 10129 |
}() |
| 10130 |
|
| 10131 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 10132 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10133 |
} |
| 10134 |
|
| 10135 |
// AddSet adds incr to the existing count for set. |
| 10136 |
// |
| 10137 |
// This metric is retrieved from the `used` field of the |
| 10138 |
// [K8s ResourceQuotaStatus]. |
| 10139 |
// |
| 10140 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10141 |
func (m ResourceQuotaMemoryRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10142 |
if set.Len() == 0 { |
| 10143 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10144 |
return |
| 10145 |
} |
| 10146 |
|
| 10147 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10148 |
defer func() { |
| 10149 |
*o = (*o)[:0] |
| 10150 |
addOptPool.Put(o) |
| 10151 |
}() |
| 10152 |
|
| 10153 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 10154 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10155 |
} |
| 10156 |
|
| 10157 |
// ResourceQuotaObjectCountHard is an instrument used to record metric values |
| 10158 |
// conforming to the "k8s.resourcequota.object_count.hard" semantic conventions. |
| 10159 |
// It represents the object count limits in a specific namespace. |
| 10160 |
// The value represents the configured quota limit of the resource in the |
| 10161 |
// namespace. |
| 10162 |
type ResourceQuotaObjectCountHard struct { |
| 10163 |
metric.Int64UpDownCounter |
| 10164 |
} |
| 10165 |
|
| 10166 |
var newResourceQuotaObjectCountHardOpts = []metric.Int64UpDownCounterOption{ |
| 10167 |
metric.WithDescription("The object count limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 10168 |
metric.WithUnit("{object}"), |
| 10169 |
} |
| 10170 |
|
| 10171 |
// NewResourceQuotaObjectCountHard returns a new ResourceQuotaObjectCountHard |
| 10172 |
// instrument. |
| 10173 |
func NewResourceQuotaObjectCountHard( |
| 10174 |
m metric.Meter, |
| 10175 |
opt ...metric.Int64UpDownCounterOption, |
| 10176 |
) (ResourceQuotaObjectCountHard, error) { |
| 10177 |
// Check if the meter is nil. |
| 10178 |
if m == nil { |
| 10179 |
return ResourceQuotaObjectCountHard{noop.Int64UpDownCounter{}}, nil |
| 10180 |
} |
| 10181 |
|
| 10182 |
if len(opt) == 0 { |
| 10183 |
opt = newResourceQuotaObjectCountHardOpts |
| 10184 |
} else { |
| 10185 |
opt = append(opt, newResourceQuotaObjectCountHardOpts...) |
| 10186 |
} |
| 10187 |
|
| 10188 |
i, err := m.Int64UpDownCounter( |
| 10189 |
"k8s.resourcequota.object_count.hard", |
| 10190 |
opt..., |
| 10191 |
) |
| 10192 |
if err != nil { |
| 10193 |
return ResourceQuotaObjectCountHard{noop.Int64UpDownCounter{}}, err |
| 10194 |
} |
| 10195 |
return ResourceQuotaObjectCountHard{i}, nil |
| 10196 |
} |
| 10197 |
|
| 10198 |
// Inst returns the underlying metric instrument. |
| 10199 |
func (m ResourceQuotaObjectCountHard) Inst() metric.Int64UpDownCounter { |
| 10200 |
return m.Int64UpDownCounter |
| 10201 |
} |
| 10202 |
|
| 10203 |
// Name returns the semantic convention name of the instrument. |
| 10204 |
func (ResourceQuotaObjectCountHard) Name() string { |
| 10205 |
return "k8s.resourcequota.object_count.hard" |
| 10206 |
} |
| 10207 |
|
| 10208 |
// Unit returns the semantic convention unit of the instrument |
| 10209 |
func (ResourceQuotaObjectCountHard) Unit() string { |
| 10210 |
return "{object}" |
| 10211 |
} |
| 10212 |
|
| 10213 |
// Description returns the semantic convention description of the instrument |
| 10214 |
func (ResourceQuotaObjectCountHard) Description() string { |
| 10215 |
return "The object count limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 10216 |
} |
| 10217 |
|
| 10218 |
// Add adds incr to the existing count for attrs. |
| 10219 |
// |
| 10220 |
// The resourcequotaResourceName is the the name of the K8s resource a resource |
| 10221 |
// quota defines. |
| 10222 |
// |
| 10223 |
// This metric is retrieved from the `hard` field of the |
| 10224 |
// [K8s ResourceQuotaStatus]. |
| 10225 |
// |
| 10226 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10227 |
func (m ResourceQuotaObjectCountHard) Add( |
| 10228 |
ctx context.Context, |
| 10229 |
incr int64, |
| 10230 |
resourcequotaResourceName string, |
| 10231 |
attrs ...attribute.KeyValue, |
| 10232 |
) { |
| 10233 |
if len(attrs) == 0 { |
| 10234 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 10235 |
attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName), |
| 10236 |
)) |
| 10237 |
return |
| 10238 |
} |
| 10239 |
|
| 10240 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10241 |
defer func() { |
| 10242 |
*o = (*o)[:0] |
| 10243 |
addOptPool.Put(o) |
| 10244 |
}() |
| 10245 |
|
| 10246 |
*o = append( |
| 10247 |
*o, |
| 10248 |
metric.WithAttributes( |
| 10249 |
append( |
| 10250 |
attrs, |
| 10251 |
attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName), |
| 10252 |
)..., |
| 10253 |
), |
| 10254 |
) |
| 10255 |
|
| 10256 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10257 |
} |
| 10258 |
|
| 10259 |
// AddSet adds incr to the existing count for set. |
| 10260 |
// |
| 10261 |
// This metric is retrieved from the `hard` field of the |
| 10262 |
// [K8s ResourceQuotaStatus]. |
| 10263 |
// |
| 10264 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10265 |
func (m ResourceQuotaObjectCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10266 |
if set.Len() == 0 { |
| 10267 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 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(*o, metric.WithAttributeSet(set)) |
| 10278 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10279 |
} |
| 10280 |
|
| 10281 |
// ResourceQuotaObjectCountUsed is an instrument used to record metric values |
| 10282 |
// conforming to the "k8s.resourcequota.object_count.used" semantic conventions. |
| 10283 |
// It represents the object count limits in a specific namespace. |
| 10284 |
// The value represents the current observed total usage of the resource in the |
| 10285 |
// namespace. |
| 10286 |
type ResourceQuotaObjectCountUsed struct { |
| 10287 |
metric.Int64UpDownCounter |
| 10288 |
} |
| 10289 |
|
| 10290 |
var newResourceQuotaObjectCountUsedOpts = []metric.Int64UpDownCounterOption{ |
| 10291 |
metric.WithDescription("The object count limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 10292 |
metric.WithUnit("{object}"), |
| 10293 |
} |
| 10294 |
|
| 10295 |
// NewResourceQuotaObjectCountUsed returns a new ResourceQuotaObjectCountUsed |
| 10296 |
// instrument. |
| 10297 |
func NewResourceQuotaObjectCountUsed( |
| 10298 |
m metric.Meter, |
| 10299 |
opt ...metric.Int64UpDownCounterOption, |
| 10300 |
) (ResourceQuotaObjectCountUsed, error) { |
| 10301 |
// Check if the meter is nil. |
| 10302 |
if m == nil { |
| 10303 |
return ResourceQuotaObjectCountUsed{noop.Int64UpDownCounter{}}, nil |
| 10304 |
} |
| 10305 |
|
| 10306 |
if len(opt) == 0 { |
| 10307 |
opt = newResourceQuotaObjectCountUsedOpts |
| 10308 |
} else { |
| 10309 |
opt = append(opt, newResourceQuotaObjectCountUsedOpts...) |
| 10310 |
} |
| 10311 |
|
| 10312 |
i, err := m.Int64UpDownCounter( |
| 10313 |
"k8s.resourcequota.object_count.used", |
| 10314 |
opt..., |
| 10315 |
) |
| 10316 |
if err != nil { |
| 10317 |
return ResourceQuotaObjectCountUsed{noop.Int64UpDownCounter{}}, err |
| 10318 |
} |
| 10319 |
return ResourceQuotaObjectCountUsed{i}, nil |
| 10320 |
} |
| 10321 |
|
| 10322 |
// Inst returns the underlying metric instrument. |
| 10323 |
func (m ResourceQuotaObjectCountUsed) Inst() metric.Int64UpDownCounter { |
| 10324 |
return m.Int64UpDownCounter |
| 10325 |
} |
| 10326 |
|
| 10327 |
// Name returns the semantic convention name of the instrument. |
| 10328 |
func (ResourceQuotaObjectCountUsed) Name() string { |
| 10329 |
return "k8s.resourcequota.object_count.used" |
| 10330 |
} |
| 10331 |
|
| 10332 |
// Unit returns the semantic convention unit of the instrument |
| 10333 |
func (ResourceQuotaObjectCountUsed) Unit() string { |
| 10334 |
return "{object}" |
| 10335 |
} |
| 10336 |
|
| 10337 |
// Description returns the semantic convention description of the instrument |
| 10338 |
func (ResourceQuotaObjectCountUsed) Description() string { |
| 10339 |
return "The object count limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 10340 |
} |
| 10341 |
|
| 10342 |
// Add adds incr to the existing count for attrs. |
| 10343 |
// |
| 10344 |
// The resourcequotaResourceName is the the name of the K8s resource a resource |
| 10345 |
// quota defines. |
| 10346 |
// |
| 10347 |
// This metric is retrieved from the `used` field of the |
| 10348 |
// [K8s ResourceQuotaStatus]. |
| 10349 |
// |
| 10350 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10351 |
func (m ResourceQuotaObjectCountUsed) Add( |
| 10352 |
ctx context.Context, |
| 10353 |
incr int64, |
| 10354 |
resourcequotaResourceName string, |
| 10355 |
attrs ...attribute.KeyValue, |
| 10356 |
) { |
| 10357 |
if len(attrs) == 0 { |
| 10358 |
m.Int64UpDownCounter.Add(ctx, incr, metric.WithAttributes( |
| 10359 |
attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName), |
| 10360 |
)) |
| 10361 |
return |
| 10362 |
} |
| 10363 |
|
| 10364 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10365 |
defer func() { |
| 10366 |
*o = (*o)[:0] |
| 10367 |
addOptPool.Put(o) |
| 10368 |
}() |
| 10369 |
|
| 10370 |
*o = append( |
| 10371 |
*o, |
| 10372 |
metric.WithAttributes( |
| 10373 |
append( |
| 10374 |
attrs, |
| 10375 |
attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName), |
| 10376 |
)..., |
| 10377 |
), |
| 10378 |
) |
| 10379 |
|
| 10380 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10381 |
} |
| 10382 |
|
| 10383 |
// AddSet adds incr to the existing count for set. |
| 10384 |
// |
| 10385 |
// This metric is retrieved from the `used` field of the |
| 10386 |
// [K8s ResourceQuotaStatus]. |
| 10387 |
// |
| 10388 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10389 |
func (m ResourceQuotaObjectCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10390 |
if set.Len() == 0 { |
| 10391 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 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(*o, metric.WithAttributeSet(set)) |
| 10402 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10403 |
} |
| 10404 |
|
| 10405 |
// ResourceQuotaPersistentvolumeclaimCountHard is an instrument used to record |
| 10406 |
// metric values conforming to the |
| 10407 |
// "k8s.resourcequota.persistentvolumeclaim_count.hard" semantic conventions. It |
| 10408 |
// represents the total number of PersistentVolumeClaims that can exist in the |
| 10409 |
// namespace. |
| 10410 |
// The value represents the configured quota limit of the resource in the |
| 10411 |
// namespace. |
| 10412 |
type ResourceQuotaPersistentvolumeclaimCountHard struct { |
| 10413 |
metric.Int64UpDownCounter |
| 10414 |
} |
| 10415 |
|
| 10416 |
var newResourceQuotaPersistentvolumeclaimCountHardOpts = []metric.Int64UpDownCounterOption{ |
| 10417 |
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."), |
| 10418 |
metric.WithUnit("{persistentvolumeclaim}"), |
| 10419 |
} |
| 10420 |
|
| 10421 |
// NewResourceQuotaPersistentvolumeclaimCountHard returns a new |
| 10422 |
// ResourceQuotaPersistentvolumeclaimCountHard instrument. |
| 10423 |
func NewResourceQuotaPersistentvolumeclaimCountHard( |
| 10424 |
m metric.Meter, |
| 10425 |
opt ...metric.Int64UpDownCounterOption, |
| 10426 |
) (ResourceQuotaPersistentvolumeclaimCountHard, error) { |
| 10427 |
// Check if the meter is nil. |
| 10428 |
if m == nil { |
| 10429 |
return ResourceQuotaPersistentvolumeclaimCountHard{noop.Int64UpDownCounter{}}, nil |
| 10430 |
} |
| 10431 |
|
| 10432 |
if len(opt) == 0 { |
| 10433 |
opt = newResourceQuotaPersistentvolumeclaimCountHardOpts |
| 10434 |
} else { |
| 10435 |
opt = append(opt, newResourceQuotaPersistentvolumeclaimCountHardOpts...) |
| 10436 |
} |
| 10437 |
|
| 10438 |
i, err := m.Int64UpDownCounter( |
| 10439 |
"k8s.resourcequota.persistentvolumeclaim_count.hard", |
| 10440 |
opt..., |
| 10441 |
) |
| 10442 |
if err != nil { |
| 10443 |
return ResourceQuotaPersistentvolumeclaimCountHard{noop.Int64UpDownCounter{}}, err |
| 10444 |
} |
| 10445 |
return ResourceQuotaPersistentvolumeclaimCountHard{i}, nil |
| 10446 |
} |
| 10447 |
|
| 10448 |
// Inst returns the underlying metric instrument. |
| 10449 |
func (m ResourceQuotaPersistentvolumeclaimCountHard) Inst() metric.Int64UpDownCounter { |
| 10450 |
return m.Int64UpDownCounter |
| 10451 |
} |
| 10452 |
|
| 10453 |
// Name returns the semantic convention name of the instrument. |
| 10454 |
func (ResourceQuotaPersistentvolumeclaimCountHard) Name() string { |
| 10455 |
return "k8s.resourcequota.persistentvolumeclaim_count.hard" |
| 10456 |
} |
| 10457 |
|
| 10458 |
// Unit returns the semantic convention unit of the instrument |
| 10459 |
func (ResourceQuotaPersistentvolumeclaimCountHard) Unit() string { |
| 10460 |
return "{persistentvolumeclaim}" |
| 10461 |
} |
| 10462 |
|
| 10463 |
// Description returns the semantic convention description of the instrument |
| 10464 |
func (ResourceQuotaPersistentvolumeclaimCountHard) Description() string { |
| 10465 |
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." |
| 10466 |
} |
| 10467 |
|
| 10468 |
// Add adds incr to the existing count for attrs. |
| 10469 |
// |
| 10470 |
// All additional attrs passed are included in the recorded value. |
| 10471 |
// |
| 10472 |
// This metric is retrieved from the `hard` field of the |
| 10473 |
// [K8s ResourceQuotaStatus]. |
| 10474 |
// |
| 10475 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10476 |
// defined for a specific |
| 10477 |
// storage class. |
| 10478 |
// |
| 10479 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10480 |
func (m ResourceQuotaPersistentvolumeclaimCountHard) Add( |
| 10481 |
ctx context.Context, |
| 10482 |
incr int64, |
| 10483 |
attrs ...attribute.KeyValue, |
| 10484 |
) { |
| 10485 |
if len(attrs) == 0 { |
| 10486 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10487 |
return |
| 10488 |
} |
| 10489 |
|
| 10490 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10491 |
defer func() { |
| 10492 |
*o = (*o)[:0] |
| 10493 |
addOptPool.Put(o) |
| 10494 |
}() |
| 10495 |
|
| 10496 |
*o = append( |
| 10497 |
*o, |
| 10498 |
metric.WithAttributes( |
| 10499 |
attrs..., |
| 10500 |
), |
| 10501 |
) |
| 10502 |
|
| 10503 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10504 |
} |
| 10505 |
|
| 10506 |
// AddSet adds incr to the existing count for set. |
| 10507 |
// |
| 10508 |
// This metric is retrieved from the `hard` field of the |
| 10509 |
// [K8s ResourceQuotaStatus]. |
| 10510 |
// |
| 10511 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10512 |
// defined for a specific |
| 10513 |
// storage class. |
| 10514 |
// |
| 10515 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10516 |
func (m ResourceQuotaPersistentvolumeclaimCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10517 |
if set.Len() == 0 { |
| 10518 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10519 |
return |
| 10520 |
} |
| 10521 |
|
| 10522 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10523 |
defer func() { |
| 10524 |
*o = (*o)[:0] |
| 10525 |
addOptPool.Put(o) |
| 10526 |
}() |
| 10527 |
|
| 10528 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 10529 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10530 |
} |
| 10531 |
|
| 10532 |
// AttrStorageclassName returns an optional attribute for the |
| 10533 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 10534 |
// [StorageClass] object. |
| 10535 |
// |
| 10536 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 10537 |
func (ResourceQuotaPersistentvolumeclaimCountHard) AttrStorageclassName(val string) attribute.KeyValue { |
| 10538 |
return attribute.String("k8s.storageclass.name", val) |
| 10539 |
} |
| 10540 |
|
| 10541 |
// ResourceQuotaPersistentvolumeclaimCountUsed is an instrument used to record |
| 10542 |
// metric values conforming to the |
| 10543 |
// "k8s.resourcequota.persistentvolumeclaim_count.used" semantic conventions. It |
| 10544 |
// represents the total number of PersistentVolumeClaims that can exist in the |
| 10545 |
// namespace. |
| 10546 |
// The value represents the current observed total usage of the resource in the |
| 10547 |
// namespace. |
| 10548 |
type ResourceQuotaPersistentvolumeclaimCountUsed struct { |
| 10549 |
metric.Int64UpDownCounter |
| 10550 |
} |
| 10551 |
|
| 10552 |
var newResourceQuotaPersistentvolumeclaimCountUsedOpts = []metric.Int64UpDownCounterOption{ |
| 10553 |
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."), |
| 10554 |
metric.WithUnit("{persistentvolumeclaim}"), |
| 10555 |
} |
| 10556 |
|
| 10557 |
// NewResourceQuotaPersistentvolumeclaimCountUsed returns a new |
| 10558 |
// ResourceQuotaPersistentvolumeclaimCountUsed instrument. |
| 10559 |
func NewResourceQuotaPersistentvolumeclaimCountUsed( |
| 10560 |
m metric.Meter, |
| 10561 |
opt ...metric.Int64UpDownCounterOption, |
| 10562 |
) (ResourceQuotaPersistentvolumeclaimCountUsed, error) { |
| 10563 |
// Check if the meter is nil. |
| 10564 |
if m == nil { |
| 10565 |
return ResourceQuotaPersistentvolumeclaimCountUsed{noop.Int64UpDownCounter{}}, nil |
| 10566 |
} |
| 10567 |
|
| 10568 |
if len(opt) == 0 { |
| 10569 |
opt = newResourceQuotaPersistentvolumeclaimCountUsedOpts |
| 10570 |
} else { |
| 10571 |
opt = append(opt, newResourceQuotaPersistentvolumeclaimCountUsedOpts...) |
| 10572 |
} |
| 10573 |
|
| 10574 |
i, err := m.Int64UpDownCounter( |
| 10575 |
"k8s.resourcequota.persistentvolumeclaim_count.used", |
| 10576 |
opt..., |
| 10577 |
) |
| 10578 |
if err != nil { |
| 10579 |
return ResourceQuotaPersistentvolumeclaimCountUsed{noop.Int64UpDownCounter{}}, err |
| 10580 |
} |
| 10581 |
return ResourceQuotaPersistentvolumeclaimCountUsed{i}, nil |
| 10582 |
} |
| 10583 |
|
| 10584 |
// Inst returns the underlying metric instrument. |
| 10585 |
func (m ResourceQuotaPersistentvolumeclaimCountUsed) Inst() metric.Int64UpDownCounter { |
| 10586 |
return m.Int64UpDownCounter |
| 10587 |
} |
| 10588 |
|
| 10589 |
// Name returns the semantic convention name of the instrument. |
| 10590 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) Name() string { |
| 10591 |
return "k8s.resourcequota.persistentvolumeclaim_count.used" |
| 10592 |
} |
| 10593 |
|
| 10594 |
// Unit returns the semantic convention unit of the instrument |
| 10595 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) Unit() string { |
| 10596 |
return "{persistentvolumeclaim}" |
| 10597 |
} |
| 10598 |
|
| 10599 |
// Description returns the semantic convention description of the instrument |
| 10600 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) Description() string { |
| 10601 |
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." |
| 10602 |
} |
| 10603 |
|
| 10604 |
// Add adds incr to the existing count for attrs. |
| 10605 |
// |
| 10606 |
// All additional attrs passed are included in the recorded value. |
| 10607 |
// |
| 10608 |
// This metric is retrieved from the `used` field of the |
| 10609 |
// [K8s ResourceQuotaStatus]. |
| 10610 |
// |
| 10611 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10612 |
// defined for a specific |
| 10613 |
// storage class. |
| 10614 |
// |
| 10615 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10616 |
func (m ResourceQuotaPersistentvolumeclaimCountUsed) Add( |
| 10617 |
ctx context.Context, |
| 10618 |
incr int64, |
| 10619 |
attrs ...attribute.KeyValue, |
| 10620 |
) { |
| 10621 |
if len(attrs) == 0 { |
| 10622 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10623 |
return |
| 10624 |
} |
| 10625 |
|
| 10626 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10627 |
defer func() { |
| 10628 |
*o = (*o)[:0] |
| 10629 |
addOptPool.Put(o) |
| 10630 |
}() |
| 10631 |
|
| 10632 |
*o = append( |
| 10633 |
*o, |
| 10634 |
metric.WithAttributes( |
| 10635 |
attrs..., |
| 10636 |
), |
| 10637 |
) |
| 10638 |
|
| 10639 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10640 |
} |
| 10641 |
|
| 10642 |
// AddSet adds incr to the existing count for set. |
| 10643 |
// |
| 10644 |
// This metric is retrieved from the `used` field of the |
| 10645 |
// [K8s ResourceQuotaStatus]. |
| 10646 |
// |
| 10647 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10648 |
// defined for a specific |
| 10649 |
// storage class. |
| 10650 |
// |
| 10651 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10652 |
func (m ResourceQuotaPersistentvolumeclaimCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10653 |
if set.Len() == 0 { |
| 10654 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10655 |
return |
| 10656 |
} |
| 10657 |
|
| 10658 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10659 |
defer func() { |
| 10660 |
*o = (*o)[:0] |
| 10661 |
addOptPool.Put(o) |
| 10662 |
}() |
| 10663 |
|
| 10664 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 10665 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10666 |
} |
| 10667 |
|
| 10668 |
// AttrStorageclassName returns an optional attribute for the |
| 10669 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 10670 |
// [StorageClass] object. |
| 10671 |
// |
| 10672 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 10673 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) AttrStorageclassName(val string) attribute.KeyValue { |
| 10674 |
return attribute.String("k8s.storageclass.name", val) |
| 10675 |
} |
| 10676 |
|
| 10677 |
// ResourceQuotaStorageRequestHard is an instrument used to record metric values |
| 10678 |
// conforming to the "k8s.resourcequota.storage.request.hard" semantic |
| 10679 |
// conventions. It represents the storage requests in a specific namespace. |
| 10680 |
// The value represents the configured quota limit of the resource in the |
| 10681 |
// namespace. |
| 10682 |
type ResourceQuotaStorageRequestHard struct { |
| 10683 |
metric.Int64UpDownCounter |
| 10684 |
} |
| 10685 |
|
| 10686 |
var newResourceQuotaStorageRequestHardOpts = []metric.Int64UpDownCounterOption{ |
| 10687 |
metric.WithDescription("The storage requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 10688 |
metric.WithUnit("By"), |
| 10689 |
} |
| 10690 |
|
| 10691 |
// NewResourceQuotaStorageRequestHard returns a new |
| 10692 |
// ResourceQuotaStorageRequestHard instrument. |
| 10693 |
func NewResourceQuotaStorageRequestHard( |
| 10694 |
m metric.Meter, |
| 10695 |
opt ...metric.Int64UpDownCounterOption, |
| 10696 |
) (ResourceQuotaStorageRequestHard, error) { |
| 10697 |
// Check if the meter is nil. |
| 10698 |
if m == nil { |
| 10699 |
return ResourceQuotaStorageRequestHard{noop.Int64UpDownCounter{}}, nil |
| 10700 |
} |
| 10701 |
|
| 10702 |
if len(opt) == 0 { |
| 10703 |
opt = newResourceQuotaStorageRequestHardOpts |
| 10704 |
} else { |
| 10705 |
opt = append(opt, newResourceQuotaStorageRequestHardOpts...) |
| 10706 |
} |
| 10707 |
|
| 10708 |
i, err := m.Int64UpDownCounter( |
| 10709 |
"k8s.resourcequota.storage.request.hard", |
| 10710 |
opt..., |
| 10711 |
) |
| 10712 |
if err != nil { |
| 10713 |
return ResourceQuotaStorageRequestHard{noop.Int64UpDownCounter{}}, err |
| 10714 |
} |
| 10715 |
return ResourceQuotaStorageRequestHard{i}, nil |
| 10716 |
} |
| 10717 |
|
| 10718 |
// Inst returns the underlying metric instrument. |
| 10719 |
func (m ResourceQuotaStorageRequestHard) Inst() metric.Int64UpDownCounter { |
| 10720 |
return m.Int64UpDownCounter |
| 10721 |
} |
| 10722 |
|
| 10723 |
// Name returns the semantic convention name of the instrument. |
| 10724 |
func (ResourceQuotaStorageRequestHard) Name() string { |
| 10725 |
return "k8s.resourcequota.storage.request.hard" |
| 10726 |
} |
| 10727 |
|
| 10728 |
// Unit returns the semantic convention unit of the instrument |
| 10729 |
func (ResourceQuotaStorageRequestHard) Unit() string { |
| 10730 |
return "By" |
| 10731 |
} |
| 10732 |
|
| 10733 |
// Description returns the semantic convention description of the instrument |
| 10734 |
func (ResourceQuotaStorageRequestHard) Description() string { |
| 10735 |
return "The storage requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 10736 |
} |
| 10737 |
|
| 10738 |
// Add adds incr to the existing count for attrs. |
| 10739 |
// |
| 10740 |
// All additional attrs passed are included in the recorded value. |
| 10741 |
// |
| 10742 |
// This metric is retrieved from the `hard` field of the |
| 10743 |
// [K8s ResourceQuotaStatus]. |
| 10744 |
// |
| 10745 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10746 |
// defined for a specific |
| 10747 |
// storage class. |
| 10748 |
// |
| 10749 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10750 |
func (m ResourceQuotaStorageRequestHard) Add( |
| 10751 |
ctx context.Context, |
| 10752 |
incr int64, |
| 10753 |
attrs ...attribute.KeyValue, |
| 10754 |
) { |
| 10755 |
if len(attrs) == 0 { |
| 10756 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10757 |
return |
| 10758 |
} |
| 10759 |
|
| 10760 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10761 |
defer func() { |
| 10762 |
*o = (*o)[:0] |
| 10763 |
addOptPool.Put(o) |
| 10764 |
}() |
| 10765 |
|
| 10766 |
*o = append( |
| 10767 |
*o, |
| 10768 |
metric.WithAttributes( |
| 10769 |
attrs..., |
| 10770 |
), |
| 10771 |
) |
| 10772 |
|
| 10773 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10774 |
} |
| 10775 |
|
| 10776 |
// AddSet adds incr to the existing count for set. |
| 10777 |
// |
| 10778 |
// This metric is retrieved from the `hard` field of the |
| 10779 |
// [K8s ResourceQuotaStatus]. |
| 10780 |
// |
| 10781 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10782 |
// defined for a specific |
| 10783 |
// storage class. |
| 10784 |
// |
| 10785 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10786 |
func (m ResourceQuotaStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10787 |
if set.Len() == 0 { |
| 10788 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10789 |
return |
| 10790 |
} |
| 10791 |
|
| 10792 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10793 |
defer func() { |
| 10794 |
*o = (*o)[:0] |
| 10795 |
addOptPool.Put(o) |
| 10796 |
}() |
| 10797 |
|
| 10798 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 10799 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10800 |
} |
| 10801 |
|
| 10802 |
// AttrStorageclassName returns an optional attribute for the |
| 10803 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 10804 |
// [StorageClass] object. |
| 10805 |
// |
| 10806 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 10807 |
func (ResourceQuotaStorageRequestHard) AttrStorageclassName(val string) attribute.KeyValue { |
| 10808 |
return attribute.String("k8s.storageclass.name", val) |
| 10809 |
} |
| 10810 |
|
| 10811 |
// ResourceQuotaStorageRequestUsed is an instrument used to record metric values |
| 10812 |
// conforming to the "k8s.resourcequota.storage.request.used" semantic |
| 10813 |
// conventions. It represents the storage requests in a specific namespace. |
| 10814 |
// The value represents the current observed total usage of the resource in the |
| 10815 |
// namespace. |
| 10816 |
type ResourceQuotaStorageRequestUsed struct { |
| 10817 |
metric.Int64UpDownCounter |
| 10818 |
} |
| 10819 |
|
| 10820 |
var newResourceQuotaStorageRequestUsedOpts = []metric.Int64UpDownCounterOption{ |
| 10821 |
metric.WithDescription("The storage requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 10822 |
metric.WithUnit("By"), |
| 10823 |
} |
| 10824 |
|
| 10825 |
// NewResourceQuotaStorageRequestUsed returns a new |
| 10826 |
// ResourceQuotaStorageRequestUsed instrument. |
| 10827 |
func NewResourceQuotaStorageRequestUsed( |
| 10828 |
m metric.Meter, |
| 10829 |
opt ...metric.Int64UpDownCounterOption, |
| 10830 |
) (ResourceQuotaStorageRequestUsed, error) { |
| 10831 |
// Check if the meter is nil. |
| 10832 |
if m == nil { |
| 10833 |
return ResourceQuotaStorageRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 10834 |
} |
| 10835 |
|
| 10836 |
if len(opt) == 0 { |
| 10837 |
opt = newResourceQuotaStorageRequestUsedOpts |
| 10838 |
} else { |
| 10839 |
opt = append(opt, newResourceQuotaStorageRequestUsedOpts...) |
| 10840 |
} |
| 10841 |
|
| 10842 |
i, err := m.Int64UpDownCounter( |
| 10843 |
"k8s.resourcequota.storage.request.used", |
| 10844 |
opt..., |
| 10845 |
) |
| 10846 |
if err != nil { |
| 10847 |
return ResourceQuotaStorageRequestUsed{noop.Int64UpDownCounter{}}, err |
| 10848 |
} |
| 10849 |
return ResourceQuotaStorageRequestUsed{i}, nil |
| 10850 |
} |
| 10851 |
|
| 10852 |
// Inst returns the underlying metric instrument. |
| 10853 |
func (m ResourceQuotaStorageRequestUsed) Inst() metric.Int64UpDownCounter { |
| 10854 |
return m.Int64UpDownCounter |
| 10855 |
} |
| 10856 |
|
| 10857 |
// Name returns the semantic convention name of the instrument. |
| 10858 |
func (ResourceQuotaStorageRequestUsed) Name() string { |
| 10859 |
return "k8s.resourcequota.storage.request.used" |
| 10860 |
} |
| 10861 |
|
| 10862 |
// Unit returns the semantic convention unit of the instrument |
| 10863 |
func (ResourceQuotaStorageRequestUsed) Unit() string { |
| 10864 |
return "By" |
| 10865 |
} |
| 10866 |
|
| 10867 |
// Description returns the semantic convention description of the instrument |
| 10868 |
func (ResourceQuotaStorageRequestUsed) Description() string { |
| 10869 |
return "The storage requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 10870 |
} |
| 10871 |
|
| 10872 |
// Add adds incr to the existing count for attrs. |
| 10873 |
// |
| 10874 |
// All additional attrs passed are included in the recorded value. |
| 10875 |
// |
| 10876 |
// This metric is retrieved from the `used` field of the |
| 10877 |
// [K8s ResourceQuotaStatus]. |
| 10878 |
// |
| 10879 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10880 |
// defined for a specific |
| 10881 |
// storage class. |
| 10882 |
// |
| 10883 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10884 |
func (m ResourceQuotaStorageRequestUsed) Add( |
| 10885 |
ctx context.Context, |
| 10886 |
incr int64, |
| 10887 |
attrs ...attribute.KeyValue, |
| 10888 |
) { |
| 10889 |
if len(attrs) == 0 { |
| 10890 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10891 |
return |
| 10892 |
} |
| 10893 |
|
| 10894 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10895 |
defer func() { |
| 10896 |
*o = (*o)[:0] |
| 10897 |
addOptPool.Put(o) |
| 10898 |
}() |
| 10899 |
|
| 10900 |
*o = append( |
| 10901 |
*o, |
| 10902 |
metric.WithAttributes( |
| 10903 |
attrs..., |
| 10904 |
), |
| 10905 |
) |
| 10906 |
|
| 10907 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10908 |
} |
| 10909 |
|
| 10910 |
// AddSet adds incr to the existing count for set. |
| 10911 |
// |
| 10912 |
// This metric is retrieved from the `used` field of the |
| 10913 |
// [K8s ResourceQuotaStatus]. |
| 10914 |
// |
| 10915 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 10916 |
// defined for a specific |
| 10917 |
// storage class. |
| 10918 |
// |
| 10919 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 10920 |
func (m ResourceQuotaStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 10921 |
if set.Len() == 0 { |
| 10922 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 10923 |
return |
| 10924 |
} |
| 10925 |
|
| 10926 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 10927 |
defer func() { |
| 10928 |
*o = (*o)[:0] |
| 10929 |
addOptPool.Put(o) |
| 10930 |
}() |
| 10931 |
|
| 10932 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 10933 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 10934 |
} |
| 10935 |
|
| 10936 |
// AttrStorageclassName returns an optional attribute for the |
| 10937 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 10938 |
// [StorageClass] object. |
| 10939 |
// |
| 10940 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 10941 |
func (ResourceQuotaStorageRequestUsed) AttrStorageclassName(val string) attribute.KeyValue { |
| 10942 |
return attribute.String("k8s.storageclass.name", val) |
| 10943 |
} |
| 10944 |
|
| 10945 |
// StatefulSetPodCurrent is an instrument used to record metric values conforming |
| 10946 |
// to the "k8s.statefulset.pod.current" semantic conventions. It represents the |
| 10947 |
// number of replica pods created by the statefulset controller from the |
| 10948 |
// statefulset version indicated by currentRevision. |
| 10949 |
type StatefulSetPodCurrent struct { |
| 10950 |
metric.Int64UpDownCounter |
| 10951 |
} |
| 10952 |
|
| 10953 |
var newStatefulSetPodCurrentOpts = []metric.Int64UpDownCounterOption{ |
| 10954 |
metric.WithDescription("The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision."), |
| 10955 |
metric.WithUnit("{pod}"), |
| 10956 |
} |
| 10957 |
|
| 10958 |
// NewStatefulSetPodCurrent returns a new StatefulSetPodCurrent instrument. |
| 10959 |
func NewStatefulSetPodCurrent( |
| 10960 |
m metric.Meter, |
| 10961 |
opt ...metric.Int64UpDownCounterOption, |
| 10962 |
) (StatefulSetPodCurrent, error) { |
| 10963 |
// Check if the meter is nil. |
| 10964 |
if m == nil { |
| 10965 |
return StatefulSetPodCurrent{noop.Int64UpDownCounter{}}, nil |
| 10966 |
} |
| 10967 |
|
| 10968 |
if len(opt) == 0 { |
| 10969 |
opt = newStatefulSetPodCurrentOpts |
| 10970 |
} else { |
| 10971 |
opt = append(opt, newStatefulSetPodCurrentOpts...) |
| 10972 |
} |
| 10973 |
|
| 10974 |
i, err := m.Int64UpDownCounter( |
| 10975 |
"k8s.statefulset.pod.current", |
| 10976 |
opt..., |
| 10977 |
) |
| 10978 |
if err != nil { |
| 10979 |
return StatefulSetPodCurrent{noop.Int64UpDownCounter{}}, err |
| 10980 |
} |
| 10981 |
return StatefulSetPodCurrent{i}, nil |
| 10982 |
} |
| 10983 |
|
| 10984 |
// Inst returns the underlying metric instrument. |
| 10985 |
func (m StatefulSetPodCurrent) Inst() metric.Int64UpDownCounter { |
| 10986 |
return m.Int64UpDownCounter |
| 10987 |
} |
| 10988 |
|
| 10989 |
// Name returns the semantic convention name of the instrument. |
| 10990 |
func (StatefulSetPodCurrent) Name() string { |
| 10991 |
return "k8s.statefulset.pod.current" |
| 10992 |
} |
| 10993 |
|
| 10994 |
// Unit returns the semantic convention unit of the instrument |
| 10995 |
func (StatefulSetPodCurrent) Unit() string { |
| 10996 |
return "{pod}" |
| 10997 |
} |
| 10998 |
|
| 10999 |
// Description returns the semantic convention description of the instrument |
| 11000 |
func (StatefulSetPodCurrent) Description() string { |
| 11001 |
return "The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision." |
| 11002 |
} |
| 11003 |
|
| 11004 |
// Add adds incr to the existing count for attrs. |
| 11005 |
// |
| 11006 |
// This metric aligns with the `currentReplicas` field of the |
| 11007 |
// [K8s StatefulSetStatus]. |
| 11008 |
// |
| 11009 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 11010 |
func (m StatefulSetPodCurrent) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 11011 |
if len(attrs) == 0 { |
| 11012 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11013 |
return |
| 11014 |
} |
| 11015 |
|
| 11016 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11017 |
defer func() { |
| 11018 |
*o = (*o)[:0] |
| 11019 |
addOptPool.Put(o) |
| 11020 |
}() |
| 11021 |
|
| 11022 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 11023 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11024 |
} |
| 11025 |
|
| 11026 |
// AddSet adds incr to the existing count for set. |
| 11027 |
// |
| 11028 |
// This metric aligns with the `currentReplicas` field of the |
| 11029 |
// [K8s StatefulSetStatus]. |
| 11030 |
// |
| 11031 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 11032 |
func (m StatefulSetPodCurrent) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 11033 |
if set.Len() == 0 { |
| 11034 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11035 |
return |
| 11036 |
} |
| 11037 |
|
| 11038 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11039 |
defer func() { |
| 11040 |
*o = (*o)[:0] |
| 11041 |
addOptPool.Put(o) |
| 11042 |
}() |
| 11043 |
|
| 11044 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 11045 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11046 |
} |
| 11047 |
|
| 11048 |
// StatefulSetPodDesired is an instrument used to record metric values conforming |
| 11049 |
// to the "k8s.statefulset.pod.desired" semantic conventions. It represents the |
| 11050 |
// number of desired replica pods in this statefulset. |
| 11051 |
type StatefulSetPodDesired struct { |
| 11052 |
metric.Int64UpDownCounter |
| 11053 |
} |
| 11054 |
|
| 11055 |
var newStatefulSetPodDesiredOpts = []metric.Int64UpDownCounterOption{ |
| 11056 |
metric.WithDescription("Number of desired replica pods in this statefulset."), |
| 11057 |
metric.WithUnit("{pod}"), |
| 11058 |
} |
| 11059 |
|
| 11060 |
// NewStatefulSetPodDesired returns a new StatefulSetPodDesired instrument. |
| 11061 |
func NewStatefulSetPodDesired( |
| 11062 |
m metric.Meter, |
| 11063 |
opt ...metric.Int64UpDownCounterOption, |
| 11064 |
) (StatefulSetPodDesired, error) { |
| 11065 |
// Check if the meter is nil. |
| 11066 |
if m == nil { |
| 11067 |
return StatefulSetPodDesired{noop.Int64UpDownCounter{}}, nil |
| 11068 |
} |
| 11069 |
|
| 11070 |
if len(opt) == 0 { |
| 11071 |
opt = newStatefulSetPodDesiredOpts |
| 11072 |
} else { |
| 11073 |
opt = append(opt, newStatefulSetPodDesiredOpts...) |
| 11074 |
} |
| 11075 |
|
| 11076 |
i, err := m.Int64UpDownCounter( |
| 11077 |
"k8s.statefulset.pod.desired", |
| 11078 |
opt..., |
| 11079 |
) |
| 11080 |
if err != nil { |
| 11081 |
return StatefulSetPodDesired{noop.Int64UpDownCounter{}}, err |
| 11082 |
} |
| 11083 |
return StatefulSetPodDesired{i}, nil |
| 11084 |
} |
| 11085 |
|
| 11086 |
// Inst returns the underlying metric instrument. |
| 11087 |
func (m StatefulSetPodDesired) Inst() metric.Int64UpDownCounter { |
| 11088 |
return m.Int64UpDownCounter |
| 11089 |
} |
| 11090 |
|
| 11091 |
// Name returns the semantic convention name of the instrument. |
| 11092 |
func (StatefulSetPodDesired) Name() string { |
| 11093 |
return "k8s.statefulset.pod.desired" |
| 11094 |
} |
| 11095 |
|
| 11096 |
// Unit returns the semantic convention unit of the instrument |
| 11097 |
func (StatefulSetPodDesired) Unit() string { |
| 11098 |
return "{pod}" |
| 11099 |
} |
| 11100 |
|
| 11101 |
// Description returns the semantic convention description of the instrument |
| 11102 |
func (StatefulSetPodDesired) Description() string { |
| 11103 |
return "Number of desired replica pods in this statefulset." |
| 11104 |
} |
| 11105 |
|
| 11106 |
// Add adds incr to the existing count for attrs. |
| 11107 |
// |
| 11108 |
// This metric aligns with the `replicas` field of the |
| 11109 |
// [K8s StatefulSetSpec]. |
| 11110 |
// |
| 11111 |
// [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps |
| 11112 |
func (m StatefulSetPodDesired) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 11113 |
if len(attrs) == 0 { |
| 11114 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11115 |
return |
| 11116 |
} |
| 11117 |
|
| 11118 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11119 |
defer func() { |
| 11120 |
*o = (*o)[:0] |
| 11121 |
addOptPool.Put(o) |
| 11122 |
}() |
| 11123 |
|
| 11124 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 11125 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11126 |
} |
| 11127 |
|
| 11128 |
// AddSet adds incr to the existing count for set. |
| 11129 |
// |
| 11130 |
// This metric aligns with the `replicas` field of the |
| 11131 |
// [K8s StatefulSetSpec]. |
| 11132 |
// |
| 11133 |
// [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps |
| 11134 |
func (m StatefulSetPodDesired) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 11135 |
if set.Len() == 0 { |
| 11136 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11137 |
return |
| 11138 |
} |
| 11139 |
|
| 11140 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11141 |
defer func() { |
| 11142 |
*o = (*o)[:0] |
| 11143 |
addOptPool.Put(o) |
| 11144 |
}() |
| 11145 |
|
| 11146 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 11147 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11148 |
} |
| 11149 |
|
| 11150 |
// StatefulSetPodReady is an instrument used to record metric values conforming |
| 11151 |
// to the "k8s.statefulset.pod.ready" semantic conventions. It represents the |
| 11152 |
// number of replica pods created for this statefulset with a Ready Condition. |
| 11153 |
type StatefulSetPodReady struct { |
| 11154 |
metric.Int64UpDownCounter |
| 11155 |
} |
| 11156 |
|
| 11157 |
var newStatefulSetPodReadyOpts = []metric.Int64UpDownCounterOption{ |
| 11158 |
metric.WithDescription("The number of replica pods created for this statefulset with a Ready Condition."), |
| 11159 |
metric.WithUnit("{pod}"), |
| 11160 |
} |
| 11161 |
|
| 11162 |
// NewStatefulSetPodReady returns a new StatefulSetPodReady instrument. |
| 11163 |
func NewStatefulSetPodReady( |
| 11164 |
m metric.Meter, |
| 11165 |
opt ...metric.Int64UpDownCounterOption, |
| 11166 |
) (StatefulSetPodReady, error) { |
| 11167 |
// Check if the meter is nil. |
| 11168 |
if m == nil { |
| 11169 |
return StatefulSetPodReady{noop.Int64UpDownCounter{}}, nil |
| 11170 |
} |
| 11171 |
|
| 11172 |
if len(opt) == 0 { |
| 11173 |
opt = newStatefulSetPodReadyOpts |
| 11174 |
} else { |
| 11175 |
opt = append(opt, newStatefulSetPodReadyOpts...) |
| 11176 |
} |
| 11177 |
|
| 11178 |
i, err := m.Int64UpDownCounter( |
| 11179 |
"k8s.statefulset.pod.ready", |
| 11180 |
opt..., |
| 11181 |
) |
| 11182 |
if err != nil { |
| 11183 |
return StatefulSetPodReady{noop.Int64UpDownCounter{}}, err |
| 11184 |
} |
| 11185 |
return StatefulSetPodReady{i}, nil |
| 11186 |
} |
| 11187 |
|
| 11188 |
// Inst returns the underlying metric instrument. |
| 11189 |
func (m StatefulSetPodReady) Inst() metric.Int64UpDownCounter { |
| 11190 |
return m.Int64UpDownCounter |
| 11191 |
} |
| 11192 |
|
| 11193 |
// Name returns the semantic convention name of the instrument. |
| 11194 |
func (StatefulSetPodReady) Name() string { |
| 11195 |
return "k8s.statefulset.pod.ready" |
| 11196 |
} |
| 11197 |
|
| 11198 |
// Unit returns the semantic convention unit of the instrument |
| 11199 |
func (StatefulSetPodReady) Unit() string { |
| 11200 |
return "{pod}" |
| 11201 |
} |
| 11202 |
|
| 11203 |
// Description returns the semantic convention description of the instrument |
| 11204 |
func (StatefulSetPodReady) Description() string { |
| 11205 |
return "The number of replica pods created for this statefulset with a Ready Condition." |
| 11206 |
} |
| 11207 |
|
| 11208 |
// Add adds incr to the existing count for attrs. |
| 11209 |
// |
| 11210 |
// This metric aligns with the `readyReplicas` field of the |
| 11211 |
// [K8s StatefulSetStatus]. |
| 11212 |
// |
| 11213 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 11214 |
func (m StatefulSetPodReady) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 11215 |
if len(attrs) == 0 { |
| 11216 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11217 |
return |
| 11218 |
} |
| 11219 |
|
| 11220 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11221 |
defer func() { |
| 11222 |
*o = (*o)[:0] |
| 11223 |
addOptPool.Put(o) |
| 11224 |
}() |
| 11225 |
|
| 11226 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 11227 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11228 |
} |
| 11229 |
|
| 11230 |
// AddSet adds incr to the existing count for set. |
| 11231 |
// |
| 11232 |
// This metric aligns with the `readyReplicas` field of the |
| 11233 |
// [K8s StatefulSetStatus]. |
| 11234 |
// |
| 11235 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 11236 |
func (m StatefulSetPodReady) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 11237 |
if set.Len() == 0 { |
| 11238 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11239 |
return |
| 11240 |
} |
| 11241 |
|
| 11242 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11243 |
defer func() { |
| 11244 |
*o = (*o)[:0] |
| 11245 |
addOptPool.Put(o) |
| 11246 |
}() |
| 11247 |
|
| 11248 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 11249 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11250 |
} |
| 11251 |
|
| 11252 |
// StatefulSetPodUpdated is an instrument used to record metric values conforming |
| 11253 |
// to the "k8s.statefulset.pod.updated" semantic conventions. It represents the |
| 11254 |
// number of replica pods created by the statefulset controller from the |
| 11255 |
// statefulset version indicated by updateRevision. |
| 11256 |
type StatefulSetPodUpdated struct { |
| 11257 |
metric.Int64UpDownCounter |
| 11258 |
} |
| 11259 |
|
| 11260 |
var newStatefulSetPodUpdatedOpts = []metric.Int64UpDownCounterOption{ |
| 11261 |
metric.WithDescription("Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision."), |
| 11262 |
metric.WithUnit("{pod}"), |
| 11263 |
} |
| 11264 |
|
| 11265 |
// NewStatefulSetPodUpdated returns a new StatefulSetPodUpdated instrument. |
| 11266 |
func NewStatefulSetPodUpdated( |
| 11267 |
m metric.Meter, |
| 11268 |
opt ...metric.Int64UpDownCounterOption, |
| 11269 |
) (StatefulSetPodUpdated, error) { |
| 11270 |
// Check if the meter is nil. |
| 11271 |
if m == nil { |
| 11272 |
return StatefulSetPodUpdated{noop.Int64UpDownCounter{}}, nil |
| 11273 |
} |
| 11274 |
|
| 11275 |
if len(opt) == 0 { |
| 11276 |
opt = newStatefulSetPodUpdatedOpts |
| 11277 |
} else { |
| 11278 |
opt = append(opt, newStatefulSetPodUpdatedOpts...) |
| 11279 |
} |
| 11280 |
|
| 11281 |
i, err := m.Int64UpDownCounter( |
| 11282 |
"k8s.statefulset.pod.updated", |
| 11283 |
opt..., |
| 11284 |
) |
| 11285 |
if err != nil { |
| 11286 |
return StatefulSetPodUpdated{noop.Int64UpDownCounter{}}, err |
| 11287 |
} |
| 11288 |
return StatefulSetPodUpdated{i}, nil |
| 11289 |
} |
| 11290 |
|
| 11291 |
// Inst returns the underlying metric instrument. |
| 11292 |
func (m StatefulSetPodUpdated) Inst() metric.Int64UpDownCounter { |
| 11293 |
return m.Int64UpDownCounter |
| 11294 |
} |
| 11295 |
|
| 11296 |
// Name returns the semantic convention name of the instrument. |
| 11297 |
func (StatefulSetPodUpdated) Name() string { |
| 11298 |
return "k8s.statefulset.pod.updated" |
| 11299 |
} |
| 11300 |
|
| 11301 |
// Unit returns the semantic convention unit of the instrument |
| 11302 |
func (StatefulSetPodUpdated) Unit() string { |
| 11303 |
return "{pod}" |
| 11304 |
} |
| 11305 |
|
| 11306 |
// Description returns the semantic convention description of the instrument |
| 11307 |
func (StatefulSetPodUpdated) Description() string { |
| 11308 |
return "Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision." |
| 11309 |
} |
| 11310 |
|
| 11311 |
// Add adds incr to the existing count for attrs. |
| 11312 |
// |
| 11313 |
// This metric aligns with the `updatedReplicas` field of the |
| 11314 |
// [K8s StatefulSetStatus]. |
| 11315 |
// |
| 11316 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 11317 |
func (m StatefulSetPodUpdated) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 11318 |
if len(attrs) == 0 { |
| 11319 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11320 |
return |
| 11321 |
} |
| 11322 |
|
| 11323 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11324 |
defer func() { |
| 11325 |
*o = (*o)[:0] |
| 11326 |
addOptPool.Put(o) |
| 11327 |
}() |
| 11328 |
|
| 11329 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 11330 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11331 |
} |
| 11332 |
|
| 11333 |
// AddSet adds incr to the existing count for set. |
| 11334 |
// |
| 11335 |
// This metric aligns with the `updatedReplicas` field of the |
| 11336 |
// [K8s StatefulSetStatus]. |
| 11337 |
// |
| 11338 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 11339 |
func (m StatefulSetPodUpdated) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 11340 |
if set.Len() == 0 { |
| 11341 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 11342 |
return |
| 11343 |
} |
| 11344 |
|
| 11345 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 11346 |
defer func() { |
| 11347 |
*o = (*o)[:0] |
| 11348 |
addOptPool.Put(o) |
| 11349 |
}() |
| 11350 |
|
| 11351 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 11352 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 11353 |
} |