| 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 |
// NetworkIODirectionAttr is an attribute conforming to the network.io.direction |
| 132 |
// semantic conventions. It represents the network IO operation direction. |
| 133 |
type NetworkIODirectionAttr string |
| 134 |
|
| 135 |
var ( |
| 136 |
// NetworkIODirectionTransmit is the standardized value "transmit" of |
| 137 |
// NetworkIODirectionAttr. |
| 138 |
NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit" |
| 139 |
// NetworkIODirectionReceive is the standardized value "receive" of |
| 140 |
// NetworkIODirectionAttr. |
| 141 |
NetworkIODirectionReceive NetworkIODirectionAttr = "receive" |
| 142 |
) |
| 143 |
|
| 144 |
// ContainerCPULimit is an instrument used to record metric values conforming to |
| 145 |
// the "k8s.container.cpu.limit" semantic conventions. It represents the maximum |
| 146 |
// CPU resource limit set for the container. |
| 147 |
type ContainerCPULimit struct { |
| 148 |
metric.Int64UpDownCounter |
| 149 |
} |
| 150 |
|
| 151 |
// NewContainerCPULimit returns a new ContainerCPULimit instrument. |
| 152 |
func NewContainerCPULimit( |
| 153 |
m metric.Meter, |
| 154 |
opt ...metric.Int64UpDownCounterOption, |
| 155 |
) (ContainerCPULimit, error) { |
| 156 |
// Check if the meter is nil. |
| 157 |
if m == nil { |
| 158 |
return ContainerCPULimit{noop.Int64UpDownCounter{}}, nil |
| 159 |
} |
| 160 |
|
| 161 |
i, err := m.Int64UpDownCounter( |
| 162 |
"k8s.container.cpu.limit", |
| 163 |
append([]metric.Int64UpDownCounterOption{ |
| 164 |
metric.WithDescription("Maximum CPU resource limit set for the container"), |
| 165 |
metric.WithUnit("{cpu}"), |
| 166 |
}, opt...)..., |
| 167 |
) |
| 168 |
if err != nil { |
| 169 |
return ContainerCPULimit{noop.Int64UpDownCounter{}}, err |
| 170 |
} |
| 171 |
return ContainerCPULimit{i}, nil |
| 172 |
} |
| 173 |
|
| 174 |
// Inst returns the underlying metric instrument. |
| 175 |
func (m ContainerCPULimit) Inst() metric.Int64UpDownCounter { |
| 176 |
return m.Int64UpDownCounter |
| 177 |
} |
| 178 |
|
| 179 |
// Name returns the semantic convention name of the instrument. |
| 180 |
func (ContainerCPULimit) Name() string { |
| 181 |
return "k8s.container.cpu.limit" |
| 182 |
} |
| 183 |
|
| 184 |
// Unit returns the semantic convention unit of the instrument |
| 185 |
func (ContainerCPULimit) Unit() string { |
| 186 |
return "{cpu}" |
| 187 |
} |
| 188 |
|
| 189 |
// Description returns the semantic convention description of the instrument |
| 190 |
func (ContainerCPULimit) Description() string { |
| 191 |
return "Maximum CPU resource limit set for the container" |
| 192 |
} |
| 193 |
|
| 194 |
// Add adds incr to the existing count for attrs. |
| 195 |
// |
| 196 |
// See |
| 197 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 198 |
// for details. |
| 199 |
func (m ContainerCPULimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 200 |
if len(attrs) == 0 { |
| 201 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 202 |
return |
| 203 |
} |
| 204 |
|
| 205 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 206 |
defer func() { |
| 207 |
*o = (*o)[:0] |
| 208 |
addOptPool.Put(o) |
| 209 |
}() |
| 210 |
|
| 211 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 212 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 213 |
} |
| 214 |
|
| 215 |
// AddSet adds incr to the existing count for set. |
| 216 |
// |
| 217 |
// See |
| 218 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 219 |
// for details. |
| 220 |
func (m ContainerCPULimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 221 |
if set.Len() == 0 { |
| 222 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 223 |
return |
| 224 |
} |
| 225 |
|
| 226 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 227 |
defer func() { |
| 228 |
*o = (*o)[:0] |
| 229 |
addOptPool.Put(o) |
| 230 |
}() |
| 231 |
|
| 232 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 233 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 234 |
} |
| 235 |
|
| 236 |
// ContainerCPURequest is an instrument used to record metric values conforming |
| 237 |
// to the "k8s.container.cpu.request" semantic conventions. It represents the CPU |
| 238 |
// resource requested for the container. |
| 239 |
type ContainerCPURequest struct { |
| 240 |
metric.Int64UpDownCounter |
| 241 |
} |
| 242 |
|
| 243 |
// NewContainerCPURequest returns a new ContainerCPURequest instrument. |
| 244 |
func NewContainerCPURequest( |
| 245 |
m metric.Meter, |
| 246 |
opt ...metric.Int64UpDownCounterOption, |
| 247 |
) (ContainerCPURequest, error) { |
| 248 |
// Check if the meter is nil. |
| 249 |
if m == nil { |
| 250 |
return ContainerCPURequest{noop.Int64UpDownCounter{}}, nil |
| 251 |
} |
| 252 |
|
| 253 |
i, err := m.Int64UpDownCounter( |
| 254 |
"k8s.container.cpu.request", |
| 255 |
append([]metric.Int64UpDownCounterOption{ |
| 256 |
metric.WithDescription("CPU resource requested for the container"), |
| 257 |
metric.WithUnit("{cpu}"), |
| 258 |
}, opt...)..., |
| 259 |
) |
| 260 |
if err != nil { |
| 261 |
return ContainerCPURequest{noop.Int64UpDownCounter{}}, err |
| 262 |
} |
| 263 |
return ContainerCPURequest{i}, nil |
| 264 |
} |
| 265 |
|
| 266 |
// Inst returns the underlying metric instrument. |
| 267 |
func (m ContainerCPURequest) Inst() metric.Int64UpDownCounter { |
| 268 |
return m.Int64UpDownCounter |
| 269 |
} |
| 270 |
|
| 271 |
// Name returns the semantic convention name of the instrument. |
| 272 |
func (ContainerCPURequest) Name() string { |
| 273 |
return "k8s.container.cpu.request" |
| 274 |
} |
| 275 |
|
| 276 |
// Unit returns the semantic convention unit of the instrument |
| 277 |
func (ContainerCPURequest) Unit() string { |
| 278 |
return "{cpu}" |
| 279 |
} |
| 280 |
|
| 281 |
// Description returns the semantic convention description of the instrument |
| 282 |
func (ContainerCPURequest) Description() string { |
| 283 |
return "CPU resource requested for the container" |
| 284 |
} |
| 285 |
|
| 286 |
// Add adds incr to the existing count for attrs. |
| 287 |
// |
| 288 |
// See |
| 289 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 290 |
// for details. |
| 291 |
func (m ContainerCPURequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 292 |
if len(attrs) == 0 { |
| 293 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 294 |
return |
| 295 |
} |
| 296 |
|
| 297 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 298 |
defer func() { |
| 299 |
*o = (*o)[:0] |
| 300 |
addOptPool.Put(o) |
| 301 |
}() |
| 302 |
|
| 303 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 304 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 305 |
} |
| 306 |
|
| 307 |
// AddSet adds incr to the existing count for set. |
| 308 |
// |
| 309 |
// See |
| 310 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 311 |
// for details. |
| 312 |
func (m ContainerCPURequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 313 |
if set.Len() == 0 { |
| 314 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 315 |
return |
| 316 |
} |
| 317 |
|
| 318 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 319 |
defer func() { |
| 320 |
*o = (*o)[:0] |
| 321 |
addOptPool.Put(o) |
| 322 |
}() |
| 323 |
|
| 324 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 325 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 326 |
} |
| 327 |
|
| 328 |
// ContainerEphemeralStorageLimit is an instrument used to record metric values |
| 329 |
// conforming to the "k8s.container.ephemeral_storage.limit" semantic |
| 330 |
// conventions. It represents the maximum ephemeral storage resource limit set |
| 331 |
// for the container. |
| 332 |
type ContainerEphemeralStorageLimit struct { |
| 333 |
metric.Int64UpDownCounter |
| 334 |
} |
| 335 |
|
| 336 |
// NewContainerEphemeralStorageLimit returns a new ContainerEphemeralStorageLimit |
| 337 |
// instrument. |
| 338 |
func NewContainerEphemeralStorageLimit( |
| 339 |
m metric.Meter, |
| 340 |
opt ...metric.Int64UpDownCounterOption, |
| 341 |
) (ContainerEphemeralStorageLimit, error) { |
| 342 |
// Check if the meter is nil. |
| 343 |
if m == nil { |
| 344 |
return ContainerEphemeralStorageLimit{noop.Int64UpDownCounter{}}, nil |
| 345 |
} |
| 346 |
|
| 347 |
i, err := m.Int64UpDownCounter( |
| 348 |
"k8s.container.ephemeral_storage.limit", |
| 349 |
append([]metric.Int64UpDownCounterOption{ |
| 350 |
metric.WithDescription("Maximum ephemeral storage resource limit set for the container"), |
| 351 |
metric.WithUnit("By"), |
| 352 |
}, opt...)..., |
| 353 |
) |
| 354 |
if err != nil { |
| 355 |
return ContainerEphemeralStorageLimit{noop.Int64UpDownCounter{}}, err |
| 356 |
} |
| 357 |
return ContainerEphemeralStorageLimit{i}, nil |
| 358 |
} |
| 359 |
|
| 360 |
// Inst returns the underlying metric instrument. |
| 361 |
func (m ContainerEphemeralStorageLimit) Inst() metric.Int64UpDownCounter { |
| 362 |
return m.Int64UpDownCounter |
| 363 |
} |
| 364 |
|
| 365 |
// Name returns the semantic convention name of the instrument. |
| 366 |
func (ContainerEphemeralStorageLimit) Name() string { |
| 367 |
return "k8s.container.ephemeral_storage.limit" |
| 368 |
} |
| 369 |
|
| 370 |
// Unit returns the semantic convention unit of the instrument |
| 371 |
func (ContainerEphemeralStorageLimit) Unit() string { |
| 372 |
return "By" |
| 373 |
} |
| 374 |
|
| 375 |
// Description returns the semantic convention description of the instrument |
| 376 |
func (ContainerEphemeralStorageLimit) Description() string { |
| 377 |
return "Maximum ephemeral storage resource limit set for the container" |
| 378 |
} |
| 379 |
|
| 380 |
// Add adds incr to the existing count for attrs. |
| 381 |
// |
| 382 |
// See |
| 383 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 384 |
// for details. |
| 385 |
func (m ContainerEphemeralStorageLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 386 |
if len(attrs) == 0 { |
| 387 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 388 |
return |
| 389 |
} |
| 390 |
|
| 391 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 392 |
defer func() { |
| 393 |
*o = (*o)[:0] |
| 394 |
addOptPool.Put(o) |
| 395 |
}() |
| 396 |
|
| 397 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 398 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 399 |
} |
| 400 |
|
| 401 |
// AddSet adds incr to the existing count for set. |
| 402 |
// |
| 403 |
// See |
| 404 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 405 |
// for details. |
| 406 |
func (m ContainerEphemeralStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 407 |
if set.Len() == 0 { |
| 408 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 409 |
return |
| 410 |
} |
| 411 |
|
| 412 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 413 |
defer func() { |
| 414 |
*o = (*o)[:0] |
| 415 |
addOptPool.Put(o) |
| 416 |
}() |
| 417 |
|
| 418 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 419 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 420 |
} |
| 421 |
|
| 422 |
// ContainerEphemeralStorageRequest is an instrument used to record metric values |
| 423 |
// conforming to the "k8s.container.ephemeral_storage.request" semantic |
| 424 |
// conventions. It represents the ephemeral storage resource requested for the |
| 425 |
// container. |
| 426 |
type ContainerEphemeralStorageRequest struct { |
| 427 |
metric.Int64UpDownCounter |
| 428 |
} |
| 429 |
|
| 430 |
// NewContainerEphemeralStorageRequest returns a new |
| 431 |
// ContainerEphemeralStorageRequest instrument. |
| 432 |
func NewContainerEphemeralStorageRequest( |
| 433 |
m metric.Meter, |
| 434 |
opt ...metric.Int64UpDownCounterOption, |
| 435 |
) (ContainerEphemeralStorageRequest, error) { |
| 436 |
// Check if the meter is nil. |
| 437 |
if m == nil { |
| 438 |
return ContainerEphemeralStorageRequest{noop.Int64UpDownCounter{}}, nil |
| 439 |
} |
| 440 |
|
| 441 |
i, err := m.Int64UpDownCounter( |
| 442 |
"k8s.container.ephemeral_storage.request", |
| 443 |
append([]metric.Int64UpDownCounterOption{ |
| 444 |
metric.WithDescription("Ephemeral storage resource requested for the container"), |
| 445 |
metric.WithUnit("By"), |
| 446 |
}, opt...)..., |
| 447 |
) |
| 448 |
if err != nil { |
| 449 |
return ContainerEphemeralStorageRequest{noop.Int64UpDownCounter{}}, err |
| 450 |
} |
| 451 |
return ContainerEphemeralStorageRequest{i}, nil |
| 452 |
} |
| 453 |
|
| 454 |
// Inst returns the underlying metric instrument. |
| 455 |
func (m ContainerEphemeralStorageRequest) Inst() metric.Int64UpDownCounter { |
| 456 |
return m.Int64UpDownCounter |
| 457 |
} |
| 458 |
|
| 459 |
// Name returns the semantic convention name of the instrument. |
| 460 |
func (ContainerEphemeralStorageRequest) Name() string { |
| 461 |
return "k8s.container.ephemeral_storage.request" |
| 462 |
} |
| 463 |
|
| 464 |
// Unit returns the semantic convention unit of the instrument |
| 465 |
func (ContainerEphemeralStorageRequest) Unit() string { |
| 466 |
return "By" |
| 467 |
} |
| 468 |
|
| 469 |
// Description returns the semantic convention description of the instrument |
| 470 |
func (ContainerEphemeralStorageRequest) Description() string { |
| 471 |
return "Ephemeral storage resource requested for the container" |
| 472 |
} |
| 473 |
|
| 474 |
// Add adds incr to the existing count for attrs. |
| 475 |
// |
| 476 |
// See |
| 477 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 478 |
// for details. |
| 479 |
func (m ContainerEphemeralStorageRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 480 |
if len(attrs) == 0 { |
| 481 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 482 |
return |
| 483 |
} |
| 484 |
|
| 485 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 486 |
defer func() { |
| 487 |
*o = (*o)[:0] |
| 488 |
addOptPool.Put(o) |
| 489 |
}() |
| 490 |
|
| 491 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 492 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 493 |
} |
| 494 |
|
| 495 |
// AddSet adds incr to the existing count for set. |
| 496 |
// |
| 497 |
// See |
| 498 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 499 |
// for details. |
| 500 |
func (m ContainerEphemeralStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 501 |
if set.Len() == 0 { |
| 502 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 503 |
return |
| 504 |
} |
| 505 |
|
| 506 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 507 |
defer func() { |
| 508 |
*o = (*o)[:0] |
| 509 |
addOptPool.Put(o) |
| 510 |
}() |
| 511 |
|
| 512 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 513 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 514 |
} |
| 515 |
|
| 516 |
// ContainerMemoryLimit is an instrument used to record metric values conforming |
| 517 |
// to the "k8s.container.memory.limit" semantic conventions. It represents the |
| 518 |
// maximum memory resource limit set for the container. |
| 519 |
type ContainerMemoryLimit struct { |
| 520 |
metric.Int64UpDownCounter |
| 521 |
} |
| 522 |
|
| 523 |
// NewContainerMemoryLimit returns a new ContainerMemoryLimit instrument. |
| 524 |
func NewContainerMemoryLimit( |
| 525 |
m metric.Meter, |
| 526 |
opt ...metric.Int64UpDownCounterOption, |
| 527 |
) (ContainerMemoryLimit, error) { |
| 528 |
// Check if the meter is nil. |
| 529 |
if m == nil { |
| 530 |
return ContainerMemoryLimit{noop.Int64UpDownCounter{}}, nil |
| 531 |
} |
| 532 |
|
| 533 |
i, err := m.Int64UpDownCounter( |
| 534 |
"k8s.container.memory.limit", |
| 535 |
append([]metric.Int64UpDownCounterOption{ |
| 536 |
metric.WithDescription("Maximum memory resource limit set for the container"), |
| 537 |
metric.WithUnit("By"), |
| 538 |
}, opt...)..., |
| 539 |
) |
| 540 |
if err != nil { |
| 541 |
return ContainerMemoryLimit{noop.Int64UpDownCounter{}}, err |
| 542 |
} |
| 543 |
return ContainerMemoryLimit{i}, nil |
| 544 |
} |
| 545 |
|
| 546 |
// Inst returns the underlying metric instrument. |
| 547 |
func (m ContainerMemoryLimit) Inst() metric.Int64UpDownCounter { |
| 548 |
return m.Int64UpDownCounter |
| 549 |
} |
| 550 |
|
| 551 |
// Name returns the semantic convention name of the instrument. |
| 552 |
func (ContainerMemoryLimit) Name() string { |
| 553 |
return "k8s.container.memory.limit" |
| 554 |
} |
| 555 |
|
| 556 |
// Unit returns the semantic convention unit of the instrument |
| 557 |
func (ContainerMemoryLimit) Unit() string { |
| 558 |
return "By" |
| 559 |
} |
| 560 |
|
| 561 |
// Description returns the semantic convention description of the instrument |
| 562 |
func (ContainerMemoryLimit) Description() string { |
| 563 |
return "Maximum memory resource limit set for the container" |
| 564 |
} |
| 565 |
|
| 566 |
// Add adds incr to the existing count for attrs. |
| 567 |
// |
| 568 |
// See |
| 569 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 570 |
// for details. |
| 571 |
func (m ContainerMemoryLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 572 |
if len(attrs) == 0 { |
| 573 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 574 |
return |
| 575 |
} |
| 576 |
|
| 577 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 578 |
defer func() { |
| 579 |
*o = (*o)[:0] |
| 580 |
addOptPool.Put(o) |
| 581 |
}() |
| 582 |
|
| 583 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 584 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 585 |
} |
| 586 |
|
| 587 |
// AddSet adds incr to the existing count for set. |
| 588 |
// |
| 589 |
// See |
| 590 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 591 |
// for details. |
| 592 |
func (m ContainerMemoryLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 593 |
if set.Len() == 0 { |
| 594 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 595 |
return |
| 596 |
} |
| 597 |
|
| 598 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 599 |
defer func() { |
| 600 |
*o = (*o)[:0] |
| 601 |
addOptPool.Put(o) |
| 602 |
}() |
| 603 |
|
| 604 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 605 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 606 |
} |
| 607 |
|
| 608 |
// ContainerMemoryRequest is an instrument used to record metric values |
| 609 |
// conforming to the "k8s.container.memory.request" semantic conventions. It |
| 610 |
// represents the memory resource requested for the container. |
| 611 |
type ContainerMemoryRequest struct { |
| 612 |
metric.Int64UpDownCounter |
| 613 |
} |
| 614 |
|
| 615 |
// NewContainerMemoryRequest returns a new ContainerMemoryRequest instrument. |
| 616 |
func NewContainerMemoryRequest( |
| 617 |
m metric.Meter, |
| 618 |
opt ...metric.Int64UpDownCounterOption, |
| 619 |
) (ContainerMemoryRequest, error) { |
| 620 |
// Check if the meter is nil. |
| 621 |
if m == nil { |
| 622 |
return ContainerMemoryRequest{noop.Int64UpDownCounter{}}, nil |
| 623 |
} |
| 624 |
|
| 625 |
i, err := m.Int64UpDownCounter( |
| 626 |
"k8s.container.memory.request", |
| 627 |
append([]metric.Int64UpDownCounterOption{ |
| 628 |
metric.WithDescription("Memory resource requested for the container"), |
| 629 |
metric.WithUnit("By"), |
| 630 |
}, opt...)..., |
| 631 |
) |
| 632 |
if err != nil { |
| 633 |
return ContainerMemoryRequest{noop.Int64UpDownCounter{}}, err |
| 634 |
} |
| 635 |
return ContainerMemoryRequest{i}, nil |
| 636 |
} |
| 637 |
|
| 638 |
// Inst returns the underlying metric instrument. |
| 639 |
func (m ContainerMemoryRequest) Inst() metric.Int64UpDownCounter { |
| 640 |
return m.Int64UpDownCounter |
| 641 |
} |
| 642 |
|
| 643 |
// Name returns the semantic convention name of the instrument. |
| 644 |
func (ContainerMemoryRequest) Name() string { |
| 645 |
return "k8s.container.memory.request" |
| 646 |
} |
| 647 |
|
| 648 |
// Unit returns the semantic convention unit of the instrument |
| 649 |
func (ContainerMemoryRequest) Unit() string { |
| 650 |
return "By" |
| 651 |
} |
| 652 |
|
| 653 |
// Description returns the semantic convention description of the instrument |
| 654 |
func (ContainerMemoryRequest) Description() string { |
| 655 |
return "Memory resource requested for the container" |
| 656 |
} |
| 657 |
|
| 658 |
// Add adds incr to the existing count for attrs. |
| 659 |
// |
| 660 |
// See |
| 661 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 662 |
// for details. |
| 663 |
func (m ContainerMemoryRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 664 |
if len(attrs) == 0 { |
| 665 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 666 |
return |
| 667 |
} |
| 668 |
|
| 669 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 670 |
defer func() { |
| 671 |
*o = (*o)[:0] |
| 672 |
addOptPool.Put(o) |
| 673 |
}() |
| 674 |
|
| 675 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 676 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 677 |
} |
| 678 |
|
| 679 |
// AddSet adds incr to the existing count for set. |
| 680 |
// |
| 681 |
// See |
| 682 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 683 |
// for details. |
| 684 |
func (m ContainerMemoryRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 685 |
if set.Len() == 0 { |
| 686 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 687 |
return |
| 688 |
} |
| 689 |
|
| 690 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 691 |
defer func() { |
| 692 |
*o = (*o)[:0] |
| 693 |
addOptPool.Put(o) |
| 694 |
}() |
| 695 |
|
| 696 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 697 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 698 |
} |
| 699 |
|
| 700 |
// ContainerReady is an instrument used to record metric values conforming to the |
| 701 |
// "k8s.container.ready" semantic conventions. It represents the indicates |
| 702 |
// whether the container is currently marked as ready to accept traffic, based on |
| 703 |
// its readiness probe (1 = ready, 0 = not ready). |
| 704 |
type ContainerReady struct { |
| 705 |
metric.Int64UpDownCounter |
| 706 |
} |
| 707 |
|
| 708 |
// NewContainerReady returns a new ContainerReady instrument. |
| 709 |
func NewContainerReady( |
| 710 |
m metric.Meter, |
| 711 |
opt ...metric.Int64UpDownCounterOption, |
| 712 |
) (ContainerReady, error) { |
| 713 |
// Check if the meter is nil. |
| 714 |
if m == nil { |
| 715 |
return ContainerReady{noop.Int64UpDownCounter{}}, nil |
| 716 |
} |
| 717 |
|
| 718 |
i, err := m.Int64UpDownCounter( |
| 719 |
"k8s.container.ready", |
| 720 |
append([]metric.Int64UpDownCounterOption{ |
| 721 |
metric.WithDescription("Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready)"), |
| 722 |
metric.WithUnit("{container}"), |
| 723 |
}, opt...)..., |
| 724 |
) |
| 725 |
if err != nil { |
| 726 |
return ContainerReady{noop.Int64UpDownCounter{}}, err |
| 727 |
} |
| 728 |
return ContainerReady{i}, nil |
| 729 |
} |
| 730 |
|
| 731 |
// Inst returns the underlying metric instrument. |
| 732 |
func (m ContainerReady) Inst() metric.Int64UpDownCounter { |
| 733 |
return m.Int64UpDownCounter |
| 734 |
} |
| 735 |
|
| 736 |
// Name returns the semantic convention name of the instrument. |
| 737 |
func (ContainerReady) Name() string { |
| 738 |
return "k8s.container.ready" |
| 739 |
} |
| 740 |
|
| 741 |
// Unit returns the semantic convention unit of the instrument |
| 742 |
func (ContainerReady) Unit() string { |
| 743 |
return "{container}" |
| 744 |
} |
| 745 |
|
| 746 |
// Description returns the semantic convention description of the instrument |
| 747 |
func (ContainerReady) Description() string { |
| 748 |
return "Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready)" |
| 749 |
} |
| 750 |
|
| 751 |
// Add adds incr to the existing count for attrs. |
| 752 |
// |
| 753 |
// This metric SHOULD reflect the value of the `ready` field in the |
| 754 |
// [K8s ContainerStatus]. |
| 755 |
// |
| 756 |
// [K8s ContainerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core |
| 757 |
func (m ContainerReady) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 758 |
if len(attrs) == 0 { |
| 759 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 760 |
return |
| 761 |
} |
| 762 |
|
| 763 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 764 |
defer func() { |
| 765 |
*o = (*o)[:0] |
| 766 |
addOptPool.Put(o) |
| 767 |
}() |
| 768 |
|
| 769 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 770 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 771 |
} |
| 772 |
|
| 773 |
// AddSet adds incr to the existing count for set. |
| 774 |
// |
| 775 |
// This metric SHOULD reflect the value of the `ready` field in the |
| 776 |
// [K8s ContainerStatus]. |
| 777 |
// |
| 778 |
// [K8s ContainerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core |
| 779 |
func (m ContainerReady) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 780 |
if set.Len() == 0 { |
| 781 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 782 |
return |
| 783 |
} |
| 784 |
|
| 785 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 786 |
defer func() { |
| 787 |
*o = (*o)[:0] |
| 788 |
addOptPool.Put(o) |
| 789 |
}() |
| 790 |
|
| 791 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 792 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 793 |
} |
| 794 |
|
| 795 |
// ContainerRestartCount is an instrument used to record metric values conforming |
| 796 |
// to the "k8s.container.restart.count" semantic conventions. It represents the |
| 797 |
// describes how many times the container has restarted (since the last counter |
| 798 |
// reset). |
| 799 |
type ContainerRestartCount struct { |
| 800 |
metric.Int64UpDownCounter |
| 801 |
} |
| 802 |
|
| 803 |
// NewContainerRestartCount returns a new ContainerRestartCount instrument. |
| 804 |
func NewContainerRestartCount( |
| 805 |
m metric.Meter, |
| 806 |
opt ...metric.Int64UpDownCounterOption, |
| 807 |
) (ContainerRestartCount, error) { |
| 808 |
// Check if the meter is nil. |
| 809 |
if m == nil { |
| 810 |
return ContainerRestartCount{noop.Int64UpDownCounter{}}, nil |
| 811 |
} |
| 812 |
|
| 813 |
i, err := m.Int64UpDownCounter( |
| 814 |
"k8s.container.restart.count", |
| 815 |
append([]metric.Int64UpDownCounterOption{ |
| 816 |
metric.WithDescription("Describes how many times the container has restarted (since the last counter reset)"), |
| 817 |
metric.WithUnit("{restart}"), |
| 818 |
}, opt...)..., |
| 819 |
) |
| 820 |
if err != nil { |
| 821 |
return ContainerRestartCount{noop.Int64UpDownCounter{}}, err |
| 822 |
} |
| 823 |
return ContainerRestartCount{i}, nil |
| 824 |
} |
| 825 |
|
| 826 |
// Inst returns the underlying metric instrument. |
| 827 |
func (m ContainerRestartCount) Inst() metric.Int64UpDownCounter { |
| 828 |
return m.Int64UpDownCounter |
| 829 |
} |
| 830 |
|
| 831 |
// Name returns the semantic convention name of the instrument. |
| 832 |
func (ContainerRestartCount) Name() string { |
| 833 |
return "k8s.container.restart.count" |
| 834 |
} |
| 835 |
|
| 836 |
// Unit returns the semantic convention unit of the instrument |
| 837 |
func (ContainerRestartCount) Unit() string { |
| 838 |
return "{restart}" |
| 839 |
} |
| 840 |
|
| 841 |
// Description returns the semantic convention description of the instrument |
| 842 |
func (ContainerRestartCount) Description() string { |
| 843 |
return "Describes how many times the container has restarted (since the last counter reset)" |
| 844 |
} |
| 845 |
|
| 846 |
// Add adds incr to the existing count for attrs. |
| 847 |
// |
| 848 |
// This value is pulled directly from the K8s API and the value can go |
| 849 |
// indefinitely high and be reset to 0 |
| 850 |
// at any time depending on how your kubelet is configured to prune dead |
| 851 |
// containers. |
| 852 |
// It is best to not depend too much on the exact value but rather look at it as |
| 853 |
// either == 0, in which case you can conclude there were no restarts in the |
| 854 |
// recent past, or > 0, in which case |
| 855 |
// you can conclude there were restarts in the recent past, and not try and |
| 856 |
// analyze the value beyond that. |
| 857 |
func (m ContainerRestartCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 858 |
if len(attrs) == 0 { |
| 859 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 860 |
return |
| 861 |
} |
| 862 |
|
| 863 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 864 |
defer func() { |
| 865 |
*o = (*o)[:0] |
| 866 |
addOptPool.Put(o) |
| 867 |
}() |
| 868 |
|
| 869 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 870 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 871 |
} |
| 872 |
|
| 873 |
// AddSet adds incr to the existing count for set. |
| 874 |
// |
| 875 |
// This value is pulled directly from the K8s API and the value can go |
| 876 |
// indefinitely high and be reset to 0 |
| 877 |
// at any time depending on how your kubelet is configured to prune dead |
| 878 |
// containers. |
| 879 |
// It is best to not depend too much on the exact value but rather look at it as |
| 880 |
// either == 0, in which case you can conclude there were no restarts in the |
| 881 |
// recent past, or > 0, in which case |
| 882 |
// you can conclude there were restarts in the recent past, and not try and |
| 883 |
// analyze the value beyond that. |
| 884 |
func (m ContainerRestartCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 885 |
if set.Len() == 0 { |
| 886 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 887 |
return |
| 888 |
} |
| 889 |
|
| 890 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 891 |
defer func() { |
| 892 |
*o = (*o)[:0] |
| 893 |
addOptPool.Put(o) |
| 894 |
}() |
| 895 |
|
| 896 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 897 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 898 |
} |
| 899 |
|
| 900 |
// ContainerStatusReason is an instrument used to record metric values conforming |
| 901 |
// to the "k8s.container.status.reason" semantic conventions. It represents the |
| 902 |
// describes the number of K8s containers that are currently in a state for a |
| 903 |
// given reason. |
| 904 |
type ContainerStatusReason struct { |
| 905 |
metric.Int64UpDownCounter |
| 906 |
} |
| 907 |
|
| 908 |
// NewContainerStatusReason returns a new ContainerStatusReason instrument. |
| 909 |
func NewContainerStatusReason( |
| 910 |
m metric.Meter, |
| 911 |
opt ...metric.Int64UpDownCounterOption, |
| 912 |
) (ContainerStatusReason, error) { |
| 913 |
// Check if the meter is nil. |
| 914 |
if m == nil { |
| 915 |
return ContainerStatusReason{noop.Int64UpDownCounter{}}, nil |
| 916 |
} |
| 917 |
|
| 918 |
i, err := m.Int64UpDownCounter( |
| 919 |
"k8s.container.status.reason", |
| 920 |
append([]metric.Int64UpDownCounterOption{ |
| 921 |
metric.WithDescription("Describes the number of K8s containers that are currently in a state for a given reason"), |
| 922 |
metric.WithUnit("{container}"), |
| 923 |
}, opt...)..., |
| 924 |
) |
| 925 |
if err != nil { |
| 926 |
return ContainerStatusReason{noop.Int64UpDownCounter{}}, err |
| 927 |
} |
| 928 |
return ContainerStatusReason{i}, nil |
| 929 |
} |
| 930 |
|
| 931 |
// Inst returns the underlying metric instrument. |
| 932 |
func (m ContainerStatusReason) Inst() metric.Int64UpDownCounter { |
| 933 |
return m.Int64UpDownCounter |
| 934 |
} |
| 935 |
|
| 936 |
// Name returns the semantic convention name of the instrument. |
| 937 |
func (ContainerStatusReason) Name() string { |
| 938 |
return "k8s.container.status.reason" |
| 939 |
} |
| 940 |
|
| 941 |
// Unit returns the semantic convention unit of the instrument |
| 942 |
func (ContainerStatusReason) Unit() string { |
| 943 |
return "{container}" |
| 944 |
} |
| 945 |
|
| 946 |
// Description returns the semantic convention description of the instrument |
| 947 |
func (ContainerStatusReason) Description() string { |
| 948 |
return "Describes the number of K8s containers that are currently in a state for a given reason" |
| 949 |
} |
| 950 |
|
| 951 |
// Add adds incr to the existing count for attrs. |
| 952 |
// |
| 953 |
// The containerStatusReason is the the reason for the container state. |
| 954 |
// Corresponds to the `reason` field of the: [K8s ContainerStateWaiting] or |
| 955 |
// [K8s ContainerStateTerminated] |
| 956 |
// |
| 957 |
// [K8s ContainerStateWaiting]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatewaiting-v1-core |
| 958 |
// [K8s ContainerStateTerminated]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstateterminated-v1-core |
| 959 |
// |
| 960 |
// All possible container state reasons will be reported at each time interval to |
| 961 |
// avoid missing metrics. |
| 962 |
// Only the value corresponding to the current state reason will be non-zero. |
| 963 |
func (m ContainerStatusReason) Add( |
| 964 |
ctx context.Context, |
| 965 |
incr int64, |
| 966 |
containerStatusReason ContainerStatusReasonAttr, |
| 967 |
attrs ...attribute.KeyValue, |
| 968 |
) { |
| 969 |
if len(attrs) == 0 { |
| 970 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 971 |
return |
| 972 |
} |
| 973 |
|
| 974 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 975 |
defer func() { |
| 976 |
*o = (*o)[:0] |
| 977 |
addOptPool.Put(o) |
| 978 |
}() |
| 979 |
|
| 980 |
*o = append( |
| 981 |
*o, |
| 982 |
metric.WithAttributes( |
| 983 |
append( |
| 984 |
attrs, |
| 985 |
attribute.String("k8s.container.status.reason", string(containerStatusReason)), |
| 986 |
)..., |
| 987 |
), |
| 988 |
) |
| 989 |
|
| 990 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 991 |
} |
| 992 |
|
| 993 |
// AddSet adds incr to the existing count for set. |
| 994 |
// |
| 995 |
// All possible container state reasons will be reported at each time interval to |
| 996 |
// avoid missing metrics. |
| 997 |
// Only the value corresponding to the current state reason will be non-zero. |
| 998 |
func (m ContainerStatusReason) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 999 |
if set.Len() == 0 { |
| 1000 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1001 |
return |
| 1002 |
} |
| 1003 |
|
| 1004 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1005 |
defer func() { |
| 1006 |
*o = (*o)[:0] |
| 1007 |
addOptPool.Put(o) |
| 1008 |
}() |
| 1009 |
|
| 1010 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1011 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1012 |
} |
| 1013 |
|
| 1014 |
// ContainerStatusState is an instrument used to record metric values conforming |
| 1015 |
// to the "k8s.container.status.state" semantic conventions. It represents the |
| 1016 |
// describes the number of K8s containers that are currently in a given state. |
| 1017 |
type ContainerStatusState struct { |
| 1018 |
metric.Int64UpDownCounter |
| 1019 |
} |
| 1020 |
|
| 1021 |
// NewContainerStatusState returns a new ContainerStatusState instrument. |
| 1022 |
func NewContainerStatusState( |
| 1023 |
m metric.Meter, |
| 1024 |
opt ...metric.Int64UpDownCounterOption, |
| 1025 |
) (ContainerStatusState, error) { |
| 1026 |
// Check if the meter is nil. |
| 1027 |
if m == nil { |
| 1028 |
return ContainerStatusState{noop.Int64UpDownCounter{}}, nil |
| 1029 |
} |
| 1030 |
|
| 1031 |
i, err := m.Int64UpDownCounter( |
| 1032 |
"k8s.container.status.state", |
| 1033 |
append([]metric.Int64UpDownCounterOption{ |
| 1034 |
metric.WithDescription("Describes the number of K8s containers that are currently in a given state"), |
| 1035 |
metric.WithUnit("{container}"), |
| 1036 |
}, opt...)..., |
| 1037 |
) |
| 1038 |
if err != nil { |
| 1039 |
return ContainerStatusState{noop.Int64UpDownCounter{}}, err |
| 1040 |
} |
| 1041 |
return ContainerStatusState{i}, nil |
| 1042 |
} |
| 1043 |
|
| 1044 |
// Inst returns the underlying metric instrument. |
| 1045 |
func (m ContainerStatusState) Inst() metric.Int64UpDownCounter { |
| 1046 |
return m.Int64UpDownCounter |
| 1047 |
} |
| 1048 |
|
| 1049 |
// Name returns the semantic convention name of the instrument. |
| 1050 |
func (ContainerStatusState) Name() string { |
| 1051 |
return "k8s.container.status.state" |
| 1052 |
} |
| 1053 |
|
| 1054 |
// Unit returns the semantic convention unit of the instrument |
| 1055 |
func (ContainerStatusState) Unit() string { |
| 1056 |
return "{container}" |
| 1057 |
} |
| 1058 |
|
| 1059 |
// Description returns the semantic convention description of the instrument |
| 1060 |
func (ContainerStatusState) Description() string { |
| 1061 |
return "Describes the number of K8s containers that are currently in a given state" |
| 1062 |
} |
| 1063 |
|
| 1064 |
// Add adds incr to the existing count for attrs. |
| 1065 |
// |
| 1066 |
// The containerStatusState is the the state of the container. |
| 1067 |
// [K8s ContainerState] |
| 1068 |
// |
| 1069 |
// [K8s ContainerState]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstate-v1-core |
| 1070 |
// |
| 1071 |
// All possible container states will be reported at each time interval to avoid |
| 1072 |
// missing metrics. |
| 1073 |
// Only the value corresponding to the current state will be non-zero. |
| 1074 |
func (m ContainerStatusState) Add( |
| 1075 |
ctx context.Context, |
| 1076 |
incr int64, |
| 1077 |
containerStatusState ContainerStatusStateAttr, |
| 1078 |
attrs ...attribute.KeyValue, |
| 1079 |
) { |
| 1080 |
if len(attrs) == 0 { |
| 1081 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1082 |
return |
| 1083 |
} |
| 1084 |
|
| 1085 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1086 |
defer func() { |
| 1087 |
*o = (*o)[:0] |
| 1088 |
addOptPool.Put(o) |
| 1089 |
}() |
| 1090 |
|
| 1091 |
*o = append( |
| 1092 |
*o, |
| 1093 |
metric.WithAttributes( |
| 1094 |
append( |
| 1095 |
attrs, |
| 1096 |
attribute.String("k8s.container.status.state", string(containerStatusState)), |
| 1097 |
)..., |
| 1098 |
), |
| 1099 |
) |
| 1100 |
|
| 1101 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1102 |
} |
| 1103 |
|
| 1104 |
// AddSet adds incr to the existing count for set. |
| 1105 |
// |
| 1106 |
// All possible container states will be reported at each time interval to avoid |
| 1107 |
// missing metrics. |
| 1108 |
// Only the value corresponding to the current state will be non-zero. |
| 1109 |
func (m ContainerStatusState) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1110 |
if set.Len() == 0 { |
| 1111 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1112 |
return |
| 1113 |
} |
| 1114 |
|
| 1115 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1116 |
defer func() { |
| 1117 |
*o = (*o)[:0] |
| 1118 |
addOptPool.Put(o) |
| 1119 |
}() |
| 1120 |
|
| 1121 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1122 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1123 |
} |
| 1124 |
|
| 1125 |
// ContainerStorageLimit is an instrument used to record metric values conforming |
| 1126 |
// to the "k8s.container.storage.limit" semantic conventions. It represents the |
| 1127 |
// maximum storage resource limit set for the container. |
| 1128 |
type ContainerStorageLimit struct { |
| 1129 |
metric.Int64UpDownCounter |
| 1130 |
} |
| 1131 |
|
| 1132 |
// NewContainerStorageLimit returns a new ContainerStorageLimit instrument. |
| 1133 |
func NewContainerStorageLimit( |
| 1134 |
m metric.Meter, |
| 1135 |
opt ...metric.Int64UpDownCounterOption, |
| 1136 |
) (ContainerStorageLimit, error) { |
| 1137 |
// Check if the meter is nil. |
| 1138 |
if m == nil { |
| 1139 |
return ContainerStorageLimit{noop.Int64UpDownCounter{}}, nil |
| 1140 |
} |
| 1141 |
|
| 1142 |
i, err := m.Int64UpDownCounter( |
| 1143 |
"k8s.container.storage.limit", |
| 1144 |
append([]metric.Int64UpDownCounterOption{ |
| 1145 |
metric.WithDescription("Maximum storage resource limit set for the container"), |
| 1146 |
metric.WithUnit("By"), |
| 1147 |
}, opt...)..., |
| 1148 |
) |
| 1149 |
if err != nil { |
| 1150 |
return ContainerStorageLimit{noop.Int64UpDownCounter{}}, err |
| 1151 |
} |
| 1152 |
return ContainerStorageLimit{i}, nil |
| 1153 |
} |
| 1154 |
|
| 1155 |
// Inst returns the underlying metric instrument. |
| 1156 |
func (m ContainerStorageLimit) Inst() metric.Int64UpDownCounter { |
| 1157 |
return m.Int64UpDownCounter |
| 1158 |
} |
| 1159 |
|
| 1160 |
// Name returns the semantic convention name of the instrument. |
| 1161 |
func (ContainerStorageLimit) Name() string { |
| 1162 |
return "k8s.container.storage.limit" |
| 1163 |
} |
| 1164 |
|
| 1165 |
// Unit returns the semantic convention unit of the instrument |
| 1166 |
func (ContainerStorageLimit) Unit() string { |
| 1167 |
return "By" |
| 1168 |
} |
| 1169 |
|
| 1170 |
// Description returns the semantic convention description of the instrument |
| 1171 |
func (ContainerStorageLimit) Description() string { |
| 1172 |
return "Maximum storage resource limit set for the container" |
| 1173 |
} |
| 1174 |
|
| 1175 |
// Add adds incr to the existing count for attrs. |
| 1176 |
// |
| 1177 |
// See |
| 1178 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1179 |
// for details. |
| 1180 |
func (m ContainerStorageLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1181 |
if len(attrs) == 0 { |
| 1182 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1183 |
return |
| 1184 |
} |
| 1185 |
|
| 1186 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1187 |
defer func() { |
| 1188 |
*o = (*o)[:0] |
| 1189 |
addOptPool.Put(o) |
| 1190 |
}() |
| 1191 |
|
| 1192 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1193 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1194 |
} |
| 1195 |
|
| 1196 |
// AddSet adds incr to the existing count for set. |
| 1197 |
// |
| 1198 |
// See |
| 1199 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1200 |
// for details. |
| 1201 |
func (m ContainerStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1202 |
if set.Len() == 0 { |
| 1203 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1204 |
return |
| 1205 |
} |
| 1206 |
|
| 1207 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1208 |
defer func() { |
| 1209 |
*o = (*o)[:0] |
| 1210 |
addOptPool.Put(o) |
| 1211 |
}() |
| 1212 |
|
| 1213 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1214 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1215 |
} |
| 1216 |
|
| 1217 |
// ContainerStorageRequest is an instrument used to record metric values |
| 1218 |
// conforming to the "k8s.container.storage.request" semantic conventions. It |
| 1219 |
// represents the storage resource requested for the container. |
| 1220 |
type ContainerStorageRequest struct { |
| 1221 |
metric.Int64UpDownCounter |
| 1222 |
} |
| 1223 |
|
| 1224 |
// NewContainerStorageRequest returns a new ContainerStorageRequest instrument. |
| 1225 |
func NewContainerStorageRequest( |
| 1226 |
m metric.Meter, |
| 1227 |
opt ...metric.Int64UpDownCounterOption, |
| 1228 |
) (ContainerStorageRequest, error) { |
| 1229 |
// Check if the meter is nil. |
| 1230 |
if m == nil { |
| 1231 |
return ContainerStorageRequest{noop.Int64UpDownCounter{}}, nil |
| 1232 |
} |
| 1233 |
|
| 1234 |
i, err := m.Int64UpDownCounter( |
| 1235 |
"k8s.container.storage.request", |
| 1236 |
append([]metric.Int64UpDownCounterOption{ |
| 1237 |
metric.WithDescription("Storage resource requested for the container"), |
| 1238 |
metric.WithUnit("By"), |
| 1239 |
}, opt...)..., |
| 1240 |
) |
| 1241 |
if err != nil { |
| 1242 |
return ContainerStorageRequest{noop.Int64UpDownCounter{}}, err |
| 1243 |
} |
| 1244 |
return ContainerStorageRequest{i}, nil |
| 1245 |
} |
| 1246 |
|
| 1247 |
// Inst returns the underlying metric instrument. |
| 1248 |
func (m ContainerStorageRequest) Inst() metric.Int64UpDownCounter { |
| 1249 |
return m.Int64UpDownCounter |
| 1250 |
} |
| 1251 |
|
| 1252 |
// Name returns the semantic convention name of the instrument. |
| 1253 |
func (ContainerStorageRequest) Name() string { |
| 1254 |
return "k8s.container.storage.request" |
| 1255 |
} |
| 1256 |
|
| 1257 |
// Unit returns the semantic convention unit of the instrument |
| 1258 |
func (ContainerStorageRequest) Unit() string { |
| 1259 |
return "By" |
| 1260 |
} |
| 1261 |
|
| 1262 |
// Description returns the semantic convention description of the instrument |
| 1263 |
func (ContainerStorageRequest) Description() string { |
| 1264 |
return "Storage resource requested for the container" |
| 1265 |
} |
| 1266 |
|
| 1267 |
// Add adds incr to the existing count for attrs. |
| 1268 |
// |
| 1269 |
// See |
| 1270 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1271 |
// for details. |
| 1272 |
func (m ContainerStorageRequest) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1273 |
if len(attrs) == 0 { |
| 1274 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1275 |
return |
| 1276 |
} |
| 1277 |
|
| 1278 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1279 |
defer func() { |
| 1280 |
*o = (*o)[:0] |
| 1281 |
addOptPool.Put(o) |
| 1282 |
}() |
| 1283 |
|
| 1284 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1285 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1286 |
} |
| 1287 |
|
| 1288 |
// AddSet adds incr to the existing count for set. |
| 1289 |
// |
| 1290 |
// See |
| 1291 |
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core |
| 1292 |
// for details. |
| 1293 |
func (m ContainerStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1294 |
if set.Len() == 0 { |
| 1295 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1296 |
return |
| 1297 |
} |
| 1298 |
|
| 1299 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1300 |
defer func() { |
| 1301 |
*o = (*o)[:0] |
| 1302 |
addOptPool.Put(o) |
| 1303 |
}() |
| 1304 |
|
| 1305 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1306 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1307 |
} |
| 1308 |
|
| 1309 |
// CronJobActiveJobs is an instrument used to record metric values conforming to |
| 1310 |
// the "k8s.cronjob.active_jobs" semantic conventions. It represents the number |
| 1311 |
// of actively running jobs for a cronjob. |
| 1312 |
type CronJobActiveJobs struct { |
| 1313 |
metric.Int64UpDownCounter |
| 1314 |
} |
| 1315 |
|
| 1316 |
// NewCronJobActiveJobs returns a new CronJobActiveJobs instrument. |
| 1317 |
func NewCronJobActiveJobs( |
| 1318 |
m metric.Meter, |
| 1319 |
opt ...metric.Int64UpDownCounterOption, |
| 1320 |
) (CronJobActiveJobs, error) { |
| 1321 |
// Check if the meter is nil. |
| 1322 |
if m == nil { |
| 1323 |
return CronJobActiveJobs{noop.Int64UpDownCounter{}}, nil |
| 1324 |
} |
| 1325 |
|
| 1326 |
i, err := m.Int64UpDownCounter( |
| 1327 |
"k8s.cronjob.active_jobs", |
| 1328 |
append([]metric.Int64UpDownCounterOption{ |
| 1329 |
metric.WithDescription("The number of actively running jobs for a cronjob"), |
| 1330 |
metric.WithUnit("{job}"), |
| 1331 |
}, opt...)..., |
| 1332 |
) |
| 1333 |
if err != nil { |
| 1334 |
return CronJobActiveJobs{noop.Int64UpDownCounter{}}, err |
| 1335 |
} |
| 1336 |
return CronJobActiveJobs{i}, nil |
| 1337 |
} |
| 1338 |
|
| 1339 |
// Inst returns the underlying metric instrument. |
| 1340 |
func (m CronJobActiveJobs) Inst() metric.Int64UpDownCounter { |
| 1341 |
return m.Int64UpDownCounter |
| 1342 |
} |
| 1343 |
|
| 1344 |
// Name returns the semantic convention name of the instrument. |
| 1345 |
func (CronJobActiveJobs) Name() string { |
| 1346 |
return "k8s.cronjob.active_jobs" |
| 1347 |
} |
| 1348 |
|
| 1349 |
// Unit returns the semantic convention unit of the instrument |
| 1350 |
func (CronJobActiveJobs) Unit() string { |
| 1351 |
return "{job}" |
| 1352 |
} |
| 1353 |
|
| 1354 |
// Description returns the semantic convention description of the instrument |
| 1355 |
func (CronJobActiveJobs) Description() string { |
| 1356 |
return "The number of actively running jobs for a cronjob" |
| 1357 |
} |
| 1358 |
|
| 1359 |
// Add adds incr to the existing count for attrs. |
| 1360 |
// |
| 1361 |
// This metric aligns with the `active` field of the |
| 1362 |
// [K8s CronJobStatus]. |
| 1363 |
// |
| 1364 |
// [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch |
| 1365 |
func (m CronJobActiveJobs) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1366 |
if len(attrs) == 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.WithAttributes(attrs...)) |
| 1378 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1379 |
} |
| 1380 |
|
| 1381 |
// AddSet adds incr to the existing count for set. |
| 1382 |
// |
| 1383 |
// This metric aligns with the `active` field of the |
| 1384 |
// [K8s CronJobStatus]. |
| 1385 |
// |
| 1386 |
// [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch |
| 1387 |
func (m CronJobActiveJobs) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1388 |
if set.Len() == 0 { |
| 1389 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1390 |
return |
| 1391 |
} |
| 1392 |
|
| 1393 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1394 |
defer func() { |
| 1395 |
*o = (*o)[:0] |
| 1396 |
addOptPool.Put(o) |
| 1397 |
}() |
| 1398 |
|
| 1399 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1400 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1401 |
} |
| 1402 |
|
| 1403 |
// DaemonSetCurrentScheduledNodes is an instrument used to record metric values |
| 1404 |
// conforming to the "k8s.daemonset.current_scheduled_nodes" semantic |
| 1405 |
// conventions. It represents the number of nodes that are running at least 1 |
| 1406 |
// daemon pod and are supposed to run the daemon pod. |
| 1407 |
type DaemonSetCurrentScheduledNodes struct { |
| 1408 |
metric.Int64UpDownCounter |
| 1409 |
} |
| 1410 |
|
| 1411 |
// NewDaemonSetCurrentScheduledNodes returns a new DaemonSetCurrentScheduledNodes |
| 1412 |
// instrument. |
| 1413 |
func NewDaemonSetCurrentScheduledNodes( |
| 1414 |
m metric.Meter, |
| 1415 |
opt ...metric.Int64UpDownCounterOption, |
| 1416 |
) (DaemonSetCurrentScheduledNodes, error) { |
| 1417 |
// Check if the meter is nil. |
| 1418 |
if m == nil { |
| 1419 |
return DaemonSetCurrentScheduledNodes{noop.Int64UpDownCounter{}}, nil |
| 1420 |
} |
| 1421 |
|
| 1422 |
i, err := m.Int64UpDownCounter( |
| 1423 |
"k8s.daemonset.current_scheduled_nodes", |
| 1424 |
append([]metric.Int64UpDownCounterOption{ |
| 1425 |
metric.WithDescription("Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod"), |
| 1426 |
metric.WithUnit("{node}"), |
| 1427 |
}, opt...)..., |
| 1428 |
) |
| 1429 |
if err != nil { |
| 1430 |
return DaemonSetCurrentScheduledNodes{noop.Int64UpDownCounter{}}, err |
| 1431 |
} |
| 1432 |
return DaemonSetCurrentScheduledNodes{i}, nil |
| 1433 |
} |
| 1434 |
|
| 1435 |
// Inst returns the underlying metric instrument. |
| 1436 |
func (m DaemonSetCurrentScheduledNodes) Inst() metric.Int64UpDownCounter { |
| 1437 |
return m.Int64UpDownCounter |
| 1438 |
} |
| 1439 |
|
| 1440 |
// Name returns the semantic convention name of the instrument. |
| 1441 |
func (DaemonSetCurrentScheduledNodes) Name() string { |
| 1442 |
return "k8s.daemonset.current_scheduled_nodes" |
| 1443 |
} |
| 1444 |
|
| 1445 |
// Unit returns the semantic convention unit of the instrument |
| 1446 |
func (DaemonSetCurrentScheduledNodes) Unit() string { |
| 1447 |
return "{node}" |
| 1448 |
} |
| 1449 |
|
| 1450 |
// Description returns the semantic convention description of the instrument |
| 1451 |
func (DaemonSetCurrentScheduledNodes) Description() string { |
| 1452 |
return "Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod" |
| 1453 |
} |
| 1454 |
|
| 1455 |
// Add adds incr to the existing count for attrs. |
| 1456 |
// |
| 1457 |
// This metric aligns with the `currentNumberScheduled` field of the |
| 1458 |
// [K8s DaemonSetStatus]. |
| 1459 |
// |
| 1460 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1461 |
func (m DaemonSetCurrentScheduledNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1462 |
if len(attrs) == 0 { |
| 1463 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1464 |
return |
| 1465 |
} |
| 1466 |
|
| 1467 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1468 |
defer func() { |
| 1469 |
*o = (*o)[:0] |
| 1470 |
addOptPool.Put(o) |
| 1471 |
}() |
| 1472 |
|
| 1473 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1474 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1475 |
} |
| 1476 |
|
| 1477 |
// AddSet adds incr to the existing count for set. |
| 1478 |
// |
| 1479 |
// This metric aligns with the `currentNumberScheduled` field of the |
| 1480 |
// [K8s DaemonSetStatus]. |
| 1481 |
// |
| 1482 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1483 |
func (m DaemonSetCurrentScheduledNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1484 |
if set.Len() == 0 { |
| 1485 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1486 |
return |
| 1487 |
} |
| 1488 |
|
| 1489 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1490 |
defer func() { |
| 1491 |
*o = (*o)[:0] |
| 1492 |
addOptPool.Put(o) |
| 1493 |
}() |
| 1494 |
|
| 1495 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1496 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1497 |
} |
| 1498 |
|
| 1499 |
// DaemonSetDesiredScheduledNodes is an instrument used to record metric values |
| 1500 |
// conforming to the "k8s.daemonset.desired_scheduled_nodes" semantic |
| 1501 |
// conventions. It represents the number of nodes that should be running the |
| 1502 |
// daemon pod (including nodes currently running the daemon pod). |
| 1503 |
type DaemonSetDesiredScheduledNodes struct { |
| 1504 |
metric.Int64UpDownCounter |
| 1505 |
} |
| 1506 |
|
| 1507 |
// NewDaemonSetDesiredScheduledNodes returns a new DaemonSetDesiredScheduledNodes |
| 1508 |
// instrument. |
| 1509 |
func NewDaemonSetDesiredScheduledNodes( |
| 1510 |
m metric.Meter, |
| 1511 |
opt ...metric.Int64UpDownCounterOption, |
| 1512 |
) (DaemonSetDesiredScheduledNodes, error) { |
| 1513 |
// Check if the meter is nil. |
| 1514 |
if m == nil { |
| 1515 |
return DaemonSetDesiredScheduledNodes{noop.Int64UpDownCounter{}}, nil |
| 1516 |
} |
| 1517 |
|
| 1518 |
i, err := m.Int64UpDownCounter( |
| 1519 |
"k8s.daemonset.desired_scheduled_nodes", |
| 1520 |
append([]metric.Int64UpDownCounterOption{ |
| 1521 |
metric.WithDescription("Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)"), |
| 1522 |
metric.WithUnit("{node}"), |
| 1523 |
}, opt...)..., |
| 1524 |
) |
| 1525 |
if err != nil { |
| 1526 |
return DaemonSetDesiredScheduledNodes{noop.Int64UpDownCounter{}}, err |
| 1527 |
} |
| 1528 |
return DaemonSetDesiredScheduledNodes{i}, nil |
| 1529 |
} |
| 1530 |
|
| 1531 |
// Inst returns the underlying metric instrument. |
| 1532 |
func (m DaemonSetDesiredScheduledNodes) Inst() metric.Int64UpDownCounter { |
| 1533 |
return m.Int64UpDownCounter |
| 1534 |
} |
| 1535 |
|
| 1536 |
// Name returns the semantic convention name of the instrument. |
| 1537 |
func (DaemonSetDesiredScheduledNodes) Name() string { |
| 1538 |
return "k8s.daemonset.desired_scheduled_nodes" |
| 1539 |
} |
| 1540 |
|
| 1541 |
// Unit returns the semantic convention unit of the instrument |
| 1542 |
func (DaemonSetDesiredScheduledNodes) Unit() string { |
| 1543 |
return "{node}" |
| 1544 |
} |
| 1545 |
|
| 1546 |
// Description returns the semantic convention description of the instrument |
| 1547 |
func (DaemonSetDesiredScheduledNodes) Description() string { |
| 1548 |
return "Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)" |
| 1549 |
} |
| 1550 |
|
| 1551 |
// Add adds incr to the existing count for attrs. |
| 1552 |
// |
| 1553 |
// This metric aligns with the `desiredNumberScheduled` field of the |
| 1554 |
// [K8s DaemonSetStatus]. |
| 1555 |
// |
| 1556 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1557 |
func (m DaemonSetDesiredScheduledNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1558 |
if len(attrs) == 0 { |
| 1559 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1560 |
return |
| 1561 |
} |
| 1562 |
|
| 1563 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1564 |
defer func() { |
| 1565 |
*o = (*o)[:0] |
| 1566 |
addOptPool.Put(o) |
| 1567 |
}() |
| 1568 |
|
| 1569 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1570 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1571 |
} |
| 1572 |
|
| 1573 |
// AddSet adds incr to the existing count for set. |
| 1574 |
// |
| 1575 |
// This metric aligns with the `desiredNumberScheduled` field of the |
| 1576 |
// [K8s DaemonSetStatus]. |
| 1577 |
// |
| 1578 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1579 |
func (m DaemonSetDesiredScheduledNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1580 |
if set.Len() == 0 { |
| 1581 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1582 |
return |
| 1583 |
} |
| 1584 |
|
| 1585 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1586 |
defer func() { |
| 1587 |
*o = (*o)[:0] |
| 1588 |
addOptPool.Put(o) |
| 1589 |
}() |
| 1590 |
|
| 1591 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1592 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1593 |
} |
| 1594 |
|
| 1595 |
// DaemonSetMisscheduledNodes is an instrument used to record metric values |
| 1596 |
// conforming to the "k8s.daemonset.misscheduled_nodes" semantic conventions. It |
| 1597 |
// represents the number of nodes that are running the daemon pod, but are not |
| 1598 |
// supposed to run the daemon pod. |
| 1599 |
type DaemonSetMisscheduledNodes struct { |
| 1600 |
metric.Int64UpDownCounter |
| 1601 |
} |
| 1602 |
|
| 1603 |
// NewDaemonSetMisscheduledNodes returns a new DaemonSetMisscheduledNodes |
| 1604 |
// instrument. |
| 1605 |
func NewDaemonSetMisscheduledNodes( |
| 1606 |
m metric.Meter, |
| 1607 |
opt ...metric.Int64UpDownCounterOption, |
| 1608 |
) (DaemonSetMisscheduledNodes, error) { |
| 1609 |
// Check if the meter is nil. |
| 1610 |
if m == nil { |
| 1611 |
return DaemonSetMisscheduledNodes{noop.Int64UpDownCounter{}}, nil |
| 1612 |
} |
| 1613 |
|
| 1614 |
i, err := m.Int64UpDownCounter( |
| 1615 |
"k8s.daemonset.misscheduled_nodes", |
| 1616 |
append([]metric.Int64UpDownCounterOption{ |
| 1617 |
metric.WithDescription("Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod"), |
| 1618 |
metric.WithUnit("{node}"), |
| 1619 |
}, opt...)..., |
| 1620 |
) |
| 1621 |
if err != nil { |
| 1622 |
return DaemonSetMisscheduledNodes{noop.Int64UpDownCounter{}}, err |
| 1623 |
} |
| 1624 |
return DaemonSetMisscheduledNodes{i}, nil |
| 1625 |
} |
| 1626 |
|
| 1627 |
// Inst returns the underlying metric instrument. |
| 1628 |
func (m DaemonSetMisscheduledNodes) Inst() metric.Int64UpDownCounter { |
| 1629 |
return m.Int64UpDownCounter |
| 1630 |
} |
| 1631 |
|
| 1632 |
// Name returns the semantic convention name of the instrument. |
| 1633 |
func (DaemonSetMisscheduledNodes) Name() string { |
| 1634 |
return "k8s.daemonset.misscheduled_nodes" |
| 1635 |
} |
| 1636 |
|
| 1637 |
// Unit returns the semantic convention unit of the instrument |
| 1638 |
func (DaemonSetMisscheduledNodes) Unit() string { |
| 1639 |
return "{node}" |
| 1640 |
} |
| 1641 |
|
| 1642 |
// Description returns the semantic convention description of the instrument |
| 1643 |
func (DaemonSetMisscheduledNodes) Description() string { |
| 1644 |
return "Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod" |
| 1645 |
} |
| 1646 |
|
| 1647 |
// Add adds incr to the existing count for attrs. |
| 1648 |
// |
| 1649 |
// This metric aligns with the `numberMisscheduled` field of the |
| 1650 |
// [K8s DaemonSetStatus]. |
| 1651 |
// |
| 1652 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1653 |
func (m DaemonSetMisscheduledNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1654 |
if len(attrs) == 0 { |
| 1655 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1656 |
return |
| 1657 |
} |
| 1658 |
|
| 1659 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1660 |
defer func() { |
| 1661 |
*o = (*o)[:0] |
| 1662 |
addOptPool.Put(o) |
| 1663 |
}() |
| 1664 |
|
| 1665 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1666 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1667 |
} |
| 1668 |
|
| 1669 |
// AddSet adds incr to the existing count for set. |
| 1670 |
// |
| 1671 |
// This metric aligns with the `numberMisscheduled` field of the |
| 1672 |
// [K8s DaemonSetStatus]. |
| 1673 |
// |
| 1674 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1675 |
func (m DaemonSetMisscheduledNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1676 |
if set.Len() == 0 { |
| 1677 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1678 |
return |
| 1679 |
} |
| 1680 |
|
| 1681 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1682 |
defer func() { |
| 1683 |
*o = (*o)[:0] |
| 1684 |
addOptPool.Put(o) |
| 1685 |
}() |
| 1686 |
|
| 1687 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1688 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1689 |
} |
| 1690 |
|
| 1691 |
// DaemonSetReadyNodes is an instrument used to record metric values conforming |
| 1692 |
// to the "k8s.daemonset.ready_nodes" semantic conventions. It represents the |
| 1693 |
// number of nodes that should be running the daemon pod and have one or more of |
| 1694 |
// the daemon pod running and ready. |
| 1695 |
type DaemonSetReadyNodes struct { |
| 1696 |
metric.Int64UpDownCounter |
| 1697 |
} |
| 1698 |
|
| 1699 |
// NewDaemonSetReadyNodes returns a new DaemonSetReadyNodes instrument. |
| 1700 |
func NewDaemonSetReadyNodes( |
| 1701 |
m metric.Meter, |
| 1702 |
opt ...metric.Int64UpDownCounterOption, |
| 1703 |
) (DaemonSetReadyNodes, error) { |
| 1704 |
// Check if the meter is nil. |
| 1705 |
if m == nil { |
| 1706 |
return DaemonSetReadyNodes{noop.Int64UpDownCounter{}}, nil |
| 1707 |
} |
| 1708 |
|
| 1709 |
i, err := m.Int64UpDownCounter( |
| 1710 |
"k8s.daemonset.ready_nodes", |
| 1711 |
append([]metric.Int64UpDownCounterOption{ |
| 1712 |
metric.WithDescription("Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready"), |
| 1713 |
metric.WithUnit("{node}"), |
| 1714 |
}, opt...)..., |
| 1715 |
) |
| 1716 |
if err != nil { |
| 1717 |
return DaemonSetReadyNodes{noop.Int64UpDownCounter{}}, err |
| 1718 |
} |
| 1719 |
return DaemonSetReadyNodes{i}, nil |
| 1720 |
} |
| 1721 |
|
| 1722 |
// Inst returns the underlying metric instrument. |
| 1723 |
func (m DaemonSetReadyNodes) Inst() metric.Int64UpDownCounter { |
| 1724 |
return m.Int64UpDownCounter |
| 1725 |
} |
| 1726 |
|
| 1727 |
// Name returns the semantic convention name of the instrument. |
| 1728 |
func (DaemonSetReadyNodes) Name() string { |
| 1729 |
return "k8s.daemonset.ready_nodes" |
| 1730 |
} |
| 1731 |
|
| 1732 |
// Unit returns the semantic convention unit of the instrument |
| 1733 |
func (DaemonSetReadyNodes) Unit() string { |
| 1734 |
return "{node}" |
| 1735 |
} |
| 1736 |
|
| 1737 |
// Description returns the semantic convention description of the instrument |
| 1738 |
func (DaemonSetReadyNodes) Description() string { |
| 1739 |
return "Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready" |
| 1740 |
} |
| 1741 |
|
| 1742 |
// Add adds incr to the existing count for attrs. |
| 1743 |
// |
| 1744 |
// This metric aligns with the `numberReady` field of the |
| 1745 |
// [K8s DaemonSetStatus]. |
| 1746 |
// |
| 1747 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1748 |
func (m DaemonSetReadyNodes) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1749 |
if len(attrs) == 0 { |
| 1750 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1751 |
return |
| 1752 |
} |
| 1753 |
|
| 1754 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1755 |
defer func() { |
| 1756 |
*o = (*o)[:0] |
| 1757 |
addOptPool.Put(o) |
| 1758 |
}() |
| 1759 |
|
| 1760 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1761 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1762 |
} |
| 1763 |
|
| 1764 |
// AddSet adds incr to the existing count for set. |
| 1765 |
// |
| 1766 |
// This metric aligns with the `numberReady` field of the |
| 1767 |
// [K8s DaemonSetStatus]. |
| 1768 |
// |
| 1769 |
// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps |
| 1770 |
func (m DaemonSetReadyNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1771 |
if set.Len() == 0 { |
| 1772 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1773 |
return |
| 1774 |
} |
| 1775 |
|
| 1776 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1777 |
defer func() { |
| 1778 |
*o = (*o)[:0] |
| 1779 |
addOptPool.Put(o) |
| 1780 |
}() |
| 1781 |
|
| 1782 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1783 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1784 |
} |
| 1785 |
|
| 1786 |
// DeploymentAvailablePods is an instrument used to record metric values |
| 1787 |
// conforming to the "k8s.deployment.available_pods" semantic conventions. It |
| 1788 |
// represents the total number of available replica pods (ready for at least |
| 1789 |
// minReadySeconds) targeted by this deployment. |
| 1790 |
type DeploymentAvailablePods struct { |
| 1791 |
metric.Int64UpDownCounter |
| 1792 |
} |
| 1793 |
|
| 1794 |
// NewDeploymentAvailablePods returns a new DeploymentAvailablePods instrument. |
| 1795 |
func NewDeploymentAvailablePods( |
| 1796 |
m metric.Meter, |
| 1797 |
opt ...metric.Int64UpDownCounterOption, |
| 1798 |
) (DeploymentAvailablePods, error) { |
| 1799 |
// Check if the meter is nil. |
| 1800 |
if m == nil { |
| 1801 |
return DeploymentAvailablePods{noop.Int64UpDownCounter{}}, nil |
| 1802 |
} |
| 1803 |
|
| 1804 |
i, err := m.Int64UpDownCounter( |
| 1805 |
"k8s.deployment.available_pods", |
| 1806 |
append([]metric.Int64UpDownCounterOption{ |
| 1807 |
metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment"), |
| 1808 |
metric.WithUnit("{pod}"), |
| 1809 |
}, opt...)..., |
| 1810 |
) |
| 1811 |
if err != nil { |
| 1812 |
return DeploymentAvailablePods{noop.Int64UpDownCounter{}}, err |
| 1813 |
} |
| 1814 |
return DeploymentAvailablePods{i}, nil |
| 1815 |
} |
| 1816 |
|
| 1817 |
// Inst returns the underlying metric instrument. |
| 1818 |
func (m DeploymentAvailablePods) Inst() metric.Int64UpDownCounter { |
| 1819 |
return m.Int64UpDownCounter |
| 1820 |
} |
| 1821 |
|
| 1822 |
// Name returns the semantic convention name of the instrument. |
| 1823 |
func (DeploymentAvailablePods) Name() string { |
| 1824 |
return "k8s.deployment.available_pods" |
| 1825 |
} |
| 1826 |
|
| 1827 |
// Unit returns the semantic convention unit of the instrument |
| 1828 |
func (DeploymentAvailablePods) Unit() string { |
| 1829 |
return "{pod}" |
| 1830 |
} |
| 1831 |
|
| 1832 |
// Description returns the semantic convention description of the instrument |
| 1833 |
func (DeploymentAvailablePods) Description() string { |
| 1834 |
return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment" |
| 1835 |
} |
| 1836 |
|
| 1837 |
// Add adds incr to the existing count for attrs. |
| 1838 |
// |
| 1839 |
// This metric aligns with the `availableReplicas` field of the |
| 1840 |
// [K8s DeploymentStatus]. |
| 1841 |
// |
| 1842 |
// [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps |
| 1843 |
func (m DeploymentAvailablePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1844 |
if len(attrs) == 0 { |
| 1845 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1846 |
return |
| 1847 |
} |
| 1848 |
|
| 1849 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1850 |
defer func() { |
| 1851 |
*o = (*o)[:0] |
| 1852 |
addOptPool.Put(o) |
| 1853 |
}() |
| 1854 |
|
| 1855 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1856 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1857 |
} |
| 1858 |
|
| 1859 |
// AddSet adds incr to the existing count for set. |
| 1860 |
// |
| 1861 |
// This metric aligns with the `availableReplicas` field of the |
| 1862 |
// [K8s DeploymentStatus]. |
| 1863 |
// |
| 1864 |
// [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps |
| 1865 |
func (m DeploymentAvailablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1866 |
if set.Len() == 0 { |
| 1867 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1868 |
return |
| 1869 |
} |
| 1870 |
|
| 1871 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1872 |
defer func() { |
| 1873 |
*o = (*o)[:0] |
| 1874 |
addOptPool.Put(o) |
| 1875 |
}() |
| 1876 |
|
| 1877 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1878 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1879 |
} |
| 1880 |
|
| 1881 |
// DeploymentDesiredPods is an instrument used to record metric values conforming |
| 1882 |
// to the "k8s.deployment.desired_pods" semantic conventions. It represents the |
| 1883 |
// number of desired replica pods in this deployment. |
| 1884 |
type DeploymentDesiredPods struct { |
| 1885 |
metric.Int64UpDownCounter |
| 1886 |
} |
| 1887 |
|
| 1888 |
// NewDeploymentDesiredPods returns a new DeploymentDesiredPods instrument. |
| 1889 |
func NewDeploymentDesiredPods( |
| 1890 |
m metric.Meter, |
| 1891 |
opt ...metric.Int64UpDownCounterOption, |
| 1892 |
) (DeploymentDesiredPods, error) { |
| 1893 |
// Check if the meter is nil. |
| 1894 |
if m == nil { |
| 1895 |
return DeploymentDesiredPods{noop.Int64UpDownCounter{}}, nil |
| 1896 |
} |
| 1897 |
|
| 1898 |
i, err := m.Int64UpDownCounter( |
| 1899 |
"k8s.deployment.desired_pods", |
| 1900 |
append([]metric.Int64UpDownCounterOption{ |
| 1901 |
metric.WithDescription("Number of desired replica pods in this deployment"), |
| 1902 |
metric.WithUnit("{pod}"), |
| 1903 |
}, opt...)..., |
| 1904 |
) |
| 1905 |
if err != nil { |
| 1906 |
return DeploymentDesiredPods{noop.Int64UpDownCounter{}}, err |
| 1907 |
} |
| 1908 |
return DeploymentDesiredPods{i}, nil |
| 1909 |
} |
| 1910 |
|
| 1911 |
// Inst returns the underlying metric instrument. |
| 1912 |
func (m DeploymentDesiredPods) Inst() metric.Int64UpDownCounter { |
| 1913 |
return m.Int64UpDownCounter |
| 1914 |
} |
| 1915 |
|
| 1916 |
// Name returns the semantic convention name of the instrument. |
| 1917 |
func (DeploymentDesiredPods) Name() string { |
| 1918 |
return "k8s.deployment.desired_pods" |
| 1919 |
} |
| 1920 |
|
| 1921 |
// Unit returns the semantic convention unit of the instrument |
| 1922 |
func (DeploymentDesiredPods) Unit() string { |
| 1923 |
return "{pod}" |
| 1924 |
} |
| 1925 |
|
| 1926 |
// Description returns the semantic convention description of the instrument |
| 1927 |
func (DeploymentDesiredPods) Description() string { |
| 1928 |
return "Number of desired replica pods in this deployment" |
| 1929 |
} |
| 1930 |
|
| 1931 |
// Add adds incr to the existing count for attrs. |
| 1932 |
// |
| 1933 |
// This metric aligns with the `replicas` field of the |
| 1934 |
// [K8s DeploymentSpec]. |
| 1935 |
// |
| 1936 |
// [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps |
| 1937 |
func (m DeploymentDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 1938 |
if len(attrs) == 0 { |
| 1939 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1940 |
return |
| 1941 |
} |
| 1942 |
|
| 1943 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1944 |
defer func() { |
| 1945 |
*o = (*o)[:0] |
| 1946 |
addOptPool.Put(o) |
| 1947 |
}() |
| 1948 |
|
| 1949 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 1950 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1951 |
} |
| 1952 |
|
| 1953 |
// AddSet adds incr to the existing count for set. |
| 1954 |
// |
| 1955 |
// This metric aligns with the `replicas` field of the |
| 1956 |
// [K8s DeploymentSpec]. |
| 1957 |
// |
| 1958 |
// [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps |
| 1959 |
func (m DeploymentDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1960 |
if set.Len() == 0 { |
| 1961 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1962 |
return |
| 1963 |
} |
| 1964 |
|
| 1965 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1966 |
defer func() { |
| 1967 |
*o = (*o)[:0] |
| 1968 |
addOptPool.Put(o) |
| 1969 |
}() |
| 1970 |
|
| 1971 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1972 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1973 |
} |
| 1974 |
|
| 1975 |
// HPACurrentPods is an instrument used to record metric values conforming to the |
| 1976 |
// "k8s.hpa.current_pods" semantic conventions. It represents the current number |
| 1977 |
// of replica pods managed by this horizontal pod autoscaler, as last seen by the |
| 1978 |
// autoscaler. |
| 1979 |
type HPACurrentPods struct { |
| 1980 |
metric.Int64UpDownCounter |
| 1981 |
} |
| 1982 |
|
| 1983 |
// NewHPACurrentPods returns a new HPACurrentPods instrument. |
| 1984 |
func NewHPACurrentPods( |
| 1985 |
m metric.Meter, |
| 1986 |
opt ...metric.Int64UpDownCounterOption, |
| 1987 |
) (HPACurrentPods, error) { |
| 1988 |
// Check if the meter is nil. |
| 1989 |
if m == nil { |
| 1990 |
return HPACurrentPods{noop.Int64UpDownCounter{}}, nil |
| 1991 |
} |
| 1992 |
|
| 1993 |
i, err := m.Int64UpDownCounter( |
| 1994 |
"k8s.hpa.current_pods", |
| 1995 |
append([]metric.Int64UpDownCounterOption{ |
| 1996 |
metric.WithDescription("Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler"), |
| 1997 |
metric.WithUnit("{pod}"), |
| 1998 |
}, opt...)..., |
| 1999 |
) |
| 2000 |
if err != nil { |
| 2001 |
return HPACurrentPods{noop.Int64UpDownCounter{}}, err |
| 2002 |
} |
| 2003 |
return HPACurrentPods{i}, nil |
| 2004 |
} |
| 2005 |
|
| 2006 |
// Inst returns the underlying metric instrument. |
| 2007 |
func (m HPACurrentPods) Inst() metric.Int64UpDownCounter { |
| 2008 |
return m.Int64UpDownCounter |
| 2009 |
} |
| 2010 |
|
| 2011 |
// Name returns the semantic convention name of the instrument. |
| 2012 |
func (HPACurrentPods) Name() string { |
| 2013 |
return "k8s.hpa.current_pods" |
| 2014 |
} |
| 2015 |
|
| 2016 |
// Unit returns the semantic convention unit of the instrument |
| 2017 |
func (HPACurrentPods) Unit() string { |
| 2018 |
return "{pod}" |
| 2019 |
} |
| 2020 |
|
| 2021 |
// Description returns the semantic convention description of the instrument |
| 2022 |
func (HPACurrentPods) Description() string { |
| 2023 |
return "Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler" |
| 2024 |
} |
| 2025 |
|
| 2026 |
// Add adds incr to the existing count for attrs. |
| 2027 |
// |
| 2028 |
// This metric aligns with the `currentReplicas` field of the |
| 2029 |
// [K8s HorizontalPodAutoscalerStatus] |
| 2030 |
// |
| 2031 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 2032 |
func (m HPACurrentPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2033 |
if len(attrs) == 0 { |
| 2034 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2035 |
return |
| 2036 |
} |
| 2037 |
|
| 2038 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2039 |
defer func() { |
| 2040 |
*o = (*o)[:0] |
| 2041 |
addOptPool.Put(o) |
| 2042 |
}() |
| 2043 |
|
| 2044 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2045 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2046 |
} |
| 2047 |
|
| 2048 |
// AddSet adds incr to the existing count for set. |
| 2049 |
// |
| 2050 |
// This metric aligns with the `currentReplicas` field of the |
| 2051 |
// [K8s HorizontalPodAutoscalerStatus] |
| 2052 |
// |
| 2053 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 2054 |
func (m HPACurrentPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2055 |
if set.Len() == 0 { |
| 2056 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2057 |
return |
| 2058 |
} |
| 2059 |
|
| 2060 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2061 |
defer func() { |
| 2062 |
*o = (*o)[:0] |
| 2063 |
addOptPool.Put(o) |
| 2064 |
}() |
| 2065 |
|
| 2066 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2067 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2068 |
} |
| 2069 |
|
| 2070 |
// HPADesiredPods is an instrument used to record metric values conforming to the |
| 2071 |
// "k8s.hpa.desired_pods" semantic conventions. It represents the desired number |
| 2072 |
// of replica pods managed by this horizontal pod autoscaler, as last calculated |
| 2073 |
// by the autoscaler. |
| 2074 |
type HPADesiredPods struct { |
| 2075 |
metric.Int64UpDownCounter |
| 2076 |
} |
| 2077 |
|
| 2078 |
// NewHPADesiredPods returns a new HPADesiredPods instrument. |
| 2079 |
func NewHPADesiredPods( |
| 2080 |
m metric.Meter, |
| 2081 |
opt ...metric.Int64UpDownCounterOption, |
| 2082 |
) (HPADesiredPods, error) { |
| 2083 |
// Check if the meter is nil. |
| 2084 |
if m == nil { |
| 2085 |
return HPADesiredPods{noop.Int64UpDownCounter{}}, nil |
| 2086 |
} |
| 2087 |
|
| 2088 |
i, err := m.Int64UpDownCounter( |
| 2089 |
"k8s.hpa.desired_pods", |
| 2090 |
append([]metric.Int64UpDownCounterOption{ |
| 2091 |
metric.WithDescription("Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler"), |
| 2092 |
metric.WithUnit("{pod}"), |
| 2093 |
}, opt...)..., |
| 2094 |
) |
| 2095 |
if err != nil { |
| 2096 |
return HPADesiredPods{noop.Int64UpDownCounter{}}, err |
| 2097 |
} |
| 2098 |
return HPADesiredPods{i}, nil |
| 2099 |
} |
| 2100 |
|
| 2101 |
// Inst returns the underlying metric instrument. |
| 2102 |
func (m HPADesiredPods) Inst() metric.Int64UpDownCounter { |
| 2103 |
return m.Int64UpDownCounter |
| 2104 |
} |
| 2105 |
|
| 2106 |
// Name returns the semantic convention name of the instrument. |
| 2107 |
func (HPADesiredPods) Name() string { |
| 2108 |
return "k8s.hpa.desired_pods" |
| 2109 |
} |
| 2110 |
|
| 2111 |
// Unit returns the semantic convention unit of the instrument |
| 2112 |
func (HPADesiredPods) Unit() string { |
| 2113 |
return "{pod}" |
| 2114 |
} |
| 2115 |
|
| 2116 |
// Description returns the semantic convention description of the instrument |
| 2117 |
func (HPADesiredPods) Description() string { |
| 2118 |
return "Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler" |
| 2119 |
} |
| 2120 |
|
| 2121 |
// Add adds incr to the existing count for attrs. |
| 2122 |
// |
| 2123 |
// This metric aligns with the `desiredReplicas` field of the |
| 2124 |
// [K8s HorizontalPodAutoscalerStatus] |
| 2125 |
// |
| 2126 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 2127 |
func (m HPADesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2128 |
if len(attrs) == 0 { |
| 2129 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2130 |
return |
| 2131 |
} |
| 2132 |
|
| 2133 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2134 |
defer func() { |
| 2135 |
*o = (*o)[:0] |
| 2136 |
addOptPool.Put(o) |
| 2137 |
}() |
| 2138 |
|
| 2139 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2140 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2141 |
} |
| 2142 |
|
| 2143 |
// AddSet adds incr to the existing count for set. |
| 2144 |
// |
| 2145 |
// This metric aligns with the `desiredReplicas` field of the |
| 2146 |
// [K8s HorizontalPodAutoscalerStatus] |
| 2147 |
// |
| 2148 |
// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling |
| 2149 |
func (m HPADesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2150 |
if set.Len() == 0 { |
| 2151 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2152 |
return |
| 2153 |
} |
| 2154 |
|
| 2155 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2156 |
defer func() { |
| 2157 |
*o = (*o)[:0] |
| 2158 |
addOptPool.Put(o) |
| 2159 |
}() |
| 2160 |
|
| 2161 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2162 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2163 |
} |
| 2164 |
|
| 2165 |
// HPAMaxPods is an instrument used to record metric values conforming to the |
| 2166 |
// "k8s.hpa.max_pods" semantic conventions. It represents the upper limit for the |
| 2167 |
// number of replica pods to which the autoscaler can scale up. |
| 2168 |
type HPAMaxPods struct { |
| 2169 |
metric.Int64UpDownCounter |
| 2170 |
} |
| 2171 |
|
| 2172 |
// NewHPAMaxPods returns a new HPAMaxPods instrument. |
| 2173 |
func NewHPAMaxPods( |
| 2174 |
m metric.Meter, |
| 2175 |
opt ...metric.Int64UpDownCounterOption, |
| 2176 |
) (HPAMaxPods, error) { |
| 2177 |
// Check if the meter is nil. |
| 2178 |
if m == nil { |
| 2179 |
return HPAMaxPods{noop.Int64UpDownCounter{}}, nil |
| 2180 |
} |
| 2181 |
|
| 2182 |
i, err := m.Int64UpDownCounter( |
| 2183 |
"k8s.hpa.max_pods", |
| 2184 |
append([]metric.Int64UpDownCounterOption{ |
| 2185 |
metric.WithDescription("The upper limit for the number of replica pods to which the autoscaler can scale up"), |
| 2186 |
metric.WithUnit("{pod}"), |
| 2187 |
}, opt...)..., |
| 2188 |
) |
| 2189 |
if err != nil { |
| 2190 |
return HPAMaxPods{noop.Int64UpDownCounter{}}, err |
| 2191 |
} |
| 2192 |
return HPAMaxPods{i}, nil |
| 2193 |
} |
| 2194 |
|
| 2195 |
// Inst returns the underlying metric instrument. |
| 2196 |
func (m HPAMaxPods) Inst() metric.Int64UpDownCounter { |
| 2197 |
return m.Int64UpDownCounter |
| 2198 |
} |
| 2199 |
|
| 2200 |
// Name returns the semantic convention name of the instrument. |
| 2201 |
func (HPAMaxPods) Name() string { |
| 2202 |
return "k8s.hpa.max_pods" |
| 2203 |
} |
| 2204 |
|
| 2205 |
// Unit returns the semantic convention unit of the instrument |
| 2206 |
func (HPAMaxPods) Unit() string { |
| 2207 |
return "{pod}" |
| 2208 |
} |
| 2209 |
|
| 2210 |
// Description returns the semantic convention description of the instrument |
| 2211 |
func (HPAMaxPods) Description() string { |
| 2212 |
return "The upper limit for the number of replica pods to which the autoscaler can scale up" |
| 2213 |
} |
| 2214 |
|
| 2215 |
// Add adds incr to the existing count for attrs. |
| 2216 |
// |
| 2217 |
// This metric aligns with the `maxReplicas` field of the |
| 2218 |
// [K8s HorizontalPodAutoscalerSpec] |
| 2219 |
// |
| 2220 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 2221 |
func (m HPAMaxPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2222 |
if len(attrs) == 0 { |
| 2223 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2224 |
return |
| 2225 |
} |
| 2226 |
|
| 2227 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2228 |
defer func() { |
| 2229 |
*o = (*o)[:0] |
| 2230 |
addOptPool.Put(o) |
| 2231 |
}() |
| 2232 |
|
| 2233 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2234 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2235 |
} |
| 2236 |
|
| 2237 |
// AddSet adds incr to the existing count for set. |
| 2238 |
// |
| 2239 |
// This metric aligns with the `maxReplicas` field of the |
| 2240 |
// [K8s HorizontalPodAutoscalerSpec] |
| 2241 |
// |
| 2242 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 2243 |
func (m HPAMaxPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2244 |
if set.Len() == 0 { |
| 2245 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2246 |
return |
| 2247 |
} |
| 2248 |
|
| 2249 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2250 |
defer func() { |
| 2251 |
*o = (*o)[:0] |
| 2252 |
addOptPool.Put(o) |
| 2253 |
}() |
| 2254 |
|
| 2255 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2256 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2257 |
} |
| 2258 |
|
| 2259 |
// HPAMetricTargetCPUAverageUtilization is an instrument used to record metric |
| 2260 |
// values conforming to the "k8s.hpa.metric.target.cpu.average_utilization" |
| 2261 |
// semantic conventions. It represents the target average utilization, in |
| 2262 |
// percentage, for CPU resource in HPA config. |
| 2263 |
type HPAMetricTargetCPUAverageUtilization struct { |
| 2264 |
metric.Int64Gauge |
| 2265 |
} |
| 2266 |
|
| 2267 |
// NewHPAMetricTargetCPUAverageUtilization returns a new |
| 2268 |
// HPAMetricTargetCPUAverageUtilization instrument. |
| 2269 |
func NewHPAMetricTargetCPUAverageUtilization( |
| 2270 |
m metric.Meter, |
| 2271 |
opt ...metric.Int64GaugeOption, |
| 2272 |
) (HPAMetricTargetCPUAverageUtilization, error) { |
| 2273 |
// Check if the meter is nil. |
| 2274 |
if m == nil { |
| 2275 |
return HPAMetricTargetCPUAverageUtilization{noop.Int64Gauge{}}, nil |
| 2276 |
} |
| 2277 |
|
| 2278 |
i, err := m.Int64Gauge( |
| 2279 |
"k8s.hpa.metric.target.cpu.average_utilization", |
| 2280 |
append([]metric.Int64GaugeOption{ |
| 2281 |
metric.WithDescription("Target average utilization, in percentage, for CPU resource in HPA config."), |
| 2282 |
metric.WithUnit("1"), |
| 2283 |
}, opt...)..., |
| 2284 |
) |
| 2285 |
if err != nil { |
| 2286 |
return HPAMetricTargetCPUAverageUtilization{noop.Int64Gauge{}}, err |
| 2287 |
} |
| 2288 |
return HPAMetricTargetCPUAverageUtilization{i}, nil |
| 2289 |
} |
| 2290 |
|
| 2291 |
// Inst returns the underlying metric instrument. |
| 2292 |
func (m HPAMetricTargetCPUAverageUtilization) Inst() metric.Int64Gauge { |
| 2293 |
return m.Int64Gauge |
| 2294 |
} |
| 2295 |
|
| 2296 |
// Name returns the semantic convention name of the instrument. |
| 2297 |
func (HPAMetricTargetCPUAverageUtilization) Name() string { |
| 2298 |
return "k8s.hpa.metric.target.cpu.average_utilization" |
| 2299 |
} |
| 2300 |
|
| 2301 |
// Unit returns the semantic convention unit of the instrument |
| 2302 |
func (HPAMetricTargetCPUAverageUtilization) Unit() string { |
| 2303 |
return "1" |
| 2304 |
} |
| 2305 |
|
| 2306 |
// Description returns the semantic convention description of the instrument |
| 2307 |
func (HPAMetricTargetCPUAverageUtilization) Description() string { |
| 2308 |
return "Target average utilization, in percentage, for CPU resource in HPA config." |
| 2309 |
} |
| 2310 |
|
| 2311 |
// Record records val to the current distribution for attrs. |
| 2312 |
// |
| 2313 |
// All additional attrs passed are included in the recorded value. |
| 2314 |
// |
| 2315 |
// This metric aligns with the `averageUtilization` field of the |
| 2316 |
// [K8s HPA MetricTarget]. |
| 2317 |
// If the type of the metric is [`ContainerResource`], |
| 2318 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2319 |
// container within the pod to which the metric applies. |
| 2320 |
// |
| 2321 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2322 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2323 |
func (m HPAMetricTargetCPUAverageUtilization) Record( |
| 2324 |
ctx context.Context, |
| 2325 |
val int64, |
| 2326 |
attrs ...attribute.KeyValue, |
| 2327 |
) { |
| 2328 |
if len(attrs) == 0 { |
| 2329 |
m.Int64Gauge.Record(ctx, val) |
| 2330 |
return |
| 2331 |
} |
| 2332 |
|
| 2333 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2334 |
defer func() { |
| 2335 |
*o = (*o)[:0] |
| 2336 |
recOptPool.Put(o) |
| 2337 |
}() |
| 2338 |
|
| 2339 |
*o = append( |
| 2340 |
*o, |
| 2341 |
metric.WithAttributes( |
| 2342 |
attrs..., |
| 2343 |
), |
| 2344 |
) |
| 2345 |
|
| 2346 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2347 |
} |
| 2348 |
|
| 2349 |
// RecordSet records val to the current distribution for set. |
| 2350 |
// |
| 2351 |
// This metric aligns with the `averageUtilization` field of the |
| 2352 |
// [K8s HPA MetricTarget]. |
| 2353 |
// If the type of the metric is [`ContainerResource`], |
| 2354 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2355 |
// container within the pod to which the metric applies. |
| 2356 |
// |
| 2357 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2358 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2359 |
func (m HPAMetricTargetCPUAverageUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2360 |
if set.Len() == 0 { |
| 2361 |
m.Int64Gauge.Record(ctx, val) |
| 2362 |
return |
| 2363 |
} |
| 2364 |
|
| 2365 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2366 |
defer func() { |
| 2367 |
*o = (*o)[:0] |
| 2368 |
recOptPool.Put(o) |
| 2369 |
}() |
| 2370 |
|
| 2371 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2372 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2373 |
} |
| 2374 |
|
| 2375 |
// AttrContainerName returns an optional attribute for the "k8s.container.name" |
| 2376 |
// semantic convention. It represents the name of the Container from Pod |
| 2377 |
// specification, must be unique within a Pod. Container runtime usually uses |
| 2378 |
// different globally unique name (`container.name`). |
| 2379 |
func (HPAMetricTargetCPUAverageUtilization) AttrContainerName(val string) attribute.KeyValue { |
| 2380 |
return attribute.String("k8s.container.name", val) |
| 2381 |
} |
| 2382 |
|
| 2383 |
// AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type" |
| 2384 |
// semantic convention. It represents the type of metric source for the |
| 2385 |
// horizontal pod autoscaler. |
| 2386 |
func (HPAMetricTargetCPUAverageUtilization) AttrHPAMetricType(val string) attribute.KeyValue { |
| 2387 |
return attribute.String("k8s.hpa.metric.type", val) |
| 2388 |
} |
| 2389 |
|
| 2390 |
// HPAMetricTargetCPUAverageValue is an instrument used to record metric values |
| 2391 |
// conforming to the "k8s.hpa.metric.target.cpu.average_value" semantic |
| 2392 |
// conventions. It represents the target average value for CPU resource in HPA |
| 2393 |
// config. |
| 2394 |
type HPAMetricTargetCPUAverageValue struct { |
| 2395 |
metric.Int64Gauge |
| 2396 |
} |
| 2397 |
|
| 2398 |
// NewHPAMetricTargetCPUAverageValue returns a new HPAMetricTargetCPUAverageValue |
| 2399 |
// instrument. |
| 2400 |
func NewHPAMetricTargetCPUAverageValue( |
| 2401 |
m metric.Meter, |
| 2402 |
opt ...metric.Int64GaugeOption, |
| 2403 |
) (HPAMetricTargetCPUAverageValue, error) { |
| 2404 |
// Check if the meter is nil. |
| 2405 |
if m == nil { |
| 2406 |
return HPAMetricTargetCPUAverageValue{noop.Int64Gauge{}}, nil |
| 2407 |
} |
| 2408 |
|
| 2409 |
i, err := m.Int64Gauge( |
| 2410 |
"k8s.hpa.metric.target.cpu.average_value", |
| 2411 |
append([]metric.Int64GaugeOption{ |
| 2412 |
metric.WithDescription("Target average value for CPU resource in HPA config."), |
| 2413 |
metric.WithUnit("{cpu}"), |
| 2414 |
}, opt...)..., |
| 2415 |
) |
| 2416 |
if err != nil { |
| 2417 |
return HPAMetricTargetCPUAverageValue{noop.Int64Gauge{}}, err |
| 2418 |
} |
| 2419 |
return HPAMetricTargetCPUAverageValue{i}, nil |
| 2420 |
} |
| 2421 |
|
| 2422 |
// Inst returns the underlying metric instrument. |
| 2423 |
func (m HPAMetricTargetCPUAverageValue) Inst() metric.Int64Gauge { |
| 2424 |
return m.Int64Gauge |
| 2425 |
} |
| 2426 |
|
| 2427 |
// Name returns the semantic convention name of the instrument. |
| 2428 |
func (HPAMetricTargetCPUAverageValue) Name() string { |
| 2429 |
return "k8s.hpa.metric.target.cpu.average_value" |
| 2430 |
} |
| 2431 |
|
| 2432 |
// Unit returns the semantic convention unit of the instrument |
| 2433 |
func (HPAMetricTargetCPUAverageValue) Unit() string { |
| 2434 |
return "{cpu}" |
| 2435 |
} |
| 2436 |
|
| 2437 |
// Description returns the semantic convention description of the instrument |
| 2438 |
func (HPAMetricTargetCPUAverageValue) Description() string { |
| 2439 |
return "Target average value for CPU resource in HPA config." |
| 2440 |
} |
| 2441 |
|
| 2442 |
// Record records val to the current distribution for attrs. |
| 2443 |
// |
| 2444 |
// All additional attrs passed are included in the recorded value. |
| 2445 |
// |
| 2446 |
// This metric aligns with the `averageValue` field of the |
| 2447 |
// [K8s HPA MetricTarget]. |
| 2448 |
// If the type of the metric is [`ContainerResource`], |
| 2449 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2450 |
// container within the pod to which the metric applies. |
| 2451 |
// |
| 2452 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2453 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2454 |
func (m HPAMetricTargetCPUAverageValue) Record( |
| 2455 |
ctx context.Context, |
| 2456 |
val int64, |
| 2457 |
attrs ...attribute.KeyValue, |
| 2458 |
) { |
| 2459 |
if len(attrs) == 0 { |
| 2460 |
m.Int64Gauge.Record(ctx, val) |
| 2461 |
return |
| 2462 |
} |
| 2463 |
|
| 2464 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2465 |
defer func() { |
| 2466 |
*o = (*o)[:0] |
| 2467 |
recOptPool.Put(o) |
| 2468 |
}() |
| 2469 |
|
| 2470 |
*o = append( |
| 2471 |
*o, |
| 2472 |
metric.WithAttributes( |
| 2473 |
attrs..., |
| 2474 |
), |
| 2475 |
) |
| 2476 |
|
| 2477 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2478 |
} |
| 2479 |
|
| 2480 |
// RecordSet records val to the current distribution for set. |
| 2481 |
// |
| 2482 |
// This metric aligns with the `averageValue` field of the |
| 2483 |
// [K8s HPA MetricTarget]. |
| 2484 |
// If the type of the metric is [`ContainerResource`], |
| 2485 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2486 |
// container within the pod to which the metric applies. |
| 2487 |
// |
| 2488 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2489 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2490 |
func (m HPAMetricTargetCPUAverageValue) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2491 |
if set.Len() == 0 { |
| 2492 |
m.Int64Gauge.Record(ctx, val) |
| 2493 |
return |
| 2494 |
} |
| 2495 |
|
| 2496 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2497 |
defer func() { |
| 2498 |
*o = (*o)[:0] |
| 2499 |
recOptPool.Put(o) |
| 2500 |
}() |
| 2501 |
|
| 2502 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2503 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2504 |
} |
| 2505 |
|
| 2506 |
// AttrContainerName returns an optional attribute for the "k8s.container.name" |
| 2507 |
// semantic convention. It represents the name of the Container from Pod |
| 2508 |
// specification, must be unique within a Pod. Container runtime usually uses |
| 2509 |
// different globally unique name (`container.name`). |
| 2510 |
func (HPAMetricTargetCPUAverageValue) AttrContainerName(val string) attribute.KeyValue { |
| 2511 |
return attribute.String("k8s.container.name", val) |
| 2512 |
} |
| 2513 |
|
| 2514 |
// AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type" |
| 2515 |
// semantic convention. It represents the type of metric source for the |
| 2516 |
// horizontal pod autoscaler. |
| 2517 |
func (HPAMetricTargetCPUAverageValue) AttrHPAMetricType(val string) attribute.KeyValue { |
| 2518 |
return attribute.String("k8s.hpa.metric.type", val) |
| 2519 |
} |
| 2520 |
|
| 2521 |
// HPAMetricTargetCPUValue is an instrument used to record metric values |
| 2522 |
// conforming to the "k8s.hpa.metric.target.cpu.value" semantic conventions. It |
| 2523 |
// represents the target value for CPU resource in HPA config. |
| 2524 |
type HPAMetricTargetCPUValue struct { |
| 2525 |
metric.Int64Gauge |
| 2526 |
} |
| 2527 |
|
| 2528 |
// NewHPAMetricTargetCPUValue returns a new HPAMetricTargetCPUValue instrument. |
| 2529 |
func NewHPAMetricTargetCPUValue( |
| 2530 |
m metric.Meter, |
| 2531 |
opt ...metric.Int64GaugeOption, |
| 2532 |
) (HPAMetricTargetCPUValue, error) { |
| 2533 |
// Check if the meter is nil. |
| 2534 |
if m == nil { |
| 2535 |
return HPAMetricTargetCPUValue{noop.Int64Gauge{}}, nil |
| 2536 |
} |
| 2537 |
|
| 2538 |
i, err := m.Int64Gauge( |
| 2539 |
"k8s.hpa.metric.target.cpu.value", |
| 2540 |
append([]metric.Int64GaugeOption{ |
| 2541 |
metric.WithDescription("Target value for CPU resource in HPA config."), |
| 2542 |
metric.WithUnit("{cpu}"), |
| 2543 |
}, opt...)..., |
| 2544 |
) |
| 2545 |
if err != nil { |
| 2546 |
return HPAMetricTargetCPUValue{noop.Int64Gauge{}}, err |
| 2547 |
} |
| 2548 |
return HPAMetricTargetCPUValue{i}, nil |
| 2549 |
} |
| 2550 |
|
| 2551 |
// Inst returns the underlying metric instrument. |
| 2552 |
func (m HPAMetricTargetCPUValue) Inst() metric.Int64Gauge { |
| 2553 |
return m.Int64Gauge |
| 2554 |
} |
| 2555 |
|
| 2556 |
// Name returns the semantic convention name of the instrument. |
| 2557 |
func (HPAMetricTargetCPUValue) Name() string { |
| 2558 |
return "k8s.hpa.metric.target.cpu.value" |
| 2559 |
} |
| 2560 |
|
| 2561 |
// Unit returns the semantic convention unit of the instrument |
| 2562 |
func (HPAMetricTargetCPUValue) Unit() string { |
| 2563 |
return "{cpu}" |
| 2564 |
} |
| 2565 |
|
| 2566 |
// Description returns the semantic convention description of the instrument |
| 2567 |
func (HPAMetricTargetCPUValue) Description() string { |
| 2568 |
return "Target value for CPU resource in HPA config." |
| 2569 |
} |
| 2570 |
|
| 2571 |
// Record records val to the current distribution for attrs. |
| 2572 |
// |
| 2573 |
// All additional attrs passed are included in the recorded value. |
| 2574 |
// |
| 2575 |
// This metric aligns with the `value` field of the |
| 2576 |
// [K8s HPA MetricTarget]. |
| 2577 |
// If the type of the metric is [`ContainerResource`], |
| 2578 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2579 |
// container within the pod to which the metric applies. |
| 2580 |
// |
| 2581 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2582 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2583 |
func (m HPAMetricTargetCPUValue) Record( |
| 2584 |
ctx context.Context, |
| 2585 |
val int64, |
| 2586 |
attrs ...attribute.KeyValue, |
| 2587 |
) { |
| 2588 |
if len(attrs) == 0 { |
| 2589 |
m.Int64Gauge.Record(ctx, val) |
| 2590 |
return |
| 2591 |
} |
| 2592 |
|
| 2593 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2594 |
defer func() { |
| 2595 |
*o = (*o)[:0] |
| 2596 |
recOptPool.Put(o) |
| 2597 |
}() |
| 2598 |
|
| 2599 |
*o = append( |
| 2600 |
*o, |
| 2601 |
metric.WithAttributes( |
| 2602 |
attrs..., |
| 2603 |
), |
| 2604 |
) |
| 2605 |
|
| 2606 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2607 |
} |
| 2608 |
|
| 2609 |
// RecordSet records val to the current distribution for set. |
| 2610 |
// |
| 2611 |
// This metric aligns with the `value` field of the |
| 2612 |
// [K8s HPA MetricTarget]. |
| 2613 |
// If the type of the metric is [`ContainerResource`], |
| 2614 |
// the `k8s.container.name` attribute MUST be set to identify the specific |
| 2615 |
// container within the pod to which the metric applies. |
| 2616 |
// |
| 2617 |
// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling |
| 2618 |
// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis |
| 2619 |
func (m HPAMetricTargetCPUValue) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2620 |
if set.Len() == 0 { |
| 2621 |
m.Int64Gauge.Record(ctx, val) |
| 2622 |
return |
| 2623 |
} |
| 2624 |
|
| 2625 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2626 |
defer func() { |
| 2627 |
*o = (*o)[:0] |
| 2628 |
recOptPool.Put(o) |
| 2629 |
}() |
| 2630 |
|
| 2631 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2632 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2633 |
} |
| 2634 |
|
| 2635 |
// AttrContainerName returns an optional attribute for the "k8s.container.name" |
| 2636 |
// semantic convention. It represents the name of the Container from Pod |
| 2637 |
// specification, must be unique within a Pod. Container runtime usually uses |
| 2638 |
// different globally unique name (`container.name`). |
| 2639 |
func (HPAMetricTargetCPUValue) AttrContainerName(val string) attribute.KeyValue { |
| 2640 |
return attribute.String("k8s.container.name", val) |
| 2641 |
} |
| 2642 |
|
| 2643 |
// AttrHPAMetricType returns an optional attribute for the "k8s.hpa.metric.type" |
| 2644 |
// semantic convention. It represents the type of metric source for the |
| 2645 |
// horizontal pod autoscaler. |
| 2646 |
func (HPAMetricTargetCPUValue) AttrHPAMetricType(val string) attribute.KeyValue { |
| 2647 |
return attribute.String("k8s.hpa.metric.type", val) |
| 2648 |
} |
| 2649 |
|
| 2650 |
// HPAMinPods is an instrument used to record metric values conforming to the |
| 2651 |
// "k8s.hpa.min_pods" semantic conventions. It represents the lower limit for the |
| 2652 |
// number of replica pods to which the autoscaler can scale down. |
| 2653 |
type HPAMinPods struct { |
| 2654 |
metric.Int64UpDownCounter |
| 2655 |
} |
| 2656 |
|
| 2657 |
// NewHPAMinPods returns a new HPAMinPods instrument. |
| 2658 |
func NewHPAMinPods( |
| 2659 |
m metric.Meter, |
| 2660 |
opt ...metric.Int64UpDownCounterOption, |
| 2661 |
) (HPAMinPods, error) { |
| 2662 |
// Check if the meter is nil. |
| 2663 |
if m == nil { |
| 2664 |
return HPAMinPods{noop.Int64UpDownCounter{}}, nil |
| 2665 |
} |
| 2666 |
|
| 2667 |
i, err := m.Int64UpDownCounter( |
| 2668 |
"k8s.hpa.min_pods", |
| 2669 |
append([]metric.Int64UpDownCounterOption{ |
| 2670 |
metric.WithDescription("The lower limit for the number of replica pods to which the autoscaler can scale down"), |
| 2671 |
metric.WithUnit("{pod}"), |
| 2672 |
}, opt...)..., |
| 2673 |
) |
| 2674 |
if err != nil { |
| 2675 |
return HPAMinPods{noop.Int64UpDownCounter{}}, err |
| 2676 |
} |
| 2677 |
return HPAMinPods{i}, nil |
| 2678 |
} |
| 2679 |
|
| 2680 |
// Inst returns the underlying metric instrument. |
| 2681 |
func (m HPAMinPods) Inst() metric.Int64UpDownCounter { |
| 2682 |
return m.Int64UpDownCounter |
| 2683 |
} |
| 2684 |
|
| 2685 |
// Name returns the semantic convention name of the instrument. |
| 2686 |
func (HPAMinPods) Name() string { |
| 2687 |
return "k8s.hpa.min_pods" |
| 2688 |
} |
| 2689 |
|
| 2690 |
// Unit returns the semantic convention unit of the instrument |
| 2691 |
func (HPAMinPods) Unit() string { |
| 2692 |
return "{pod}" |
| 2693 |
} |
| 2694 |
|
| 2695 |
// Description returns the semantic convention description of the instrument |
| 2696 |
func (HPAMinPods) Description() string { |
| 2697 |
return "The lower limit for the number of replica pods to which the autoscaler can scale down" |
| 2698 |
} |
| 2699 |
|
| 2700 |
// Add adds incr to the existing count for attrs. |
| 2701 |
// |
| 2702 |
// This metric aligns with the `minReplicas` field of the |
| 2703 |
// [K8s HorizontalPodAutoscalerSpec] |
| 2704 |
// |
| 2705 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 2706 |
func (m HPAMinPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2707 |
if len(attrs) == 0 { |
| 2708 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2709 |
return |
| 2710 |
} |
| 2711 |
|
| 2712 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2713 |
defer func() { |
| 2714 |
*o = (*o)[:0] |
| 2715 |
addOptPool.Put(o) |
| 2716 |
}() |
| 2717 |
|
| 2718 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2719 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2720 |
} |
| 2721 |
|
| 2722 |
// AddSet adds incr to the existing count for set. |
| 2723 |
// |
| 2724 |
// This metric aligns with the `minReplicas` field of the |
| 2725 |
// [K8s HorizontalPodAutoscalerSpec] |
| 2726 |
// |
| 2727 |
// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling |
| 2728 |
func (m HPAMinPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2729 |
if set.Len() == 0 { |
| 2730 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2731 |
return |
| 2732 |
} |
| 2733 |
|
| 2734 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2735 |
defer func() { |
| 2736 |
*o = (*o)[:0] |
| 2737 |
addOptPool.Put(o) |
| 2738 |
}() |
| 2739 |
|
| 2740 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2741 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2742 |
} |
| 2743 |
|
| 2744 |
// JobActivePods is an instrument used to record metric values conforming to the |
| 2745 |
// "k8s.job.active_pods" semantic conventions. It represents the number of |
| 2746 |
// pending and actively running pods for a job. |
| 2747 |
type JobActivePods struct { |
| 2748 |
metric.Int64UpDownCounter |
| 2749 |
} |
| 2750 |
|
| 2751 |
// NewJobActivePods returns a new JobActivePods instrument. |
| 2752 |
func NewJobActivePods( |
| 2753 |
m metric.Meter, |
| 2754 |
opt ...metric.Int64UpDownCounterOption, |
| 2755 |
) (JobActivePods, error) { |
| 2756 |
// Check if the meter is nil. |
| 2757 |
if m == nil { |
| 2758 |
return JobActivePods{noop.Int64UpDownCounter{}}, nil |
| 2759 |
} |
| 2760 |
|
| 2761 |
i, err := m.Int64UpDownCounter( |
| 2762 |
"k8s.job.active_pods", |
| 2763 |
append([]metric.Int64UpDownCounterOption{ |
| 2764 |
metric.WithDescription("The number of pending and actively running pods for a job"), |
| 2765 |
metric.WithUnit("{pod}"), |
| 2766 |
}, opt...)..., |
| 2767 |
) |
| 2768 |
if err != nil { |
| 2769 |
return JobActivePods{noop.Int64UpDownCounter{}}, err |
| 2770 |
} |
| 2771 |
return JobActivePods{i}, nil |
| 2772 |
} |
| 2773 |
|
| 2774 |
// Inst returns the underlying metric instrument. |
| 2775 |
func (m JobActivePods) Inst() metric.Int64UpDownCounter { |
| 2776 |
return m.Int64UpDownCounter |
| 2777 |
} |
| 2778 |
|
| 2779 |
// Name returns the semantic convention name of the instrument. |
| 2780 |
func (JobActivePods) Name() string { |
| 2781 |
return "k8s.job.active_pods" |
| 2782 |
} |
| 2783 |
|
| 2784 |
// Unit returns the semantic convention unit of the instrument |
| 2785 |
func (JobActivePods) Unit() string { |
| 2786 |
return "{pod}" |
| 2787 |
} |
| 2788 |
|
| 2789 |
// Description returns the semantic convention description of the instrument |
| 2790 |
func (JobActivePods) Description() string { |
| 2791 |
return "The number of pending and actively running pods for a job" |
| 2792 |
} |
| 2793 |
|
| 2794 |
// Add adds incr to the existing count for attrs. |
| 2795 |
// |
| 2796 |
// This metric aligns with the `active` field of the |
| 2797 |
// [K8s JobStatus]. |
| 2798 |
// |
| 2799 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 2800 |
func (m JobActivePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2801 |
if len(attrs) == 0 { |
| 2802 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2803 |
return |
| 2804 |
} |
| 2805 |
|
| 2806 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2807 |
defer func() { |
| 2808 |
*o = (*o)[:0] |
| 2809 |
addOptPool.Put(o) |
| 2810 |
}() |
| 2811 |
|
| 2812 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2813 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2814 |
} |
| 2815 |
|
| 2816 |
// AddSet adds incr to the existing count for set. |
| 2817 |
// |
| 2818 |
// This metric aligns with the `active` field of the |
| 2819 |
// [K8s JobStatus]. |
| 2820 |
// |
| 2821 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 2822 |
func (m JobActivePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2823 |
if set.Len() == 0 { |
| 2824 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2825 |
return |
| 2826 |
} |
| 2827 |
|
| 2828 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2829 |
defer func() { |
| 2830 |
*o = (*o)[:0] |
| 2831 |
addOptPool.Put(o) |
| 2832 |
}() |
| 2833 |
|
| 2834 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2835 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2836 |
} |
| 2837 |
|
| 2838 |
// JobDesiredSuccessfulPods is an instrument used to record metric values |
| 2839 |
// conforming to the "k8s.job.desired_successful_pods" semantic conventions. It |
| 2840 |
// represents the desired number of successfully finished pods the job should be |
| 2841 |
// run with. |
| 2842 |
type JobDesiredSuccessfulPods struct { |
| 2843 |
metric.Int64UpDownCounter |
| 2844 |
} |
| 2845 |
|
| 2846 |
// NewJobDesiredSuccessfulPods returns a new JobDesiredSuccessfulPods instrument. |
| 2847 |
func NewJobDesiredSuccessfulPods( |
| 2848 |
m metric.Meter, |
| 2849 |
opt ...metric.Int64UpDownCounterOption, |
| 2850 |
) (JobDesiredSuccessfulPods, error) { |
| 2851 |
// Check if the meter is nil. |
| 2852 |
if m == nil { |
| 2853 |
return JobDesiredSuccessfulPods{noop.Int64UpDownCounter{}}, nil |
| 2854 |
} |
| 2855 |
|
| 2856 |
i, err := m.Int64UpDownCounter( |
| 2857 |
"k8s.job.desired_successful_pods", |
| 2858 |
append([]metric.Int64UpDownCounterOption{ |
| 2859 |
metric.WithDescription("The desired number of successfully finished pods the job should be run with"), |
| 2860 |
metric.WithUnit("{pod}"), |
| 2861 |
}, opt...)..., |
| 2862 |
) |
| 2863 |
if err != nil { |
| 2864 |
return JobDesiredSuccessfulPods{noop.Int64UpDownCounter{}}, err |
| 2865 |
} |
| 2866 |
return JobDesiredSuccessfulPods{i}, nil |
| 2867 |
} |
| 2868 |
|
| 2869 |
// Inst returns the underlying metric instrument. |
| 2870 |
func (m JobDesiredSuccessfulPods) Inst() metric.Int64UpDownCounter { |
| 2871 |
return m.Int64UpDownCounter |
| 2872 |
} |
| 2873 |
|
| 2874 |
// Name returns the semantic convention name of the instrument. |
| 2875 |
func (JobDesiredSuccessfulPods) Name() string { |
| 2876 |
return "k8s.job.desired_successful_pods" |
| 2877 |
} |
| 2878 |
|
| 2879 |
// Unit returns the semantic convention unit of the instrument |
| 2880 |
func (JobDesiredSuccessfulPods) Unit() string { |
| 2881 |
return "{pod}" |
| 2882 |
} |
| 2883 |
|
| 2884 |
// Description returns the semantic convention description of the instrument |
| 2885 |
func (JobDesiredSuccessfulPods) Description() string { |
| 2886 |
return "The desired number of successfully finished pods the job should be run with" |
| 2887 |
} |
| 2888 |
|
| 2889 |
// Add adds incr to the existing count for attrs. |
| 2890 |
// |
| 2891 |
// This metric aligns with the `completions` field of the |
| 2892 |
// [K8s JobSpec].. |
| 2893 |
// |
| 2894 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 2895 |
func (m JobDesiredSuccessfulPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2896 |
if len(attrs) == 0 { |
| 2897 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2898 |
return |
| 2899 |
} |
| 2900 |
|
| 2901 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2902 |
defer func() { |
| 2903 |
*o = (*o)[:0] |
| 2904 |
addOptPool.Put(o) |
| 2905 |
}() |
| 2906 |
|
| 2907 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 2908 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2909 |
} |
| 2910 |
|
| 2911 |
// AddSet adds incr to the existing count for set. |
| 2912 |
// |
| 2913 |
// This metric aligns with the `completions` field of the |
| 2914 |
// [K8s JobSpec].. |
| 2915 |
// |
| 2916 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 2917 |
func (m JobDesiredSuccessfulPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2918 |
if set.Len() == 0 { |
| 2919 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2920 |
return |
| 2921 |
} |
| 2922 |
|
| 2923 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2924 |
defer func() { |
| 2925 |
*o = (*o)[:0] |
| 2926 |
addOptPool.Put(o) |
| 2927 |
}() |
| 2928 |
|
| 2929 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2930 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2931 |
} |
| 2932 |
|
| 2933 |
// JobFailedPods is an instrument used to record metric values conforming to the |
| 2934 |
// "k8s.job.failed_pods" semantic conventions. It represents the number of pods |
| 2935 |
// which reached phase Failed for a job. |
| 2936 |
type JobFailedPods struct { |
| 2937 |
metric.Int64UpDownCounter |
| 2938 |
} |
| 2939 |
|
| 2940 |
// NewJobFailedPods returns a new JobFailedPods instrument. |
| 2941 |
func NewJobFailedPods( |
| 2942 |
m metric.Meter, |
| 2943 |
opt ...metric.Int64UpDownCounterOption, |
| 2944 |
) (JobFailedPods, error) { |
| 2945 |
// Check if the meter is nil. |
| 2946 |
if m == nil { |
| 2947 |
return JobFailedPods{noop.Int64UpDownCounter{}}, nil |
| 2948 |
} |
| 2949 |
|
| 2950 |
i, err := m.Int64UpDownCounter( |
| 2951 |
"k8s.job.failed_pods", |
| 2952 |
append([]metric.Int64UpDownCounterOption{ |
| 2953 |
metric.WithDescription("The number of pods which reached phase Failed for a job"), |
| 2954 |
metric.WithUnit("{pod}"), |
| 2955 |
}, opt...)..., |
| 2956 |
) |
| 2957 |
if err != nil { |
| 2958 |
return JobFailedPods{noop.Int64UpDownCounter{}}, err |
| 2959 |
} |
| 2960 |
return JobFailedPods{i}, nil |
| 2961 |
} |
| 2962 |
|
| 2963 |
// Inst returns the underlying metric instrument. |
| 2964 |
func (m JobFailedPods) Inst() metric.Int64UpDownCounter { |
| 2965 |
return m.Int64UpDownCounter |
| 2966 |
} |
| 2967 |
|
| 2968 |
// Name returns the semantic convention name of the instrument. |
| 2969 |
func (JobFailedPods) Name() string { |
| 2970 |
return "k8s.job.failed_pods" |
| 2971 |
} |
| 2972 |
|
| 2973 |
// Unit returns the semantic convention unit of the instrument |
| 2974 |
func (JobFailedPods) Unit() string { |
| 2975 |
return "{pod}" |
| 2976 |
} |
| 2977 |
|
| 2978 |
// Description returns the semantic convention description of the instrument |
| 2979 |
func (JobFailedPods) Description() string { |
| 2980 |
return "The number of pods which reached phase Failed for a job" |
| 2981 |
} |
| 2982 |
|
| 2983 |
// Add adds incr to the existing count for attrs. |
| 2984 |
// |
| 2985 |
// This metric aligns with the `failed` field of the |
| 2986 |
// [K8s JobStatus]. |
| 2987 |
// |
| 2988 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 2989 |
func (m JobFailedPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 2990 |
if len(attrs) == 0 { |
| 2991 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2992 |
return |
| 2993 |
} |
| 2994 |
|
| 2995 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2996 |
defer func() { |
| 2997 |
*o = (*o)[:0] |
| 2998 |
addOptPool.Put(o) |
| 2999 |
}() |
| 3000 |
|
| 3001 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3002 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3003 |
} |
| 3004 |
|
| 3005 |
// AddSet adds incr to the existing count for set. |
| 3006 |
// |
| 3007 |
// This metric aligns with the `failed` field of the |
| 3008 |
// [K8s JobStatus]. |
| 3009 |
// |
| 3010 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3011 |
func (m JobFailedPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3012 |
if set.Len() == 0 { |
| 3013 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3014 |
return |
| 3015 |
} |
| 3016 |
|
| 3017 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3018 |
defer func() { |
| 3019 |
*o = (*o)[:0] |
| 3020 |
addOptPool.Put(o) |
| 3021 |
}() |
| 3022 |
|
| 3023 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3024 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3025 |
} |
| 3026 |
|
| 3027 |
// JobMaxParallelPods is an instrument used to record metric values conforming to |
| 3028 |
// the "k8s.job.max_parallel_pods" semantic conventions. It represents the max |
| 3029 |
// desired number of pods the job should run at any given time. |
| 3030 |
type JobMaxParallelPods struct { |
| 3031 |
metric.Int64UpDownCounter |
| 3032 |
} |
| 3033 |
|
| 3034 |
// NewJobMaxParallelPods returns a new JobMaxParallelPods instrument. |
| 3035 |
func NewJobMaxParallelPods( |
| 3036 |
m metric.Meter, |
| 3037 |
opt ...metric.Int64UpDownCounterOption, |
| 3038 |
) (JobMaxParallelPods, error) { |
| 3039 |
// Check if the meter is nil. |
| 3040 |
if m == nil { |
| 3041 |
return JobMaxParallelPods{noop.Int64UpDownCounter{}}, nil |
| 3042 |
} |
| 3043 |
|
| 3044 |
i, err := m.Int64UpDownCounter( |
| 3045 |
"k8s.job.max_parallel_pods", |
| 3046 |
append([]metric.Int64UpDownCounterOption{ |
| 3047 |
metric.WithDescription("The max desired number of pods the job should run at any given time"), |
| 3048 |
metric.WithUnit("{pod}"), |
| 3049 |
}, opt...)..., |
| 3050 |
) |
| 3051 |
if err != nil { |
| 3052 |
return JobMaxParallelPods{noop.Int64UpDownCounter{}}, err |
| 3053 |
} |
| 3054 |
return JobMaxParallelPods{i}, nil |
| 3055 |
} |
| 3056 |
|
| 3057 |
// Inst returns the underlying metric instrument. |
| 3058 |
func (m JobMaxParallelPods) Inst() metric.Int64UpDownCounter { |
| 3059 |
return m.Int64UpDownCounter |
| 3060 |
} |
| 3061 |
|
| 3062 |
// Name returns the semantic convention name of the instrument. |
| 3063 |
func (JobMaxParallelPods) Name() string { |
| 3064 |
return "k8s.job.max_parallel_pods" |
| 3065 |
} |
| 3066 |
|
| 3067 |
// Unit returns the semantic convention unit of the instrument |
| 3068 |
func (JobMaxParallelPods) Unit() string { |
| 3069 |
return "{pod}" |
| 3070 |
} |
| 3071 |
|
| 3072 |
// Description returns the semantic convention description of the instrument |
| 3073 |
func (JobMaxParallelPods) Description() string { |
| 3074 |
return "The max desired number of pods the job should run at any given time" |
| 3075 |
} |
| 3076 |
|
| 3077 |
// Add adds incr to the existing count for attrs. |
| 3078 |
// |
| 3079 |
// This metric aligns with the `parallelism` field of the |
| 3080 |
// [K8s JobSpec]. |
| 3081 |
// |
| 3082 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 3083 |
func (m JobMaxParallelPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3084 |
if len(attrs) == 0 { |
| 3085 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3086 |
return |
| 3087 |
} |
| 3088 |
|
| 3089 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3090 |
defer func() { |
| 3091 |
*o = (*o)[:0] |
| 3092 |
addOptPool.Put(o) |
| 3093 |
}() |
| 3094 |
|
| 3095 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3096 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3097 |
} |
| 3098 |
|
| 3099 |
// AddSet adds incr to the existing count for set. |
| 3100 |
// |
| 3101 |
// This metric aligns with the `parallelism` field of the |
| 3102 |
// [K8s JobSpec]. |
| 3103 |
// |
| 3104 |
// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch |
| 3105 |
func (m JobMaxParallelPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3106 |
if set.Len() == 0 { |
| 3107 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3108 |
return |
| 3109 |
} |
| 3110 |
|
| 3111 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3112 |
defer func() { |
| 3113 |
*o = (*o)[:0] |
| 3114 |
addOptPool.Put(o) |
| 3115 |
}() |
| 3116 |
|
| 3117 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3118 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3119 |
} |
| 3120 |
|
| 3121 |
// JobSuccessfulPods is an instrument used to record metric values conforming to |
| 3122 |
// the "k8s.job.successful_pods" semantic conventions. It represents the number |
| 3123 |
// of pods which reached phase Succeeded for a job. |
| 3124 |
type JobSuccessfulPods struct { |
| 3125 |
metric.Int64UpDownCounter |
| 3126 |
} |
| 3127 |
|
| 3128 |
// NewJobSuccessfulPods returns a new JobSuccessfulPods instrument. |
| 3129 |
func NewJobSuccessfulPods( |
| 3130 |
m metric.Meter, |
| 3131 |
opt ...metric.Int64UpDownCounterOption, |
| 3132 |
) (JobSuccessfulPods, error) { |
| 3133 |
// Check if the meter is nil. |
| 3134 |
if m == nil { |
| 3135 |
return JobSuccessfulPods{noop.Int64UpDownCounter{}}, nil |
| 3136 |
} |
| 3137 |
|
| 3138 |
i, err := m.Int64UpDownCounter( |
| 3139 |
"k8s.job.successful_pods", |
| 3140 |
append([]metric.Int64UpDownCounterOption{ |
| 3141 |
metric.WithDescription("The number of pods which reached phase Succeeded for a job"), |
| 3142 |
metric.WithUnit("{pod}"), |
| 3143 |
}, opt...)..., |
| 3144 |
) |
| 3145 |
if err != nil { |
| 3146 |
return JobSuccessfulPods{noop.Int64UpDownCounter{}}, err |
| 3147 |
} |
| 3148 |
return JobSuccessfulPods{i}, nil |
| 3149 |
} |
| 3150 |
|
| 3151 |
// Inst returns the underlying metric instrument. |
| 3152 |
func (m JobSuccessfulPods) Inst() metric.Int64UpDownCounter { |
| 3153 |
return m.Int64UpDownCounter |
| 3154 |
} |
| 3155 |
|
| 3156 |
// Name returns the semantic convention name of the instrument. |
| 3157 |
func (JobSuccessfulPods) Name() string { |
| 3158 |
return "k8s.job.successful_pods" |
| 3159 |
} |
| 3160 |
|
| 3161 |
// Unit returns the semantic convention unit of the instrument |
| 3162 |
func (JobSuccessfulPods) Unit() string { |
| 3163 |
return "{pod}" |
| 3164 |
} |
| 3165 |
|
| 3166 |
// Description returns the semantic convention description of the instrument |
| 3167 |
func (JobSuccessfulPods) Description() string { |
| 3168 |
return "The number of pods which reached phase Succeeded for a job" |
| 3169 |
} |
| 3170 |
|
| 3171 |
// Add adds incr to the existing count for attrs. |
| 3172 |
// |
| 3173 |
// This metric aligns with the `succeeded` field of the |
| 3174 |
// [K8s JobStatus]. |
| 3175 |
// |
| 3176 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3177 |
func (m JobSuccessfulPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3178 |
if len(attrs) == 0 { |
| 3179 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3180 |
return |
| 3181 |
} |
| 3182 |
|
| 3183 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3184 |
defer func() { |
| 3185 |
*o = (*o)[:0] |
| 3186 |
addOptPool.Put(o) |
| 3187 |
}() |
| 3188 |
|
| 3189 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3190 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3191 |
} |
| 3192 |
|
| 3193 |
// AddSet adds incr to the existing count for set. |
| 3194 |
// |
| 3195 |
// This metric aligns with the `succeeded` field of the |
| 3196 |
// [K8s JobStatus]. |
| 3197 |
// |
| 3198 |
// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch |
| 3199 |
func (m JobSuccessfulPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3200 |
if set.Len() == 0 { |
| 3201 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3202 |
return |
| 3203 |
} |
| 3204 |
|
| 3205 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3206 |
defer func() { |
| 3207 |
*o = (*o)[:0] |
| 3208 |
addOptPool.Put(o) |
| 3209 |
}() |
| 3210 |
|
| 3211 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3212 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3213 |
} |
| 3214 |
|
| 3215 |
// NamespacePhase is an instrument used to record metric values conforming to the |
| 3216 |
// "k8s.namespace.phase" semantic conventions. It represents the describes number |
| 3217 |
// of K8s namespaces that are currently in a given phase. |
| 3218 |
type NamespacePhase struct { |
| 3219 |
metric.Int64UpDownCounter |
| 3220 |
} |
| 3221 |
|
| 3222 |
// NewNamespacePhase returns a new NamespacePhase instrument. |
| 3223 |
func NewNamespacePhase( |
| 3224 |
m metric.Meter, |
| 3225 |
opt ...metric.Int64UpDownCounterOption, |
| 3226 |
) (NamespacePhase, error) { |
| 3227 |
// Check if the meter is nil. |
| 3228 |
if m == nil { |
| 3229 |
return NamespacePhase{noop.Int64UpDownCounter{}}, nil |
| 3230 |
} |
| 3231 |
|
| 3232 |
i, err := m.Int64UpDownCounter( |
| 3233 |
"k8s.namespace.phase", |
| 3234 |
append([]metric.Int64UpDownCounterOption{ |
| 3235 |
metric.WithDescription("Describes number of K8s namespaces that are currently in a given phase."), |
| 3236 |
metric.WithUnit("{namespace}"), |
| 3237 |
}, opt...)..., |
| 3238 |
) |
| 3239 |
if err != nil { |
| 3240 |
return NamespacePhase{noop.Int64UpDownCounter{}}, err |
| 3241 |
} |
| 3242 |
return NamespacePhase{i}, nil |
| 3243 |
} |
| 3244 |
|
| 3245 |
// Inst returns the underlying metric instrument. |
| 3246 |
func (m NamespacePhase) Inst() metric.Int64UpDownCounter { |
| 3247 |
return m.Int64UpDownCounter |
| 3248 |
} |
| 3249 |
|
| 3250 |
// Name returns the semantic convention name of the instrument. |
| 3251 |
func (NamespacePhase) Name() string { |
| 3252 |
return "k8s.namespace.phase" |
| 3253 |
} |
| 3254 |
|
| 3255 |
// Unit returns the semantic convention unit of the instrument |
| 3256 |
func (NamespacePhase) Unit() string { |
| 3257 |
return "{namespace}" |
| 3258 |
} |
| 3259 |
|
| 3260 |
// Description returns the semantic convention description of the instrument |
| 3261 |
func (NamespacePhase) Description() string { |
| 3262 |
return "Describes number of K8s namespaces that are currently in a given phase." |
| 3263 |
} |
| 3264 |
|
| 3265 |
// Add adds incr to the existing count for attrs. |
| 3266 |
// |
| 3267 |
// The namespacePhase is the the phase of the K8s namespace. |
| 3268 |
func (m NamespacePhase) Add( |
| 3269 |
ctx context.Context, |
| 3270 |
incr int64, |
| 3271 |
namespacePhase NamespacePhaseAttr, |
| 3272 |
attrs ...attribute.KeyValue, |
| 3273 |
) { |
| 3274 |
if len(attrs) == 0 { |
| 3275 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3276 |
return |
| 3277 |
} |
| 3278 |
|
| 3279 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3280 |
defer func() { |
| 3281 |
*o = (*o)[:0] |
| 3282 |
addOptPool.Put(o) |
| 3283 |
}() |
| 3284 |
|
| 3285 |
*o = append( |
| 3286 |
*o, |
| 3287 |
metric.WithAttributes( |
| 3288 |
append( |
| 3289 |
attrs, |
| 3290 |
attribute.String("k8s.namespace.phase", string(namespacePhase)), |
| 3291 |
)..., |
| 3292 |
), |
| 3293 |
) |
| 3294 |
|
| 3295 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3296 |
} |
| 3297 |
|
| 3298 |
// AddSet adds incr to the existing count for set. |
| 3299 |
func (m NamespacePhase) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3300 |
if set.Len() == 0 { |
| 3301 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3302 |
return |
| 3303 |
} |
| 3304 |
|
| 3305 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3306 |
defer func() { |
| 3307 |
*o = (*o)[:0] |
| 3308 |
addOptPool.Put(o) |
| 3309 |
}() |
| 3310 |
|
| 3311 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3312 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3313 |
} |
| 3314 |
|
| 3315 |
// NodeAllocatableCPU is an instrument used to record metric values conforming to |
| 3316 |
// the "k8s.node.allocatable.cpu" semantic conventions. It represents the amount |
| 3317 |
// of cpu allocatable on the node. |
| 3318 |
type NodeAllocatableCPU struct { |
| 3319 |
metric.Int64UpDownCounter |
| 3320 |
} |
| 3321 |
|
| 3322 |
// NewNodeAllocatableCPU returns a new NodeAllocatableCPU instrument. |
| 3323 |
func NewNodeAllocatableCPU( |
| 3324 |
m metric.Meter, |
| 3325 |
opt ...metric.Int64UpDownCounterOption, |
| 3326 |
) (NodeAllocatableCPU, error) { |
| 3327 |
// Check if the meter is nil. |
| 3328 |
if m == nil { |
| 3329 |
return NodeAllocatableCPU{noop.Int64UpDownCounter{}}, nil |
| 3330 |
} |
| 3331 |
|
| 3332 |
i, err := m.Int64UpDownCounter( |
| 3333 |
"k8s.node.allocatable.cpu", |
| 3334 |
append([]metric.Int64UpDownCounterOption{ |
| 3335 |
metric.WithDescription("Amount of cpu allocatable on the node"), |
| 3336 |
metric.WithUnit("{cpu}"), |
| 3337 |
}, opt...)..., |
| 3338 |
) |
| 3339 |
if err != nil { |
| 3340 |
return NodeAllocatableCPU{noop.Int64UpDownCounter{}}, err |
| 3341 |
} |
| 3342 |
return NodeAllocatableCPU{i}, nil |
| 3343 |
} |
| 3344 |
|
| 3345 |
// Inst returns the underlying metric instrument. |
| 3346 |
func (m NodeAllocatableCPU) Inst() metric.Int64UpDownCounter { |
| 3347 |
return m.Int64UpDownCounter |
| 3348 |
} |
| 3349 |
|
| 3350 |
// Name returns the semantic convention name of the instrument. |
| 3351 |
func (NodeAllocatableCPU) Name() string { |
| 3352 |
return "k8s.node.allocatable.cpu" |
| 3353 |
} |
| 3354 |
|
| 3355 |
// Unit returns the semantic convention unit of the instrument |
| 3356 |
func (NodeAllocatableCPU) Unit() string { |
| 3357 |
return "{cpu}" |
| 3358 |
} |
| 3359 |
|
| 3360 |
// Description returns the semantic convention description of the instrument |
| 3361 |
func (NodeAllocatableCPU) Description() string { |
| 3362 |
return "Amount of cpu allocatable on the node" |
| 3363 |
} |
| 3364 |
|
| 3365 |
// Add adds incr to the existing count for attrs. |
| 3366 |
func (m NodeAllocatableCPU) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3367 |
if len(attrs) == 0 { |
| 3368 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3369 |
return |
| 3370 |
} |
| 3371 |
|
| 3372 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3373 |
defer func() { |
| 3374 |
*o = (*o)[:0] |
| 3375 |
addOptPool.Put(o) |
| 3376 |
}() |
| 3377 |
|
| 3378 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3379 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3380 |
} |
| 3381 |
|
| 3382 |
// AddSet adds incr to the existing count for set. |
| 3383 |
func (m NodeAllocatableCPU) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3384 |
if set.Len() == 0 { |
| 3385 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3386 |
return |
| 3387 |
} |
| 3388 |
|
| 3389 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3390 |
defer func() { |
| 3391 |
*o = (*o)[:0] |
| 3392 |
addOptPool.Put(o) |
| 3393 |
}() |
| 3394 |
|
| 3395 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3396 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3397 |
} |
| 3398 |
|
| 3399 |
// NodeAllocatableEphemeralStorage is an instrument used to record metric values |
| 3400 |
// conforming to the "k8s.node.allocatable.ephemeral_storage" semantic |
| 3401 |
// conventions. It represents the amount of ephemeral-storage allocatable on the |
| 3402 |
// node. |
| 3403 |
type NodeAllocatableEphemeralStorage struct { |
| 3404 |
metric.Int64UpDownCounter |
| 3405 |
} |
| 3406 |
|
| 3407 |
// NewNodeAllocatableEphemeralStorage returns a new |
| 3408 |
// NodeAllocatableEphemeralStorage instrument. |
| 3409 |
func NewNodeAllocatableEphemeralStorage( |
| 3410 |
m metric.Meter, |
| 3411 |
opt ...metric.Int64UpDownCounterOption, |
| 3412 |
) (NodeAllocatableEphemeralStorage, error) { |
| 3413 |
// Check if the meter is nil. |
| 3414 |
if m == nil { |
| 3415 |
return NodeAllocatableEphemeralStorage{noop.Int64UpDownCounter{}}, nil |
| 3416 |
} |
| 3417 |
|
| 3418 |
i, err := m.Int64UpDownCounter( |
| 3419 |
"k8s.node.allocatable.ephemeral_storage", |
| 3420 |
append([]metric.Int64UpDownCounterOption{ |
| 3421 |
metric.WithDescription("Amount of ephemeral-storage allocatable on the node"), |
| 3422 |
metric.WithUnit("By"), |
| 3423 |
}, opt...)..., |
| 3424 |
) |
| 3425 |
if err != nil { |
| 3426 |
return NodeAllocatableEphemeralStorage{noop.Int64UpDownCounter{}}, err |
| 3427 |
} |
| 3428 |
return NodeAllocatableEphemeralStorage{i}, nil |
| 3429 |
} |
| 3430 |
|
| 3431 |
// Inst returns the underlying metric instrument. |
| 3432 |
func (m NodeAllocatableEphemeralStorage) Inst() metric.Int64UpDownCounter { |
| 3433 |
return m.Int64UpDownCounter |
| 3434 |
} |
| 3435 |
|
| 3436 |
// Name returns the semantic convention name of the instrument. |
| 3437 |
func (NodeAllocatableEphemeralStorage) Name() string { |
| 3438 |
return "k8s.node.allocatable.ephemeral_storage" |
| 3439 |
} |
| 3440 |
|
| 3441 |
// Unit returns the semantic convention unit of the instrument |
| 3442 |
func (NodeAllocatableEphemeralStorage) Unit() string { |
| 3443 |
return "By" |
| 3444 |
} |
| 3445 |
|
| 3446 |
// Description returns the semantic convention description of the instrument |
| 3447 |
func (NodeAllocatableEphemeralStorage) Description() string { |
| 3448 |
return "Amount of ephemeral-storage allocatable on the node" |
| 3449 |
} |
| 3450 |
|
| 3451 |
// Add adds incr to the existing count for attrs. |
| 3452 |
func (m NodeAllocatableEphemeralStorage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3453 |
if len(attrs) == 0 { |
| 3454 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3455 |
return |
| 3456 |
} |
| 3457 |
|
| 3458 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3459 |
defer func() { |
| 3460 |
*o = (*o)[:0] |
| 3461 |
addOptPool.Put(o) |
| 3462 |
}() |
| 3463 |
|
| 3464 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3465 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3466 |
} |
| 3467 |
|
| 3468 |
// AddSet adds incr to the existing count for set. |
| 3469 |
func (m NodeAllocatableEphemeralStorage) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3470 |
if set.Len() == 0 { |
| 3471 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3472 |
return |
| 3473 |
} |
| 3474 |
|
| 3475 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3476 |
defer func() { |
| 3477 |
*o = (*o)[:0] |
| 3478 |
addOptPool.Put(o) |
| 3479 |
}() |
| 3480 |
|
| 3481 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3482 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3483 |
} |
| 3484 |
|
| 3485 |
// NodeAllocatableMemory is an instrument used to record metric values conforming |
| 3486 |
// to the "k8s.node.allocatable.memory" semantic conventions. It represents the |
| 3487 |
// amount of memory allocatable on the node. |
| 3488 |
type NodeAllocatableMemory struct { |
| 3489 |
metric.Int64UpDownCounter |
| 3490 |
} |
| 3491 |
|
| 3492 |
// NewNodeAllocatableMemory returns a new NodeAllocatableMemory instrument. |
| 3493 |
func NewNodeAllocatableMemory( |
| 3494 |
m metric.Meter, |
| 3495 |
opt ...metric.Int64UpDownCounterOption, |
| 3496 |
) (NodeAllocatableMemory, error) { |
| 3497 |
// Check if the meter is nil. |
| 3498 |
if m == nil { |
| 3499 |
return NodeAllocatableMemory{noop.Int64UpDownCounter{}}, nil |
| 3500 |
} |
| 3501 |
|
| 3502 |
i, err := m.Int64UpDownCounter( |
| 3503 |
"k8s.node.allocatable.memory", |
| 3504 |
append([]metric.Int64UpDownCounterOption{ |
| 3505 |
metric.WithDescription("Amount of memory allocatable on the node"), |
| 3506 |
metric.WithUnit("By"), |
| 3507 |
}, opt...)..., |
| 3508 |
) |
| 3509 |
if err != nil { |
| 3510 |
return NodeAllocatableMemory{noop.Int64UpDownCounter{}}, err |
| 3511 |
} |
| 3512 |
return NodeAllocatableMemory{i}, nil |
| 3513 |
} |
| 3514 |
|
| 3515 |
// Inst returns the underlying metric instrument. |
| 3516 |
func (m NodeAllocatableMemory) Inst() metric.Int64UpDownCounter { |
| 3517 |
return m.Int64UpDownCounter |
| 3518 |
} |
| 3519 |
|
| 3520 |
// Name returns the semantic convention name of the instrument. |
| 3521 |
func (NodeAllocatableMemory) Name() string { |
| 3522 |
return "k8s.node.allocatable.memory" |
| 3523 |
} |
| 3524 |
|
| 3525 |
// Unit returns the semantic convention unit of the instrument |
| 3526 |
func (NodeAllocatableMemory) Unit() string { |
| 3527 |
return "By" |
| 3528 |
} |
| 3529 |
|
| 3530 |
// Description returns the semantic convention description of the instrument |
| 3531 |
func (NodeAllocatableMemory) Description() string { |
| 3532 |
return "Amount of memory allocatable on the node" |
| 3533 |
} |
| 3534 |
|
| 3535 |
// Add adds incr to the existing count for attrs. |
| 3536 |
func (m NodeAllocatableMemory) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 3537 |
if len(attrs) == 0 { |
| 3538 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3539 |
return |
| 3540 |
} |
| 3541 |
|
| 3542 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3543 |
defer func() { |
| 3544 |
*o = (*o)[:0] |
| 3545 |
addOptPool.Put(o) |
| 3546 |
}() |
| 3547 |
|
| 3548 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3549 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3550 |
} |
| 3551 |
|
| 3552 |
// AddSet adds incr to the existing count for set. |
| 3553 |
func (m NodeAllocatableMemory) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3554 |
if set.Len() == 0 { |
| 3555 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3556 |
return |
| 3557 |
} |
| 3558 |
|
| 3559 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3560 |
defer func() { |
| 3561 |
*o = (*o)[:0] |
| 3562 |
addOptPool.Put(o) |
| 3563 |
}() |
| 3564 |
|
| 3565 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3566 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3567 |
} |
| 3568 |
|
| 3569 |
// NodeAllocatablePods is an instrument used to record metric values conforming |
| 3570 |
// to the "k8s.node.allocatable.pods" semantic conventions. It represents the |
| 3571 |
// amount of pods allocatable on the node. |
| 3572 |
type NodeAllocatablePods struct { |
| 3573 |
metric.Int64UpDownCounter |
| 3574 |
} |
| 3575 |
|
| 3576 |
// NewNodeAllocatablePods returns a new NodeAllocatablePods instrument. |
| 3577 |
func NewNodeAllocatablePods( |
| 3578 |
m metric.Meter, |
| 3579 |
opt ...metric.Int64UpDownCounterOption, |
| 3580 |
) (NodeAllocatablePods, error) { |
| 3581 |
// Check if the meter is nil. |
| 3582 |
if m == nil { |
| 3583 |
return NodeAllocatablePods{noop.Int64UpDownCounter{}}, nil |
| 3584 |
} |
| 3585 |
|
| 3586 |
i, err := m.Int64UpDownCounter( |
| 3587 |
"k8s.node.allocatable.pods", |
| 3588 |
append([]metric.Int64UpDownCounterOption{ |
| 3589 |
metric.WithDescription("Amount of pods allocatable on the node"), |
| 3590 |
metric.WithUnit("{pod}"), |
| 3591 |
}, opt...)..., |
| 3592 |
) |
| 3593 |
if err != nil { |
| 3594 |
return NodeAllocatablePods{noop.Int64UpDownCounter{}}, err |
| 3595 |
} |
| 3596 |
return NodeAllocatablePods{i}, nil |
| 3597 |
} |
| 3598 |
|
| 3599 |
// Inst returns the underlying metric instrument. |
| 3600 |
func (m NodeAllocatablePods) Inst() metric.Int64UpDownCounter { |
| 3601 |
return m.Int64UpDownCounter |
| 3602 |
} |
| 3603 |
|
| 3604 |
// Name returns the semantic convention name of the instrument. |
| 3605 |
func (NodeAllocatablePods) Name() string { |
| 3606 |
return "k8s.node.allocatable.pods" |
| 3607 |
} |
| 3608 |
|
| 3609 |
// Unit returns the semantic convention unit of the instrument |
| 3610 |
func (NodeAllocatablePods) Unit() string { |
| 3611 |
return "{pod}" |
| 3612 |
} |
| 3613 |
|
| 3614 |
// Description returns the semantic convention description of the instrument |
| 3615 |
func (NodeAllocatablePods) Description() string { |
| 3616 |
return "Amount of pods allocatable on the node" |
| 3617 |
} |
| 3618 |
|
| 3619 |
// Add adds incr to the existing count for attrs. |
| 3620 |
func (m NodeAllocatablePods) 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 |
func (m NodeAllocatablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3638 |
if set.Len() == 0 { |
| 3639 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3640 |
return |
| 3641 |
} |
| 3642 |
|
| 3643 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3644 |
defer func() { |
| 3645 |
*o = (*o)[:0] |
| 3646 |
addOptPool.Put(o) |
| 3647 |
}() |
| 3648 |
|
| 3649 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3650 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3651 |
} |
| 3652 |
|
| 3653 |
// NodeConditionStatus is an instrument used to record metric values conforming |
| 3654 |
// to the "k8s.node.condition.status" semantic conventions. It represents the |
| 3655 |
// describes the condition of a particular Node. |
| 3656 |
type NodeConditionStatus struct { |
| 3657 |
metric.Int64UpDownCounter |
| 3658 |
} |
| 3659 |
|
| 3660 |
// NewNodeConditionStatus returns a new NodeConditionStatus instrument. |
| 3661 |
func NewNodeConditionStatus( |
| 3662 |
m metric.Meter, |
| 3663 |
opt ...metric.Int64UpDownCounterOption, |
| 3664 |
) (NodeConditionStatus, error) { |
| 3665 |
// Check if the meter is nil. |
| 3666 |
if m == nil { |
| 3667 |
return NodeConditionStatus{noop.Int64UpDownCounter{}}, nil |
| 3668 |
} |
| 3669 |
|
| 3670 |
i, err := m.Int64UpDownCounter( |
| 3671 |
"k8s.node.condition.status", |
| 3672 |
append([]metric.Int64UpDownCounterOption{ |
| 3673 |
metric.WithDescription("Describes the condition of a particular Node."), |
| 3674 |
metric.WithUnit("{node}"), |
| 3675 |
}, opt...)..., |
| 3676 |
) |
| 3677 |
if err != nil { |
| 3678 |
return NodeConditionStatus{noop.Int64UpDownCounter{}}, err |
| 3679 |
} |
| 3680 |
return NodeConditionStatus{i}, nil |
| 3681 |
} |
| 3682 |
|
| 3683 |
// Inst returns the underlying metric instrument. |
| 3684 |
func (m NodeConditionStatus) Inst() metric.Int64UpDownCounter { |
| 3685 |
return m.Int64UpDownCounter |
| 3686 |
} |
| 3687 |
|
| 3688 |
// Name returns the semantic convention name of the instrument. |
| 3689 |
func (NodeConditionStatus) Name() string { |
| 3690 |
return "k8s.node.condition.status" |
| 3691 |
} |
| 3692 |
|
| 3693 |
// Unit returns the semantic convention unit of the instrument |
| 3694 |
func (NodeConditionStatus) Unit() string { |
| 3695 |
return "{node}" |
| 3696 |
} |
| 3697 |
|
| 3698 |
// Description returns the semantic convention description of the instrument |
| 3699 |
func (NodeConditionStatus) Description() string { |
| 3700 |
return "Describes the condition of a particular Node." |
| 3701 |
} |
| 3702 |
|
| 3703 |
// Add adds incr to the existing count for attrs. |
| 3704 |
// |
| 3705 |
// The nodeConditionStatus is the the status of the condition, one of True, |
| 3706 |
// False, Unknown. |
| 3707 |
// |
| 3708 |
// The nodeConditionType is the the condition type of a K8s Node. |
| 3709 |
// |
| 3710 |
// All possible node condition pairs (type and status) will be reported at each |
| 3711 |
// time interval to avoid missing metrics. Condition pairs corresponding to the |
| 3712 |
// current conditions' statuses will be non-zero. |
| 3713 |
func (m NodeConditionStatus) Add( |
| 3714 |
ctx context.Context, |
| 3715 |
incr int64, |
| 3716 |
nodeConditionStatus NodeConditionStatusAttr, |
| 3717 |
nodeConditionType NodeConditionTypeAttr, |
| 3718 |
attrs ...attribute.KeyValue, |
| 3719 |
) { |
| 3720 |
if len(attrs) == 0 { |
| 3721 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3722 |
return |
| 3723 |
} |
| 3724 |
|
| 3725 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3726 |
defer func() { |
| 3727 |
*o = (*o)[:0] |
| 3728 |
addOptPool.Put(o) |
| 3729 |
}() |
| 3730 |
|
| 3731 |
*o = append( |
| 3732 |
*o, |
| 3733 |
metric.WithAttributes( |
| 3734 |
append( |
| 3735 |
attrs, |
| 3736 |
attribute.String("k8s.node.condition.status", string(nodeConditionStatus)), |
| 3737 |
attribute.String("k8s.node.condition.type", string(nodeConditionType)), |
| 3738 |
)..., |
| 3739 |
), |
| 3740 |
) |
| 3741 |
|
| 3742 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3743 |
} |
| 3744 |
|
| 3745 |
// AddSet adds incr to the existing count for set. |
| 3746 |
// |
| 3747 |
// All possible node condition pairs (type and status) will be reported at each |
| 3748 |
// time interval to avoid missing metrics. Condition pairs corresponding to the |
| 3749 |
// current conditions' statuses will be non-zero. |
| 3750 |
func (m NodeConditionStatus) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3751 |
if set.Len() == 0 { |
| 3752 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3753 |
return |
| 3754 |
} |
| 3755 |
|
| 3756 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3757 |
defer func() { |
| 3758 |
*o = (*o)[:0] |
| 3759 |
addOptPool.Put(o) |
| 3760 |
}() |
| 3761 |
|
| 3762 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3763 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3764 |
} |
| 3765 |
|
| 3766 |
// NodeCPUTime is an instrument used to record metric values conforming to the |
| 3767 |
// "k8s.node.cpu.time" semantic conventions. It represents the total CPU time |
| 3768 |
// consumed. |
| 3769 |
type NodeCPUTime struct { |
| 3770 |
metric.Float64Counter |
| 3771 |
} |
| 3772 |
|
| 3773 |
// NewNodeCPUTime returns a new NodeCPUTime instrument. |
| 3774 |
func NewNodeCPUTime( |
| 3775 |
m metric.Meter, |
| 3776 |
opt ...metric.Float64CounterOption, |
| 3777 |
) (NodeCPUTime, error) { |
| 3778 |
// Check if the meter is nil. |
| 3779 |
if m == nil { |
| 3780 |
return NodeCPUTime{noop.Float64Counter{}}, nil |
| 3781 |
} |
| 3782 |
|
| 3783 |
i, err := m.Float64Counter( |
| 3784 |
"k8s.node.cpu.time", |
| 3785 |
append([]metric.Float64CounterOption{ |
| 3786 |
metric.WithDescription("Total CPU time consumed"), |
| 3787 |
metric.WithUnit("s"), |
| 3788 |
}, opt...)..., |
| 3789 |
) |
| 3790 |
if err != nil { |
| 3791 |
return NodeCPUTime{noop.Float64Counter{}}, err |
| 3792 |
} |
| 3793 |
return NodeCPUTime{i}, nil |
| 3794 |
} |
| 3795 |
|
| 3796 |
// Inst returns the underlying metric instrument. |
| 3797 |
func (m NodeCPUTime) Inst() metric.Float64Counter { |
| 3798 |
return m.Float64Counter |
| 3799 |
} |
| 3800 |
|
| 3801 |
// Name returns the semantic convention name of the instrument. |
| 3802 |
func (NodeCPUTime) Name() string { |
| 3803 |
return "k8s.node.cpu.time" |
| 3804 |
} |
| 3805 |
|
| 3806 |
// Unit returns the semantic convention unit of the instrument |
| 3807 |
func (NodeCPUTime) Unit() string { |
| 3808 |
return "s" |
| 3809 |
} |
| 3810 |
|
| 3811 |
// Description returns the semantic convention description of the instrument |
| 3812 |
func (NodeCPUTime) Description() string { |
| 3813 |
return "Total CPU time consumed" |
| 3814 |
} |
| 3815 |
|
| 3816 |
// Add adds incr to the existing count for attrs. |
| 3817 |
// |
| 3818 |
// Total CPU time consumed by the specific Node on all available CPU cores |
| 3819 |
func (m NodeCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { |
| 3820 |
if len(attrs) == 0 { |
| 3821 |
m.Float64Counter.Add(ctx, incr) |
| 3822 |
return |
| 3823 |
} |
| 3824 |
|
| 3825 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3826 |
defer func() { |
| 3827 |
*o = (*o)[:0] |
| 3828 |
addOptPool.Put(o) |
| 3829 |
}() |
| 3830 |
|
| 3831 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3832 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 3833 |
} |
| 3834 |
|
| 3835 |
// AddSet adds incr to the existing count for set. |
| 3836 |
// |
| 3837 |
// Total CPU time consumed by the specific Node on all available CPU cores |
| 3838 |
func (m NodeCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { |
| 3839 |
if set.Len() == 0 { |
| 3840 |
m.Float64Counter.Add(ctx, incr) |
| 3841 |
return |
| 3842 |
} |
| 3843 |
|
| 3844 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3845 |
defer func() { |
| 3846 |
*o = (*o)[:0] |
| 3847 |
addOptPool.Put(o) |
| 3848 |
}() |
| 3849 |
|
| 3850 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3851 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 3852 |
} |
| 3853 |
|
| 3854 |
// NodeCPUUsage is an instrument used to record metric values conforming to the |
| 3855 |
// "k8s.node.cpu.usage" semantic conventions. It represents the node's CPU usage, |
| 3856 |
// measured in cpus. Range from 0 to the number of allocatable CPUs. |
| 3857 |
type NodeCPUUsage struct { |
| 3858 |
metric.Int64Gauge |
| 3859 |
} |
| 3860 |
|
| 3861 |
// NewNodeCPUUsage returns a new NodeCPUUsage instrument. |
| 3862 |
func NewNodeCPUUsage( |
| 3863 |
m metric.Meter, |
| 3864 |
opt ...metric.Int64GaugeOption, |
| 3865 |
) (NodeCPUUsage, error) { |
| 3866 |
// Check if the meter is nil. |
| 3867 |
if m == nil { |
| 3868 |
return NodeCPUUsage{noop.Int64Gauge{}}, nil |
| 3869 |
} |
| 3870 |
|
| 3871 |
i, err := m.Int64Gauge( |
| 3872 |
"k8s.node.cpu.usage", |
| 3873 |
append([]metric.Int64GaugeOption{ |
| 3874 |
metric.WithDescription("Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"), |
| 3875 |
metric.WithUnit("{cpu}"), |
| 3876 |
}, opt...)..., |
| 3877 |
) |
| 3878 |
if err != nil { |
| 3879 |
return NodeCPUUsage{noop.Int64Gauge{}}, err |
| 3880 |
} |
| 3881 |
return NodeCPUUsage{i}, nil |
| 3882 |
} |
| 3883 |
|
| 3884 |
// Inst returns the underlying metric instrument. |
| 3885 |
func (m NodeCPUUsage) Inst() metric.Int64Gauge { |
| 3886 |
return m.Int64Gauge |
| 3887 |
} |
| 3888 |
|
| 3889 |
// Name returns the semantic convention name of the instrument. |
| 3890 |
func (NodeCPUUsage) Name() string { |
| 3891 |
return "k8s.node.cpu.usage" |
| 3892 |
} |
| 3893 |
|
| 3894 |
// Unit returns the semantic convention unit of the instrument |
| 3895 |
func (NodeCPUUsage) Unit() string { |
| 3896 |
return "{cpu}" |
| 3897 |
} |
| 3898 |
|
| 3899 |
// Description returns the semantic convention description of the instrument |
| 3900 |
func (NodeCPUUsage) Description() string { |
| 3901 |
return "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs" |
| 3902 |
} |
| 3903 |
|
| 3904 |
// Record records val to the current distribution for attrs. |
| 3905 |
// |
| 3906 |
// CPU usage of the specific Node on all available CPU cores, averaged over the |
| 3907 |
// sample window |
| 3908 |
func (m NodeCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 3909 |
if len(attrs) == 0 { |
| 3910 |
m.Int64Gauge.Record(ctx, val) |
| 3911 |
return |
| 3912 |
} |
| 3913 |
|
| 3914 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 3915 |
defer func() { |
| 3916 |
*o = (*o)[:0] |
| 3917 |
recOptPool.Put(o) |
| 3918 |
}() |
| 3919 |
|
| 3920 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 3921 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 3922 |
} |
| 3923 |
|
| 3924 |
// RecordSet records val to the current distribution for set. |
| 3925 |
// |
| 3926 |
// CPU usage of the specific Node on all available CPU cores, averaged over the |
| 3927 |
// sample window |
| 3928 |
func (m NodeCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 3929 |
if set.Len() == 0 { |
| 3930 |
m.Int64Gauge.Record(ctx, val) |
| 3931 |
return |
| 3932 |
} |
| 3933 |
|
| 3934 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 3935 |
defer func() { |
| 3936 |
*o = (*o)[:0] |
| 3937 |
recOptPool.Put(o) |
| 3938 |
}() |
| 3939 |
|
| 3940 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3941 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 3942 |
} |
| 3943 |
|
| 3944 |
// NodeMemoryUsage is an instrument used to record metric values conforming to |
| 3945 |
// the "k8s.node.memory.usage" semantic conventions. It represents the memory |
| 3946 |
// usage of the Node. |
| 3947 |
type NodeMemoryUsage struct { |
| 3948 |
metric.Int64Gauge |
| 3949 |
} |
| 3950 |
|
| 3951 |
// NewNodeMemoryUsage returns a new NodeMemoryUsage instrument. |
| 3952 |
func NewNodeMemoryUsage( |
| 3953 |
m metric.Meter, |
| 3954 |
opt ...metric.Int64GaugeOption, |
| 3955 |
) (NodeMemoryUsage, error) { |
| 3956 |
// Check if the meter is nil. |
| 3957 |
if m == nil { |
| 3958 |
return NodeMemoryUsage{noop.Int64Gauge{}}, nil |
| 3959 |
} |
| 3960 |
|
| 3961 |
i, err := m.Int64Gauge( |
| 3962 |
"k8s.node.memory.usage", |
| 3963 |
append([]metric.Int64GaugeOption{ |
| 3964 |
metric.WithDescription("Memory usage of the Node"), |
| 3965 |
metric.WithUnit("By"), |
| 3966 |
}, opt...)..., |
| 3967 |
) |
| 3968 |
if err != nil { |
| 3969 |
return NodeMemoryUsage{noop.Int64Gauge{}}, err |
| 3970 |
} |
| 3971 |
return NodeMemoryUsage{i}, nil |
| 3972 |
} |
| 3973 |
|
| 3974 |
// Inst returns the underlying metric instrument. |
| 3975 |
func (m NodeMemoryUsage) Inst() metric.Int64Gauge { |
| 3976 |
return m.Int64Gauge |
| 3977 |
} |
| 3978 |
|
| 3979 |
// Name returns the semantic convention name of the instrument. |
| 3980 |
func (NodeMemoryUsage) Name() string { |
| 3981 |
return "k8s.node.memory.usage" |
| 3982 |
} |
| 3983 |
|
| 3984 |
// Unit returns the semantic convention unit of the instrument |
| 3985 |
func (NodeMemoryUsage) Unit() string { |
| 3986 |
return "By" |
| 3987 |
} |
| 3988 |
|
| 3989 |
// Description returns the semantic convention description of the instrument |
| 3990 |
func (NodeMemoryUsage) Description() string { |
| 3991 |
return "Memory usage of the Node" |
| 3992 |
} |
| 3993 |
|
| 3994 |
// Record records val to the current distribution for attrs. |
| 3995 |
// |
| 3996 |
// Total memory usage of the Node |
| 3997 |
func (m NodeMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 3998 |
if len(attrs) == 0 { |
| 3999 |
m.Int64Gauge.Record(ctx, val) |
| 4000 |
return |
| 4001 |
} |
| 4002 |
|
| 4003 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4004 |
defer func() { |
| 4005 |
*o = (*o)[:0] |
| 4006 |
recOptPool.Put(o) |
| 4007 |
}() |
| 4008 |
|
| 4009 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4010 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4011 |
} |
| 4012 |
|
| 4013 |
// RecordSet records val to the current distribution for set. |
| 4014 |
// |
| 4015 |
// Total memory usage of the Node |
| 4016 |
func (m NodeMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 4017 |
if set.Len() == 0 { |
| 4018 |
m.Int64Gauge.Record(ctx, val) |
| 4019 |
return |
| 4020 |
} |
| 4021 |
|
| 4022 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4023 |
defer func() { |
| 4024 |
*o = (*o)[:0] |
| 4025 |
recOptPool.Put(o) |
| 4026 |
}() |
| 4027 |
|
| 4028 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4029 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4030 |
} |
| 4031 |
|
| 4032 |
// NodeNetworkErrors is an instrument used to record metric values conforming to |
| 4033 |
// the "k8s.node.network.errors" semantic conventions. It represents the node |
| 4034 |
// network errors. |
| 4035 |
type NodeNetworkErrors struct { |
| 4036 |
metric.Int64Counter |
| 4037 |
} |
| 4038 |
|
| 4039 |
// NewNodeNetworkErrors returns a new NodeNetworkErrors instrument. |
| 4040 |
func NewNodeNetworkErrors( |
| 4041 |
m metric.Meter, |
| 4042 |
opt ...metric.Int64CounterOption, |
| 4043 |
) (NodeNetworkErrors, error) { |
| 4044 |
// Check if the meter is nil. |
| 4045 |
if m == nil { |
| 4046 |
return NodeNetworkErrors{noop.Int64Counter{}}, nil |
| 4047 |
} |
| 4048 |
|
| 4049 |
i, err := m.Int64Counter( |
| 4050 |
"k8s.node.network.errors", |
| 4051 |
append([]metric.Int64CounterOption{ |
| 4052 |
metric.WithDescription("Node network errors"), |
| 4053 |
metric.WithUnit("{error}"), |
| 4054 |
}, opt...)..., |
| 4055 |
) |
| 4056 |
if err != nil { |
| 4057 |
return NodeNetworkErrors{noop.Int64Counter{}}, err |
| 4058 |
} |
| 4059 |
return NodeNetworkErrors{i}, nil |
| 4060 |
} |
| 4061 |
|
| 4062 |
// Inst returns the underlying metric instrument. |
| 4063 |
func (m NodeNetworkErrors) Inst() metric.Int64Counter { |
| 4064 |
return m.Int64Counter |
| 4065 |
} |
| 4066 |
|
| 4067 |
// Name returns the semantic convention name of the instrument. |
| 4068 |
func (NodeNetworkErrors) Name() string { |
| 4069 |
return "k8s.node.network.errors" |
| 4070 |
} |
| 4071 |
|
| 4072 |
// Unit returns the semantic convention unit of the instrument |
| 4073 |
func (NodeNetworkErrors) Unit() string { |
| 4074 |
return "{error}" |
| 4075 |
} |
| 4076 |
|
| 4077 |
// Description returns the semantic convention description of the instrument |
| 4078 |
func (NodeNetworkErrors) Description() string { |
| 4079 |
return "Node network errors" |
| 4080 |
} |
| 4081 |
|
| 4082 |
// Add adds incr to the existing count for attrs. |
| 4083 |
// |
| 4084 |
// All additional attrs passed are included in the recorded value. |
| 4085 |
func (m NodeNetworkErrors) Add( |
| 4086 |
ctx context.Context, |
| 4087 |
incr int64, |
| 4088 |
attrs ...attribute.KeyValue, |
| 4089 |
) { |
| 4090 |
if len(attrs) == 0 { |
| 4091 |
m.Int64Counter.Add(ctx, incr) |
| 4092 |
return |
| 4093 |
} |
| 4094 |
|
| 4095 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4096 |
defer func() { |
| 4097 |
*o = (*o)[:0] |
| 4098 |
addOptPool.Put(o) |
| 4099 |
}() |
| 4100 |
|
| 4101 |
*o = append( |
| 4102 |
*o, |
| 4103 |
metric.WithAttributes( |
| 4104 |
attrs..., |
| 4105 |
), |
| 4106 |
) |
| 4107 |
|
| 4108 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4109 |
} |
| 4110 |
|
| 4111 |
// AddSet adds incr to the existing count for set. |
| 4112 |
func (m NodeNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4113 |
if set.Len() == 0 { |
| 4114 |
m.Int64Counter.Add(ctx, incr) |
| 4115 |
return |
| 4116 |
} |
| 4117 |
|
| 4118 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4119 |
defer func() { |
| 4120 |
*o = (*o)[:0] |
| 4121 |
addOptPool.Put(o) |
| 4122 |
}() |
| 4123 |
|
| 4124 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4125 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4126 |
} |
| 4127 |
|
| 4128 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 4129 |
// "network.interface.name" semantic convention. It represents the network |
| 4130 |
// interface name. |
| 4131 |
func (NodeNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 4132 |
return attribute.String("network.interface.name", val) |
| 4133 |
} |
| 4134 |
|
| 4135 |
// AttrNetworkIODirection returns an optional attribute for the |
| 4136 |
// "network.io.direction" semantic convention. It represents the network IO |
| 4137 |
// operation direction. |
| 4138 |
func (NodeNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 4139 |
return attribute.String("network.io.direction", string(val)) |
| 4140 |
} |
| 4141 |
|
| 4142 |
// NodeNetworkIO is an instrument used to record metric values conforming to the |
| 4143 |
// "k8s.node.network.io" semantic conventions. It represents the network bytes |
| 4144 |
// for the Node. |
| 4145 |
type NodeNetworkIO struct { |
| 4146 |
metric.Int64Counter |
| 4147 |
} |
| 4148 |
|
| 4149 |
// NewNodeNetworkIO returns a new NodeNetworkIO instrument. |
| 4150 |
func NewNodeNetworkIO( |
| 4151 |
m metric.Meter, |
| 4152 |
opt ...metric.Int64CounterOption, |
| 4153 |
) (NodeNetworkIO, error) { |
| 4154 |
// Check if the meter is nil. |
| 4155 |
if m == nil { |
| 4156 |
return NodeNetworkIO{noop.Int64Counter{}}, nil |
| 4157 |
} |
| 4158 |
|
| 4159 |
i, err := m.Int64Counter( |
| 4160 |
"k8s.node.network.io", |
| 4161 |
append([]metric.Int64CounterOption{ |
| 4162 |
metric.WithDescription("Network bytes for the Node"), |
| 4163 |
metric.WithUnit("By"), |
| 4164 |
}, opt...)..., |
| 4165 |
) |
| 4166 |
if err != nil { |
| 4167 |
return NodeNetworkIO{noop.Int64Counter{}}, err |
| 4168 |
} |
| 4169 |
return NodeNetworkIO{i}, nil |
| 4170 |
} |
| 4171 |
|
| 4172 |
// Inst returns the underlying metric instrument. |
| 4173 |
func (m NodeNetworkIO) Inst() metric.Int64Counter { |
| 4174 |
return m.Int64Counter |
| 4175 |
} |
| 4176 |
|
| 4177 |
// Name returns the semantic convention name of the instrument. |
| 4178 |
func (NodeNetworkIO) Name() string { |
| 4179 |
return "k8s.node.network.io" |
| 4180 |
} |
| 4181 |
|
| 4182 |
// Unit returns the semantic convention unit of the instrument |
| 4183 |
func (NodeNetworkIO) Unit() string { |
| 4184 |
return "By" |
| 4185 |
} |
| 4186 |
|
| 4187 |
// Description returns the semantic convention description of the instrument |
| 4188 |
func (NodeNetworkIO) Description() string { |
| 4189 |
return "Network bytes for the Node" |
| 4190 |
} |
| 4191 |
|
| 4192 |
// Add adds incr to the existing count for attrs. |
| 4193 |
// |
| 4194 |
// All additional attrs passed are included in the recorded value. |
| 4195 |
func (m NodeNetworkIO) Add( |
| 4196 |
ctx context.Context, |
| 4197 |
incr int64, |
| 4198 |
attrs ...attribute.KeyValue, |
| 4199 |
) { |
| 4200 |
if len(attrs) == 0 { |
| 4201 |
m.Int64Counter.Add(ctx, incr) |
| 4202 |
return |
| 4203 |
} |
| 4204 |
|
| 4205 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4206 |
defer func() { |
| 4207 |
*o = (*o)[:0] |
| 4208 |
addOptPool.Put(o) |
| 4209 |
}() |
| 4210 |
|
| 4211 |
*o = append( |
| 4212 |
*o, |
| 4213 |
metric.WithAttributes( |
| 4214 |
attrs..., |
| 4215 |
), |
| 4216 |
) |
| 4217 |
|
| 4218 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4219 |
} |
| 4220 |
|
| 4221 |
// AddSet adds incr to the existing count for set. |
| 4222 |
func (m NodeNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4223 |
if set.Len() == 0 { |
| 4224 |
m.Int64Counter.Add(ctx, incr) |
| 4225 |
return |
| 4226 |
} |
| 4227 |
|
| 4228 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4229 |
defer func() { |
| 4230 |
*o = (*o)[:0] |
| 4231 |
addOptPool.Put(o) |
| 4232 |
}() |
| 4233 |
|
| 4234 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4235 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4236 |
} |
| 4237 |
|
| 4238 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 4239 |
// "network.interface.name" semantic convention. It represents the network |
| 4240 |
// interface name. |
| 4241 |
func (NodeNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 4242 |
return attribute.String("network.interface.name", val) |
| 4243 |
} |
| 4244 |
|
| 4245 |
// AttrNetworkIODirection returns an optional attribute for the |
| 4246 |
// "network.io.direction" semantic convention. It represents the network IO |
| 4247 |
// operation direction. |
| 4248 |
func (NodeNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 4249 |
return attribute.String("network.io.direction", string(val)) |
| 4250 |
} |
| 4251 |
|
| 4252 |
// NodeUptime is an instrument used to record metric values conforming to the |
| 4253 |
// "k8s.node.uptime" semantic conventions. It represents the time the Node has |
| 4254 |
// been running. |
| 4255 |
type NodeUptime struct { |
| 4256 |
metric.Float64Gauge |
| 4257 |
} |
| 4258 |
|
| 4259 |
// NewNodeUptime returns a new NodeUptime instrument. |
| 4260 |
func NewNodeUptime( |
| 4261 |
m metric.Meter, |
| 4262 |
opt ...metric.Float64GaugeOption, |
| 4263 |
) (NodeUptime, error) { |
| 4264 |
// Check if the meter is nil. |
| 4265 |
if m == nil { |
| 4266 |
return NodeUptime{noop.Float64Gauge{}}, nil |
| 4267 |
} |
| 4268 |
|
| 4269 |
i, err := m.Float64Gauge( |
| 4270 |
"k8s.node.uptime", |
| 4271 |
append([]metric.Float64GaugeOption{ |
| 4272 |
metric.WithDescription("The time the Node has been running"), |
| 4273 |
metric.WithUnit("s"), |
| 4274 |
}, opt...)..., |
| 4275 |
) |
| 4276 |
if err != nil { |
| 4277 |
return NodeUptime{noop.Float64Gauge{}}, err |
| 4278 |
} |
| 4279 |
return NodeUptime{i}, nil |
| 4280 |
} |
| 4281 |
|
| 4282 |
// Inst returns the underlying metric instrument. |
| 4283 |
func (m NodeUptime) Inst() metric.Float64Gauge { |
| 4284 |
return m.Float64Gauge |
| 4285 |
} |
| 4286 |
|
| 4287 |
// Name returns the semantic convention name of the instrument. |
| 4288 |
func (NodeUptime) Name() string { |
| 4289 |
return "k8s.node.uptime" |
| 4290 |
} |
| 4291 |
|
| 4292 |
// Unit returns the semantic convention unit of the instrument |
| 4293 |
func (NodeUptime) Unit() string { |
| 4294 |
return "s" |
| 4295 |
} |
| 4296 |
|
| 4297 |
// Description returns the semantic convention description of the instrument |
| 4298 |
func (NodeUptime) Description() string { |
| 4299 |
return "The time the Node has been running" |
| 4300 |
} |
| 4301 |
|
| 4302 |
// Record records val to the current distribution for attrs. |
| 4303 |
// |
| 4304 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 4305 |
// seconds as a floating point number with the highest precision available. |
| 4306 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 4307 |
func (m NodeUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) { |
| 4308 |
if len(attrs) == 0 { |
| 4309 |
m.Float64Gauge.Record(ctx, val) |
| 4310 |
return |
| 4311 |
} |
| 4312 |
|
| 4313 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4314 |
defer func() { |
| 4315 |
*o = (*o)[:0] |
| 4316 |
recOptPool.Put(o) |
| 4317 |
}() |
| 4318 |
|
| 4319 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4320 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 4321 |
} |
| 4322 |
|
| 4323 |
// RecordSet records val to the current distribution for set. |
| 4324 |
// |
| 4325 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 4326 |
// seconds as a floating point number with the highest precision available. |
| 4327 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 4328 |
func (m NodeUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { |
| 4329 |
if set.Len() == 0 { |
| 4330 |
m.Float64Gauge.Record(ctx, val) |
| 4331 |
return |
| 4332 |
} |
| 4333 |
|
| 4334 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4335 |
defer func() { |
| 4336 |
*o = (*o)[:0] |
| 4337 |
recOptPool.Put(o) |
| 4338 |
}() |
| 4339 |
|
| 4340 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4341 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 4342 |
} |
| 4343 |
|
| 4344 |
// PodCPUTime is an instrument used to record metric values conforming to the |
| 4345 |
// "k8s.pod.cpu.time" semantic conventions. It represents the total CPU time |
| 4346 |
// consumed. |
| 4347 |
type PodCPUTime struct { |
| 4348 |
metric.Float64Counter |
| 4349 |
} |
| 4350 |
|
| 4351 |
// NewPodCPUTime returns a new PodCPUTime instrument. |
| 4352 |
func NewPodCPUTime( |
| 4353 |
m metric.Meter, |
| 4354 |
opt ...metric.Float64CounterOption, |
| 4355 |
) (PodCPUTime, error) { |
| 4356 |
// Check if the meter is nil. |
| 4357 |
if m == nil { |
| 4358 |
return PodCPUTime{noop.Float64Counter{}}, nil |
| 4359 |
} |
| 4360 |
|
| 4361 |
i, err := m.Float64Counter( |
| 4362 |
"k8s.pod.cpu.time", |
| 4363 |
append([]metric.Float64CounterOption{ |
| 4364 |
metric.WithDescription("Total CPU time consumed"), |
| 4365 |
metric.WithUnit("s"), |
| 4366 |
}, opt...)..., |
| 4367 |
) |
| 4368 |
if err != nil { |
| 4369 |
return PodCPUTime{noop.Float64Counter{}}, err |
| 4370 |
} |
| 4371 |
return PodCPUTime{i}, nil |
| 4372 |
} |
| 4373 |
|
| 4374 |
// Inst returns the underlying metric instrument. |
| 4375 |
func (m PodCPUTime) Inst() metric.Float64Counter { |
| 4376 |
return m.Float64Counter |
| 4377 |
} |
| 4378 |
|
| 4379 |
// Name returns the semantic convention name of the instrument. |
| 4380 |
func (PodCPUTime) Name() string { |
| 4381 |
return "k8s.pod.cpu.time" |
| 4382 |
} |
| 4383 |
|
| 4384 |
// Unit returns the semantic convention unit of the instrument |
| 4385 |
func (PodCPUTime) Unit() string { |
| 4386 |
return "s" |
| 4387 |
} |
| 4388 |
|
| 4389 |
// Description returns the semantic convention description of the instrument |
| 4390 |
func (PodCPUTime) Description() string { |
| 4391 |
return "Total CPU time consumed" |
| 4392 |
} |
| 4393 |
|
| 4394 |
// Add adds incr to the existing count for attrs. |
| 4395 |
// |
| 4396 |
// Total CPU time consumed by the specific Pod on all available CPU cores |
| 4397 |
func (m PodCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { |
| 4398 |
if len(attrs) == 0 { |
| 4399 |
m.Float64Counter.Add(ctx, incr) |
| 4400 |
return |
| 4401 |
} |
| 4402 |
|
| 4403 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4404 |
defer func() { |
| 4405 |
*o = (*o)[:0] |
| 4406 |
addOptPool.Put(o) |
| 4407 |
}() |
| 4408 |
|
| 4409 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4410 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 4411 |
} |
| 4412 |
|
| 4413 |
// AddSet adds incr to the existing count for set. |
| 4414 |
// |
| 4415 |
// Total CPU time consumed by the specific Pod on all available CPU cores |
| 4416 |
func (m PodCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { |
| 4417 |
if set.Len() == 0 { |
| 4418 |
m.Float64Counter.Add(ctx, incr) |
| 4419 |
return |
| 4420 |
} |
| 4421 |
|
| 4422 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4423 |
defer func() { |
| 4424 |
*o = (*o)[:0] |
| 4425 |
addOptPool.Put(o) |
| 4426 |
}() |
| 4427 |
|
| 4428 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4429 |
m.Float64Counter.Add(ctx, incr, *o...) |
| 4430 |
} |
| 4431 |
|
| 4432 |
// PodCPUUsage is an instrument used to record metric values conforming to the |
| 4433 |
// "k8s.pod.cpu.usage" semantic conventions. It represents the pod's CPU usage, |
| 4434 |
// measured in cpus. Range from 0 to the number of allocatable CPUs. |
| 4435 |
type PodCPUUsage struct { |
| 4436 |
metric.Int64Gauge |
| 4437 |
} |
| 4438 |
|
| 4439 |
// NewPodCPUUsage returns a new PodCPUUsage instrument. |
| 4440 |
func NewPodCPUUsage( |
| 4441 |
m metric.Meter, |
| 4442 |
opt ...metric.Int64GaugeOption, |
| 4443 |
) (PodCPUUsage, error) { |
| 4444 |
// Check if the meter is nil. |
| 4445 |
if m == nil { |
| 4446 |
return PodCPUUsage{noop.Int64Gauge{}}, nil |
| 4447 |
} |
| 4448 |
|
| 4449 |
i, err := m.Int64Gauge( |
| 4450 |
"k8s.pod.cpu.usage", |
| 4451 |
append([]metric.Int64GaugeOption{ |
| 4452 |
metric.WithDescription("Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"), |
| 4453 |
metric.WithUnit("{cpu}"), |
| 4454 |
}, opt...)..., |
| 4455 |
) |
| 4456 |
if err != nil { |
| 4457 |
return PodCPUUsage{noop.Int64Gauge{}}, err |
| 4458 |
} |
| 4459 |
return PodCPUUsage{i}, nil |
| 4460 |
} |
| 4461 |
|
| 4462 |
// Inst returns the underlying metric instrument. |
| 4463 |
func (m PodCPUUsage) Inst() metric.Int64Gauge { |
| 4464 |
return m.Int64Gauge |
| 4465 |
} |
| 4466 |
|
| 4467 |
// Name returns the semantic convention name of the instrument. |
| 4468 |
func (PodCPUUsage) Name() string { |
| 4469 |
return "k8s.pod.cpu.usage" |
| 4470 |
} |
| 4471 |
|
| 4472 |
// Unit returns the semantic convention unit of the instrument |
| 4473 |
func (PodCPUUsage) Unit() string { |
| 4474 |
return "{cpu}" |
| 4475 |
} |
| 4476 |
|
| 4477 |
// Description returns the semantic convention description of the instrument |
| 4478 |
func (PodCPUUsage) Description() string { |
| 4479 |
return "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs" |
| 4480 |
} |
| 4481 |
|
| 4482 |
// Record records val to the current distribution for attrs. |
| 4483 |
// |
| 4484 |
// CPU usage of the specific Pod on all available CPU cores, averaged over the |
| 4485 |
// sample window |
| 4486 |
func (m PodCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 4487 |
if len(attrs) == 0 { |
| 4488 |
m.Int64Gauge.Record(ctx, val) |
| 4489 |
return |
| 4490 |
} |
| 4491 |
|
| 4492 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4493 |
defer func() { |
| 4494 |
*o = (*o)[:0] |
| 4495 |
recOptPool.Put(o) |
| 4496 |
}() |
| 4497 |
|
| 4498 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4499 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4500 |
} |
| 4501 |
|
| 4502 |
// RecordSet records val to the current distribution for set. |
| 4503 |
// |
| 4504 |
// CPU usage of the specific Pod on all available CPU cores, averaged over the |
| 4505 |
// sample window |
| 4506 |
func (m PodCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 4507 |
if set.Len() == 0 { |
| 4508 |
m.Int64Gauge.Record(ctx, val) |
| 4509 |
return |
| 4510 |
} |
| 4511 |
|
| 4512 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4513 |
defer func() { |
| 4514 |
*o = (*o)[:0] |
| 4515 |
recOptPool.Put(o) |
| 4516 |
}() |
| 4517 |
|
| 4518 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4519 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4520 |
} |
| 4521 |
|
| 4522 |
// PodMemoryUsage is an instrument used to record metric values conforming to the |
| 4523 |
// "k8s.pod.memory.usage" semantic conventions. It represents the memory usage of |
| 4524 |
// the Pod. |
| 4525 |
type PodMemoryUsage struct { |
| 4526 |
metric.Int64Gauge |
| 4527 |
} |
| 4528 |
|
| 4529 |
// NewPodMemoryUsage returns a new PodMemoryUsage instrument. |
| 4530 |
func NewPodMemoryUsage( |
| 4531 |
m metric.Meter, |
| 4532 |
opt ...metric.Int64GaugeOption, |
| 4533 |
) (PodMemoryUsage, error) { |
| 4534 |
// Check if the meter is nil. |
| 4535 |
if m == nil { |
| 4536 |
return PodMemoryUsage{noop.Int64Gauge{}}, nil |
| 4537 |
} |
| 4538 |
|
| 4539 |
i, err := m.Int64Gauge( |
| 4540 |
"k8s.pod.memory.usage", |
| 4541 |
append([]metric.Int64GaugeOption{ |
| 4542 |
metric.WithDescription("Memory usage of the Pod"), |
| 4543 |
metric.WithUnit("By"), |
| 4544 |
}, opt...)..., |
| 4545 |
) |
| 4546 |
if err != nil { |
| 4547 |
return PodMemoryUsage{noop.Int64Gauge{}}, err |
| 4548 |
} |
| 4549 |
return PodMemoryUsage{i}, nil |
| 4550 |
} |
| 4551 |
|
| 4552 |
// Inst returns the underlying metric instrument. |
| 4553 |
func (m PodMemoryUsage) Inst() metric.Int64Gauge { |
| 4554 |
return m.Int64Gauge |
| 4555 |
} |
| 4556 |
|
| 4557 |
// Name returns the semantic convention name of the instrument. |
| 4558 |
func (PodMemoryUsage) Name() string { |
| 4559 |
return "k8s.pod.memory.usage" |
| 4560 |
} |
| 4561 |
|
| 4562 |
// Unit returns the semantic convention unit of the instrument |
| 4563 |
func (PodMemoryUsage) Unit() string { |
| 4564 |
return "By" |
| 4565 |
} |
| 4566 |
|
| 4567 |
// Description returns the semantic convention description of the instrument |
| 4568 |
func (PodMemoryUsage) Description() string { |
| 4569 |
return "Memory usage of the Pod" |
| 4570 |
} |
| 4571 |
|
| 4572 |
// Record records val to the current distribution for attrs. |
| 4573 |
// |
| 4574 |
// Total memory usage of the Pod |
| 4575 |
func (m PodMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { |
| 4576 |
if len(attrs) == 0 { |
| 4577 |
m.Int64Gauge.Record(ctx, val) |
| 4578 |
return |
| 4579 |
} |
| 4580 |
|
| 4581 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4582 |
defer func() { |
| 4583 |
*o = (*o)[:0] |
| 4584 |
recOptPool.Put(o) |
| 4585 |
}() |
| 4586 |
|
| 4587 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4588 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4589 |
} |
| 4590 |
|
| 4591 |
// RecordSet records val to the current distribution for set. |
| 4592 |
// |
| 4593 |
// Total memory usage of the Pod |
| 4594 |
func (m PodMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 4595 |
if set.Len() == 0 { |
| 4596 |
m.Int64Gauge.Record(ctx, val) |
| 4597 |
return |
| 4598 |
} |
| 4599 |
|
| 4600 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4601 |
defer func() { |
| 4602 |
*o = (*o)[:0] |
| 4603 |
recOptPool.Put(o) |
| 4604 |
}() |
| 4605 |
|
| 4606 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4607 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4608 |
} |
| 4609 |
|
| 4610 |
// PodNetworkErrors is an instrument used to record metric values conforming to |
| 4611 |
// the "k8s.pod.network.errors" semantic conventions. It represents the pod |
| 4612 |
// network errors. |
| 4613 |
type PodNetworkErrors struct { |
| 4614 |
metric.Int64Counter |
| 4615 |
} |
| 4616 |
|
| 4617 |
// NewPodNetworkErrors returns a new PodNetworkErrors instrument. |
| 4618 |
func NewPodNetworkErrors( |
| 4619 |
m metric.Meter, |
| 4620 |
opt ...metric.Int64CounterOption, |
| 4621 |
) (PodNetworkErrors, error) { |
| 4622 |
// Check if the meter is nil. |
| 4623 |
if m == nil { |
| 4624 |
return PodNetworkErrors{noop.Int64Counter{}}, nil |
| 4625 |
} |
| 4626 |
|
| 4627 |
i, err := m.Int64Counter( |
| 4628 |
"k8s.pod.network.errors", |
| 4629 |
append([]metric.Int64CounterOption{ |
| 4630 |
metric.WithDescription("Pod network errors"), |
| 4631 |
metric.WithUnit("{error}"), |
| 4632 |
}, opt...)..., |
| 4633 |
) |
| 4634 |
if err != nil { |
| 4635 |
return PodNetworkErrors{noop.Int64Counter{}}, err |
| 4636 |
} |
| 4637 |
return PodNetworkErrors{i}, nil |
| 4638 |
} |
| 4639 |
|
| 4640 |
// Inst returns the underlying metric instrument. |
| 4641 |
func (m PodNetworkErrors) Inst() metric.Int64Counter { |
| 4642 |
return m.Int64Counter |
| 4643 |
} |
| 4644 |
|
| 4645 |
// Name returns the semantic convention name of the instrument. |
| 4646 |
func (PodNetworkErrors) Name() string { |
| 4647 |
return "k8s.pod.network.errors" |
| 4648 |
} |
| 4649 |
|
| 4650 |
// Unit returns the semantic convention unit of the instrument |
| 4651 |
func (PodNetworkErrors) Unit() string { |
| 4652 |
return "{error}" |
| 4653 |
} |
| 4654 |
|
| 4655 |
// Description returns the semantic convention description of the instrument |
| 4656 |
func (PodNetworkErrors) Description() string { |
| 4657 |
return "Pod network errors" |
| 4658 |
} |
| 4659 |
|
| 4660 |
// Add adds incr to the existing count for attrs. |
| 4661 |
// |
| 4662 |
// All additional attrs passed are included in the recorded value. |
| 4663 |
func (m PodNetworkErrors) Add( |
| 4664 |
ctx context.Context, |
| 4665 |
incr int64, |
| 4666 |
attrs ...attribute.KeyValue, |
| 4667 |
) { |
| 4668 |
if len(attrs) == 0 { |
| 4669 |
m.Int64Counter.Add(ctx, incr) |
| 4670 |
return |
| 4671 |
} |
| 4672 |
|
| 4673 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4674 |
defer func() { |
| 4675 |
*o = (*o)[:0] |
| 4676 |
addOptPool.Put(o) |
| 4677 |
}() |
| 4678 |
|
| 4679 |
*o = append( |
| 4680 |
*o, |
| 4681 |
metric.WithAttributes( |
| 4682 |
attrs..., |
| 4683 |
), |
| 4684 |
) |
| 4685 |
|
| 4686 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4687 |
} |
| 4688 |
|
| 4689 |
// AddSet adds incr to the existing count for set. |
| 4690 |
func (m PodNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4691 |
if set.Len() == 0 { |
| 4692 |
m.Int64Counter.Add(ctx, incr) |
| 4693 |
return |
| 4694 |
} |
| 4695 |
|
| 4696 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4697 |
defer func() { |
| 4698 |
*o = (*o)[:0] |
| 4699 |
addOptPool.Put(o) |
| 4700 |
}() |
| 4701 |
|
| 4702 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4703 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4704 |
} |
| 4705 |
|
| 4706 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 4707 |
// "network.interface.name" semantic convention. It represents the network |
| 4708 |
// interface name. |
| 4709 |
func (PodNetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 4710 |
return attribute.String("network.interface.name", val) |
| 4711 |
} |
| 4712 |
|
| 4713 |
// AttrNetworkIODirection returns an optional attribute for the |
| 4714 |
// "network.io.direction" semantic convention. It represents the network IO |
| 4715 |
// operation direction. |
| 4716 |
func (PodNetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 4717 |
return attribute.String("network.io.direction", string(val)) |
| 4718 |
} |
| 4719 |
|
| 4720 |
// PodNetworkIO is an instrument used to record metric values conforming to the |
| 4721 |
// "k8s.pod.network.io" semantic conventions. It represents the network bytes for |
| 4722 |
// the Pod. |
| 4723 |
type PodNetworkIO struct { |
| 4724 |
metric.Int64Counter |
| 4725 |
} |
| 4726 |
|
| 4727 |
// NewPodNetworkIO returns a new PodNetworkIO instrument. |
| 4728 |
func NewPodNetworkIO( |
| 4729 |
m metric.Meter, |
| 4730 |
opt ...metric.Int64CounterOption, |
| 4731 |
) (PodNetworkIO, error) { |
| 4732 |
// Check if the meter is nil. |
| 4733 |
if m == nil { |
| 4734 |
return PodNetworkIO{noop.Int64Counter{}}, nil |
| 4735 |
} |
| 4736 |
|
| 4737 |
i, err := m.Int64Counter( |
| 4738 |
"k8s.pod.network.io", |
| 4739 |
append([]metric.Int64CounterOption{ |
| 4740 |
metric.WithDescription("Network bytes for the Pod"), |
| 4741 |
metric.WithUnit("By"), |
| 4742 |
}, opt...)..., |
| 4743 |
) |
| 4744 |
if err != nil { |
| 4745 |
return PodNetworkIO{noop.Int64Counter{}}, err |
| 4746 |
} |
| 4747 |
return PodNetworkIO{i}, nil |
| 4748 |
} |
| 4749 |
|
| 4750 |
// Inst returns the underlying metric instrument. |
| 4751 |
func (m PodNetworkIO) Inst() metric.Int64Counter { |
| 4752 |
return m.Int64Counter |
| 4753 |
} |
| 4754 |
|
| 4755 |
// Name returns the semantic convention name of the instrument. |
| 4756 |
func (PodNetworkIO) Name() string { |
| 4757 |
return "k8s.pod.network.io" |
| 4758 |
} |
| 4759 |
|
| 4760 |
// Unit returns the semantic convention unit of the instrument |
| 4761 |
func (PodNetworkIO) Unit() string { |
| 4762 |
return "By" |
| 4763 |
} |
| 4764 |
|
| 4765 |
// Description returns the semantic convention description of the instrument |
| 4766 |
func (PodNetworkIO) Description() string { |
| 4767 |
return "Network bytes for the Pod" |
| 4768 |
} |
| 4769 |
|
| 4770 |
// Add adds incr to the existing count for attrs. |
| 4771 |
// |
| 4772 |
// All additional attrs passed are included in the recorded value. |
| 4773 |
func (m PodNetworkIO) Add( |
| 4774 |
ctx context.Context, |
| 4775 |
incr int64, |
| 4776 |
attrs ...attribute.KeyValue, |
| 4777 |
) { |
| 4778 |
if len(attrs) == 0 { |
| 4779 |
m.Int64Counter.Add(ctx, incr) |
| 4780 |
return |
| 4781 |
} |
| 4782 |
|
| 4783 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4784 |
defer func() { |
| 4785 |
*o = (*o)[:0] |
| 4786 |
addOptPool.Put(o) |
| 4787 |
}() |
| 4788 |
|
| 4789 |
*o = append( |
| 4790 |
*o, |
| 4791 |
metric.WithAttributes( |
| 4792 |
attrs..., |
| 4793 |
), |
| 4794 |
) |
| 4795 |
|
| 4796 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4797 |
} |
| 4798 |
|
| 4799 |
// AddSet adds incr to the existing count for set. |
| 4800 |
func (m PodNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4801 |
if set.Len() == 0 { |
| 4802 |
m.Int64Counter.Add(ctx, incr) |
| 4803 |
return |
| 4804 |
} |
| 4805 |
|
| 4806 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4807 |
defer func() { |
| 4808 |
*o = (*o)[:0] |
| 4809 |
addOptPool.Put(o) |
| 4810 |
}() |
| 4811 |
|
| 4812 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4813 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4814 |
} |
| 4815 |
|
| 4816 |
// AttrNetworkInterfaceName returns an optional attribute for the |
| 4817 |
// "network.interface.name" semantic convention. It represents the network |
| 4818 |
// interface name. |
| 4819 |
func (PodNetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue { |
| 4820 |
return attribute.String("network.interface.name", val) |
| 4821 |
} |
| 4822 |
|
| 4823 |
// AttrNetworkIODirection returns an optional attribute for the |
| 4824 |
// "network.io.direction" semantic convention. It represents the network IO |
| 4825 |
// operation direction. |
| 4826 |
func (PodNetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 4827 |
return attribute.String("network.io.direction", string(val)) |
| 4828 |
} |
| 4829 |
|
| 4830 |
// PodUptime is an instrument used to record metric values conforming to the |
| 4831 |
// "k8s.pod.uptime" semantic conventions. It represents the time the Pod has been |
| 4832 |
// running. |
| 4833 |
type PodUptime struct { |
| 4834 |
metric.Float64Gauge |
| 4835 |
} |
| 4836 |
|
| 4837 |
// NewPodUptime returns a new PodUptime instrument. |
| 4838 |
func NewPodUptime( |
| 4839 |
m metric.Meter, |
| 4840 |
opt ...metric.Float64GaugeOption, |
| 4841 |
) (PodUptime, error) { |
| 4842 |
// Check if the meter is nil. |
| 4843 |
if m == nil { |
| 4844 |
return PodUptime{noop.Float64Gauge{}}, nil |
| 4845 |
} |
| 4846 |
|
| 4847 |
i, err := m.Float64Gauge( |
| 4848 |
"k8s.pod.uptime", |
| 4849 |
append([]metric.Float64GaugeOption{ |
| 4850 |
metric.WithDescription("The time the Pod has been running"), |
| 4851 |
metric.WithUnit("s"), |
| 4852 |
}, opt...)..., |
| 4853 |
) |
| 4854 |
if err != nil { |
| 4855 |
return PodUptime{noop.Float64Gauge{}}, err |
| 4856 |
} |
| 4857 |
return PodUptime{i}, nil |
| 4858 |
} |
| 4859 |
|
| 4860 |
// Inst returns the underlying metric instrument. |
| 4861 |
func (m PodUptime) Inst() metric.Float64Gauge { |
| 4862 |
return m.Float64Gauge |
| 4863 |
} |
| 4864 |
|
| 4865 |
// Name returns the semantic convention name of the instrument. |
| 4866 |
func (PodUptime) Name() string { |
| 4867 |
return "k8s.pod.uptime" |
| 4868 |
} |
| 4869 |
|
| 4870 |
// Unit returns the semantic convention unit of the instrument |
| 4871 |
func (PodUptime) Unit() string { |
| 4872 |
return "s" |
| 4873 |
} |
| 4874 |
|
| 4875 |
// Description returns the semantic convention description of the instrument |
| 4876 |
func (PodUptime) Description() string { |
| 4877 |
return "The time the Pod has been running" |
| 4878 |
} |
| 4879 |
|
| 4880 |
// Record records val to the current distribution for attrs. |
| 4881 |
// |
| 4882 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 4883 |
// seconds as a floating point number with the highest precision available. |
| 4884 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 4885 |
func (m PodUptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) { |
| 4886 |
if len(attrs) == 0 { |
| 4887 |
m.Float64Gauge.Record(ctx, val) |
| 4888 |
return |
| 4889 |
} |
| 4890 |
|
| 4891 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4892 |
defer func() { |
| 4893 |
*o = (*o)[:0] |
| 4894 |
recOptPool.Put(o) |
| 4895 |
}() |
| 4896 |
|
| 4897 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4898 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 4899 |
} |
| 4900 |
|
| 4901 |
// RecordSet records val to the current distribution for set. |
| 4902 |
// |
| 4903 |
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in |
| 4904 |
// seconds as a floating point number with the highest precision available. |
| 4905 |
// The actual accuracy would depend on the instrumentation and operating system. |
| 4906 |
func (m PodUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { |
| 4907 |
if set.Len() == 0 { |
| 4908 |
m.Float64Gauge.Record(ctx, val) |
| 4909 |
return |
| 4910 |
} |
| 4911 |
|
| 4912 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4913 |
defer func() { |
| 4914 |
*o = (*o)[:0] |
| 4915 |
recOptPool.Put(o) |
| 4916 |
}() |
| 4917 |
|
| 4918 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4919 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 4920 |
} |
| 4921 |
|
| 4922 |
// ReplicaSetAvailablePods is an instrument used to record metric values |
| 4923 |
// conforming to the "k8s.replicaset.available_pods" semantic conventions. It |
| 4924 |
// represents the total number of available replica pods (ready for at least |
| 4925 |
// minReadySeconds) targeted by this replicaset. |
| 4926 |
type ReplicaSetAvailablePods struct { |
| 4927 |
metric.Int64UpDownCounter |
| 4928 |
} |
| 4929 |
|
| 4930 |
// NewReplicaSetAvailablePods returns a new ReplicaSetAvailablePods instrument. |
| 4931 |
func NewReplicaSetAvailablePods( |
| 4932 |
m metric.Meter, |
| 4933 |
opt ...metric.Int64UpDownCounterOption, |
| 4934 |
) (ReplicaSetAvailablePods, error) { |
| 4935 |
// Check if the meter is nil. |
| 4936 |
if m == nil { |
| 4937 |
return ReplicaSetAvailablePods{noop.Int64UpDownCounter{}}, nil |
| 4938 |
} |
| 4939 |
|
| 4940 |
i, err := m.Int64UpDownCounter( |
| 4941 |
"k8s.replicaset.available_pods", |
| 4942 |
append([]metric.Int64UpDownCounterOption{ |
| 4943 |
metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset"), |
| 4944 |
metric.WithUnit("{pod}"), |
| 4945 |
}, opt...)..., |
| 4946 |
) |
| 4947 |
if err != nil { |
| 4948 |
return ReplicaSetAvailablePods{noop.Int64UpDownCounter{}}, err |
| 4949 |
} |
| 4950 |
return ReplicaSetAvailablePods{i}, nil |
| 4951 |
} |
| 4952 |
|
| 4953 |
// Inst returns the underlying metric instrument. |
| 4954 |
func (m ReplicaSetAvailablePods) Inst() metric.Int64UpDownCounter { |
| 4955 |
return m.Int64UpDownCounter |
| 4956 |
} |
| 4957 |
|
| 4958 |
// Name returns the semantic convention name of the instrument. |
| 4959 |
func (ReplicaSetAvailablePods) Name() string { |
| 4960 |
return "k8s.replicaset.available_pods" |
| 4961 |
} |
| 4962 |
|
| 4963 |
// Unit returns the semantic convention unit of the instrument |
| 4964 |
func (ReplicaSetAvailablePods) Unit() string { |
| 4965 |
return "{pod}" |
| 4966 |
} |
| 4967 |
|
| 4968 |
// Description returns the semantic convention description of the instrument |
| 4969 |
func (ReplicaSetAvailablePods) Description() string { |
| 4970 |
return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset" |
| 4971 |
} |
| 4972 |
|
| 4973 |
// Add adds incr to the existing count for attrs. |
| 4974 |
// |
| 4975 |
// This metric aligns with the `availableReplicas` field of the |
| 4976 |
// [K8s ReplicaSetStatus]. |
| 4977 |
// |
| 4978 |
// [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps |
| 4979 |
func (m ReplicaSetAvailablePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 4980 |
if len(attrs) == 0 { |
| 4981 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4982 |
return |
| 4983 |
} |
| 4984 |
|
| 4985 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4986 |
defer func() { |
| 4987 |
*o = (*o)[:0] |
| 4988 |
addOptPool.Put(o) |
| 4989 |
}() |
| 4990 |
|
| 4991 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 4992 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4993 |
} |
| 4994 |
|
| 4995 |
// AddSet adds incr to the existing count for set. |
| 4996 |
// |
| 4997 |
// This metric aligns with the `availableReplicas` field of the |
| 4998 |
// [K8s ReplicaSetStatus]. |
| 4999 |
// |
| 5000 |
// [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps |
| 5001 |
func (m ReplicaSetAvailablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5002 |
if set.Len() == 0 { |
| 5003 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5004 |
return |
| 5005 |
} |
| 5006 |
|
| 5007 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5008 |
defer func() { |
| 5009 |
*o = (*o)[:0] |
| 5010 |
addOptPool.Put(o) |
| 5011 |
}() |
| 5012 |
|
| 5013 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5014 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5015 |
} |
| 5016 |
|
| 5017 |
// ReplicaSetDesiredPods is an instrument used to record metric values conforming |
| 5018 |
// to the "k8s.replicaset.desired_pods" semantic conventions. It represents the |
| 5019 |
// number of desired replica pods in this replicaset. |
| 5020 |
type ReplicaSetDesiredPods struct { |
| 5021 |
metric.Int64UpDownCounter |
| 5022 |
} |
| 5023 |
|
| 5024 |
// NewReplicaSetDesiredPods returns a new ReplicaSetDesiredPods instrument. |
| 5025 |
func NewReplicaSetDesiredPods( |
| 5026 |
m metric.Meter, |
| 5027 |
opt ...metric.Int64UpDownCounterOption, |
| 5028 |
) (ReplicaSetDesiredPods, error) { |
| 5029 |
// Check if the meter is nil. |
| 5030 |
if m == nil { |
| 5031 |
return ReplicaSetDesiredPods{noop.Int64UpDownCounter{}}, nil |
| 5032 |
} |
| 5033 |
|
| 5034 |
i, err := m.Int64UpDownCounter( |
| 5035 |
"k8s.replicaset.desired_pods", |
| 5036 |
append([]metric.Int64UpDownCounterOption{ |
| 5037 |
metric.WithDescription("Number of desired replica pods in this replicaset"), |
| 5038 |
metric.WithUnit("{pod}"), |
| 5039 |
}, opt...)..., |
| 5040 |
) |
| 5041 |
if err != nil { |
| 5042 |
return ReplicaSetDesiredPods{noop.Int64UpDownCounter{}}, err |
| 5043 |
} |
| 5044 |
return ReplicaSetDesiredPods{i}, nil |
| 5045 |
} |
| 5046 |
|
| 5047 |
// Inst returns the underlying metric instrument. |
| 5048 |
func (m ReplicaSetDesiredPods) Inst() metric.Int64UpDownCounter { |
| 5049 |
return m.Int64UpDownCounter |
| 5050 |
} |
| 5051 |
|
| 5052 |
// Name returns the semantic convention name of the instrument. |
| 5053 |
func (ReplicaSetDesiredPods) Name() string { |
| 5054 |
return "k8s.replicaset.desired_pods" |
| 5055 |
} |
| 5056 |
|
| 5057 |
// Unit returns the semantic convention unit of the instrument |
| 5058 |
func (ReplicaSetDesiredPods) Unit() string { |
| 5059 |
return "{pod}" |
| 5060 |
} |
| 5061 |
|
| 5062 |
// Description returns the semantic convention description of the instrument |
| 5063 |
func (ReplicaSetDesiredPods) Description() string { |
| 5064 |
return "Number of desired replica pods in this replicaset" |
| 5065 |
} |
| 5066 |
|
| 5067 |
// Add adds incr to the existing count for attrs. |
| 5068 |
// |
| 5069 |
// This metric aligns with the `replicas` field of the |
| 5070 |
// [K8s ReplicaSetSpec]. |
| 5071 |
// |
| 5072 |
// [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps |
| 5073 |
func (m ReplicaSetDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5074 |
if len(attrs) == 0 { |
| 5075 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5076 |
return |
| 5077 |
} |
| 5078 |
|
| 5079 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5080 |
defer func() { |
| 5081 |
*o = (*o)[:0] |
| 5082 |
addOptPool.Put(o) |
| 5083 |
}() |
| 5084 |
|
| 5085 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5086 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5087 |
} |
| 5088 |
|
| 5089 |
// AddSet adds incr to the existing count for set. |
| 5090 |
// |
| 5091 |
// This metric aligns with the `replicas` field of the |
| 5092 |
// [K8s ReplicaSetSpec]. |
| 5093 |
// |
| 5094 |
// [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps |
| 5095 |
func (m ReplicaSetDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5096 |
if set.Len() == 0 { |
| 5097 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5098 |
return |
| 5099 |
} |
| 5100 |
|
| 5101 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5102 |
defer func() { |
| 5103 |
*o = (*o)[:0] |
| 5104 |
addOptPool.Put(o) |
| 5105 |
}() |
| 5106 |
|
| 5107 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5108 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5109 |
} |
| 5110 |
|
| 5111 |
// ReplicationControllerAvailablePods is an instrument used to record metric |
| 5112 |
// values conforming to the "k8s.replicationcontroller.available_pods" semantic |
| 5113 |
// conventions. It represents the total number of available replica pods (ready |
| 5114 |
// for at least minReadySeconds) targeted by this replication controller. |
| 5115 |
type ReplicationControllerAvailablePods struct { |
| 5116 |
metric.Int64UpDownCounter |
| 5117 |
} |
| 5118 |
|
| 5119 |
// NewReplicationControllerAvailablePods returns a new |
| 5120 |
// ReplicationControllerAvailablePods instrument. |
| 5121 |
func NewReplicationControllerAvailablePods( |
| 5122 |
m metric.Meter, |
| 5123 |
opt ...metric.Int64UpDownCounterOption, |
| 5124 |
) (ReplicationControllerAvailablePods, error) { |
| 5125 |
// Check if the meter is nil. |
| 5126 |
if m == nil { |
| 5127 |
return ReplicationControllerAvailablePods{noop.Int64UpDownCounter{}}, nil |
| 5128 |
} |
| 5129 |
|
| 5130 |
i, err := m.Int64UpDownCounter( |
| 5131 |
"k8s.replicationcontroller.available_pods", |
| 5132 |
append([]metric.Int64UpDownCounterOption{ |
| 5133 |
metric.WithDescription("Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller"), |
| 5134 |
metric.WithUnit("{pod}"), |
| 5135 |
}, opt...)..., |
| 5136 |
) |
| 5137 |
if err != nil { |
| 5138 |
return ReplicationControllerAvailablePods{noop.Int64UpDownCounter{}}, err |
| 5139 |
} |
| 5140 |
return ReplicationControllerAvailablePods{i}, nil |
| 5141 |
} |
| 5142 |
|
| 5143 |
// Inst returns the underlying metric instrument. |
| 5144 |
func (m ReplicationControllerAvailablePods) Inst() metric.Int64UpDownCounter { |
| 5145 |
return m.Int64UpDownCounter |
| 5146 |
} |
| 5147 |
|
| 5148 |
// Name returns the semantic convention name of the instrument. |
| 5149 |
func (ReplicationControllerAvailablePods) Name() string { |
| 5150 |
return "k8s.replicationcontroller.available_pods" |
| 5151 |
} |
| 5152 |
|
| 5153 |
// Unit returns the semantic convention unit of the instrument |
| 5154 |
func (ReplicationControllerAvailablePods) Unit() string { |
| 5155 |
return "{pod}" |
| 5156 |
} |
| 5157 |
|
| 5158 |
// Description returns the semantic convention description of the instrument |
| 5159 |
func (ReplicationControllerAvailablePods) Description() string { |
| 5160 |
return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller" |
| 5161 |
} |
| 5162 |
|
| 5163 |
// Add adds incr to the existing count for attrs. |
| 5164 |
// |
| 5165 |
// This metric aligns with the `availableReplicas` field of the |
| 5166 |
// [K8s ReplicationControllerStatus] |
| 5167 |
// |
| 5168 |
// [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core |
| 5169 |
func (m ReplicationControllerAvailablePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5170 |
if len(attrs) == 0 { |
| 5171 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5172 |
return |
| 5173 |
} |
| 5174 |
|
| 5175 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5176 |
defer func() { |
| 5177 |
*o = (*o)[:0] |
| 5178 |
addOptPool.Put(o) |
| 5179 |
}() |
| 5180 |
|
| 5181 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5182 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5183 |
} |
| 5184 |
|
| 5185 |
// AddSet adds incr to the existing count for set. |
| 5186 |
// |
| 5187 |
// This metric aligns with the `availableReplicas` field of the |
| 5188 |
// [K8s ReplicationControllerStatus] |
| 5189 |
// |
| 5190 |
// [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core |
| 5191 |
func (m ReplicationControllerAvailablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5192 |
if set.Len() == 0 { |
| 5193 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5194 |
return |
| 5195 |
} |
| 5196 |
|
| 5197 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5198 |
defer func() { |
| 5199 |
*o = (*o)[:0] |
| 5200 |
addOptPool.Put(o) |
| 5201 |
}() |
| 5202 |
|
| 5203 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5204 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5205 |
} |
| 5206 |
|
| 5207 |
// ReplicationControllerDesiredPods is an instrument used to record metric values |
| 5208 |
// conforming to the "k8s.replicationcontroller.desired_pods" semantic |
| 5209 |
// conventions. It represents the number of desired replica pods in this |
| 5210 |
// replication controller. |
| 5211 |
type ReplicationControllerDesiredPods struct { |
| 5212 |
metric.Int64UpDownCounter |
| 5213 |
} |
| 5214 |
|
| 5215 |
// NewReplicationControllerDesiredPods returns a new |
| 5216 |
// ReplicationControllerDesiredPods instrument. |
| 5217 |
func NewReplicationControllerDesiredPods( |
| 5218 |
m metric.Meter, |
| 5219 |
opt ...metric.Int64UpDownCounterOption, |
| 5220 |
) (ReplicationControllerDesiredPods, error) { |
| 5221 |
// Check if the meter is nil. |
| 5222 |
if m == nil { |
| 5223 |
return ReplicationControllerDesiredPods{noop.Int64UpDownCounter{}}, nil |
| 5224 |
} |
| 5225 |
|
| 5226 |
i, err := m.Int64UpDownCounter( |
| 5227 |
"k8s.replicationcontroller.desired_pods", |
| 5228 |
append([]metric.Int64UpDownCounterOption{ |
| 5229 |
metric.WithDescription("Number of desired replica pods in this replication controller"), |
| 5230 |
metric.WithUnit("{pod}"), |
| 5231 |
}, opt...)..., |
| 5232 |
) |
| 5233 |
if err != nil { |
| 5234 |
return ReplicationControllerDesiredPods{noop.Int64UpDownCounter{}}, err |
| 5235 |
} |
| 5236 |
return ReplicationControllerDesiredPods{i}, nil |
| 5237 |
} |
| 5238 |
|
| 5239 |
// Inst returns the underlying metric instrument. |
| 5240 |
func (m ReplicationControllerDesiredPods) Inst() metric.Int64UpDownCounter { |
| 5241 |
return m.Int64UpDownCounter |
| 5242 |
} |
| 5243 |
|
| 5244 |
// Name returns the semantic convention name of the instrument. |
| 5245 |
func (ReplicationControllerDesiredPods) Name() string { |
| 5246 |
return "k8s.replicationcontroller.desired_pods" |
| 5247 |
} |
| 5248 |
|
| 5249 |
// Unit returns the semantic convention unit of the instrument |
| 5250 |
func (ReplicationControllerDesiredPods) Unit() string { |
| 5251 |
return "{pod}" |
| 5252 |
} |
| 5253 |
|
| 5254 |
// Description returns the semantic convention description of the instrument |
| 5255 |
func (ReplicationControllerDesiredPods) Description() string { |
| 5256 |
return "Number of desired replica pods in this replication controller" |
| 5257 |
} |
| 5258 |
|
| 5259 |
// Add adds incr to the existing count for attrs. |
| 5260 |
// |
| 5261 |
// This metric aligns with the `replicas` field of the |
| 5262 |
// [K8s ReplicationControllerSpec] |
| 5263 |
// |
| 5264 |
// [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core |
| 5265 |
func (m ReplicationControllerDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5266 |
if len(attrs) == 0 { |
| 5267 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5268 |
return |
| 5269 |
} |
| 5270 |
|
| 5271 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5272 |
defer func() { |
| 5273 |
*o = (*o)[:0] |
| 5274 |
addOptPool.Put(o) |
| 5275 |
}() |
| 5276 |
|
| 5277 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5278 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5279 |
} |
| 5280 |
|
| 5281 |
// AddSet adds incr to the existing count for set. |
| 5282 |
// |
| 5283 |
// This metric aligns with the `replicas` field of the |
| 5284 |
// [K8s ReplicationControllerSpec] |
| 5285 |
// |
| 5286 |
// [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core |
| 5287 |
func (m ReplicationControllerDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5288 |
if set.Len() == 0 { |
| 5289 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5290 |
return |
| 5291 |
} |
| 5292 |
|
| 5293 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5294 |
defer func() { |
| 5295 |
*o = (*o)[:0] |
| 5296 |
addOptPool.Put(o) |
| 5297 |
}() |
| 5298 |
|
| 5299 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5300 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5301 |
} |
| 5302 |
|
| 5303 |
// ResourceQuotaCPULimitHard is an instrument used to record metric values |
| 5304 |
// conforming to the "k8s.resourcequota.cpu.limit.hard" semantic conventions. It |
| 5305 |
// represents the CPU limits in a specific namespace. |
| 5306 |
// The value represents the configured quota limit of the resource in the |
| 5307 |
// namespace. |
| 5308 |
type ResourceQuotaCPULimitHard struct { |
| 5309 |
metric.Int64UpDownCounter |
| 5310 |
} |
| 5311 |
|
| 5312 |
// NewResourceQuotaCPULimitHard returns a new ResourceQuotaCPULimitHard |
| 5313 |
// instrument. |
| 5314 |
func NewResourceQuotaCPULimitHard( |
| 5315 |
m metric.Meter, |
| 5316 |
opt ...metric.Int64UpDownCounterOption, |
| 5317 |
) (ResourceQuotaCPULimitHard, error) { |
| 5318 |
// Check if the meter is nil. |
| 5319 |
if m == nil { |
| 5320 |
return ResourceQuotaCPULimitHard{noop.Int64UpDownCounter{}}, nil |
| 5321 |
} |
| 5322 |
|
| 5323 |
i, err := m.Int64UpDownCounter( |
| 5324 |
"k8s.resourcequota.cpu.limit.hard", |
| 5325 |
append([]metric.Int64UpDownCounterOption{ |
| 5326 |
metric.WithDescription("The CPU limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 5327 |
metric.WithUnit("{cpu}"), |
| 5328 |
}, opt...)..., |
| 5329 |
) |
| 5330 |
if err != nil { |
| 5331 |
return ResourceQuotaCPULimitHard{noop.Int64UpDownCounter{}}, err |
| 5332 |
} |
| 5333 |
return ResourceQuotaCPULimitHard{i}, nil |
| 5334 |
} |
| 5335 |
|
| 5336 |
// Inst returns the underlying metric instrument. |
| 5337 |
func (m ResourceQuotaCPULimitHard) Inst() metric.Int64UpDownCounter { |
| 5338 |
return m.Int64UpDownCounter |
| 5339 |
} |
| 5340 |
|
| 5341 |
// Name returns the semantic convention name of the instrument. |
| 5342 |
func (ResourceQuotaCPULimitHard) Name() string { |
| 5343 |
return "k8s.resourcequota.cpu.limit.hard" |
| 5344 |
} |
| 5345 |
|
| 5346 |
// Unit returns the semantic convention unit of the instrument |
| 5347 |
func (ResourceQuotaCPULimitHard) Unit() string { |
| 5348 |
return "{cpu}" |
| 5349 |
} |
| 5350 |
|
| 5351 |
// Description returns the semantic convention description of the instrument |
| 5352 |
func (ResourceQuotaCPULimitHard) Description() string { |
| 5353 |
return "The CPU limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 5354 |
} |
| 5355 |
|
| 5356 |
// Add adds incr to the existing count for attrs. |
| 5357 |
// |
| 5358 |
// This metric is retrieved from the `hard` field of the |
| 5359 |
// [K8s ResourceQuotaStatus]. |
| 5360 |
// |
| 5361 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5362 |
func (m ResourceQuotaCPULimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5363 |
if len(attrs) == 0 { |
| 5364 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5365 |
return |
| 5366 |
} |
| 5367 |
|
| 5368 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5369 |
defer func() { |
| 5370 |
*o = (*o)[:0] |
| 5371 |
addOptPool.Put(o) |
| 5372 |
}() |
| 5373 |
|
| 5374 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5375 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5376 |
} |
| 5377 |
|
| 5378 |
// AddSet adds incr to the existing count for set. |
| 5379 |
// |
| 5380 |
// This metric is retrieved from the `hard` field of the |
| 5381 |
// [K8s ResourceQuotaStatus]. |
| 5382 |
// |
| 5383 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5384 |
func (m ResourceQuotaCPULimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5385 |
if set.Len() == 0 { |
| 5386 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5387 |
return |
| 5388 |
} |
| 5389 |
|
| 5390 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5391 |
defer func() { |
| 5392 |
*o = (*o)[:0] |
| 5393 |
addOptPool.Put(o) |
| 5394 |
}() |
| 5395 |
|
| 5396 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5397 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5398 |
} |
| 5399 |
|
| 5400 |
// ResourceQuotaCPULimitUsed is an instrument used to record metric values |
| 5401 |
// conforming to the "k8s.resourcequota.cpu.limit.used" semantic conventions. It |
| 5402 |
// represents the CPU limits in a specific namespace. |
| 5403 |
// The value represents the current observed total usage of the resource in the |
| 5404 |
// namespace. |
| 5405 |
type ResourceQuotaCPULimitUsed struct { |
| 5406 |
metric.Int64UpDownCounter |
| 5407 |
} |
| 5408 |
|
| 5409 |
// NewResourceQuotaCPULimitUsed returns a new ResourceQuotaCPULimitUsed |
| 5410 |
// instrument. |
| 5411 |
func NewResourceQuotaCPULimitUsed( |
| 5412 |
m metric.Meter, |
| 5413 |
opt ...metric.Int64UpDownCounterOption, |
| 5414 |
) (ResourceQuotaCPULimitUsed, error) { |
| 5415 |
// Check if the meter is nil. |
| 5416 |
if m == nil { |
| 5417 |
return ResourceQuotaCPULimitUsed{noop.Int64UpDownCounter{}}, nil |
| 5418 |
} |
| 5419 |
|
| 5420 |
i, err := m.Int64UpDownCounter( |
| 5421 |
"k8s.resourcequota.cpu.limit.used", |
| 5422 |
append([]metric.Int64UpDownCounterOption{ |
| 5423 |
metric.WithDescription("The CPU limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 5424 |
metric.WithUnit("{cpu}"), |
| 5425 |
}, opt...)..., |
| 5426 |
) |
| 5427 |
if err != nil { |
| 5428 |
return ResourceQuotaCPULimitUsed{noop.Int64UpDownCounter{}}, err |
| 5429 |
} |
| 5430 |
return ResourceQuotaCPULimitUsed{i}, nil |
| 5431 |
} |
| 5432 |
|
| 5433 |
// Inst returns the underlying metric instrument. |
| 5434 |
func (m ResourceQuotaCPULimitUsed) Inst() metric.Int64UpDownCounter { |
| 5435 |
return m.Int64UpDownCounter |
| 5436 |
} |
| 5437 |
|
| 5438 |
// Name returns the semantic convention name of the instrument. |
| 5439 |
func (ResourceQuotaCPULimitUsed) Name() string { |
| 5440 |
return "k8s.resourcequota.cpu.limit.used" |
| 5441 |
} |
| 5442 |
|
| 5443 |
// Unit returns the semantic convention unit of the instrument |
| 5444 |
func (ResourceQuotaCPULimitUsed) Unit() string { |
| 5445 |
return "{cpu}" |
| 5446 |
} |
| 5447 |
|
| 5448 |
// Description returns the semantic convention description of the instrument |
| 5449 |
func (ResourceQuotaCPULimitUsed) Description() string { |
| 5450 |
return "The CPU limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 5451 |
} |
| 5452 |
|
| 5453 |
// Add adds incr to the existing count for attrs. |
| 5454 |
// |
| 5455 |
// This metric is retrieved from the `used` field of the |
| 5456 |
// [K8s ResourceQuotaStatus]. |
| 5457 |
// |
| 5458 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5459 |
func (m ResourceQuotaCPULimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5460 |
if len(attrs) == 0 { |
| 5461 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5462 |
return |
| 5463 |
} |
| 5464 |
|
| 5465 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5466 |
defer func() { |
| 5467 |
*o = (*o)[:0] |
| 5468 |
addOptPool.Put(o) |
| 5469 |
}() |
| 5470 |
|
| 5471 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5472 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5473 |
} |
| 5474 |
|
| 5475 |
// AddSet adds incr to the existing count for set. |
| 5476 |
// |
| 5477 |
// This metric is retrieved from the `used` field of the |
| 5478 |
// [K8s ResourceQuotaStatus]. |
| 5479 |
// |
| 5480 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5481 |
func (m ResourceQuotaCPULimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5482 |
if set.Len() == 0 { |
| 5483 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5484 |
return |
| 5485 |
} |
| 5486 |
|
| 5487 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5488 |
defer func() { |
| 5489 |
*o = (*o)[:0] |
| 5490 |
addOptPool.Put(o) |
| 5491 |
}() |
| 5492 |
|
| 5493 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5494 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5495 |
} |
| 5496 |
|
| 5497 |
// ResourceQuotaCPURequestHard is an instrument used to record metric values |
| 5498 |
// conforming to the "k8s.resourcequota.cpu.request.hard" semantic conventions. |
| 5499 |
// It represents the CPU requests in a specific namespace. |
| 5500 |
// The value represents the configured quota limit of the resource in the |
| 5501 |
// namespace. |
| 5502 |
type ResourceQuotaCPURequestHard struct { |
| 5503 |
metric.Int64UpDownCounter |
| 5504 |
} |
| 5505 |
|
| 5506 |
// NewResourceQuotaCPURequestHard returns a new ResourceQuotaCPURequestHard |
| 5507 |
// instrument. |
| 5508 |
func NewResourceQuotaCPURequestHard( |
| 5509 |
m metric.Meter, |
| 5510 |
opt ...metric.Int64UpDownCounterOption, |
| 5511 |
) (ResourceQuotaCPURequestHard, error) { |
| 5512 |
// Check if the meter is nil. |
| 5513 |
if m == nil { |
| 5514 |
return ResourceQuotaCPURequestHard{noop.Int64UpDownCounter{}}, nil |
| 5515 |
} |
| 5516 |
|
| 5517 |
i, err := m.Int64UpDownCounter( |
| 5518 |
"k8s.resourcequota.cpu.request.hard", |
| 5519 |
append([]metric.Int64UpDownCounterOption{ |
| 5520 |
metric.WithDescription("The CPU requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 5521 |
metric.WithUnit("{cpu}"), |
| 5522 |
}, opt...)..., |
| 5523 |
) |
| 5524 |
if err != nil { |
| 5525 |
return ResourceQuotaCPURequestHard{noop.Int64UpDownCounter{}}, err |
| 5526 |
} |
| 5527 |
return ResourceQuotaCPURequestHard{i}, nil |
| 5528 |
} |
| 5529 |
|
| 5530 |
// Inst returns the underlying metric instrument. |
| 5531 |
func (m ResourceQuotaCPURequestHard) Inst() metric.Int64UpDownCounter { |
| 5532 |
return m.Int64UpDownCounter |
| 5533 |
} |
| 5534 |
|
| 5535 |
// Name returns the semantic convention name of the instrument. |
| 5536 |
func (ResourceQuotaCPURequestHard) Name() string { |
| 5537 |
return "k8s.resourcequota.cpu.request.hard" |
| 5538 |
} |
| 5539 |
|
| 5540 |
// Unit returns the semantic convention unit of the instrument |
| 5541 |
func (ResourceQuotaCPURequestHard) Unit() string { |
| 5542 |
return "{cpu}" |
| 5543 |
} |
| 5544 |
|
| 5545 |
// Description returns the semantic convention description of the instrument |
| 5546 |
func (ResourceQuotaCPURequestHard) Description() string { |
| 5547 |
return "The CPU requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 5548 |
} |
| 5549 |
|
| 5550 |
// Add adds incr to the existing count for attrs. |
| 5551 |
// |
| 5552 |
// This metric is retrieved from the `hard` field of the |
| 5553 |
// [K8s ResourceQuotaStatus]. |
| 5554 |
// |
| 5555 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5556 |
func (m ResourceQuotaCPURequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5557 |
if len(attrs) == 0 { |
| 5558 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5559 |
return |
| 5560 |
} |
| 5561 |
|
| 5562 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5563 |
defer func() { |
| 5564 |
*o = (*o)[:0] |
| 5565 |
addOptPool.Put(o) |
| 5566 |
}() |
| 5567 |
|
| 5568 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5569 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5570 |
} |
| 5571 |
|
| 5572 |
// AddSet adds incr to the existing count for set. |
| 5573 |
// |
| 5574 |
// This metric is retrieved from the `hard` field of the |
| 5575 |
// [K8s ResourceQuotaStatus]. |
| 5576 |
// |
| 5577 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5578 |
func (m ResourceQuotaCPURequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5579 |
if set.Len() == 0 { |
| 5580 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5581 |
return |
| 5582 |
} |
| 5583 |
|
| 5584 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5585 |
defer func() { |
| 5586 |
*o = (*o)[:0] |
| 5587 |
addOptPool.Put(o) |
| 5588 |
}() |
| 5589 |
|
| 5590 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5591 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5592 |
} |
| 5593 |
|
| 5594 |
// ResourceQuotaCPURequestUsed is an instrument used to record metric values |
| 5595 |
// conforming to the "k8s.resourcequota.cpu.request.used" semantic conventions. |
| 5596 |
// It represents the CPU requests in a specific namespace. |
| 5597 |
// The value represents the current observed total usage of the resource in the |
| 5598 |
// namespace. |
| 5599 |
type ResourceQuotaCPURequestUsed struct { |
| 5600 |
metric.Int64UpDownCounter |
| 5601 |
} |
| 5602 |
|
| 5603 |
// NewResourceQuotaCPURequestUsed returns a new ResourceQuotaCPURequestUsed |
| 5604 |
// instrument. |
| 5605 |
func NewResourceQuotaCPURequestUsed( |
| 5606 |
m metric.Meter, |
| 5607 |
opt ...metric.Int64UpDownCounterOption, |
| 5608 |
) (ResourceQuotaCPURequestUsed, error) { |
| 5609 |
// Check if the meter is nil. |
| 5610 |
if m == nil { |
| 5611 |
return ResourceQuotaCPURequestUsed{noop.Int64UpDownCounter{}}, nil |
| 5612 |
} |
| 5613 |
|
| 5614 |
i, err := m.Int64UpDownCounter( |
| 5615 |
"k8s.resourcequota.cpu.request.used", |
| 5616 |
append([]metric.Int64UpDownCounterOption{ |
| 5617 |
metric.WithDescription("The CPU requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 5618 |
metric.WithUnit("{cpu}"), |
| 5619 |
}, opt...)..., |
| 5620 |
) |
| 5621 |
if err != nil { |
| 5622 |
return ResourceQuotaCPURequestUsed{noop.Int64UpDownCounter{}}, err |
| 5623 |
} |
| 5624 |
return ResourceQuotaCPURequestUsed{i}, nil |
| 5625 |
} |
| 5626 |
|
| 5627 |
// Inst returns the underlying metric instrument. |
| 5628 |
func (m ResourceQuotaCPURequestUsed) Inst() metric.Int64UpDownCounter { |
| 5629 |
return m.Int64UpDownCounter |
| 5630 |
} |
| 5631 |
|
| 5632 |
// Name returns the semantic convention name of the instrument. |
| 5633 |
func (ResourceQuotaCPURequestUsed) Name() string { |
| 5634 |
return "k8s.resourcequota.cpu.request.used" |
| 5635 |
} |
| 5636 |
|
| 5637 |
// Unit returns the semantic convention unit of the instrument |
| 5638 |
func (ResourceQuotaCPURequestUsed) Unit() string { |
| 5639 |
return "{cpu}" |
| 5640 |
} |
| 5641 |
|
| 5642 |
// Description returns the semantic convention description of the instrument |
| 5643 |
func (ResourceQuotaCPURequestUsed) Description() string { |
| 5644 |
return "The CPU requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 5645 |
} |
| 5646 |
|
| 5647 |
// Add adds incr to the existing count for attrs. |
| 5648 |
// |
| 5649 |
// This metric is retrieved from the `used` field of the |
| 5650 |
// [K8s ResourceQuotaStatus]. |
| 5651 |
// |
| 5652 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5653 |
func (m ResourceQuotaCPURequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5654 |
if len(attrs) == 0 { |
| 5655 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5656 |
return |
| 5657 |
} |
| 5658 |
|
| 5659 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5660 |
defer func() { |
| 5661 |
*o = (*o)[:0] |
| 5662 |
addOptPool.Put(o) |
| 5663 |
}() |
| 5664 |
|
| 5665 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5666 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5667 |
} |
| 5668 |
|
| 5669 |
// AddSet adds incr to the existing count for set. |
| 5670 |
// |
| 5671 |
// This metric is retrieved from the `used` field of the |
| 5672 |
// [K8s ResourceQuotaStatus]. |
| 5673 |
// |
| 5674 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5675 |
func (m ResourceQuotaCPURequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5676 |
if set.Len() == 0 { |
| 5677 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5678 |
return |
| 5679 |
} |
| 5680 |
|
| 5681 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5682 |
defer func() { |
| 5683 |
*o = (*o)[:0] |
| 5684 |
addOptPool.Put(o) |
| 5685 |
}() |
| 5686 |
|
| 5687 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5688 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5689 |
} |
| 5690 |
|
| 5691 |
// ResourceQuotaEphemeralStorageLimitHard is an instrument used to record metric |
| 5692 |
// values conforming to the "k8s.resourcequota.ephemeral_storage.limit.hard" |
| 5693 |
// semantic conventions. It represents the sum of local ephemeral storage limits |
| 5694 |
// in the namespace. |
| 5695 |
// The value represents the configured quota limit of the resource in the |
| 5696 |
// namespace. |
| 5697 |
type ResourceQuotaEphemeralStorageLimitHard struct { |
| 5698 |
metric.Int64UpDownCounter |
| 5699 |
} |
| 5700 |
|
| 5701 |
// NewResourceQuotaEphemeralStorageLimitHard returns a new |
| 5702 |
// ResourceQuotaEphemeralStorageLimitHard instrument. |
| 5703 |
func NewResourceQuotaEphemeralStorageLimitHard( |
| 5704 |
m metric.Meter, |
| 5705 |
opt ...metric.Int64UpDownCounterOption, |
| 5706 |
) (ResourceQuotaEphemeralStorageLimitHard, error) { |
| 5707 |
// Check if the meter is nil. |
| 5708 |
if m == nil { |
| 5709 |
return ResourceQuotaEphemeralStorageLimitHard{noop.Int64UpDownCounter{}}, nil |
| 5710 |
} |
| 5711 |
|
| 5712 |
i, err := m.Int64UpDownCounter( |
| 5713 |
"k8s.resourcequota.ephemeral_storage.limit.hard", |
| 5714 |
append([]metric.Int64UpDownCounterOption{ |
| 5715 |
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."), |
| 5716 |
metric.WithUnit("By"), |
| 5717 |
}, opt...)..., |
| 5718 |
) |
| 5719 |
if err != nil { |
| 5720 |
return ResourceQuotaEphemeralStorageLimitHard{noop.Int64UpDownCounter{}}, err |
| 5721 |
} |
| 5722 |
return ResourceQuotaEphemeralStorageLimitHard{i}, nil |
| 5723 |
} |
| 5724 |
|
| 5725 |
// Inst returns the underlying metric instrument. |
| 5726 |
func (m ResourceQuotaEphemeralStorageLimitHard) Inst() metric.Int64UpDownCounter { |
| 5727 |
return m.Int64UpDownCounter |
| 5728 |
} |
| 5729 |
|
| 5730 |
// Name returns the semantic convention name of the instrument. |
| 5731 |
func (ResourceQuotaEphemeralStorageLimitHard) Name() string { |
| 5732 |
return "k8s.resourcequota.ephemeral_storage.limit.hard" |
| 5733 |
} |
| 5734 |
|
| 5735 |
// Unit returns the semantic convention unit of the instrument |
| 5736 |
func (ResourceQuotaEphemeralStorageLimitHard) Unit() string { |
| 5737 |
return "By" |
| 5738 |
} |
| 5739 |
|
| 5740 |
// Description returns the semantic convention description of the instrument |
| 5741 |
func (ResourceQuotaEphemeralStorageLimitHard) Description() string { |
| 5742 |
return "The sum of local ephemeral storage limits in the namespace. The value represents the configured quota limit of the resource in the namespace." |
| 5743 |
} |
| 5744 |
|
| 5745 |
// Add adds incr to the existing count for attrs. |
| 5746 |
// |
| 5747 |
// This metric is retrieved from the `hard` field of the |
| 5748 |
// [K8s ResourceQuotaStatus]. |
| 5749 |
// |
| 5750 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5751 |
func (m ResourceQuotaEphemeralStorageLimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5752 |
if len(attrs) == 0 { |
| 5753 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5754 |
return |
| 5755 |
} |
| 5756 |
|
| 5757 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5758 |
defer func() { |
| 5759 |
*o = (*o)[:0] |
| 5760 |
addOptPool.Put(o) |
| 5761 |
}() |
| 5762 |
|
| 5763 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5764 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5765 |
} |
| 5766 |
|
| 5767 |
// AddSet adds incr to the existing count for set. |
| 5768 |
// |
| 5769 |
// This metric is retrieved from the `hard` field of the |
| 5770 |
// [K8s ResourceQuotaStatus]. |
| 5771 |
// |
| 5772 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5773 |
func (m ResourceQuotaEphemeralStorageLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5774 |
if set.Len() == 0 { |
| 5775 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5776 |
return |
| 5777 |
} |
| 5778 |
|
| 5779 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5780 |
defer func() { |
| 5781 |
*o = (*o)[:0] |
| 5782 |
addOptPool.Put(o) |
| 5783 |
}() |
| 5784 |
|
| 5785 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5786 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5787 |
} |
| 5788 |
|
| 5789 |
// ResourceQuotaEphemeralStorageLimitUsed is an instrument used to record metric |
| 5790 |
// values conforming to the "k8s.resourcequota.ephemeral_storage.limit.used" |
| 5791 |
// semantic conventions. It represents the sum of local ephemeral storage limits |
| 5792 |
// in the namespace. |
| 5793 |
// The value represents the current observed total usage of the resource in the |
| 5794 |
// namespace. |
| 5795 |
type ResourceQuotaEphemeralStorageLimitUsed struct { |
| 5796 |
metric.Int64UpDownCounter |
| 5797 |
} |
| 5798 |
|
| 5799 |
// NewResourceQuotaEphemeralStorageLimitUsed returns a new |
| 5800 |
// ResourceQuotaEphemeralStorageLimitUsed instrument. |
| 5801 |
func NewResourceQuotaEphemeralStorageLimitUsed( |
| 5802 |
m metric.Meter, |
| 5803 |
opt ...metric.Int64UpDownCounterOption, |
| 5804 |
) (ResourceQuotaEphemeralStorageLimitUsed, error) { |
| 5805 |
// Check if the meter is nil. |
| 5806 |
if m == nil { |
| 5807 |
return ResourceQuotaEphemeralStorageLimitUsed{noop.Int64UpDownCounter{}}, nil |
| 5808 |
} |
| 5809 |
|
| 5810 |
i, err := m.Int64UpDownCounter( |
| 5811 |
"k8s.resourcequota.ephemeral_storage.limit.used", |
| 5812 |
append([]metric.Int64UpDownCounterOption{ |
| 5813 |
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."), |
| 5814 |
metric.WithUnit("By"), |
| 5815 |
}, opt...)..., |
| 5816 |
) |
| 5817 |
if err != nil { |
| 5818 |
return ResourceQuotaEphemeralStorageLimitUsed{noop.Int64UpDownCounter{}}, err |
| 5819 |
} |
| 5820 |
return ResourceQuotaEphemeralStorageLimitUsed{i}, nil |
| 5821 |
} |
| 5822 |
|
| 5823 |
// Inst returns the underlying metric instrument. |
| 5824 |
func (m ResourceQuotaEphemeralStorageLimitUsed) Inst() metric.Int64UpDownCounter { |
| 5825 |
return m.Int64UpDownCounter |
| 5826 |
} |
| 5827 |
|
| 5828 |
// Name returns the semantic convention name of the instrument. |
| 5829 |
func (ResourceQuotaEphemeralStorageLimitUsed) Name() string { |
| 5830 |
return "k8s.resourcequota.ephemeral_storage.limit.used" |
| 5831 |
} |
| 5832 |
|
| 5833 |
// Unit returns the semantic convention unit of the instrument |
| 5834 |
func (ResourceQuotaEphemeralStorageLimitUsed) Unit() string { |
| 5835 |
return "By" |
| 5836 |
} |
| 5837 |
|
| 5838 |
// Description returns the semantic convention description of the instrument |
| 5839 |
func (ResourceQuotaEphemeralStorageLimitUsed) Description() string { |
| 5840 |
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." |
| 5841 |
} |
| 5842 |
|
| 5843 |
// Add adds incr to the existing count for attrs. |
| 5844 |
// |
| 5845 |
// This metric is retrieved from the `used` field of the |
| 5846 |
// [K8s ResourceQuotaStatus]. |
| 5847 |
// |
| 5848 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5849 |
func (m ResourceQuotaEphemeralStorageLimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5850 |
if len(attrs) == 0 { |
| 5851 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5852 |
return |
| 5853 |
} |
| 5854 |
|
| 5855 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5856 |
defer func() { |
| 5857 |
*o = (*o)[:0] |
| 5858 |
addOptPool.Put(o) |
| 5859 |
}() |
| 5860 |
|
| 5861 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5862 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5863 |
} |
| 5864 |
|
| 5865 |
// AddSet adds incr to the existing count for set. |
| 5866 |
// |
| 5867 |
// This metric is retrieved from the `used` field of the |
| 5868 |
// [K8s ResourceQuotaStatus]. |
| 5869 |
// |
| 5870 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5871 |
func (m ResourceQuotaEphemeralStorageLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5872 |
if set.Len() == 0 { |
| 5873 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5874 |
return |
| 5875 |
} |
| 5876 |
|
| 5877 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5878 |
defer func() { |
| 5879 |
*o = (*o)[:0] |
| 5880 |
addOptPool.Put(o) |
| 5881 |
}() |
| 5882 |
|
| 5883 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5884 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5885 |
} |
| 5886 |
|
| 5887 |
// ResourceQuotaEphemeralStorageRequestHard is an instrument used to record |
| 5888 |
// metric values conforming to the |
| 5889 |
// "k8s.resourcequota.ephemeral_storage.request.hard" semantic conventions. It |
| 5890 |
// represents the sum of local ephemeral storage requests in the namespace. |
| 5891 |
// The value represents the configured quota limit of the resource in the |
| 5892 |
// namespace. |
| 5893 |
type ResourceQuotaEphemeralStorageRequestHard struct { |
| 5894 |
metric.Int64UpDownCounter |
| 5895 |
} |
| 5896 |
|
| 5897 |
// NewResourceQuotaEphemeralStorageRequestHard returns a new |
| 5898 |
// ResourceQuotaEphemeralStorageRequestHard instrument. |
| 5899 |
func NewResourceQuotaEphemeralStorageRequestHard( |
| 5900 |
m metric.Meter, |
| 5901 |
opt ...metric.Int64UpDownCounterOption, |
| 5902 |
) (ResourceQuotaEphemeralStorageRequestHard, error) { |
| 5903 |
// Check if the meter is nil. |
| 5904 |
if m == nil { |
| 5905 |
return ResourceQuotaEphemeralStorageRequestHard{noop.Int64UpDownCounter{}}, nil |
| 5906 |
} |
| 5907 |
|
| 5908 |
i, err := m.Int64UpDownCounter( |
| 5909 |
"k8s.resourcequota.ephemeral_storage.request.hard", |
| 5910 |
append([]metric.Int64UpDownCounterOption{ |
| 5911 |
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."), |
| 5912 |
metric.WithUnit("By"), |
| 5913 |
}, opt...)..., |
| 5914 |
) |
| 5915 |
if err != nil { |
| 5916 |
return ResourceQuotaEphemeralStorageRequestHard{noop.Int64UpDownCounter{}}, err |
| 5917 |
} |
| 5918 |
return ResourceQuotaEphemeralStorageRequestHard{i}, nil |
| 5919 |
} |
| 5920 |
|
| 5921 |
// Inst returns the underlying metric instrument. |
| 5922 |
func (m ResourceQuotaEphemeralStorageRequestHard) Inst() metric.Int64UpDownCounter { |
| 5923 |
return m.Int64UpDownCounter |
| 5924 |
} |
| 5925 |
|
| 5926 |
// Name returns the semantic convention name of the instrument. |
| 5927 |
func (ResourceQuotaEphemeralStorageRequestHard) Name() string { |
| 5928 |
return "k8s.resourcequota.ephemeral_storage.request.hard" |
| 5929 |
} |
| 5930 |
|
| 5931 |
// Unit returns the semantic convention unit of the instrument |
| 5932 |
func (ResourceQuotaEphemeralStorageRequestHard) Unit() string { |
| 5933 |
return "By" |
| 5934 |
} |
| 5935 |
|
| 5936 |
// Description returns the semantic convention description of the instrument |
| 5937 |
func (ResourceQuotaEphemeralStorageRequestHard) Description() string { |
| 5938 |
return "The sum of local ephemeral storage requests in the namespace. The value represents the configured quota limit of the resource in the namespace." |
| 5939 |
} |
| 5940 |
|
| 5941 |
// Add adds incr to the existing count for attrs. |
| 5942 |
// |
| 5943 |
// This metric is retrieved from the `hard` field of the |
| 5944 |
// [K8s ResourceQuotaStatus]. |
| 5945 |
// |
| 5946 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5947 |
func (m ResourceQuotaEphemeralStorageRequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 5948 |
if len(attrs) == 0 { |
| 5949 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5950 |
return |
| 5951 |
} |
| 5952 |
|
| 5953 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5954 |
defer func() { |
| 5955 |
*o = (*o)[:0] |
| 5956 |
addOptPool.Put(o) |
| 5957 |
}() |
| 5958 |
|
| 5959 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 5960 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5961 |
} |
| 5962 |
|
| 5963 |
// AddSet adds incr to the existing count for set. |
| 5964 |
// |
| 5965 |
// This metric is retrieved from the `hard` field of the |
| 5966 |
// [K8s ResourceQuotaStatus]. |
| 5967 |
// |
| 5968 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 5969 |
func (m ResourceQuotaEphemeralStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5970 |
if set.Len() == 0 { |
| 5971 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5972 |
return |
| 5973 |
} |
| 5974 |
|
| 5975 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5976 |
defer func() { |
| 5977 |
*o = (*o)[:0] |
| 5978 |
addOptPool.Put(o) |
| 5979 |
}() |
| 5980 |
|
| 5981 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5982 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5983 |
} |
| 5984 |
|
| 5985 |
// ResourceQuotaEphemeralStorageRequestUsed is an instrument used to record |
| 5986 |
// metric values conforming to the |
| 5987 |
// "k8s.resourcequota.ephemeral_storage.request.used" semantic conventions. It |
| 5988 |
// represents the sum of local ephemeral storage requests in the namespace. |
| 5989 |
// The value represents the current observed total usage of the resource in the |
| 5990 |
// namespace. |
| 5991 |
type ResourceQuotaEphemeralStorageRequestUsed struct { |
| 5992 |
metric.Int64UpDownCounter |
| 5993 |
} |
| 5994 |
|
| 5995 |
// NewResourceQuotaEphemeralStorageRequestUsed returns a new |
| 5996 |
// ResourceQuotaEphemeralStorageRequestUsed instrument. |
| 5997 |
func NewResourceQuotaEphemeralStorageRequestUsed( |
| 5998 |
m metric.Meter, |
| 5999 |
opt ...metric.Int64UpDownCounterOption, |
| 6000 |
) (ResourceQuotaEphemeralStorageRequestUsed, error) { |
| 6001 |
// Check if the meter is nil. |
| 6002 |
if m == nil { |
| 6003 |
return ResourceQuotaEphemeralStorageRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 6004 |
} |
| 6005 |
|
| 6006 |
i, err := m.Int64UpDownCounter( |
| 6007 |
"k8s.resourcequota.ephemeral_storage.request.used", |
| 6008 |
append([]metric.Int64UpDownCounterOption{ |
| 6009 |
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."), |
| 6010 |
metric.WithUnit("By"), |
| 6011 |
}, opt...)..., |
| 6012 |
) |
| 6013 |
if err != nil { |
| 6014 |
return ResourceQuotaEphemeralStorageRequestUsed{noop.Int64UpDownCounter{}}, err |
| 6015 |
} |
| 6016 |
return ResourceQuotaEphemeralStorageRequestUsed{i}, nil |
| 6017 |
} |
| 6018 |
|
| 6019 |
// Inst returns the underlying metric instrument. |
| 6020 |
func (m ResourceQuotaEphemeralStorageRequestUsed) Inst() metric.Int64UpDownCounter { |
| 6021 |
return m.Int64UpDownCounter |
| 6022 |
} |
| 6023 |
|
| 6024 |
// Name returns the semantic convention name of the instrument. |
| 6025 |
func (ResourceQuotaEphemeralStorageRequestUsed) Name() string { |
| 6026 |
return "k8s.resourcequota.ephemeral_storage.request.used" |
| 6027 |
} |
| 6028 |
|
| 6029 |
// Unit returns the semantic convention unit of the instrument |
| 6030 |
func (ResourceQuotaEphemeralStorageRequestUsed) Unit() string { |
| 6031 |
return "By" |
| 6032 |
} |
| 6033 |
|
| 6034 |
// Description returns the semantic convention description of the instrument |
| 6035 |
func (ResourceQuotaEphemeralStorageRequestUsed) Description() string { |
| 6036 |
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." |
| 6037 |
} |
| 6038 |
|
| 6039 |
// Add adds incr to the existing count for attrs. |
| 6040 |
// |
| 6041 |
// This metric is retrieved from the `used` field of the |
| 6042 |
// [K8s ResourceQuotaStatus]. |
| 6043 |
// |
| 6044 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6045 |
func (m ResourceQuotaEphemeralStorageRequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6046 |
if len(attrs) == 0 { |
| 6047 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6048 |
return |
| 6049 |
} |
| 6050 |
|
| 6051 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6052 |
defer func() { |
| 6053 |
*o = (*o)[:0] |
| 6054 |
addOptPool.Put(o) |
| 6055 |
}() |
| 6056 |
|
| 6057 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6058 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6059 |
} |
| 6060 |
|
| 6061 |
// AddSet adds incr to the existing count for set. |
| 6062 |
// |
| 6063 |
// This metric is retrieved from the `used` field of the |
| 6064 |
// [K8s ResourceQuotaStatus]. |
| 6065 |
// |
| 6066 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6067 |
func (m ResourceQuotaEphemeralStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6068 |
if set.Len() == 0 { |
| 6069 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6070 |
return |
| 6071 |
} |
| 6072 |
|
| 6073 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6074 |
defer func() { |
| 6075 |
*o = (*o)[:0] |
| 6076 |
addOptPool.Put(o) |
| 6077 |
}() |
| 6078 |
|
| 6079 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6080 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6081 |
} |
| 6082 |
|
| 6083 |
// ResourceQuotaHugepageCountRequestHard is an instrument used to record metric |
| 6084 |
// values conforming to the "k8s.resourcequota.hugepage_count.request.hard" |
| 6085 |
// semantic conventions. It represents the huge page requests in a specific |
| 6086 |
// namespace. |
| 6087 |
// The value represents the configured quota limit of the resource in the |
| 6088 |
// namespace. |
| 6089 |
type ResourceQuotaHugepageCountRequestHard struct { |
| 6090 |
metric.Int64UpDownCounter |
| 6091 |
} |
| 6092 |
|
| 6093 |
// NewResourceQuotaHugepageCountRequestHard returns a new |
| 6094 |
// ResourceQuotaHugepageCountRequestHard instrument. |
| 6095 |
func NewResourceQuotaHugepageCountRequestHard( |
| 6096 |
m metric.Meter, |
| 6097 |
opt ...metric.Int64UpDownCounterOption, |
| 6098 |
) (ResourceQuotaHugepageCountRequestHard, error) { |
| 6099 |
// Check if the meter is nil. |
| 6100 |
if m == nil { |
| 6101 |
return ResourceQuotaHugepageCountRequestHard{noop.Int64UpDownCounter{}}, nil |
| 6102 |
} |
| 6103 |
|
| 6104 |
i, err := m.Int64UpDownCounter( |
| 6105 |
"k8s.resourcequota.hugepage_count.request.hard", |
| 6106 |
append([]metric.Int64UpDownCounterOption{ |
| 6107 |
metric.WithDescription("The huge page requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 6108 |
metric.WithUnit("{hugepage}"), |
| 6109 |
}, opt...)..., |
| 6110 |
) |
| 6111 |
if err != nil { |
| 6112 |
return ResourceQuotaHugepageCountRequestHard{noop.Int64UpDownCounter{}}, err |
| 6113 |
} |
| 6114 |
return ResourceQuotaHugepageCountRequestHard{i}, nil |
| 6115 |
} |
| 6116 |
|
| 6117 |
// Inst returns the underlying metric instrument. |
| 6118 |
func (m ResourceQuotaHugepageCountRequestHard) Inst() metric.Int64UpDownCounter { |
| 6119 |
return m.Int64UpDownCounter |
| 6120 |
} |
| 6121 |
|
| 6122 |
// Name returns the semantic convention name of the instrument. |
| 6123 |
func (ResourceQuotaHugepageCountRequestHard) Name() string { |
| 6124 |
return "k8s.resourcequota.hugepage_count.request.hard" |
| 6125 |
} |
| 6126 |
|
| 6127 |
// Unit returns the semantic convention unit of the instrument |
| 6128 |
func (ResourceQuotaHugepageCountRequestHard) Unit() string { |
| 6129 |
return "{hugepage}" |
| 6130 |
} |
| 6131 |
|
| 6132 |
// Description returns the semantic convention description of the instrument |
| 6133 |
func (ResourceQuotaHugepageCountRequestHard) Description() string { |
| 6134 |
return "The huge page requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 6135 |
} |
| 6136 |
|
| 6137 |
// Add adds incr to the existing count for attrs. |
| 6138 |
// |
| 6139 |
// The hugepageSize is the the size (identifier) of the K8s huge page. |
| 6140 |
// |
| 6141 |
// This metric is retrieved from the `hard` field of the |
| 6142 |
// [K8s ResourceQuotaStatus]. |
| 6143 |
// |
| 6144 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6145 |
func (m ResourceQuotaHugepageCountRequestHard) Add( |
| 6146 |
ctx context.Context, |
| 6147 |
incr int64, |
| 6148 |
hugepageSize string, |
| 6149 |
attrs ...attribute.KeyValue, |
| 6150 |
) { |
| 6151 |
if len(attrs) == 0 { |
| 6152 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6153 |
return |
| 6154 |
} |
| 6155 |
|
| 6156 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6157 |
defer func() { |
| 6158 |
*o = (*o)[:0] |
| 6159 |
addOptPool.Put(o) |
| 6160 |
}() |
| 6161 |
|
| 6162 |
*o = append( |
| 6163 |
*o, |
| 6164 |
metric.WithAttributes( |
| 6165 |
append( |
| 6166 |
attrs, |
| 6167 |
attribute.String("k8s.hugepage.size", hugepageSize), |
| 6168 |
)..., |
| 6169 |
), |
| 6170 |
) |
| 6171 |
|
| 6172 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6173 |
} |
| 6174 |
|
| 6175 |
// AddSet adds incr to the existing count for set. |
| 6176 |
// |
| 6177 |
// This metric is retrieved from the `hard` field of the |
| 6178 |
// [K8s ResourceQuotaStatus]. |
| 6179 |
// |
| 6180 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6181 |
func (m ResourceQuotaHugepageCountRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6182 |
if set.Len() == 0 { |
| 6183 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6184 |
return |
| 6185 |
} |
| 6186 |
|
| 6187 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6188 |
defer func() { |
| 6189 |
*o = (*o)[:0] |
| 6190 |
addOptPool.Put(o) |
| 6191 |
}() |
| 6192 |
|
| 6193 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6194 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6195 |
} |
| 6196 |
|
| 6197 |
// ResourceQuotaHugepageCountRequestUsed is an instrument used to record metric |
| 6198 |
// values conforming to the "k8s.resourcequota.hugepage_count.request.used" |
| 6199 |
// semantic conventions. It represents the huge page requests in a specific |
| 6200 |
// namespace. |
| 6201 |
// The value represents the current observed total usage of the resource in the |
| 6202 |
// namespace. |
| 6203 |
type ResourceQuotaHugepageCountRequestUsed struct { |
| 6204 |
metric.Int64UpDownCounter |
| 6205 |
} |
| 6206 |
|
| 6207 |
// NewResourceQuotaHugepageCountRequestUsed returns a new |
| 6208 |
// ResourceQuotaHugepageCountRequestUsed instrument. |
| 6209 |
func NewResourceQuotaHugepageCountRequestUsed( |
| 6210 |
m metric.Meter, |
| 6211 |
opt ...metric.Int64UpDownCounterOption, |
| 6212 |
) (ResourceQuotaHugepageCountRequestUsed, error) { |
| 6213 |
// Check if the meter is nil. |
| 6214 |
if m == nil { |
| 6215 |
return ResourceQuotaHugepageCountRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 6216 |
} |
| 6217 |
|
| 6218 |
i, err := m.Int64UpDownCounter( |
| 6219 |
"k8s.resourcequota.hugepage_count.request.used", |
| 6220 |
append([]metric.Int64UpDownCounterOption{ |
| 6221 |
metric.WithDescription("The huge page requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 6222 |
metric.WithUnit("{hugepage}"), |
| 6223 |
}, opt...)..., |
| 6224 |
) |
| 6225 |
if err != nil { |
| 6226 |
return ResourceQuotaHugepageCountRequestUsed{noop.Int64UpDownCounter{}}, err |
| 6227 |
} |
| 6228 |
return ResourceQuotaHugepageCountRequestUsed{i}, nil |
| 6229 |
} |
| 6230 |
|
| 6231 |
// Inst returns the underlying metric instrument. |
| 6232 |
func (m ResourceQuotaHugepageCountRequestUsed) Inst() metric.Int64UpDownCounter { |
| 6233 |
return m.Int64UpDownCounter |
| 6234 |
} |
| 6235 |
|
| 6236 |
// Name returns the semantic convention name of the instrument. |
| 6237 |
func (ResourceQuotaHugepageCountRequestUsed) Name() string { |
| 6238 |
return "k8s.resourcequota.hugepage_count.request.used" |
| 6239 |
} |
| 6240 |
|
| 6241 |
// Unit returns the semantic convention unit of the instrument |
| 6242 |
func (ResourceQuotaHugepageCountRequestUsed) Unit() string { |
| 6243 |
return "{hugepage}" |
| 6244 |
} |
| 6245 |
|
| 6246 |
// Description returns the semantic convention description of the instrument |
| 6247 |
func (ResourceQuotaHugepageCountRequestUsed) Description() string { |
| 6248 |
return "The huge page requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 6249 |
} |
| 6250 |
|
| 6251 |
// Add adds incr to the existing count for attrs. |
| 6252 |
// |
| 6253 |
// The hugepageSize is the the size (identifier) of the K8s huge page. |
| 6254 |
// |
| 6255 |
// This metric is retrieved from the `used` field of the |
| 6256 |
// [K8s ResourceQuotaStatus]. |
| 6257 |
// |
| 6258 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6259 |
func (m ResourceQuotaHugepageCountRequestUsed) Add( |
| 6260 |
ctx context.Context, |
| 6261 |
incr int64, |
| 6262 |
hugepageSize string, |
| 6263 |
attrs ...attribute.KeyValue, |
| 6264 |
) { |
| 6265 |
if len(attrs) == 0 { |
| 6266 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6267 |
return |
| 6268 |
} |
| 6269 |
|
| 6270 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6271 |
defer func() { |
| 6272 |
*o = (*o)[:0] |
| 6273 |
addOptPool.Put(o) |
| 6274 |
}() |
| 6275 |
|
| 6276 |
*o = append( |
| 6277 |
*o, |
| 6278 |
metric.WithAttributes( |
| 6279 |
append( |
| 6280 |
attrs, |
| 6281 |
attribute.String("k8s.hugepage.size", hugepageSize), |
| 6282 |
)..., |
| 6283 |
), |
| 6284 |
) |
| 6285 |
|
| 6286 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6287 |
} |
| 6288 |
|
| 6289 |
// AddSet adds incr to the existing count for set. |
| 6290 |
// |
| 6291 |
// This metric is retrieved from the `used` field of the |
| 6292 |
// [K8s ResourceQuotaStatus]. |
| 6293 |
// |
| 6294 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6295 |
func (m ResourceQuotaHugepageCountRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6296 |
if set.Len() == 0 { |
| 6297 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6298 |
return |
| 6299 |
} |
| 6300 |
|
| 6301 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6302 |
defer func() { |
| 6303 |
*o = (*o)[:0] |
| 6304 |
addOptPool.Put(o) |
| 6305 |
}() |
| 6306 |
|
| 6307 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6308 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6309 |
} |
| 6310 |
|
| 6311 |
// ResourceQuotaMemoryLimitHard is an instrument used to record metric values |
| 6312 |
// conforming to the "k8s.resourcequota.memory.limit.hard" semantic conventions. |
| 6313 |
// It represents the memory limits in a specific namespace. |
| 6314 |
// The value represents the configured quota limit of the resource in the |
| 6315 |
// namespace. |
| 6316 |
type ResourceQuotaMemoryLimitHard struct { |
| 6317 |
metric.Int64UpDownCounter |
| 6318 |
} |
| 6319 |
|
| 6320 |
// NewResourceQuotaMemoryLimitHard returns a new ResourceQuotaMemoryLimitHard |
| 6321 |
// instrument. |
| 6322 |
func NewResourceQuotaMemoryLimitHard( |
| 6323 |
m metric.Meter, |
| 6324 |
opt ...metric.Int64UpDownCounterOption, |
| 6325 |
) (ResourceQuotaMemoryLimitHard, error) { |
| 6326 |
// Check if the meter is nil. |
| 6327 |
if m == nil { |
| 6328 |
return ResourceQuotaMemoryLimitHard{noop.Int64UpDownCounter{}}, nil |
| 6329 |
} |
| 6330 |
|
| 6331 |
i, err := m.Int64UpDownCounter( |
| 6332 |
"k8s.resourcequota.memory.limit.hard", |
| 6333 |
append([]metric.Int64UpDownCounterOption{ |
| 6334 |
metric.WithDescription("The memory limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 6335 |
metric.WithUnit("By"), |
| 6336 |
}, opt...)..., |
| 6337 |
) |
| 6338 |
if err != nil { |
| 6339 |
return ResourceQuotaMemoryLimitHard{noop.Int64UpDownCounter{}}, err |
| 6340 |
} |
| 6341 |
return ResourceQuotaMemoryLimitHard{i}, nil |
| 6342 |
} |
| 6343 |
|
| 6344 |
// Inst returns the underlying metric instrument. |
| 6345 |
func (m ResourceQuotaMemoryLimitHard) Inst() metric.Int64UpDownCounter { |
| 6346 |
return m.Int64UpDownCounter |
| 6347 |
} |
| 6348 |
|
| 6349 |
// Name returns the semantic convention name of the instrument. |
| 6350 |
func (ResourceQuotaMemoryLimitHard) Name() string { |
| 6351 |
return "k8s.resourcequota.memory.limit.hard" |
| 6352 |
} |
| 6353 |
|
| 6354 |
// Unit returns the semantic convention unit of the instrument |
| 6355 |
func (ResourceQuotaMemoryLimitHard) Unit() string { |
| 6356 |
return "By" |
| 6357 |
} |
| 6358 |
|
| 6359 |
// Description returns the semantic convention description of the instrument |
| 6360 |
func (ResourceQuotaMemoryLimitHard) Description() string { |
| 6361 |
return "The memory limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 6362 |
} |
| 6363 |
|
| 6364 |
// Add adds incr to the existing count for attrs. |
| 6365 |
// |
| 6366 |
// This metric is retrieved from the `hard` field of the |
| 6367 |
// [K8s ResourceQuotaStatus]. |
| 6368 |
// |
| 6369 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6370 |
func (m ResourceQuotaMemoryLimitHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6371 |
if len(attrs) == 0 { |
| 6372 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6373 |
return |
| 6374 |
} |
| 6375 |
|
| 6376 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6377 |
defer func() { |
| 6378 |
*o = (*o)[:0] |
| 6379 |
addOptPool.Put(o) |
| 6380 |
}() |
| 6381 |
|
| 6382 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6383 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6384 |
} |
| 6385 |
|
| 6386 |
// AddSet adds incr to the existing count for set. |
| 6387 |
// |
| 6388 |
// This metric is retrieved from the `hard` field of the |
| 6389 |
// [K8s ResourceQuotaStatus]. |
| 6390 |
// |
| 6391 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6392 |
func (m ResourceQuotaMemoryLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6393 |
if set.Len() == 0 { |
| 6394 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6395 |
return |
| 6396 |
} |
| 6397 |
|
| 6398 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6399 |
defer func() { |
| 6400 |
*o = (*o)[:0] |
| 6401 |
addOptPool.Put(o) |
| 6402 |
}() |
| 6403 |
|
| 6404 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6405 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6406 |
} |
| 6407 |
|
| 6408 |
// ResourceQuotaMemoryLimitUsed is an instrument used to record metric values |
| 6409 |
// conforming to the "k8s.resourcequota.memory.limit.used" semantic conventions. |
| 6410 |
// It represents the memory limits in a specific namespace. |
| 6411 |
// The value represents the current observed total usage of the resource in the |
| 6412 |
// namespace. |
| 6413 |
type ResourceQuotaMemoryLimitUsed struct { |
| 6414 |
metric.Int64UpDownCounter |
| 6415 |
} |
| 6416 |
|
| 6417 |
// NewResourceQuotaMemoryLimitUsed returns a new ResourceQuotaMemoryLimitUsed |
| 6418 |
// instrument. |
| 6419 |
func NewResourceQuotaMemoryLimitUsed( |
| 6420 |
m metric.Meter, |
| 6421 |
opt ...metric.Int64UpDownCounterOption, |
| 6422 |
) (ResourceQuotaMemoryLimitUsed, error) { |
| 6423 |
// Check if the meter is nil. |
| 6424 |
if m == nil { |
| 6425 |
return ResourceQuotaMemoryLimitUsed{noop.Int64UpDownCounter{}}, nil |
| 6426 |
} |
| 6427 |
|
| 6428 |
i, err := m.Int64UpDownCounter( |
| 6429 |
"k8s.resourcequota.memory.limit.used", |
| 6430 |
append([]metric.Int64UpDownCounterOption{ |
| 6431 |
metric.WithDescription("The memory limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 6432 |
metric.WithUnit("By"), |
| 6433 |
}, opt...)..., |
| 6434 |
) |
| 6435 |
if err != nil { |
| 6436 |
return ResourceQuotaMemoryLimitUsed{noop.Int64UpDownCounter{}}, err |
| 6437 |
} |
| 6438 |
return ResourceQuotaMemoryLimitUsed{i}, nil |
| 6439 |
} |
| 6440 |
|
| 6441 |
// Inst returns the underlying metric instrument. |
| 6442 |
func (m ResourceQuotaMemoryLimitUsed) Inst() metric.Int64UpDownCounter { |
| 6443 |
return m.Int64UpDownCounter |
| 6444 |
} |
| 6445 |
|
| 6446 |
// Name returns the semantic convention name of the instrument. |
| 6447 |
func (ResourceQuotaMemoryLimitUsed) Name() string { |
| 6448 |
return "k8s.resourcequota.memory.limit.used" |
| 6449 |
} |
| 6450 |
|
| 6451 |
// Unit returns the semantic convention unit of the instrument |
| 6452 |
func (ResourceQuotaMemoryLimitUsed) Unit() string { |
| 6453 |
return "By" |
| 6454 |
} |
| 6455 |
|
| 6456 |
// Description returns the semantic convention description of the instrument |
| 6457 |
func (ResourceQuotaMemoryLimitUsed) Description() string { |
| 6458 |
return "The memory limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 6459 |
} |
| 6460 |
|
| 6461 |
// Add adds incr to the existing count for attrs. |
| 6462 |
// |
| 6463 |
// This metric is retrieved from the `used` field of the |
| 6464 |
// [K8s ResourceQuotaStatus]. |
| 6465 |
// |
| 6466 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6467 |
func (m ResourceQuotaMemoryLimitUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6468 |
if len(attrs) == 0 { |
| 6469 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6470 |
return |
| 6471 |
} |
| 6472 |
|
| 6473 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6474 |
defer func() { |
| 6475 |
*o = (*o)[:0] |
| 6476 |
addOptPool.Put(o) |
| 6477 |
}() |
| 6478 |
|
| 6479 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6480 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6481 |
} |
| 6482 |
|
| 6483 |
// AddSet adds incr to the existing count for set. |
| 6484 |
// |
| 6485 |
// This metric is retrieved from the `used` field of the |
| 6486 |
// [K8s ResourceQuotaStatus]. |
| 6487 |
// |
| 6488 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6489 |
func (m ResourceQuotaMemoryLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6490 |
if set.Len() == 0 { |
| 6491 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6492 |
return |
| 6493 |
} |
| 6494 |
|
| 6495 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6496 |
defer func() { |
| 6497 |
*o = (*o)[:0] |
| 6498 |
addOptPool.Put(o) |
| 6499 |
}() |
| 6500 |
|
| 6501 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6502 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6503 |
} |
| 6504 |
|
| 6505 |
// ResourceQuotaMemoryRequestHard is an instrument used to record metric values |
| 6506 |
// conforming to the "k8s.resourcequota.memory.request.hard" semantic |
| 6507 |
// conventions. It represents the memory requests in a specific namespace. |
| 6508 |
// The value represents the configured quota limit of the resource in the |
| 6509 |
// namespace. |
| 6510 |
type ResourceQuotaMemoryRequestHard struct { |
| 6511 |
metric.Int64UpDownCounter |
| 6512 |
} |
| 6513 |
|
| 6514 |
// NewResourceQuotaMemoryRequestHard returns a new ResourceQuotaMemoryRequestHard |
| 6515 |
// instrument. |
| 6516 |
func NewResourceQuotaMemoryRequestHard( |
| 6517 |
m metric.Meter, |
| 6518 |
opt ...metric.Int64UpDownCounterOption, |
| 6519 |
) (ResourceQuotaMemoryRequestHard, error) { |
| 6520 |
// Check if the meter is nil. |
| 6521 |
if m == nil { |
| 6522 |
return ResourceQuotaMemoryRequestHard{noop.Int64UpDownCounter{}}, nil |
| 6523 |
} |
| 6524 |
|
| 6525 |
i, err := m.Int64UpDownCounter( |
| 6526 |
"k8s.resourcequota.memory.request.hard", |
| 6527 |
append([]metric.Int64UpDownCounterOption{ |
| 6528 |
metric.WithDescription("The memory requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 6529 |
metric.WithUnit("By"), |
| 6530 |
}, opt...)..., |
| 6531 |
) |
| 6532 |
if err != nil { |
| 6533 |
return ResourceQuotaMemoryRequestHard{noop.Int64UpDownCounter{}}, err |
| 6534 |
} |
| 6535 |
return ResourceQuotaMemoryRequestHard{i}, nil |
| 6536 |
} |
| 6537 |
|
| 6538 |
// Inst returns the underlying metric instrument. |
| 6539 |
func (m ResourceQuotaMemoryRequestHard) Inst() metric.Int64UpDownCounter { |
| 6540 |
return m.Int64UpDownCounter |
| 6541 |
} |
| 6542 |
|
| 6543 |
// Name returns the semantic convention name of the instrument. |
| 6544 |
func (ResourceQuotaMemoryRequestHard) Name() string { |
| 6545 |
return "k8s.resourcequota.memory.request.hard" |
| 6546 |
} |
| 6547 |
|
| 6548 |
// Unit returns the semantic convention unit of the instrument |
| 6549 |
func (ResourceQuotaMemoryRequestHard) Unit() string { |
| 6550 |
return "By" |
| 6551 |
} |
| 6552 |
|
| 6553 |
// Description returns the semantic convention description of the instrument |
| 6554 |
func (ResourceQuotaMemoryRequestHard) Description() string { |
| 6555 |
return "The memory requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 6556 |
} |
| 6557 |
|
| 6558 |
// Add adds incr to the existing count for attrs. |
| 6559 |
// |
| 6560 |
// This metric is retrieved from the `hard` field of the |
| 6561 |
// [K8s ResourceQuotaStatus]. |
| 6562 |
// |
| 6563 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6564 |
func (m ResourceQuotaMemoryRequestHard) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6565 |
if len(attrs) == 0 { |
| 6566 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6567 |
return |
| 6568 |
} |
| 6569 |
|
| 6570 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6571 |
defer func() { |
| 6572 |
*o = (*o)[:0] |
| 6573 |
addOptPool.Put(o) |
| 6574 |
}() |
| 6575 |
|
| 6576 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6577 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6578 |
} |
| 6579 |
|
| 6580 |
// AddSet adds incr to the existing count for set. |
| 6581 |
// |
| 6582 |
// This metric is retrieved from the `hard` field of the |
| 6583 |
// [K8s ResourceQuotaStatus]. |
| 6584 |
// |
| 6585 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6586 |
func (m ResourceQuotaMemoryRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6587 |
if set.Len() == 0 { |
| 6588 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6589 |
return |
| 6590 |
} |
| 6591 |
|
| 6592 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6593 |
defer func() { |
| 6594 |
*o = (*o)[:0] |
| 6595 |
addOptPool.Put(o) |
| 6596 |
}() |
| 6597 |
|
| 6598 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6599 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6600 |
} |
| 6601 |
|
| 6602 |
// ResourceQuotaMemoryRequestUsed is an instrument used to record metric values |
| 6603 |
// conforming to the "k8s.resourcequota.memory.request.used" semantic |
| 6604 |
// conventions. It represents the memory requests in a specific namespace. |
| 6605 |
// The value represents the current observed total usage of the resource in the |
| 6606 |
// namespace. |
| 6607 |
type ResourceQuotaMemoryRequestUsed struct { |
| 6608 |
metric.Int64UpDownCounter |
| 6609 |
} |
| 6610 |
|
| 6611 |
// NewResourceQuotaMemoryRequestUsed returns a new ResourceQuotaMemoryRequestUsed |
| 6612 |
// instrument. |
| 6613 |
func NewResourceQuotaMemoryRequestUsed( |
| 6614 |
m metric.Meter, |
| 6615 |
opt ...metric.Int64UpDownCounterOption, |
| 6616 |
) (ResourceQuotaMemoryRequestUsed, error) { |
| 6617 |
// Check if the meter is nil. |
| 6618 |
if m == nil { |
| 6619 |
return ResourceQuotaMemoryRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 6620 |
} |
| 6621 |
|
| 6622 |
i, err := m.Int64UpDownCounter( |
| 6623 |
"k8s.resourcequota.memory.request.used", |
| 6624 |
append([]metric.Int64UpDownCounterOption{ |
| 6625 |
metric.WithDescription("The memory requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 6626 |
metric.WithUnit("By"), |
| 6627 |
}, opt...)..., |
| 6628 |
) |
| 6629 |
if err != nil { |
| 6630 |
return ResourceQuotaMemoryRequestUsed{noop.Int64UpDownCounter{}}, err |
| 6631 |
} |
| 6632 |
return ResourceQuotaMemoryRequestUsed{i}, nil |
| 6633 |
} |
| 6634 |
|
| 6635 |
// Inst returns the underlying metric instrument. |
| 6636 |
func (m ResourceQuotaMemoryRequestUsed) Inst() metric.Int64UpDownCounter { |
| 6637 |
return m.Int64UpDownCounter |
| 6638 |
} |
| 6639 |
|
| 6640 |
// Name returns the semantic convention name of the instrument. |
| 6641 |
func (ResourceQuotaMemoryRequestUsed) Name() string { |
| 6642 |
return "k8s.resourcequota.memory.request.used" |
| 6643 |
} |
| 6644 |
|
| 6645 |
// Unit returns the semantic convention unit of the instrument |
| 6646 |
func (ResourceQuotaMemoryRequestUsed) Unit() string { |
| 6647 |
return "By" |
| 6648 |
} |
| 6649 |
|
| 6650 |
// Description returns the semantic convention description of the instrument |
| 6651 |
func (ResourceQuotaMemoryRequestUsed) Description() string { |
| 6652 |
return "The memory requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 6653 |
} |
| 6654 |
|
| 6655 |
// Add adds incr to the existing count for attrs. |
| 6656 |
// |
| 6657 |
// This metric is retrieved from the `used` field of the |
| 6658 |
// [K8s ResourceQuotaStatus]. |
| 6659 |
// |
| 6660 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6661 |
func (m ResourceQuotaMemoryRequestUsed) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 6662 |
if len(attrs) == 0 { |
| 6663 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6664 |
return |
| 6665 |
} |
| 6666 |
|
| 6667 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6668 |
defer func() { |
| 6669 |
*o = (*o)[:0] |
| 6670 |
addOptPool.Put(o) |
| 6671 |
}() |
| 6672 |
|
| 6673 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 6674 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6675 |
} |
| 6676 |
|
| 6677 |
// AddSet adds incr to the existing count for set. |
| 6678 |
// |
| 6679 |
// This metric is retrieved from the `used` field of the |
| 6680 |
// [K8s ResourceQuotaStatus]. |
| 6681 |
// |
| 6682 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6683 |
func (m ResourceQuotaMemoryRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6684 |
if set.Len() == 0 { |
| 6685 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6686 |
return |
| 6687 |
} |
| 6688 |
|
| 6689 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6690 |
defer func() { |
| 6691 |
*o = (*o)[:0] |
| 6692 |
addOptPool.Put(o) |
| 6693 |
}() |
| 6694 |
|
| 6695 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6696 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6697 |
} |
| 6698 |
|
| 6699 |
// ResourceQuotaObjectCountHard is an instrument used to record metric values |
| 6700 |
// conforming to the "k8s.resourcequota.object_count.hard" semantic conventions. |
| 6701 |
// It represents the object count limits in a specific namespace. |
| 6702 |
// The value represents the configured quota limit of the resource in the |
| 6703 |
// namespace. |
| 6704 |
type ResourceQuotaObjectCountHard struct { |
| 6705 |
metric.Int64UpDownCounter |
| 6706 |
} |
| 6707 |
|
| 6708 |
// NewResourceQuotaObjectCountHard returns a new ResourceQuotaObjectCountHard |
| 6709 |
// instrument. |
| 6710 |
func NewResourceQuotaObjectCountHard( |
| 6711 |
m metric.Meter, |
| 6712 |
opt ...metric.Int64UpDownCounterOption, |
| 6713 |
) (ResourceQuotaObjectCountHard, error) { |
| 6714 |
// Check if the meter is nil. |
| 6715 |
if m == nil { |
| 6716 |
return ResourceQuotaObjectCountHard{noop.Int64UpDownCounter{}}, nil |
| 6717 |
} |
| 6718 |
|
| 6719 |
i, err := m.Int64UpDownCounter( |
| 6720 |
"k8s.resourcequota.object_count.hard", |
| 6721 |
append([]metric.Int64UpDownCounterOption{ |
| 6722 |
metric.WithDescription("The object count limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 6723 |
metric.WithUnit("{object}"), |
| 6724 |
}, opt...)..., |
| 6725 |
) |
| 6726 |
if err != nil { |
| 6727 |
return ResourceQuotaObjectCountHard{noop.Int64UpDownCounter{}}, err |
| 6728 |
} |
| 6729 |
return ResourceQuotaObjectCountHard{i}, nil |
| 6730 |
} |
| 6731 |
|
| 6732 |
// Inst returns the underlying metric instrument. |
| 6733 |
func (m ResourceQuotaObjectCountHard) Inst() metric.Int64UpDownCounter { |
| 6734 |
return m.Int64UpDownCounter |
| 6735 |
} |
| 6736 |
|
| 6737 |
// Name returns the semantic convention name of the instrument. |
| 6738 |
func (ResourceQuotaObjectCountHard) Name() string { |
| 6739 |
return "k8s.resourcequota.object_count.hard" |
| 6740 |
} |
| 6741 |
|
| 6742 |
// Unit returns the semantic convention unit of the instrument |
| 6743 |
func (ResourceQuotaObjectCountHard) Unit() string { |
| 6744 |
return "{object}" |
| 6745 |
} |
| 6746 |
|
| 6747 |
// Description returns the semantic convention description of the instrument |
| 6748 |
func (ResourceQuotaObjectCountHard) Description() string { |
| 6749 |
return "The object count limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 6750 |
} |
| 6751 |
|
| 6752 |
// Add adds incr to the existing count for attrs. |
| 6753 |
// |
| 6754 |
// The resourcequotaResourceName is the the name of the K8s resource a resource |
| 6755 |
// quota defines. |
| 6756 |
// |
| 6757 |
// This metric is retrieved from the `hard` field of the |
| 6758 |
// [K8s ResourceQuotaStatus]. |
| 6759 |
// |
| 6760 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6761 |
func (m ResourceQuotaObjectCountHard) Add( |
| 6762 |
ctx context.Context, |
| 6763 |
incr int64, |
| 6764 |
resourcequotaResourceName string, |
| 6765 |
attrs ...attribute.KeyValue, |
| 6766 |
) { |
| 6767 |
if len(attrs) == 0 { |
| 6768 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6769 |
return |
| 6770 |
} |
| 6771 |
|
| 6772 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6773 |
defer func() { |
| 6774 |
*o = (*o)[:0] |
| 6775 |
addOptPool.Put(o) |
| 6776 |
}() |
| 6777 |
|
| 6778 |
*o = append( |
| 6779 |
*o, |
| 6780 |
metric.WithAttributes( |
| 6781 |
append( |
| 6782 |
attrs, |
| 6783 |
attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName), |
| 6784 |
)..., |
| 6785 |
), |
| 6786 |
) |
| 6787 |
|
| 6788 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6789 |
} |
| 6790 |
|
| 6791 |
// AddSet adds incr to the existing count for set. |
| 6792 |
// |
| 6793 |
// This metric is retrieved from the `hard` field of the |
| 6794 |
// [K8s ResourceQuotaStatus]. |
| 6795 |
// |
| 6796 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6797 |
func (m ResourceQuotaObjectCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6798 |
if set.Len() == 0 { |
| 6799 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6800 |
return |
| 6801 |
} |
| 6802 |
|
| 6803 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6804 |
defer func() { |
| 6805 |
*o = (*o)[:0] |
| 6806 |
addOptPool.Put(o) |
| 6807 |
}() |
| 6808 |
|
| 6809 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6810 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6811 |
} |
| 6812 |
|
| 6813 |
// ResourceQuotaObjectCountUsed is an instrument used to record metric values |
| 6814 |
// conforming to the "k8s.resourcequota.object_count.used" semantic conventions. |
| 6815 |
// It represents the object count limits in a specific namespace. |
| 6816 |
// The value represents the current observed total usage of the resource in the |
| 6817 |
// namespace. |
| 6818 |
type ResourceQuotaObjectCountUsed struct { |
| 6819 |
metric.Int64UpDownCounter |
| 6820 |
} |
| 6821 |
|
| 6822 |
// NewResourceQuotaObjectCountUsed returns a new ResourceQuotaObjectCountUsed |
| 6823 |
// instrument. |
| 6824 |
func NewResourceQuotaObjectCountUsed( |
| 6825 |
m metric.Meter, |
| 6826 |
opt ...metric.Int64UpDownCounterOption, |
| 6827 |
) (ResourceQuotaObjectCountUsed, error) { |
| 6828 |
// Check if the meter is nil. |
| 6829 |
if m == nil { |
| 6830 |
return ResourceQuotaObjectCountUsed{noop.Int64UpDownCounter{}}, nil |
| 6831 |
} |
| 6832 |
|
| 6833 |
i, err := m.Int64UpDownCounter( |
| 6834 |
"k8s.resourcequota.object_count.used", |
| 6835 |
append([]metric.Int64UpDownCounterOption{ |
| 6836 |
metric.WithDescription("The object count limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 6837 |
metric.WithUnit("{object}"), |
| 6838 |
}, opt...)..., |
| 6839 |
) |
| 6840 |
if err != nil { |
| 6841 |
return ResourceQuotaObjectCountUsed{noop.Int64UpDownCounter{}}, err |
| 6842 |
} |
| 6843 |
return ResourceQuotaObjectCountUsed{i}, nil |
| 6844 |
} |
| 6845 |
|
| 6846 |
// Inst returns the underlying metric instrument. |
| 6847 |
func (m ResourceQuotaObjectCountUsed) Inst() metric.Int64UpDownCounter { |
| 6848 |
return m.Int64UpDownCounter |
| 6849 |
} |
| 6850 |
|
| 6851 |
// Name returns the semantic convention name of the instrument. |
| 6852 |
func (ResourceQuotaObjectCountUsed) Name() string { |
| 6853 |
return "k8s.resourcequota.object_count.used" |
| 6854 |
} |
| 6855 |
|
| 6856 |
// Unit returns the semantic convention unit of the instrument |
| 6857 |
func (ResourceQuotaObjectCountUsed) Unit() string { |
| 6858 |
return "{object}" |
| 6859 |
} |
| 6860 |
|
| 6861 |
// Description returns the semantic convention description of the instrument |
| 6862 |
func (ResourceQuotaObjectCountUsed) Description() string { |
| 6863 |
return "The object count limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 6864 |
} |
| 6865 |
|
| 6866 |
// Add adds incr to the existing count for attrs. |
| 6867 |
// |
| 6868 |
// The resourcequotaResourceName is the the name of the K8s resource a resource |
| 6869 |
// quota defines. |
| 6870 |
// |
| 6871 |
// This metric is retrieved from the `used` field of the |
| 6872 |
// [K8s ResourceQuotaStatus]. |
| 6873 |
// |
| 6874 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6875 |
func (m ResourceQuotaObjectCountUsed) Add( |
| 6876 |
ctx context.Context, |
| 6877 |
incr int64, |
| 6878 |
resourcequotaResourceName string, |
| 6879 |
attrs ...attribute.KeyValue, |
| 6880 |
) { |
| 6881 |
if len(attrs) == 0 { |
| 6882 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6883 |
return |
| 6884 |
} |
| 6885 |
|
| 6886 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6887 |
defer func() { |
| 6888 |
*o = (*o)[:0] |
| 6889 |
addOptPool.Put(o) |
| 6890 |
}() |
| 6891 |
|
| 6892 |
*o = append( |
| 6893 |
*o, |
| 6894 |
metric.WithAttributes( |
| 6895 |
append( |
| 6896 |
attrs, |
| 6897 |
attribute.String("k8s.resourcequota.resource_name", resourcequotaResourceName), |
| 6898 |
)..., |
| 6899 |
), |
| 6900 |
) |
| 6901 |
|
| 6902 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6903 |
} |
| 6904 |
|
| 6905 |
// AddSet adds incr to the existing count for set. |
| 6906 |
// |
| 6907 |
// This metric is retrieved from the `used` field of the |
| 6908 |
// [K8s ResourceQuotaStatus]. |
| 6909 |
// |
| 6910 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6911 |
func (m ResourceQuotaObjectCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 6912 |
if set.Len() == 0 { |
| 6913 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 6914 |
return |
| 6915 |
} |
| 6916 |
|
| 6917 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 6918 |
defer func() { |
| 6919 |
*o = (*o)[:0] |
| 6920 |
addOptPool.Put(o) |
| 6921 |
}() |
| 6922 |
|
| 6923 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6924 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 6925 |
} |
| 6926 |
|
| 6927 |
// ResourceQuotaPersistentvolumeclaimCountHard is an instrument used to record |
| 6928 |
// metric values conforming to the |
| 6929 |
// "k8s.resourcequota.persistentvolumeclaim_count.hard" semantic conventions. It |
| 6930 |
// represents the total number of PersistentVolumeClaims that can exist in the |
| 6931 |
// namespace. |
| 6932 |
// The value represents the configured quota limit of the resource in the |
| 6933 |
// namespace. |
| 6934 |
type ResourceQuotaPersistentvolumeclaimCountHard struct { |
| 6935 |
metric.Int64UpDownCounter |
| 6936 |
} |
| 6937 |
|
| 6938 |
// NewResourceQuotaPersistentvolumeclaimCountHard returns a new |
| 6939 |
// ResourceQuotaPersistentvolumeclaimCountHard instrument. |
| 6940 |
func NewResourceQuotaPersistentvolumeclaimCountHard( |
| 6941 |
m metric.Meter, |
| 6942 |
opt ...metric.Int64UpDownCounterOption, |
| 6943 |
) (ResourceQuotaPersistentvolumeclaimCountHard, error) { |
| 6944 |
// Check if the meter is nil. |
| 6945 |
if m == nil { |
| 6946 |
return ResourceQuotaPersistentvolumeclaimCountHard{noop.Int64UpDownCounter{}}, nil |
| 6947 |
} |
| 6948 |
|
| 6949 |
i, err := m.Int64UpDownCounter( |
| 6950 |
"k8s.resourcequota.persistentvolumeclaim_count.hard", |
| 6951 |
append([]metric.Int64UpDownCounterOption{ |
| 6952 |
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."), |
| 6953 |
metric.WithUnit("{persistentvolumeclaim}"), |
| 6954 |
}, opt...)..., |
| 6955 |
) |
| 6956 |
if err != nil { |
| 6957 |
return ResourceQuotaPersistentvolumeclaimCountHard{noop.Int64UpDownCounter{}}, err |
| 6958 |
} |
| 6959 |
return ResourceQuotaPersistentvolumeclaimCountHard{i}, nil |
| 6960 |
} |
| 6961 |
|
| 6962 |
// Inst returns the underlying metric instrument. |
| 6963 |
func (m ResourceQuotaPersistentvolumeclaimCountHard) Inst() metric.Int64UpDownCounter { |
| 6964 |
return m.Int64UpDownCounter |
| 6965 |
} |
| 6966 |
|
| 6967 |
// Name returns the semantic convention name of the instrument. |
| 6968 |
func (ResourceQuotaPersistentvolumeclaimCountHard) Name() string { |
| 6969 |
return "k8s.resourcequota.persistentvolumeclaim_count.hard" |
| 6970 |
} |
| 6971 |
|
| 6972 |
// Unit returns the semantic convention unit of the instrument |
| 6973 |
func (ResourceQuotaPersistentvolumeclaimCountHard) Unit() string { |
| 6974 |
return "{persistentvolumeclaim}" |
| 6975 |
} |
| 6976 |
|
| 6977 |
// Description returns the semantic convention description of the instrument |
| 6978 |
func (ResourceQuotaPersistentvolumeclaimCountHard) Description() string { |
| 6979 |
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." |
| 6980 |
} |
| 6981 |
|
| 6982 |
// Add adds incr to the existing count for attrs. |
| 6983 |
// |
| 6984 |
// All additional attrs passed are included in the recorded value. |
| 6985 |
// |
| 6986 |
// This metric is retrieved from the `hard` field of the |
| 6987 |
// [K8s ResourceQuotaStatus]. |
| 6988 |
// |
| 6989 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 6990 |
// defined for a specific |
| 6991 |
// storage class. |
| 6992 |
// |
| 6993 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 6994 |
func (m ResourceQuotaPersistentvolumeclaimCountHard) Add( |
| 6995 |
ctx context.Context, |
| 6996 |
incr int64, |
| 6997 |
attrs ...attribute.KeyValue, |
| 6998 |
) { |
| 6999 |
if len(attrs) == 0 { |
| 7000 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7001 |
return |
| 7002 |
} |
| 7003 |
|
| 7004 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7005 |
defer func() { |
| 7006 |
*o = (*o)[:0] |
| 7007 |
addOptPool.Put(o) |
| 7008 |
}() |
| 7009 |
|
| 7010 |
*o = append( |
| 7011 |
*o, |
| 7012 |
metric.WithAttributes( |
| 7013 |
attrs..., |
| 7014 |
), |
| 7015 |
) |
| 7016 |
|
| 7017 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7018 |
} |
| 7019 |
|
| 7020 |
// AddSet adds incr to the existing count for set. |
| 7021 |
// |
| 7022 |
// This metric is retrieved from the `hard` field of the |
| 7023 |
// [K8s ResourceQuotaStatus]. |
| 7024 |
// |
| 7025 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 7026 |
// defined for a specific |
| 7027 |
// storage class. |
| 7028 |
// |
| 7029 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 7030 |
func (m ResourceQuotaPersistentvolumeclaimCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7031 |
if set.Len() == 0 { |
| 7032 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7033 |
return |
| 7034 |
} |
| 7035 |
|
| 7036 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7037 |
defer func() { |
| 7038 |
*o = (*o)[:0] |
| 7039 |
addOptPool.Put(o) |
| 7040 |
}() |
| 7041 |
|
| 7042 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7043 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7044 |
} |
| 7045 |
|
| 7046 |
// AttrStorageclassName returns an optional attribute for the |
| 7047 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 7048 |
// [StorageClass] object. |
| 7049 |
// |
| 7050 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 7051 |
func (ResourceQuotaPersistentvolumeclaimCountHard) AttrStorageclassName(val string) attribute.KeyValue { |
| 7052 |
return attribute.String("k8s.storageclass.name", val) |
| 7053 |
} |
| 7054 |
|
| 7055 |
// ResourceQuotaPersistentvolumeclaimCountUsed is an instrument used to record |
| 7056 |
// metric values conforming to the |
| 7057 |
// "k8s.resourcequota.persistentvolumeclaim_count.used" semantic conventions. It |
| 7058 |
// represents the total number of PersistentVolumeClaims that can exist in the |
| 7059 |
// namespace. |
| 7060 |
// The value represents the current observed total usage of the resource in the |
| 7061 |
// namespace. |
| 7062 |
type ResourceQuotaPersistentvolumeclaimCountUsed struct { |
| 7063 |
metric.Int64UpDownCounter |
| 7064 |
} |
| 7065 |
|
| 7066 |
// NewResourceQuotaPersistentvolumeclaimCountUsed returns a new |
| 7067 |
// ResourceQuotaPersistentvolumeclaimCountUsed instrument. |
| 7068 |
func NewResourceQuotaPersistentvolumeclaimCountUsed( |
| 7069 |
m metric.Meter, |
| 7070 |
opt ...metric.Int64UpDownCounterOption, |
| 7071 |
) (ResourceQuotaPersistentvolumeclaimCountUsed, error) { |
| 7072 |
// Check if the meter is nil. |
| 7073 |
if m == nil { |
| 7074 |
return ResourceQuotaPersistentvolumeclaimCountUsed{noop.Int64UpDownCounter{}}, nil |
| 7075 |
} |
| 7076 |
|
| 7077 |
i, err := m.Int64UpDownCounter( |
| 7078 |
"k8s.resourcequota.persistentvolumeclaim_count.used", |
| 7079 |
append([]metric.Int64UpDownCounterOption{ |
| 7080 |
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."), |
| 7081 |
metric.WithUnit("{persistentvolumeclaim}"), |
| 7082 |
}, opt...)..., |
| 7083 |
) |
| 7084 |
if err != nil { |
| 7085 |
return ResourceQuotaPersistentvolumeclaimCountUsed{noop.Int64UpDownCounter{}}, err |
| 7086 |
} |
| 7087 |
return ResourceQuotaPersistentvolumeclaimCountUsed{i}, nil |
| 7088 |
} |
| 7089 |
|
| 7090 |
// Inst returns the underlying metric instrument. |
| 7091 |
func (m ResourceQuotaPersistentvolumeclaimCountUsed) Inst() metric.Int64UpDownCounter { |
| 7092 |
return m.Int64UpDownCounter |
| 7093 |
} |
| 7094 |
|
| 7095 |
// Name returns the semantic convention name of the instrument. |
| 7096 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) Name() string { |
| 7097 |
return "k8s.resourcequota.persistentvolumeclaim_count.used" |
| 7098 |
} |
| 7099 |
|
| 7100 |
// Unit returns the semantic convention unit of the instrument |
| 7101 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) Unit() string { |
| 7102 |
return "{persistentvolumeclaim}" |
| 7103 |
} |
| 7104 |
|
| 7105 |
// Description returns the semantic convention description of the instrument |
| 7106 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) Description() string { |
| 7107 |
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." |
| 7108 |
} |
| 7109 |
|
| 7110 |
// Add adds incr to the existing count for attrs. |
| 7111 |
// |
| 7112 |
// All additional attrs passed are included in the recorded value. |
| 7113 |
// |
| 7114 |
// This metric is retrieved from the `used` field of the |
| 7115 |
// [K8s ResourceQuotaStatus]. |
| 7116 |
// |
| 7117 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 7118 |
// defined for a specific |
| 7119 |
// storage class. |
| 7120 |
// |
| 7121 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 7122 |
func (m ResourceQuotaPersistentvolumeclaimCountUsed) Add( |
| 7123 |
ctx context.Context, |
| 7124 |
incr int64, |
| 7125 |
attrs ...attribute.KeyValue, |
| 7126 |
) { |
| 7127 |
if len(attrs) == 0 { |
| 7128 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7129 |
return |
| 7130 |
} |
| 7131 |
|
| 7132 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7133 |
defer func() { |
| 7134 |
*o = (*o)[:0] |
| 7135 |
addOptPool.Put(o) |
| 7136 |
}() |
| 7137 |
|
| 7138 |
*o = append( |
| 7139 |
*o, |
| 7140 |
metric.WithAttributes( |
| 7141 |
attrs..., |
| 7142 |
), |
| 7143 |
) |
| 7144 |
|
| 7145 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7146 |
} |
| 7147 |
|
| 7148 |
// AddSet adds incr to the existing count for set. |
| 7149 |
// |
| 7150 |
// This metric is retrieved from the `used` field of the |
| 7151 |
// [K8s ResourceQuotaStatus]. |
| 7152 |
// |
| 7153 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 7154 |
// defined for a specific |
| 7155 |
// storage class. |
| 7156 |
// |
| 7157 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 7158 |
func (m ResourceQuotaPersistentvolumeclaimCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7159 |
if set.Len() == 0 { |
| 7160 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7161 |
return |
| 7162 |
} |
| 7163 |
|
| 7164 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7165 |
defer func() { |
| 7166 |
*o = (*o)[:0] |
| 7167 |
addOptPool.Put(o) |
| 7168 |
}() |
| 7169 |
|
| 7170 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7171 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7172 |
} |
| 7173 |
|
| 7174 |
// AttrStorageclassName returns an optional attribute for the |
| 7175 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 7176 |
// [StorageClass] object. |
| 7177 |
// |
| 7178 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 7179 |
func (ResourceQuotaPersistentvolumeclaimCountUsed) AttrStorageclassName(val string) attribute.KeyValue { |
| 7180 |
return attribute.String("k8s.storageclass.name", val) |
| 7181 |
} |
| 7182 |
|
| 7183 |
// ResourceQuotaStorageRequestHard is an instrument used to record metric values |
| 7184 |
// conforming to the "k8s.resourcequota.storage.request.hard" semantic |
| 7185 |
// conventions. It represents the storage requests in a specific namespace. |
| 7186 |
// The value represents the configured quota limit of the resource in the |
| 7187 |
// namespace. |
| 7188 |
type ResourceQuotaStorageRequestHard struct { |
| 7189 |
metric.Int64UpDownCounter |
| 7190 |
} |
| 7191 |
|
| 7192 |
// NewResourceQuotaStorageRequestHard returns a new |
| 7193 |
// ResourceQuotaStorageRequestHard instrument. |
| 7194 |
func NewResourceQuotaStorageRequestHard( |
| 7195 |
m metric.Meter, |
| 7196 |
opt ...metric.Int64UpDownCounterOption, |
| 7197 |
) (ResourceQuotaStorageRequestHard, error) { |
| 7198 |
// Check if the meter is nil. |
| 7199 |
if m == nil { |
| 7200 |
return ResourceQuotaStorageRequestHard{noop.Int64UpDownCounter{}}, nil |
| 7201 |
} |
| 7202 |
|
| 7203 |
i, err := m.Int64UpDownCounter( |
| 7204 |
"k8s.resourcequota.storage.request.hard", |
| 7205 |
append([]metric.Int64UpDownCounterOption{ |
| 7206 |
metric.WithDescription("The storage requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace."), |
| 7207 |
metric.WithUnit("By"), |
| 7208 |
}, opt...)..., |
| 7209 |
) |
| 7210 |
if err != nil { |
| 7211 |
return ResourceQuotaStorageRequestHard{noop.Int64UpDownCounter{}}, err |
| 7212 |
} |
| 7213 |
return ResourceQuotaStorageRequestHard{i}, nil |
| 7214 |
} |
| 7215 |
|
| 7216 |
// Inst returns the underlying metric instrument. |
| 7217 |
func (m ResourceQuotaStorageRequestHard) Inst() metric.Int64UpDownCounter { |
| 7218 |
return m.Int64UpDownCounter |
| 7219 |
} |
| 7220 |
|
| 7221 |
// Name returns the semantic convention name of the instrument. |
| 7222 |
func (ResourceQuotaStorageRequestHard) Name() string { |
| 7223 |
return "k8s.resourcequota.storage.request.hard" |
| 7224 |
} |
| 7225 |
|
| 7226 |
// Unit returns the semantic convention unit of the instrument |
| 7227 |
func (ResourceQuotaStorageRequestHard) Unit() string { |
| 7228 |
return "By" |
| 7229 |
} |
| 7230 |
|
| 7231 |
// Description returns the semantic convention description of the instrument |
| 7232 |
func (ResourceQuotaStorageRequestHard) Description() string { |
| 7233 |
return "The storage requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." |
| 7234 |
} |
| 7235 |
|
| 7236 |
// Add adds incr to the existing count for attrs. |
| 7237 |
// |
| 7238 |
// All additional attrs passed are included in the recorded value. |
| 7239 |
// |
| 7240 |
// This metric is retrieved from the `hard` field of the |
| 7241 |
// [K8s ResourceQuotaStatus]. |
| 7242 |
// |
| 7243 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 7244 |
// defined for a specific |
| 7245 |
// storage class. |
| 7246 |
// |
| 7247 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 7248 |
func (m ResourceQuotaStorageRequestHard) Add( |
| 7249 |
ctx context.Context, |
| 7250 |
incr int64, |
| 7251 |
attrs ...attribute.KeyValue, |
| 7252 |
) { |
| 7253 |
if len(attrs) == 0 { |
| 7254 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7255 |
return |
| 7256 |
} |
| 7257 |
|
| 7258 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7259 |
defer func() { |
| 7260 |
*o = (*o)[:0] |
| 7261 |
addOptPool.Put(o) |
| 7262 |
}() |
| 7263 |
|
| 7264 |
*o = append( |
| 7265 |
*o, |
| 7266 |
metric.WithAttributes( |
| 7267 |
attrs..., |
| 7268 |
), |
| 7269 |
) |
| 7270 |
|
| 7271 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7272 |
} |
| 7273 |
|
| 7274 |
// AddSet adds incr to the existing count for set. |
| 7275 |
// |
| 7276 |
// This metric is retrieved from the `hard` field of the |
| 7277 |
// [K8s ResourceQuotaStatus]. |
| 7278 |
// |
| 7279 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 7280 |
// defined for a specific |
| 7281 |
// storage class. |
| 7282 |
// |
| 7283 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 7284 |
func (m ResourceQuotaStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7285 |
if set.Len() == 0 { |
| 7286 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7287 |
return |
| 7288 |
} |
| 7289 |
|
| 7290 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7291 |
defer func() { |
| 7292 |
*o = (*o)[:0] |
| 7293 |
addOptPool.Put(o) |
| 7294 |
}() |
| 7295 |
|
| 7296 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7297 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7298 |
} |
| 7299 |
|
| 7300 |
// AttrStorageclassName returns an optional attribute for the |
| 7301 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 7302 |
// [StorageClass] object. |
| 7303 |
// |
| 7304 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 7305 |
func (ResourceQuotaStorageRequestHard) AttrStorageclassName(val string) attribute.KeyValue { |
| 7306 |
return attribute.String("k8s.storageclass.name", val) |
| 7307 |
} |
| 7308 |
|
| 7309 |
// ResourceQuotaStorageRequestUsed is an instrument used to record metric values |
| 7310 |
// conforming to the "k8s.resourcequota.storage.request.used" semantic |
| 7311 |
// conventions. It represents the storage requests in a specific namespace. |
| 7312 |
// The value represents the current observed total usage of the resource in the |
| 7313 |
// namespace. |
| 7314 |
type ResourceQuotaStorageRequestUsed struct { |
| 7315 |
metric.Int64UpDownCounter |
| 7316 |
} |
| 7317 |
|
| 7318 |
// NewResourceQuotaStorageRequestUsed returns a new |
| 7319 |
// ResourceQuotaStorageRequestUsed instrument. |
| 7320 |
func NewResourceQuotaStorageRequestUsed( |
| 7321 |
m metric.Meter, |
| 7322 |
opt ...metric.Int64UpDownCounterOption, |
| 7323 |
) (ResourceQuotaStorageRequestUsed, error) { |
| 7324 |
// Check if the meter is nil. |
| 7325 |
if m == nil { |
| 7326 |
return ResourceQuotaStorageRequestUsed{noop.Int64UpDownCounter{}}, nil |
| 7327 |
} |
| 7328 |
|
| 7329 |
i, err := m.Int64UpDownCounter( |
| 7330 |
"k8s.resourcequota.storage.request.used", |
| 7331 |
append([]metric.Int64UpDownCounterOption{ |
| 7332 |
metric.WithDescription("The storage requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace."), |
| 7333 |
metric.WithUnit("By"), |
| 7334 |
}, opt...)..., |
| 7335 |
) |
| 7336 |
if err != nil { |
| 7337 |
return ResourceQuotaStorageRequestUsed{noop.Int64UpDownCounter{}}, err |
| 7338 |
} |
| 7339 |
return ResourceQuotaStorageRequestUsed{i}, nil |
| 7340 |
} |
| 7341 |
|
| 7342 |
// Inst returns the underlying metric instrument. |
| 7343 |
func (m ResourceQuotaStorageRequestUsed) Inst() metric.Int64UpDownCounter { |
| 7344 |
return m.Int64UpDownCounter |
| 7345 |
} |
| 7346 |
|
| 7347 |
// Name returns the semantic convention name of the instrument. |
| 7348 |
func (ResourceQuotaStorageRequestUsed) Name() string { |
| 7349 |
return "k8s.resourcequota.storage.request.used" |
| 7350 |
} |
| 7351 |
|
| 7352 |
// Unit returns the semantic convention unit of the instrument |
| 7353 |
func (ResourceQuotaStorageRequestUsed) Unit() string { |
| 7354 |
return "By" |
| 7355 |
} |
| 7356 |
|
| 7357 |
// Description returns the semantic convention description of the instrument |
| 7358 |
func (ResourceQuotaStorageRequestUsed) Description() string { |
| 7359 |
return "The storage requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." |
| 7360 |
} |
| 7361 |
|
| 7362 |
// Add adds incr to the existing count for attrs. |
| 7363 |
// |
| 7364 |
// All additional attrs passed are included in the recorded value. |
| 7365 |
// |
| 7366 |
// This metric is retrieved from the `used` field of the |
| 7367 |
// [K8s ResourceQuotaStatus]. |
| 7368 |
// |
| 7369 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 7370 |
// defined for a specific |
| 7371 |
// storage class. |
| 7372 |
// |
| 7373 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 7374 |
func (m ResourceQuotaStorageRequestUsed) Add( |
| 7375 |
ctx context.Context, |
| 7376 |
incr int64, |
| 7377 |
attrs ...attribute.KeyValue, |
| 7378 |
) { |
| 7379 |
if len(attrs) == 0 { |
| 7380 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7381 |
return |
| 7382 |
} |
| 7383 |
|
| 7384 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7385 |
defer func() { |
| 7386 |
*o = (*o)[:0] |
| 7387 |
addOptPool.Put(o) |
| 7388 |
}() |
| 7389 |
|
| 7390 |
*o = append( |
| 7391 |
*o, |
| 7392 |
metric.WithAttributes( |
| 7393 |
attrs..., |
| 7394 |
), |
| 7395 |
) |
| 7396 |
|
| 7397 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7398 |
} |
| 7399 |
|
| 7400 |
// AddSet adds incr to the existing count for set. |
| 7401 |
// |
| 7402 |
// This metric is retrieved from the `used` field of the |
| 7403 |
// [K8s ResourceQuotaStatus]. |
| 7404 |
// |
| 7405 |
// The `k8s.storageclass.name` should be required when a resource quota is |
| 7406 |
// defined for a specific |
| 7407 |
// storage class. |
| 7408 |
// |
| 7409 |
// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core |
| 7410 |
func (m ResourceQuotaStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7411 |
if set.Len() == 0 { |
| 7412 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7413 |
return |
| 7414 |
} |
| 7415 |
|
| 7416 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7417 |
defer func() { |
| 7418 |
*o = (*o)[:0] |
| 7419 |
addOptPool.Put(o) |
| 7420 |
}() |
| 7421 |
|
| 7422 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7423 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7424 |
} |
| 7425 |
|
| 7426 |
// AttrStorageclassName returns an optional attribute for the |
| 7427 |
// "k8s.storageclass.name" semantic convention. It represents the name of K8s |
| 7428 |
// [StorageClass] object. |
| 7429 |
// |
| 7430 |
// [StorageClass]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#storageclass-v1-storage-k8s-io |
| 7431 |
func (ResourceQuotaStorageRequestUsed) AttrStorageclassName(val string) attribute.KeyValue { |
| 7432 |
return attribute.String("k8s.storageclass.name", val) |
| 7433 |
} |
| 7434 |
|
| 7435 |
// StatefulSetCurrentPods is an instrument used to record metric values |
| 7436 |
// conforming to the "k8s.statefulset.current_pods" semantic conventions. It |
| 7437 |
// represents the number of replica pods created by the statefulset controller |
| 7438 |
// from the statefulset version indicated by currentRevision. |
| 7439 |
type StatefulSetCurrentPods struct { |
| 7440 |
metric.Int64UpDownCounter |
| 7441 |
} |
| 7442 |
|
| 7443 |
// NewStatefulSetCurrentPods returns a new StatefulSetCurrentPods instrument. |
| 7444 |
func NewStatefulSetCurrentPods( |
| 7445 |
m metric.Meter, |
| 7446 |
opt ...metric.Int64UpDownCounterOption, |
| 7447 |
) (StatefulSetCurrentPods, error) { |
| 7448 |
// Check if the meter is nil. |
| 7449 |
if m == nil { |
| 7450 |
return StatefulSetCurrentPods{noop.Int64UpDownCounter{}}, nil |
| 7451 |
} |
| 7452 |
|
| 7453 |
i, err := m.Int64UpDownCounter( |
| 7454 |
"k8s.statefulset.current_pods", |
| 7455 |
append([]metric.Int64UpDownCounterOption{ |
| 7456 |
metric.WithDescription("The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision"), |
| 7457 |
metric.WithUnit("{pod}"), |
| 7458 |
}, opt...)..., |
| 7459 |
) |
| 7460 |
if err != nil { |
| 7461 |
return StatefulSetCurrentPods{noop.Int64UpDownCounter{}}, err |
| 7462 |
} |
| 7463 |
return StatefulSetCurrentPods{i}, nil |
| 7464 |
} |
| 7465 |
|
| 7466 |
// Inst returns the underlying metric instrument. |
| 7467 |
func (m StatefulSetCurrentPods) Inst() metric.Int64UpDownCounter { |
| 7468 |
return m.Int64UpDownCounter |
| 7469 |
} |
| 7470 |
|
| 7471 |
// Name returns the semantic convention name of the instrument. |
| 7472 |
func (StatefulSetCurrentPods) Name() string { |
| 7473 |
return "k8s.statefulset.current_pods" |
| 7474 |
} |
| 7475 |
|
| 7476 |
// Unit returns the semantic convention unit of the instrument |
| 7477 |
func (StatefulSetCurrentPods) Unit() string { |
| 7478 |
return "{pod}" |
| 7479 |
} |
| 7480 |
|
| 7481 |
// Description returns the semantic convention description of the instrument |
| 7482 |
func (StatefulSetCurrentPods) Description() string { |
| 7483 |
return "The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision" |
| 7484 |
} |
| 7485 |
|
| 7486 |
// Add adds incr to the existing count for attrs. |
| 7487 |
// |
| 7488 |
// This metric aligns with the `currentReplicas` field of the |
| 7489 |
// [K8s StatefulSetStatus]. |
| 7490 |
// |
| 7491 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 7492 |
func (m StatefulSetCurrentPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 7493 |
if len(attrs) == 0 { |
| 7494 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7495 |
return |
| 7496 |
} |
| 7497 |
|
| 7498 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7499 |
defer func() { |
| 7500 |
*o = (*o)[:0] |
| 7501 |
addOptPool.Put(o) |
| 7502 |
}() |
| 7503 |
|
| 7504 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 7505 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7506 |
} |
| 7507 |
|
| 7508 |
// AddSet adds incr to the existing count for set. |
| 7509 |
// |
| 7510 |
// This metric aligns with the `currentReplicas` field of the |
| 7511 |
// [K8s StatefulSetStatus]. |
| 7512 |
// |
| 7513 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 7514 |
func (m StatefulSetCurrentPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7515 |
if set.Len() == 0 { |
| 7516 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7517 |
return |
| 7518 |
} |
| 7519 |
|
| 7520 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7521 |
defer func() { |
| 7522 |
*o = (*o)[:0] |
| 7523 |
addOptPool.Put(o) |
| 7524 |
}() |
| 7525 |
|
| 7526 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7527 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7528 |
} |
| 7529 |
|
| 7530 |
// StatefulSetDesiredPods is an instrument used to record metric values |
| 7531 |
// conforming to the "k8s.statefulset.desired_pods" semantic conventions. It |
| 7532 |
// represents the number of desired replica pods in this statefulset. |
| 7533 |
type StatefulSetDesiredPods struct { |
| 7534 |
metric.Int64UpDownCounter |
| 7535 |
} |
| 7536 |
|
| 7537 |
// NewStatefulSetDesiredPods returns a new StatefulSetDesiredPods instrument. |
| 7538 |
func NewStatefulSetDesiredPods( |
| 7539 |
m metric.Meter, |
| 7540 |
opt ...metric.Int64UpDownCounterOption, |
| 7541 |
) (StatefulSetDesiredPods, error) { |
| 7542 |
// Check if the meter is nil. |
| 7543 |
if m == nil { |
| 7544 |
return StatefulSetDesiredPods{noop.Int64UpDownCounter{}}, nil |
| 7545 |
} |
| 7546 |
|
| 7547 |
i, err := m.Int64UpDownCounter( |
| 7548 |
"k8s.statefulset.desired_pods", |
| 7549 |
append([]metric.Int64UpDownCounterOption{ |
| 7550 |
metric.WithDescription("Number of desired replica pods in this statefulset"), |
| 7551 |
metric.WithUnit("{pod}"), |
| 7552 |
}, opt...)..., |
| 7553 |
) |
| 7554 |
if err != nil { |
| 7555 |
return StatefulSetDesiredPods{noop.Int64UpDownCounter{}}, err |
| 7556 |
} |
| 7557 |
return StatefulSetDesiredPods{i}, nil |
| 7558 |
} |
| 7559 |
|
| 7560 |
// Inst returns the underlying metric instrument. |
| 7561 |
func (m StatefulSetDesiredPods) Inst() metric.Int64UpDownCounter { |
| 7562 |
return m.Int64UpDownCounter |
| 7563 |
} |
| 7564 |
|
| 7565 |
// Name returns the semantic convention name of the instrument. |
| 7566 |
func (StatefulSetDesiredPods) Name() string { |
| 7567 |
return "k8s.statefulset.desired_pods" |
| 7568 |
} |
| 7569 |
|
| 7570 |
// Unit returns the semantic convention unit of the instrument |
| 7571 |
func (StatefulSetDesiredPods) Unit() string { |
| 7572 |
return "{pod}" |
| 7573 |
} |
| 7574 |
|
| 7575 |
// Description returns the semantic convention description of the instrument |
| 7576 |
func (StatefulSetDesiredPods) Description() string { |
| 7577 |
return "Number of desired replica pods in this statefulset" |
| 7578 |
} |
| 7579 |
|
| 7580 |
// Add adds incr to the existing count for attrs. |
| 7581 |
// |
| 7582 |
// This metric aligns with the `replicas` field of the |
| 7583 |
// [K8s StatefulSetSpec]. |
| 7584 |
// |
| 7585 |
// [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps |
| 7586 |
func (m StatefulSetDesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 7587 |
if len(attrs) == 0 { |
| 7588 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7589 |
return |
| 7590 |
} |
| 7591 |
|
| 7592 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7593 |
defer func() { |
| 7594 |
*o = (*o)[:0] |
| 7595 |
addOptPool.Put(o) |
| 7596 |
}() |
| 7597 |
|
| 7598 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 7599 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7600 |
} |
| 7601 |
|
| 7602 |
// AddSet adds incr to the existing count for set. |
| 7603 |
// |
| 7604 |
// This metric aligns with the `replicas` field of the |
| 7605 |
// [K8s StatefulSetSpec]. |
| 7606 |
// |
| 7607 |
// [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps |
| 7608 |
func (m StatefulSetDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7609 |
if set.Len() == 0 { |
| 7610 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7611 |
return |
| 7612 |
} |
| 7613 |
|
| 7614 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7615 |
defer func() { |
| 7616 |
*o = (*o)[:0] |
| 7617 |
addOptPool.Put(o) |
| 7618 |
}() |
| 7619 |
|
| 7620 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7621 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7622 |
} |
| 7623 |
|
| 7624 |
// StatefulSetReadyPods is an instrument used to record metric values conforming |
| 7625 |
// to the "k8s.statefulset.ready_pods" semantic conventions. It represents the |
| 7626 |
// number of replica pods created for this statefulset with a Ready Condition. |
| 7627 |
type StatefulSetReadyPods struct { |
| 7628 |
metric.Int64UpDownCounter |
| 7629 |
} |
| 7630 |
|
| 7631 |
// NewStatefulSetReadyPods returns a new StatefulSetReadyPods instrument. |
| 7632 |
func NewStatefulSetReadyPods( |
| 7633 |
m metric.Meter, |
| 7634 |
opt ...metric.Int64UpDownCounterOption, |
| 7635 |
) (StatefulSetReadyPods, error) { |
| 7636 |
// Check if the meter is nil. |
| 7637 |
if m == nil { |
| 7638 |
return StatefulSetReadyPods{noop.Int64UpDownCounter{}}, nil |
| 7639 |
} |
| 7640 |
|
| 7641 |
i, err := m.Int64UpDownCounter( |
| 7642 |
"k8s.statefulset.ready_pods", |
| 7643 |
append([]metric.Int64UpDownCounterOption{ |
| 7644 |
metric.WithDescription("The number of replica pods created for this statefulset with a Ready Condition"), |
| 7645 |
metric.WithUnit("{pod}"), |
| 7646 |
}, opt...)..., |
| 7647 |
) |
| 7648 |
if err != nil { |
| 7649 |
return StatefulSetReadyPods{noop.Int64UpDownCounter{}}, err |
| 7650 |
} |
| 7651 |
return StatefulSetReadyPods{i}, nil |
| 7652 |
} |
| 7653 |
|
| 7654 |
// Inst returns the underlying metric instrument. |
| 7655 |
func (m StatefulSetReadyPods) Inst() metric.Int64UpDownCounter { |
| 7656 |
return m.Int64UpDownCounter |
| 7657 |
} |
| 7658 |
|
| 7659 |
// Name returns the semantic convention name of the instrument. |
| 7660 |
func (StatefulSetReadyPods) Name() string { |
| 7661 |
return "k8s.statefulset.ready_pods" |
| 7662 |
} |
| 7663 |
|
| 7664 |
// Unit returns the semantic convention unit of the instrument |
| 7665 |
func (StatefulSetReadyPods) Unit() string { |
| 7666 |
return "{pod}" |
| 7667 |
} |
| 7668 |
|
| 7669 |
// Description returns the semantic convention description of the instrument |
| 7670 |
func (StatefulSetReadyPods) Description() string { |
| 7671 |
return "The number of replica pods created for this statefulset with a Ready Condition" |
| 7672 |
} |
| 7673 |
|
| 7674 |
// Add adds incr to the existing count for attrs. |
| 7675 |
// |
| 7676 |
// This metric aligns with the `readyReplicas` field of the |
| 7677 |
// [K8s StatefulSetStatus]. |
| 7678 |
// |
| 7679 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 7680 |
func (m StatefulSetReadyPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 7681 |
if len(attrs) == 0 { |
| 7682 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7683 |
return |
| 7684 |
} |
| 7685 |
|
| 7686 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7687 |
defer func() { |
| 7688 |
*o = (*o)[:0] |
| 7689 |
addOptPool.Put(o) |
| 7690 |
}() |
| 7691 |
|
| 7692 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 7693 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7694 |
} |
| 7695 |
|
| 7696 |
// AddSet adds incr to the existing count for set. |
| 7697 |
// |
| 7698 |
// This metric aligns with the `readyReplicas` field of the |
| 7699 |
// [K8s StatefulSetStatus]. |
| 7700 |
// |
| 7701 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 7702 |
func (m StatefulSetReadyPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7703 |
if set.Len() == 0 { |
| 7704 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7705 |
return |
| 7706 |
} |
| 7707 |
|
| 7708 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7709 |
defer func() { |
| 7710 |
*o = (*o)[:0] |
| 7711 |
addOptPool.Put(o) |
| 7712 |
}() |
| 7713 |
|
| 7714 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7715 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7716 |
} |
| 7717 |
|
| 7718 |
// StatefulSetUpdatedPods is an instrument used to record metric values |
| 7719 |
// conforming to the "k8s.statefulset.updated_pods" semantic conventions. It |
| 7720 |
// represents the number of replica pods created by the statefulset controller |
| 7721 |
// from the statefulset version indicated by updateRevision. |
| 7722 |
type StatefulSetUpdatedPods struct { |
| 7723 |
metric.Int64UpDownCounter |
| 7724 |
} |
| 7725 |
|
| 7726 |
// NewStatefulSetUpdatedPods returns a new StatefulSetUpdatedPods instrument. |
| 7727 |
func NewStatefulSetUpdatedPods( |
| 7728 |
m metric.Meter, |
| 7729 |
opt ...metric.Int64UpDownCounterOption, |
| 7730 |
) (StatefulSetUpdatedPods, error) { |
| 7731 |
// Check if the meter is nil. |
| 7732 |
if m == nil { |
| 7733 |
return StatefulSetUpdatedPods{noop.Int64UpDownCounter{}}, nil |
| 7734 |
} |
| 7735 |
|
| 7736 |
i, err := m.Int64UpDownCounter( |
| 7737 |
"k8s.statefulset.updated_pods", |
| 7738 |
append([]metric.Int64UpDownCounterOption{ |
| 7739 |
metric.WithDescription("Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision"), |
| 7740 |
metric.WithUnit("{pod}"), |
| 7741 |
}, opt...)..., |
| 7742 |
) |
| 7743 |
if err != nil { |
| 7744 |
return StatefulSetUpdatedPods{noop.Int64UpDownCounter{}}, err |
| 7745 |
} |
| 7746 |
return StatefulSetUpdatedPods{i}, nil |
| 7747 |
} |
| 7748 |
|
| 7749 |
// Inst returns the underlying metric instrument. |
| 7750 |
func (m StatefulSetUpdatedPods) Inst() metric.Int64UpDownCounter { |
| 7751 |
return m.Int64UpDownCounter |
| 7752 |
} |
| 7753 |
|
| 7754 |
// Name returns the semantic convention name of the instrument. |
| 7755 |
func (StatefulSetUpdatedPods) Name() string { |
| 7756 |
return "k8s.statefulset.updated_pods" |
| 7757 |
} |
| 7758 |
|
| 7759 |
// Unit returns the semantic convention unit of the instrument |
| 7760 |
func (StatefulSetUpdatedPods) Unit() string { |
| 7761 |
return "{pod}" |
| 7762 |
} |
| 7763 |
|
| 7764 |
// Description returns the semantic convention description of the instrument |
| 7765 |
func (StatefulSetUpdatedPods) Description() string { |
| 7766 |
return "Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision" |
| 7767 |
} |
| 7768 |
|
| 7769 |
// Add adds incr to the existing count for attrs. |
| 7770 |
// |
| 7771 |
// This metric aligns with the `updatedReplicas` field of the |
| 7772 |
// [K8s StatefulSetStatus]. |
| 7773 |
// |
| 7774 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 7775 |
func (m StatefulSetUpdatedPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { |
| 7776 |
if len(attrs) == 0 { |
| 7777 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7778 |
return |
| 7779 |
} |
| 7780 |
|
| 7781 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7782 |
defer func() { |
| 7783 |
*o = (*o)[:0] |
| 7784 |
addOptPool.Put(o) |
| 7785 |
}() |
| 7786 |
|
| 7787 |
*o = append(*o, metric.WithAttributes(attrs...)) |
| 7788 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7789 |
} |
| 7790 |
|
| 7791 |
// AddSet adds incr to the existing count for set. |
| 7792 |
// |
| 7793 |
// This metric aligns with the `updatedReplicas` field of the |
| 7794 |
// [K8s StatefulSetStatus]. |
| 7795 |
// |
| 7796 |
// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps |
| 7797 |
func (m StatefulSetUpdatedPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 7798 |
if set.Len() == 0 { |
| 7799 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 7800 |
return |
| 7801 |
} |
| 7802 |
|
| 7803 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 7804 |
defer func() { |
| 7805 |
*o = (*o)[:0] |
| 7806 |
addOptPool.Put(o) |
| 7807 |
}() |
| 7808 |
|
| 7809 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 7810 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 7811 |
} |