| 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 hwconv provides types and functionality for OpenTelemetry semantic |
| 7 |
// conventions in the "hw" namespace. |
| 8 |
package hwconv |
| 9 |
|
| 10 |
import ( |
| 11 |
"context" |
| 12 |
"sync" |
| 13 |
|
| 14 |
"go.opentelemetry.io/otel/attribute" |
| 15 |
"go.opentelemetry.io/otel/metric" |
| 16 |
"go.opentelemetry.io/otel/metric/noop" |
| 17 |
) |
| 18 |
|
| 19 |
var ( |
| 20 |
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }} |
| 21 |
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }} |
| 22 |
) |
| 23 |
|
| 24 |
// ErrorTypeAttr is an attribute conforming to the error.type semantic |
| 25 |
// conventions. It represents the type of error encountered by the component. |
| 26 |
type ErrorTypeAttr string |
| 27 |
|
| 28 |
var ( |
| 29 |
// ErrorTypeOther is a fallback error value to be used when the instrumentation |
| 30 |
// doesn't define a custom value. |
| 31 |
ErrorTypeOther ErrorTypeAttr = "_OTHER" |
| 32 |
) |
| 33 |
|
| 34 |
// BatteryStateAttr is an attribute conforming to the hw.battery.state semantic |
| 35 |
// conventions. It represents the current state of the battery. |
| 36 |
type BatteryStateAttr string |
| 37 |
|
| 38 |
var ( |
| 39 |
// BatteryStateCharging is the charging. |
| 40 |
BatteryStateCharging BatteryStateAttr = "charging" |
| 41 |
// BatteryStateDischarging is the discharging. |
| 42 |
BatteryStateDischarging BatteryStateAttr = "discharging" |
| 43 |
) |
| 44 |
|
| 45 |
// GpuTaskAttr is an attribute conforming to the hw.gpu.task semantic |
| 46 |
// conventions. It represents the type of task the GPU is performing. |
| 47 |
type GpuTaskAttr string |
| 48 |
|
| 49 |
var ( |
| 50 |
// GpuTaskDecoder is the decoder. |
| 51 |
GpuTaskDecoder GpuTaskAttr = "decoder" |
| 52 |
// GpuTaskEncoder is the encoder. |
| 53 |
GpuTaskEncoder GpuTaskAttr = "encoder" |
| 54 |
// GpuTaskGeneral is the general. |
| 55 |
GpuTaskGeneral GpuTaskAttr = "general" |
| 56 |
) |
| 57 |
|
| 58 |
// LimitTypeAttr is an attribute conforming to the hw.limit_type semantic |
| 59 |
// conventions. It represents the represents battery charge level thresholds |
| 60 |
// relevant to device operation and health. Each `limit_type` denotes a specific |
| 61 |
// charge limit such as the minimum or maximum optimal charge, the shutdown |
| 62 |
// threshold, or energy-saving thresholds. These values are typically provided by |
| 63 |
// the hardware or firmware to guide safe and efficient battery usage. |
| 64 |
type LimitTypeAttr string |
| 65 |
|
| 66 |
var ( |
| 67 |
// LimitTypeCritical is the critical. |
| 68 |
LimitTypeCritical LimitTypeAttr = "critical" |
| 69 |
// LimitTypeDegraded is the degraded. |
| 70 |
LimitTypeDegraded LimitTypeAttr = "degraded" |
| 71 |
// LimitTypeHighCritical is the high Critical. |
| 72 |
LimitTypeHighCritical LimitTypeAttr = "high.critical" |
| 73 |
// LimitTypeHighDegraded is the high Degraded. |
| 74 |
LimitTypeHighDegraded LimitTypeAttr = "high.degraded" |
| 75 |
// LimitTypeLowCritical is the low Critical. |
| 76 |
LimitTypeLowCritical LimitTypeAttr = "low.critical" |
| 77 |
// LimitTypeLowDegraded is the low Degraded. |
| 78 |
LimitTypeLowDegraded LimitTypeAttr = "low.degraded" |
| 79 |
// LimitTypeMax is the maximum. |
| 80 |
LimitTypeMax LimitTypeAttr = "max" |
| 81 |
// LimitTypeThrottled is the throttled. |
| 82 |
LimitTypeThrottled LimitTypeAttr = "throttled" |
| 83 |
// LimitTypeTurbo is the turbo. |
| 84 |
LimitTypeTurbo LimitTypeAttr = "turbo" |
| 85 |
) |
| 86 |
|
| 87 |
// LogicalDiskStateAttr is an attribute conforming to the hw.logical_disk.state |
| 88 |
// semantic conventions. It represents the state of the logical disk space usage. |
| 89 |
type LogicalDiskStateAttr string |
| 90 |
|
| 91 |
var ( |
| 92 |
// LogicalDiskStateUsed is the used. |
| 93 |
LogicalDiskStateUsed LogicalDiskStateAttr = "used" |
| 94 |
// LogicalDiskStateFree is the free. |
| 95 |
LogicalDiskStateFree LogicalDiskStateAttr = "free" |
| 96 |
) |
| 97 |
|
| 98 |
// PhysicalDiskStateAttr is an attribute conforming to the hw.physical_disk.state |
| 99 |
// semantic conventions. It represents the state of the physical disk endurance |
| 100 |
// utilization. |
| 101 |
type PhysicalDiskStateAttr string |
| 102 |
|
| 103 |
var ( |
| 104 |
// PhysicalDiskStateRemaining is the remaining. |
| 105 |
PhysicalDiskStateRemaining PhysicalDiskStateAttr = "remaining" |
| 106 |
) |
| 107 |
|
| 108 |
// StateAttr is an attribute conforming to the hw.state semantic conventions. It |
| 109 |
// represents the current state of the component. |
| 110 |
type StateAttr string |
| 111 |
|
| 112 |
var ( |
| 113 |
// StateDegraded is the degraded. |
| 114 |
StateDegraded StateAttr = "degraded" |
| 115 |
// StateFailed is the failed. |
| 116 |
StateFailed StateAttr = "failed" |
| 117 |
// StateNeedsCleaning is the needs Cleaning. |
| 118 |
StateNeedsCleaning StateAttr = "needs_cleaning" |
| 119 |
// StateOk is the OK. |
| 120 |
StateOk StateAttr = "ok" |
| 121 |
// StatePredictedFailure is the predicted Failure. |
| 122 |
StatePredictedFailure StateAttr = "predicted_failure" |
| 123 |
) |
| 124 |
|
| 125 |
// TapeDriveOperationTypeAttr is an attribute conforming to the |
| 126 |
// hw.tape_drive.operation_type semantic conventions. It represents the type of |
| 127 |
// tape drive operation. |
| 128 |
type TapeDriveOperationTypeAttr string |
| 129 |
|
| 130 |
var ( |
| 131 |
// TapeDriveOperationTypeMount is the mount. |
| 132 |
TapeDriveOperationTypeMount TapeDriveOperationTypeAttr = "mount" |
| 133 |
// TapeDriveOperationTypeUnmount is the unmount. |
| 134 |
TapeDriveOperationTypeUnmount TapeDriveOperationTypeAttr = "unmount" |
| 135 |
// TapeDriveOperationTypeClean is the clean. |
| 136 |
TapeDriveOperationTypeClean TapeDriveOperationTypeAttr = "clean" |
| 137 |
) |
| 138 |
|
| 139 |
// TypeAttr is an attribute conforming to the hw.type semantic conventions. It |
| 140 |
// represents the type of the component. |
| 141 |
type TypeAttr string |
| 142 |
|
| 143 |
var ( |
| 144 |
// TypeBattery is the battery. |
| 145 |
TypeBattery TypeAttr = "battery" |
| 146 |
// TypeCPU is the CPU. |
| 147 |
TypeCPU TypeAttr = "cpu" |
| 148 |
// TypeDiskController is the disk controller. |
| 149 |
TypeDiskController TypeAttr = "disk_controller" |
| 150 |
// TypeEnclosure is the enclosure. |
| 151 |
TypeEnclosure TypeAttr = "enclosure" |
| 152 |
// TypeFan is the fan. |
| 153 |
TypeFan TypeAttr = "fan" |
| 154 |
// TypeGpu is the GPU. |
| 155 |
TypeGpu TypeAttr = "gpu" |
| 156 |
// TypeLogicalDisk is the logical disk. |
| 157 |
TypeLogicalDisk TypeAttr = "logical_disk" |
| 158 |
// TypeMemory is the memory. |
| 159 |
TypeMemory TypeAttr = "memory" |
| 160 |
// TypeNetwork is the network. |
| 161 |
TypeNetwork TypeAttr = "network" |
| 162 |
// TypePhysicalDisk is the physical disk. |
| 163 |
TypePhysicalDisk TypeAttr = "physical_disk" |
| 164 |
// TypePowerSupply is the power supply. |
| 165 |
TypePowerSupply TypeAttr = "power_supply" |
| 166 |
// TypeTapeDrive is the tape drive. |
| 167 |
TypeTapeDrive TypeAttr = "tape_drive" |
| 168 |
// TypeTemperature is the temperature. |
| 169 |
TypeTemperature TypeAttr = "temperature" |
| 170 |
// TypeVoltage is the voltage. |
| 171 |
TypeVoltage TypeAttr = "voltage" |
| 172 |
) |
| 173 |
|
| 174 |
// NetworkIODirectionAttr is an attribute conforming to the network.io.direction |
| 175 |
// semantic conventions. It represents the direction of network traffic for |
| 176 |
// network errors. |
| 177 |
type NetworkIODirectionAttr string |
| 178 |
|
| 179 |
var ( |
| 180 |
// NetworkIODirectionTransmit is the standardized value "transmit" of |
| 181 |
// NetworkIODirectionAttr. |
| 182 |
NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit" |
| 183 |
// NetworkIODirectionReceive is the standardized value "receive" of |
| 184 |
// NetworkIODirectionAttr. |
| 185 |
NetworkIODirectionReceive NetworkIODirectionAttr = "receive" |
| 186 |
) |
| 187 |
|
| 188 |
// BatteryCharge is an instrument used to record metric values conforming to the |
| 189 |
// "hw.battery.charge" semantic conventions. It represents the remaining fraction |
| 190 |
// of battery charge. |
| 191 |
type BatteryCharge struct { |
| 192 |
metric.Int64Gauge |
| 193 |
} |
| 194 |
|
| 195 |
var newBatteryChargeOpts = []metric.Int64GaugeOption{ |
| 196 |
metric.WithDescription("Remaining fraction of battery charge."), |
| 197 |
metric.WithUnit("1"), |
| 198 |
} |
| 199 |
|
| 200 |
// NewBatteryCharge returns a new BatteryCharge instrument. |
| 201 |
func NewBatteryCharge( |
| 202 |
m metric.Meter, |
| 203 |
opt ...metric.Int64GaugeOption, |
| 204 |
) (BatteryCharge, error) { |
| 205 |
// Check if the meter is nil. |
| 206 |
if m == nil { |
| 207 |
return BatteryCharge{noop.Int64Gauge{}}, nil |
| 208 |
} |
| 209 |
|
| 210 |
if len(opt) == 0 { |
| 211 |
opt = newBatteryChargeOpts |
| 212 |
} else { |
| 213 |
opt = append(opt, newBatteryChargeOpts...) |
| 214 |
} |
| 215 |
|
| 216 |
i, err := m.Int64Gauge( |
| 217 |
"hw.battery.charge", |
| 218 |
opt..., |
| 219 |
) |
| 220 |
if err != nil { |
| 221 |
return BatteryCharge{noop.Int64Gauge{}}, err |
| 222 |
} |
| 223 |
return BatteryCharge{i}, nil |
| 224 |
} |
| 225 |
|
| 226 |
// Inst returns the underlying metric instrument. |
| 227 |
func (m BatteryCharge) Inst() metric.Int64Gauge { |
| 228 |
return m.Int64Gauge |
| 229 |
} |
| 230 |
|
| 231 |
// Name returns the semantic convention name of the instrument. |
| 232 |
func (BatteryCharge) Name() string { |
| 233 |
return "hw.battery.charge" |
| 234 |
} |
| 235 |
|
| 236 |
// Unit returns the semantic convention unit of the instrument |
| 237 |
func (BatteryCharge) Unit() string { |
| 238 |
return "1" |
| 239 |
} |
| 240 |
|
| 241 |
// Description returns the semantic convention description of the instrument |
| 242 |
func (BatteryCharge) Description() string { |
| 243 |
return "Remaining fraction of battery charge." |
| 244 |
} |
| 245 |
|
| 246 |
// Record records val to the current distribution for attrs. |
| 247 |
// |
| 248 |
// The id is the an identifier for the hardware component, unique within the |
| 249 |
// monitored host |
| 250 |
// |
| 251 |
// All additional attrs passed are included in the recorded value. |
| 252 |
func (m BatteryCharge) Record( |
| 253 |
ctx context.Context, |
| 254 |
val int64, |
| 255 |
id string, |
| 256 |
attrs ...attribute.KeyValue, |
| 257 |
) { |
| 258 |
if len(attrs) == 0 { |
| 259 |
m.Int64Gauge.Record(ctx, val) |
| 260 |
return |
| 261 |
} |
| 262 |
|
| 263 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 264 |
defer func() { |
| 265 |
*o = (*o)[:0] |
| 266 |
recOptPool.Put(o) |
| 267 |
}() |
| 268 |
|
| 269 |
*o = append( |
| 270 |
*o, |
| 271 |
metric.WithAttributes( |
| 272 |
append( |
| 273 |
attrs, |
| 274 |
attribute.String("hw.id", id), |
| 275 |
)..., |
| 276 |
), |
| 277 |
) |
| 278 |
|
| 279 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 280 |
} |
| 281 |
|
| 282 |
// RecordSet records val to the current distribution for set. |
| 283 |
func (m BatteryCharge) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 284 |
if set.Len() == 0 { |
| 285 |
m.Int64Gauge.Record(ctx, val) |
| 286 |
return |
| 287 |
} |
| 288 |
|
| 289 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 290 |
defer func() { |
| 291 |
*o = (*o)[:0] |
| 292 |
recOptPool.Put(o) |
| 293 |
}() |
| 294 |
|
| 295 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 296 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 297 |
} |
| 298 |
|
| 299 |
// AttrBatteryCapacity returns an optional attribute for the |
| 300 |
// "hw.battery.capacity" semantic convention. It represents the design capacity |
| 301 |
// in Watts-hours or Amper-hours. |
| 302 |
func (BatteryCharge) AttrBatteryCapacity(val string) attribute.KeyValue { |
| 303 |
return attribute.String("hw.battery.capacity", val) |
| 304 |
} |
| 305 |
|
| 306 |
// AttrBatteryChemistry returns an optional attribute for the |
| 307 |
// "hw.battery.chemistry" semantic convention. It represents the battery |
| 308 |
// [chemistry], e.g. Lithium-Ion, Nickel-Cadmium, etc. |
| 309 |
// |
| 310 |
// [chemistry]: https://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_Battery.html |
| 311 |
func (BatteryCharge) AttrBatteryChemistry(val string) attribute.KeyValue { |
| 312 |
return attribute.String("hw.battery.chemistry", val) |
| 313 |
} |
| 314 |
|
| 315 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 316 |
// convention. It represents the descriptive model name of the hardware |
| 317 |
// component. |
| 318 |
func (BatteryCharge) AttrModel(val string) attribute.KeyValue { |
| 319 |
return attribute.String("hw.model", val) |
| 320 |
} |
| 321 |
|
| 322 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 323 |
// It represents an easily-recognizable name for the hardware component. |
| 324 |
func (BatteryCharge) AttrName(val string) attribute.KeyValue { |
| 325 |
return attribute.String("hw.name", val) |
| 326 |
} |
| 327 |
|
| 328 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 329 |
// convention. It represents the unique identifier of the parent component |
| 330 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 331 |
func (BatteryCharge) AttrParent(val string) attribute.KeyValue { |
| 332 |
return attribute.String("hw.parent", val) |
| 333 |
} |
| 334 |
|
| 335 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 336 |
// convention. It represents the vendor name of the hardware component. |
| 337 |
func (BatteryCharge) AttrVendor(val string) attribute.KeyValue { |
| 338 |
return attribute.String("hw.vendor", val) |
| 339 |
} |
| 340 |
|
| 341 |
// BatteryChargeLimit is an instrument used to record metric values conforming to |
| 342 |
// the "hw.battery.charge.limit" semantic conventions. It represents the lower |
| 343 |
// limit of battery charge fraction to ensure proper operation. |
| 344 |
type BatteryChargeLimit struct { |
| 345 |
metric.Int64Gauge |
| 346 |
} |
| 347 |
|
| 348 |
var newBatteryChargeLimitOpts = []metric.Int64GaugeOption{ |
| 349 |
metric.WithDescription("Lower limit of battery charge fraction to ensure proper operation."), |
| 350 |
metric.WithUnit("1"), |
| 351 |
} |
| 352 |
|
| 353 |
// NewBatteryChargeLimit returns a new BatteryChargeLimit instrument. |
| 354 |
func NewBatteryChargeLimit( |
| 355 |
m metric.Meter, |
| 356 |
opt ...metric.Int64GaugeOption, |
| 357 |
) (BatteryChargeLimit, error) { |
| 358 |
// Check if the meter is nil. |
| 359 |
if m == nil { |
| 360 |
return BatteryChargeLimit{noop.Int64Gauge{}}, nil |
| 361 |
} |
| 362 |
|
| 363 |
if len(opt) == 0 { |
| 364 |
opt = newBatteryChargeLimitOpts |
| 365 |
} else { |
| 366 |
opt = append(opt, newBatteryChargeLimitOpts...) |
| 367 |
} |
| 368 |
|
| 369 |
i, err := m.Int64Gauge( |
| 370 |
"hw.battery.charge.limit", |
| 371 |
opt..., |
| 372 |
) |
| 373 |
if err != nil { |
| 374 |
return BatteryChargeLimit{noop.Int64Gauge{}}, err |
| 375 |
} |
| 376 |
return BatteryChargeLimit{i}, nil |
| 377 |
} |
| 378 |
|
| 379 |
// Inst returns the underlying metric instrument. |
| 380 |
func (m BatteryChargeLimit) Inst() metric.Int64Gauge { |
| 381 |
return m.Int64Gauge |
| 382 |
} |
| 383 |
|
| 384 |
// Name returns the semantic convention name of the instrument. |
| 385 |
func (BatteryChargeLimit) Name() string { |
| 386 |
return "hw.battery.charge.limit" |
| 387 |
} |
| 388 |
|
| 389 |
// Unit returns the semantic convention unit of the instrument |
| 390 |
func (BatteryChargeLimit) Unit() string { |
| 391 |
return "1" |
| 392 |
} |
| 393 |
|
| 394 |
// Description returns the semantic convention description of the instrument |
| 395 |
func (BatteryChargeLimit) Description() string { |
| 396 |
return "Lower limit of battery charge fraction to ensure proper operation." |
| 397 |
} |
| 398 |
|
| 399 |
// Record records val to the current distribution for attrs. |
| 400 |
// |
| 401 |
// The id is the an identifier for the hardware component, unique within the |
| 402 |
// monitored host |
| 403 |
// |
| 404 |
// All additional attrs passed are included in the recorded value. |
| 405 |
func (m BatteryChargeLimit) Record( |
| 406 |
ctx context.Context, |
| 407 |
val int64, |
| 408 |
id string, |
| 409 |
attrs ...attribute.KeyValue, |
| 410 |
) { |
| 411 |
if len(attrs) == 0 { |
| 412 |
m.Int64Gauge.Record(ctx, val) |
| 413 |
return |
| 414 |
} |
| 415 |
|
| 416 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 417 |
defer func() { |
| 418 |
*o = (*o)[:0] |
| 419 |
recOptPool.Put(o) |
| 420 |
}() |
| 421 |
|
| 422 |
*o = append( |
| 423 |
*o, |
| 424 |
metric.WithAttributes( |
| 425 |
append( |
| 426 |
attrs, |
| 427 |
attribute.String("hw.id", id), |
| 428 |
)..., |
| 429 |
), |
| 430 |
) |
| 431 |
|
| 432 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 433 |
} |
| 434 |
|
| 435 |
// RecordSet records val to the current distribution for set. |
| 436 |
func (m BatteryChargeLimit) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 437 |
if set.Len() == 0 { |
| 438 |
m.Int64Gauge.Record(ctx, val) |
| 439 |
return |
| 440 |
} |
| 441 |
|
| 442 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 443 |
defer func() { |
| 444 |
*o = (*o)[:0] |
| 445 |
recOptPool.Put(o) |
| 446 |
}() |
| 447 |
|
| 448 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 449 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 450 |
} |
| 451 |
|
| 452 |
// AttrBatteryCapacity returns an optional attribute for the |
| 453 |
// "hw.battery.capacity" semantic convention. It represents the design capacity |
| 454 |
// in Watts-hours or Amper-hours. |
| 455 |
func (BatteryChargeLimit) AttrBatteryCapacity(val string) attribute.KeyValue { |
| 456 |
return attribute.String("hw.battery.capacity", val) |
| 457 |
} |
| 458 |
|
| 459 |
// AttrBatteryChemistry returns an optional attribute for the |
| 460 |
// "hw.battery.chemistry" semantic convention. It represents the battery |
| 461 |
// [chemistry], e.g. Lithium-Ion, Nickel-Cadmium, etc. |
| 462 |
// |
| 463 |
// [chemistry]: https://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_Battery.html |
| 464 |
func (BatteryChargeLimit) AttrBatteryChemistry(val string) attribute.KeyValue { |
| 465 |
return attribute.String("hw.battery.chemistry", val) |
| 466 |
} |
| 467 |
|
| 468 |
// AttrLimitType returns an optional attribute for the "hw.limit_type" semantic |
| 469 |
// convention. It represents the represents battery charge level thresholds |
| 470 |
// relevant to device operation and health. Each `limit_type` denotes a specific |
| 471 |
// charge limit such as the minimum or maximum optimal charge, the shutdown |
| 472 |
// threshold, or energy-saving thresholds. These values are typically provided by |
| 473 |
// the hardware or firmware to guide safe and efficient battery usage. |
| 474 |
func (BatteryChargeLimit) AttrLimitType(val LimitTypeAttr) attribute.KeyValue { |
| 475 |
return attribute.String("hw.limit_type", string(val)) |
| 476 |
} |
| 477 |
|
| 478 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 479 |
// convention. It represents the descriptive model name of the hardware |
| 480 |
// component. |
| 481 |
func (BatteryChargeLimit) AttrModel(val string) attribute.KeyValue { |
| 482 |
return attribute.String("hw.model", val) |
| 483 |
} |
| 484 |
|
| 485 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 486 |
// It represents an easily-recognizable name for the hardware component. |
| 487 |
func (BatteryChargeLimit) AttrName(val string) attribute.KeyValue { |
| 488 |
return attribute.String("hw.name", val) |
| 489 |
} |
| 490 |
|
| 491 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 492 |
// convention. It represents the unique identifier of the parent component |
| 493 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 494 |
func (BatteryChargeLimit) AttrParent(val string) attribute.KeyValue { |
| 495 |
return attribute.String("hw.parent", val) |
| 496 |
} |
| 497 |
|
| 498 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 499 |
// convention. It represents the vendor name of the hardware component. |
| 500 |
func (BatteryChargeLimit) AttrVendor(val string) attribute.KeyValue { |
| 501 |
return attribute.String("hw.vendor", val) |
| 502 |
} |
| 503 |
|
| 504 |
// BatteryTimeLeft is an instrument used to record metric values conforming to |
| 505 |
// the "hw.battery.time_left" semantic conventions. It represents the time left |
| 506 |
// before battery is completely charged or discharged. |
| 507 |
type BatteryTimeLeft struct { |
| 508 |
metric.Float64Gauge |
| 509 |
} |
| 510 |
|
| 511 |
var newBatteryTimeLeftOpts = []metric.Float64GaugeOption{ |
| 512 |
metric.WithDescription("Time left before battery is completely charged or discharged."), |
| 513 |
metric.WithUnit("s"), |
| 514 |
} |
| 515 |
|
| 516 |
// NewBatteryTimeLeft returns a new BatteryTimeLeft instrument. |
| 517 |
func NewBatteryTimeLeft( |
| 518 |
m metric.Meter, |
| 519 |
opt ...metric.Float64GaugeOption, |
| 520 |
) (BatteryTimeLeft, error) { |
| 521 |
// Check if the meter is nil. |
| 522 |
if m == nil { |
| 523 |
return BatteryTimeLeft{noop.Float64Gauge{}}, nil |
| 524 |
} |
| 525 |
|
| 526 |
if len(opt) == 0 { |
| 527 |
opt = newBatteryTimeLeftOpts |
| 528 |
} else { |
| 529 |
opt = append(opt, newBatteryTimeLeftOpts...) |
| 530 |
} |
| 531 |
|
| 532 |
i, err := m.Float64Gauge( |
| 533 |
"hw.battery.time_left", |
| 534 |
opt..., |
| 535 |
) |
| 536 |
if err != nil { |
| 537 |
return BatteryTimeLeft{noop.Float64Gauge{}}, err |
| 538 |
} |
| 539 |
return BatteryTimeLeft{i}, nil |
| 540 |
} |
| 541 |
|
| 542 |
// Inst returns the underlying metric instrument. |
| 543 |
func (m BatteryTimeLeft) Inst() metric.Float64Gauge { |
| 544 |
return m.Float64Gauge |
| 545 |
} |
| 546 |
|
| 547 |
// Name returns the semantic convention name of the instrument. |
| 548 |
func (BatteryTimeLeft) Name() string { |
| 549 |
return "hw.battery.time_left" |
| 550 |
} |
| 551 |
|
| 552 |
// Unit returns the semantic convention unit of the instrument |
| 553 |
func (BatteryTimeLeft) Unit() string { |
| 554 |
return "s" |
| 555 |
} |
| 556 |
|
| 557 |
// Description returns the semantic convention description of the instrument |
| 558 |
func (BatteryTimeLeft) Description() string { |
| 559 |
return "Time left before battery is completely charged or discharged." |
| 560 |
} |
| 561 |
|
| 562 |
// Record records val to the current distribution for attrs. |
| 563 |
// |
| 564 |
// The id is the an identifier for the hardware component, unique within the |
| 565 |
// monitored host |
| 566 |
// |
| 567 |
// The state is the the current state of the component |
| 568 |
// |
| 569 |
// All additional attrs passed are included in the recorded value. |
| 570 |
func (m BatteryTimeLeft) Record( |
| 571 |
ctx context.Context, |
| 572 |
val float64, |
| 573 |
id string, |
| 574 |
state StateAttr, |
| 575 |
attrs ...attribute.KeyValue, |
| 576 |
) { |
| 577 |
if len(attrs) == 0 { |
| 578 |
m.Float64Gauge.Record(ctx, val) |
| 579 |
return |
| 580 |
} |
| 581 |
|
| 582 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 583 |
defer func() { |
| 584 |
*o = (*o)[:0] |
| 585 |
recOptPool.Put(o) |
| 586 |
}() |
| 587 |
|
| 588 |
*o = append( |
| 589 |
*o, |
| 590 |
metric.WithAttributes( |
| 591 |
append( |
| 592 |
attrs, |
| 593 |
attribute.String("hw.id", id), |
| 594 |
attribute.String("hw.state", string(state)), |
| 595 |
)..., |
| 596 |
), |
| 597 |
) |
| 598 |
|
| 599 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 600 |
} |
| 601 |
|
| 602 |
// RecordSet records val to the current distribution for set. |
| 603 |
func (m BatteryTimeLeft) RecordSet(ctx context.Context, val float64, set attribute.Set) { |
| 604 |
if set.Len() == 0 { |
| 605 |
m.Float64Gauge.Record(ctx, val) |
| 606 |
return |
| 607 |
} |
| 608 |
|
| 609 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 610 |
defer func() { |
| 611 |
*o = (*o)[:0] |
| 612 |
recOptPool.Put(o) |
| 613 |
}() |
| 614 |
|
| 615 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 616 |
m.Float64Gauge.Record(ctx, val, *o...) |
| 617 |
} |
| 618 |
|
| 619 |
// AttrBatteryState returns an optional attribute for the "hw.battery.state" |
| 620 |
// semantic convention. It represents the current state of the battery. |
| 621 |
func (BatteryTimeLeft) AttrBatteryState(val BatteryStateAttr) attribute.KeyValue { |
| 622 |
return attribute.String("hw.battery.state", string(val)) |
| 623 |
} |
| 624 |
|
| 625 |
// AttrBatteryCapacity returns an optional attribute for the |
| 626 |
// "hw.battery.capacity" semantic convention. It represents the design capacity |
| 627 |
// in Watts-hours or Amper-hours. |
| 628 |
func (BatteryTimeLeft) AttrBatteryCapacity(val string) attribute.KeyValue { |
| 629 |
return attribute.String("hw.battery.capacity", val) |
| 630 |
} |
| 631 |
|
| 632 |
// AttrBatteryChemistry returns an optional attribute for the |
| 633 |
// "hw.battery.chemistry" semantic convention. It represents the battery |
| 634 |
// [chemistry], e.g. Lithium-Ion, Nickel-Cadmium, etc. |
| 635 |
// |
| 636 |
// [chemistry]: https://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_Battery.html |
| 637 |
func (BatteryTimeLeft) AttrBatteryChemistry(val string) attribute.KeyValue { |
| 638 |
return attribute.String("hw.battery.chemistry", val) |
| 639 |
} |
| 640 |
|
| 641 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 642 |
// convention. It represents the descriptive model name of the hardware |
| 643 |
// component. |
| 644 |
func (BatteryTimeLeft) AttrModel(val string) attribute.KeyValue { |
| 645 |
return attribute.String("hw.model", val) |
| 646 |
} |
| 647 |
|
| 648 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 649 |
// It represents an easily-recognizable name for the hardware component. |
| 650 |
func (BatteryTimeLeft) AttrName(val string) attribute.KeyValue { |
| 651 |
return attribute.String("hw.name", val) |
| 652 |
} |
| 653 |
|
| 654 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 655 |
// convention. It represents the unique identifier of the parent component |
| 656 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 657 |
func (BatteryTimeLeft) AttrParent(val string) attribute.KeyValue { |
| 658 |
return attribute.String("hw.parent", val) |
| 659 |
} |
| 660 |
|
| 661 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 662 |
// convention. It represents the vendor name of the hardware component. |
| 663 |
func (BatteryTimeLeft) AttrVendor(val string) attribute.KeyValue { |
| 664 |
return attribute.String("hw.vendor", val) |
| 665 |
} |
| 666 |
|
| 667 |
// CPUSpeed is an instrument used to record metric values conforming to the |
| 668 |
// "hw.cpu.speed" semantic conventions. It represents the CPU current frequency. |
| 669 |
type CPUSpeed struct { |
| 670 |
metric.Int64Gauge |
| 671 |
} |
| 672 |
|
| 673 |
var newCPUSpeedOpts = []metric.Int64GaugeOption{ |
| 674 |
metric.WithDescription("CPU current frequency."), |
| 675 |
metric.WithUnit("Hz"), |
| 676 |
} |
| 677 |
|
| 678 |
// NewCPUSpeed returns a new CPUSpeed instrument. |
| 679 |
func NewCPUSpeed( |
| 680 |
m metric.Meter, |
| 681 |
opt ...metric.Int64GaugeOption, |
| 682 |
) (CPUSpeed, error) { |
| 683 |
// Check if the meter is nil. |
| 684 |
if m == nil { |
| 685 |
return CPUSpeed{noop.Int64Gauge{}}, nil |
| 686 |
} |
| 687 |
|
| 688 |
if len(opt) == 0 { |
| 689 |
opt = newCPUSpeedOpts |
| 690 |
} else { |
| 691 |
opt = append(opt, newCPUSpeedOpts...) |
| 692 |
} |
| 693 |
|
| 694 |
i, err := m.Int64Gauge( |
| 695 |
"hw.cpu.speed", |
| 696 |
opt..., |
| 697 |
) |
| 698 |
if err != nil { |
| 699 |
return CPUSpeed{noop.Int64Gauge{}}, err |
| 700 |
} |
| 701 |
return CPUSpeed{i}, nil |
| 702 |
} |
| 703 |
|
| 704 |
// Inst returns the underlying metric instrument. |
| 705 |
func (m CPUSpeed) Inst() metric.Int64Gauge { |
| 706 |
return m.Int64Gauge |
| 707 |
} |
| 708 |
|
| 709 |
// Name returns the semantic convention name of the instrument. |
| 710 |
func (CPUSpeed) Name() string { |
| 711 |
return "hw.cpu.speed" |
| 712 |
} |
| 713 |
|
| 714 |
// Unit returns the semantic convention unit of the instrument |
| 715 |
func (CPUSpeed) Unit() string { |
| 716 |
return "Hz" |
| 717 |
} |
| 718 |
|
| 719 |
// Description returns the semantic convention description of the instrument |
| 720 |
func (CPUSpeed) Description() string { |
| 721 |
return "CPU current frequency." |
| 722 |
} |
| 723 |
|
| 724 |
// Record records val to the current distribution for attrs. |
| 725 |
// |
| 726 |
// The id is the an identifier for the hardware component, unique within the |
| 727 |
// monitored host |
| 728 |
// |
| 729 |
// All additional attrs passed are included in the recorded value. |
| 730 |
func (m CPUSpeed) Record( |
| 731 |
ctx context.Context, |
| 732 |
val int64, |
| 733 |
id string, |
| 734 |
attrs ...attribute.KeyValue, |
| 735 |
) { |
| 736 |
if len(attrs) == 0 { |
| 737 |
m.Int64Gauge.Record(ctx, val) |
| 738 |
return |
| 739 |
} |
| 740 |
|
| 741 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 742 |
defer func() { |
| 743 |
*o = (*o)[:0] |
| 744 |
recOptPool.Put(o) |
| 745 |
}() |
| 746 |
|
| 747 |
*o = append( |
| 748 |
*o, |
| 749 |
metric.WithAttributes( |
| 750 |
append( |
| 751 |
attrs, |
| 752 |
attribute.String("hw.id", id), |
| 753 |
)..., |
| 754 |
), |
| 755 |
) |
| 756 |
|
| 757 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 758 |
} |
| 759 |
|
| 760 |
// RecordSet records val to the current distribution for set. |
| 761 |
func (m CPUSpeed) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 762 |
if set.Len() == 0 { |
| 763 |
m.Int64Gauge.Record(ctx, val) |
| 764 |
return |
| 765 |
} |
| 766 |
|
| 767 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 768 |
defer func() { |
| 769 |
*o = (*o)[:0] |
| 770 |
recOptPool.Put(o) |
| 771 |
}() |
| 772 |
|
| 773 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 774 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 775 |
} |
| 776 |
|
| 777 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 778 |
// convention. It represents the descriptive model name of the hardware |
| 779 |
// component. |
| 780 |
func (CPUSpeed) AttrModel(val string) attribute.KeyValue { |
| 781 |
return attribute.String("hw.model", val) |
| 782 |
} |
| 783 |
|
| 784 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 785 |
// It represents an easily-recognizable name for the hardware component. |
| 786 |
func (CPUSpeed) AttrName(val string) attribute.KeyValue { |
| 787 |
return attribute.String("hw.name", val) |
| 788 |
} |
| 789 |
|
| 790 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 791 |
// convention. It represents the unique identifier of the parent component |
| 792 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 793 |
func (CPUSpeed) AttrParent(val string) attribute.KeyValue { |
| 794 |
return attribute.String("hw.parent", val) |
| 795 |
} |
| 796 |
|
| 797 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 798 |
// convention. It represents the vendor name of the hardware component. |
| 799 |
func (CPUSpeed) AttrVendor(val string) attribute.KeyValue { |
| 800 |
return attribute.String("hw.vendor", val) |
| 801 |
} |
| 802 |
|
| 803 |
// CPUSpeedLimit is an instrument used to record metric values conforming to the |
| 804 |
// "hw.cpu.speed.limit" semantic conventions. It represents the CPU maximum |
| 805 |
// frequency. |
| 806 |
type CPUSpeedLimit struct { |
| 807 |
metric.Int64Gauge |
| 808 |
} |
| 809 |
|
| 810 |
var newCPUSpeedLimitOpts = []metric.Int64GaugeOption{ |
| 811 |
metric.WithDescription("CPU maximum frequency."), |
| 812 |
metric.WithUnit("Hz"), |
| 813 |
} |
| 814 |
|
| 815 |
// NewCPUSpeedLimit returns a new CPUSpeedLimit instrument. |
| 816 |
func NewCPUSpeedLimit( |
| 817 |
m metric.Meter, |
| 818 |
opt ...metric.Int64GaugeOption, |
| 819 |
) (CPUSpeedLimit, error) { |
| 820 |
// Check if the meter is nil. |
| 821 |
if m == nil { |
| 822 |
return CPUSpeedLimit{noop.Int64Gauge{}}, nil |
| 823 |
} |
| 824 |
|
| 825 |
if len(opt) == 0 { |
| 826 |
opt = newCPUSpeedLimitOpts |
| 827 |
} else { |
| 828 |
opt = append(opt, newCPUSpeedLimitOpts...) |
| 829 |
} |
| 830 |
|
| 831 |
i, err := m.Int64Gauge( |
| 832 |
"hw.cpu.speed.limit", |
| 833 |
opt..., |
| 834 |
) |
| 835 |
if err != nil { |
| 836 |
return CPUSpeedLimit{noop.Int64Gauge{}}, err |
| 837 |
} |
| 838 |
return CPUSpeedLimit{i}, nil |
| 839 |
} |
| 840 |
|
| 841 |
// Inst returns the underlying metric instrument. |
| 842 |
func (m CPUSpeedLimit) Inst() metric.Int64Gauge { |
| 843 |
return m.Int64Gauge |
| 844 |
} |
| 845 |
|
| 846 |
// Name returns the semantic convention name of the instrument. |
| 847 |
func (CPUSpeedLimit) Name() string { |
| 848 |
return "hw.cpu.speed.limit" |
| 849 |
} |
| 850 |
|
| 851 |
// Unit returns the semantic convention unit of the instrument |
| 852 |
func (CPUSpeedLimit) Unit() string { |
| 853 |
return "Hz" |
| 854 |
} |
| 855 |
|
| 856 |
// Description returns the semantic convention description of the instrument |
| 857 |
func (CPUSpeedLimit) Description() string { |
| 858 |
return "CPU maximum frequency." |
| 859 |
} |
| 860 |
|
| 861 |
// Record records val to the current distribution for attrs. |
| 862 |
// |
| 863 |
// The id is the an identifier for the hardware component, unique within the |
| 864 |
// monitored host |
| 865 |
// |
| 866 |
// All additional attrs passed are included in the recorded value. |
| 867 |
func (m CPUSpeedLimit) Record( |
| 868 |
ctx context.Context, |
| 869 |
val int64, |
| 870 |
id string, |
| 871 |
attrs ...attribute.KeyValue, |
| 872 |
) { |
| 873 |
if len(attrs) == 0 { |
| 874 |
m.Int64Gauge.Record(ctx, val) |
| 875 |
return |
| 876 |
} |
| 877 |
|
| 878 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 879 |
defer func() { |
| 880 |
*o = (*o)[:0] |
| 881 |
recOptPool.Put(o) |
| 882 |
}() |
| 883 |
|
| 884 |
*o = append( |
| 885 |
*o, |
| 886 |
metric.WithAttributes( |
| 887 |
append( |
| 888 |
attrs, |
| 889 |
attribute.String("hw.id", id), |
| 890 |
)..., |
| 891 |
), |
| 892 |
) |
| 893 |
|
| 894 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 895 |
} |
| 896 |
|
| 897 |
// RecordSet records val to the current distribution for set. |
| 898 |
func (m CPUSpeedLimit) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 899 |
if set.Len() == 0 { |
| 900 |
m.Int64Gauge.Record(ctx, val) |
| 901 |
return |
| 902 |
} |
| 903 |
|
| 904 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 905 |
defer func() { |
| 906 |
*o = (*o)[:0] |
| 907 |
recOptPool.Put(o) |
| 908 |
}() |
| 909 |
|
| 910 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 911 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 912 |
} |
| 913 |
|
| 914 |
// AttrLimitType returns an optional attribute for the "hw.limit_type" semantic |
| 915 |
// convention. It represents the type of limit for hardware components. |
| 916 |
func (CPUSpeedLimit) AttrLimitType(val LimitTypeAttr) attribute.KeyValue { |
| 917 |
return attribute.String("hw.limit_type", string(val)) |
| 918 |
} |
| 919 |
|
| 920 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 921 |
// convention. It represents the descriptive model name of the hardware |
| 922 |
// component. |
| 923 |
func (CPUSpeedLimit) AttrModel(val string) attribute.KeyValue { |
| 924 |
return attribute.String("hw.model", val) |
| 925 |
} |
| 926 |
|
| 927 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 928 |
// It represents an easily-recognizable name for the hardware component. |
| 929 |
func (CPUSpeedLimit) AttrName(val string) attribute.KeyValue { |
| 930 |
return attribute.String("hw.name", val) |
| 931 |
} |
| 932 |
|
| 933 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 934 |
// convention. It represents the unique identifier of the parent component |
| 935 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 936 |
func (CPUSpeedLimit) AttrParent(val string) attribute.KeyValue { |
| 937 |
return attribute.String("hw.parent", val) |
| 938 |
} |
| 939 |
|
| 940 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 941 |
// convention. It represents the vendor name of the hardware component. |
| 942 |
func (CPUSpeedLimit) AttrVendor(val string) attribute.KeyValue { |
| 943 |
return attribute.String("hw.vendor", val) |
| 944 |
} |
| 945 |
|
| 946 |
// Energy is an instrument used to record metric values conforming to the |
| 947 |
// "hw.energy" semantic conventions. It represents the energy consumed by the |
| 948 |
// component. |
| 949 |
type Energy struct { |
| 950 |
metric.Int64Counter |
| 951 |
} |
| 952 |
|
| 953 |
var newEnergyOpts = []metric.Int64CounterOption{ |
| 954 |
metric.WithDescription("Energy consumed by the component."), |
| 955 |
metric.WithUnit("J"), |
| 956 |
} |
| 957 |
|
| 958 |
// NewEnergy returns a new Energy instrument. |
| 959 |
func NewEnergy( |
| 960 |
m metric.Meter, |
| 961 |
opt ...metric.Int64CounterOption, |
| 962 |
) (Energy, error) { |
| 963 |
// Check if the meter is nil. |
| 964 |
if m == nil { |
| 965 |
return Energy{noop.Int64Counter{}}, nil |
| 966 |
} |
| 967 |
|
| 968 |
if len(opt) == 0 { |
| 969 |
opt = newEnergyOpts |
| 970 |
} else { |
| 971 |
opt = append(opt, newEnergyOpts...) |
| 972 |
} |
| 973 |
|
| 974 |
i, err := m.Int64Counter( |
| 975 |
"hw.energy", |
| 976 |
opt..., |
| 977 |
) |
| 978 |
if err != nil { |
| 979 |
return Energy{noop.Int64Counter{}}, err |
| 980 |
} |
| 981 |
return Energy{i}, nil |
| 982 |
} |
| 983 |
|
| 984 |
// Inst returns the underlying metric instrument. |
| 985 |
func (m Energy) Inst() metric.Int64Counter { |
| 986 |
return m.Int64Counter |
| 987 |
} |
| 988 |
|
| 989 |
// Name returns the semantic convention name of the instrument. |
| 990 |
func (Energy) Name() string { |
| 991 |
return "hw.energy" |
| 992 |
} |
| 993 |
|
| 994 |
// Unit returns the semantic convention unit of the instrument |
| 995 |
func (Energy) Unit() string { |
| 996 |
return "J" |
| 997 |
} |
| 998 |
|
| 999 |
// Description returns the semantic convention description of the instrument |
| 1000 |
func (Energy) Description() string { |
| 1001 |
return "Energy consumed by the component." |
| 1002 |
} |
| 1003 |
|
| 1004 |
// Add adds incr to the existing count for attrs. |
| 1005 |
// |
| 1006 |
// The id is the an identifier for the hardware component, unique within the |
| 1007 |
// monitored host |
| 1008 |
// |
| 1009 |
// The hwType is the type of the component |
| 1010 |
// |
| 1011 |
// All additional attrs passed are included in the recorded value. |
| 1012 |
func (m Energy) Add( |
| 1013 |
ctx context.Context, |
| 1014 |
incr int64, |
| 1015 |
id string, |
| 1016 |
hwType TypeAttr, |
| 1017 |
attrs ...attribute.KeyValue, |
| 1018 |
) { |
| 1019 |
if len(attrs) == 0 { |
| 1020 |
m.Int64Counter.Add(ctx, incr) |
| 1021 |
return |
| 1022 |
} |
| 1023 |
|
| 1024 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1025 |
defer func() { |
| 1026 |
*o = (*o)[:0] |
| 1027 |
addOptPool.Put(o) |
| 1028 |
}() |
| 1029 |
|
| 1030 |
*o = append( |
| 1031 |
*o, |
| 1032 |
metric.WithAttributes( |
| 1033 |
append( |
| 1034 |
attrs, |
| 1035 |
attribute.String("hw.id", id), |
| 1036 |
attribute.String("hw.type", string(hwType)), |
| 1037 |
)..., |
| 1038 |
), |
| 1039 |
) |
| 1040 |
|
| 1041 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 1042 |
} |
| 1043 |
|
| 1044 |
// AddSet adds incr to the existing count for set. |
| 1045 |
func (m Energy) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1046 |
if set.Len() == 0 { |
| 1047 |
m.Int64Counter.Add(ctx, incr) |
| 1048 |
return |
| 1049 |
} |
| 1050 |
|
| 1051 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1052 |
defer func() { |
| 1053 |
*o = (*o)[:0] |
| 1054 |
addOptPool.Put(o) |
| 1055 |
}() |
| 1056 |
|
| 1057 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1058 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 1059 |
} |
| 1060 |
|
| 1061 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 1062 |
// It represents an easily-recognizable name for the hardware component. |
| 1063 |
func (Energy) AttrName(val string) attribute.KeyValue { |
| 1064 |
return attribute.String("hw.name", val) |
| 1065 |
} |
| 1066 |
|
| 1067 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 1068 |
// convention. It represents the unique identifier of the parent component |
| 1069 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 1070 |
func (Energy) AttrParent(val string) attribute.KeyValue { |
| 1071 |
return attribute.String("hw.parent", val) |
| 1072 |
} |
| 1073 |
|
| 1074 |
// Errors is an instrument used to record metric values conforming to the |
| 1075 |
// "hw.errors" semantic conventions. It represents the number of errors |
| 1076 |
// encountered by the component. |
| 1077 |
type Errors struct { |
| 1078 |
metric.Int64Counter |
| 1079 |
} |
| 1080 |
|
| 1081 |
var newErrorsOpts = []metric.Int64CounterOption{ |
| 1082 |
metric.WithDescription("Number of errors encountered by the component."), |
| 1083 |
metric.WithUnit("{error}"), |
| 1084 |
} |
| 1085 |
|
| 1086 |
// NewErrors returns a new Errors instrument. |
| 1087 |
func NewErrors( |
| 1088 |
m metric.Meter, |
| 1089 |
opt ...metric.Int64CounterOption, |
| 1090 |
) (Errors, error) { |
| 1091 |
// Check if the meter is nil. |
| 1092 |
if m == nil { |
| 1093 |
return Errors{noop.Int64Counter{}}, nil |
| 1094 |
} |
| 1095 |
|
| 1096 |
if len(opt) == 0 { |
| 1097 |
opt = newErrorsOpts |
| 1098 |
} else { |
| 1099 |
opt = append(opt, newErrorsOpts...) |
| 1100 |
} |
| 1101 |
|
| 1102 |
i, err := m.Int64Counter( |
| 1103 |
"hw.errors", |
| 1104 |
opt..., |
| 1105 |
) |
| 1106 |
if err != nil { |
| 1107 |
return Errors{noop.Int64Counter{}}, err |
| 1108 |
} |
| 1109 |
return Errors{i}, nil |
| 1110 |
} |
| 1111 |
|
| 1112 |
// Inst returns the underlying metric instrument. |
| 1113 |
func (m Errors) Inst() metric.Int64Counter { |
| 1114 |
return m.Int64Counter |
| 1115 |
} |
| 1116 |
|
| 1117 |
// Name returns the semantic convention name of the instrument. |
| 1118 |
func (Errors) Name() string { |
| 1119 |
return "hw.errors" |
| 1120 |
} |
| 1121 |
|
| 1122 |
// Unit returns the semantic convention unit of the instrument |
| 1123 |
func (Errors) Unit() string { |
| 1124 |
return "{error}" |
| 1125 |
} |
| 1126 |
|
| 1127 |
// Description returns the semantic convention description of the instrument |
| 1128 |
func (Errors) Description() string { |
| 1129 |
return "Number of errors encountered by the component." |
| 1130 |
} |
| 1131 |
|
| 1132 |
// Add adds incr to the existing count for attrs. |
| 1133 |
// |
| 1134 |
// The id is the an identifier for the hardware component, unique within the |
| 1135 |
// monitored host |
| 1136 |
// |
| 1137 |
// The hwType is the type of the component |
| 1138 |
// |
| 1139 |
// All additional attrs passed are included in the recorded value. |
| 1140 |
func (m Errors) Add( |
| 1141 |
ctx context.Context, |
| 1142 |
incr int64, |
| 1143 |
id string, |
| 1144 |
hwType TypeAttr, |
| 1145 |
attrs ...attribute.KeyValue, |
| 1146 |
) { |
| 1147 |
if len(attrs) == 0 { |
| 1148 |
m.Int64Counter.Add(ctx, incr) |
| 1149 |
return |
| 1150 |
} |
| 1151 |
|
| 1152 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1153 |
defer func() { |
| 1154 |
*o = (*o)[:0] |
| 1155 |
addOptPool.Put(o) |
| 1156 |
}() |
| 1157 |
|
| 1158 |
*o = append( |
| 1159 |
*o, |
| 1160 |
metric.WithAttributes( |
| 1161 |
append( |
| 1162 |
attrs, |
| 1163 |
attribute.String("hw.id", id), |
| 1164 |
attribute.String("hw.type", string(hwType)), |
| 1165 |
)..., |
| 1166 |
), |
| 1167 |
) |
| 1168 |
|
| 1169 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 1170 |
} |
| 1171 |
|
| 1172 |
// AddSet adds incr to the existing count for set. |
| 1173 |
func (m Errors) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1174 |
if set.Len() == 0 { |
| 1175 |
m.Int64Counter.Add(ctx, incr) |
| 1176 |
return |
| 1177 |
} |
| 1178 |
|
| 1179 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1180 |
defer func() { |
| 1181 |
*o = (*o)[:0] |
| 1182 |
addOptPool.Put(o) |
| 1183 |
}() |
| 1184 |
|
| 1185 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1186 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 1187 |
} |
| 1188 |
|
| 1189 |
// AttrErrorType returns an optional attribute for the "error.type" semantic |
| 1190 |
// convention. It represents the type of error encountered by the component. |
| 1191 |
func (Errors) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue { |
| 1192 |
return attribute.String("error.type", string(val)) |
| 1193 |
} |
| 1194 |
|
| 1195 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 1196 |
// It represents an easily-recognizable name for the hardware component. |
| 1197 |
func (Errors) AttrName(val string) attribute.KeyValue { |
| 1198 |
return attribute.String("hw.name", val) |
| 1199 |
} |
| 1200 |
|
| 1201 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 1202 |
// convention. It represents the unique identifier of the parent component |
| 1203 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 1204 |
func (Errors) AttrParent(val string) attribute.KeyValue { |
| 1205 |
return attribute.String("hw.parent", val) |
| 1206 |
} |
| 1207 |
|
| 1208 |
// AttrNetworkIODirection returns an optional attribute for the |
| 1209 |
// "network.io.direction" semantic convention. It represents the direction of |
| 1210 |
// network traffic for network errors. |
| 1211 |
func (Errors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue { |
| 1212 |
return attribute.String("network.io.direction", string(val)) |
| 1213 |
} |
| 1214 |
|
| 1215 |
// FanSpeed is an instrument used to record metric values conforming to the |
| 1216 |
// "hw.fan.speed" semantic conventions. It represents the fan speed in |
| 1217 |
// revolutions per minute. |
| 1218 |
type FanSpeed struct { |
| 1219 |
metric.Int64Gauge |
| 1220 |
} |
| 1221 |
|
| 1222 |
var newFanSpeedOpts = []metric.Int64GaugeOption{ |
| 1223 |
metric.WithDescription("Fan speed in revolutions per minute."), |
| 1224 |
metric.WithUnit("rpm"), |
| 1225 |
} |
| 1226 |
|
| 1227 |
// NewFanSpeed returns a new FanSpeed instrument. |
| 1228 |
func NewFanSpeed( |
| 1229 |
m metric.Meter, |
| 1230 |
opt ...metric.Int64GaugeOption, |
| 1231 |
) (FanSpeed, error) { |
| 1232 |
// Check if the meter is nil. |
| 1233 |
if m == nil { |
| 1234 |
return FanSpeed{noop.Int64Gauge{}}, nil |
| 1235 |
} |
| 1236 |
|
| 1237 |
if len(opt) == 0 { |
| 1238 |
opt = newFanSpeedOpts |
| 1239 |
} else { |
| 1240 |
opt = append(opt, newFanSpeedOpts...) |
| 1241 |
} |
| 1242 |
|
| 1243 |
i, err := m.Int64Gauge( |
| 1244 |
"hw.fan.speed", |
| 1245 |
opt..., |
| 1246 |
) |
| 1247 |
if err != nil { |
| 1248 |
return FanSpeed{noop.Int64Gauge{}}, err |
| 1249 |
} |
| 1250 |
return FanSpeed{i}, nil |
| 1251 |
} |
| 1252 |
|
| 1253 |
// Inst returns the underlying metric instrument. |
| 1254 |
func (m FanSpeed) Inst() metric.Int64Gauge { |
| 1255 |
return m.Int64Gauge |
| 1256 |
} |
| 1257 |
|
| 1258 |
// Name returns the semantic convention name of the instrument. |
| 1259 |
func (FanSpeed) Name() string { |
| 1260 |
return "hw.fan.speed" |
| 1261 |
} |
| 1262 |
|
| 1263 |
// Unit returns the semantic convention unit of the instrument |
| 1264 |
func (FanSpeed) Unit() string { |
| 1265 |
return "rpm" |
| 1266 |
} |
| 1267 |
|
| 1268 |
// Description returns the semantic convention description of the instrument |
| 1269 |
func (FanSpeed) Description() string { |
| 1270 |
return "Fan speed in revolutions per minute." |
| 1271 |
} |
| 1272 |
|
| 1273 |
// Record records val to the current distribution for attrs. |
| 1274 |
// |
| 1275 |
// The id is the an identifier for the hardware component, unique within the |
| 1276 |
// monitored host |
| 1277 |
// |
| 1278 |
// All additional attrs passed are included in the recorded value. |
| 1279 |
func (m FanSpeed) Record( |
| 1280 |
ctx context.Context, |
| 1281 |
val int64, |
| 1282 |
id string, |
| 1283 |
attrs ...attribute.KeyValue, |
| 1284 |
) { |
| 1285 |
if len(attrs) == 0 { |
| 1286 |
m.Int64Gauge.Record(ctx, val) |
| 1287 |
return |
| 1288 |
} |
| 1289 |
|
| 1290 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 1291 |
defer func() { |
| 1292 |
*o = (*o)[:0] |
| 1293 |
recOptPool.Put(o) |
| 1294 |
}() |
| 1295 |
|
| 1296 |
*o = append( |
| 1297 |
*o, |
| 1298 |
metric.WithAttributes( |
| 1299 |
append( |
| 1300 |
attrs, |
| 1301 |
attribute.String("hw.id", id), |
| 1302 |
)..., |
| 1303 |
), |
| 1304 |
) |
| 1305 |
|
| 1306 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 1307 |
} |
| 1308 |
|
| 1309 |
// RecordSet records val to the current distribution for set. |
| 1310 |
func (m FanSpeed) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 1311 |
if set.Len() == 0 { |
| 1312 |
m.Int64Gauge.Record(ctx, val) |
| 1313 |
return |
| 1314 |
} |
| 1315 |
|
| 1316 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 1317 |
defer func() { |
| 1318 |
*o = (*o)[:0] |
| 1319 |
recOptPool.Put(o) |
| 1320 |
}() |
| 1321 |
|
| 1322 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1323 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 1324 |
} |
| 1325 |
|
| 1326 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 1327 |
// It represents an easily-recognizable name for the hardware component. |
| 1328 |
func (FanSpeed) AttrName(val string) attribute.KeyValue { |
| 1329 |
return attribute.String("hw.name", val) |
| 1330 |
} |
| 1331 |
|
| 1332 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 1333 |
// convention. It represents the unique identifier of the parent component |
| 1334 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 1335 |
func (FanSpeed) AttrParent(val string) attribute.KeyValue { |
| 1336 |
return attribute.String("hw.parent", val) |
| 1337 |
} |
| 1338 |
|
| 1339 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 1340 |
// semantic convention. It represents the location of the sensor. |
| 1341 |
func (FanSpeed) AttrSensorLocation(val string) attribute.KeyValue { |
| 1342 |
return attribute.String("hw.sensor_location", val) |
| 1343 |
} |
| 1344 |
|
| 1345 |
// FanSpeedLimit is an instrument used to record metric values conforming to the |
| 1346 |
// "hw.fan.speed.limit" semantic conventions. It represents the speed limit in |
| 1347 |
// rpm. |
| 1348 |
type FanSpeedLimit struct { |
| 1349 |
metric.Int64Gauge |
| 1350 |
} |
| 1351 |
|
| 1352 |
var newFanSpeedLimitOpts = []metric.Int64GaugeOption{ |
| 1353 |
metric.WithDescription("Speed limit in rpm."), |
| 1354 |
metric.WithUnit("rpm"), |
| 1355 |
} |
| 1356 |
|
| 1357 |
// NewFanSpeedLimit returns a new FanSpeedLimit instrument. |
| 1358 |
func NewFanSpeedLimit( |
| 1359 |
m metric.Meter, |
| 1360 |
opt ...metric.Int64GaugeOption, |
| 1361 |
) (FanSpeedLimit, error) { |
| 1362 |
// Check if the meter is nil. |
| 1363 |
if m == nil { |
| 1364 |
return FanSpeedLimit{noop.Int64Gauge{}}, nil |
| 1365 |
} |
| 1366 |
|
| 1367 |
if len(opt) == 0 { |
| 1368 |
opt = newFanSpeedLimitOpts |
| 1369 |
} else { |
| 1370 |
opt = append(opt, newFanSpeedLimitOpts...) |
| 1371 |
} |
| 1372 |
|
| 1373 |
i, err := m.Int64Gauge( |
| 1374 |
"hw.fan.speed.limit", |
| 1375 |
opt..., |
| 1376 |
) |
| 1377 |
if err != nil { |
| 1378 |
return FanSpeedLimit{noop.Int64Gauge{}}, err |
| 1379 |
} |
| 1380 |
return FanSpeedLimit{i}, nil |
| 1381 |
} |
| 1382 |
|
| 1383 |
// Inst returns the underlying metric instrument. |
| 1384 |
func (m FanSpeedLimit) Inst() metric.Int64Gauge { |
| 1385 |
return m.Int64Gauge |
| 1386 |
} |
| 1387 |
|
| 1388 |
// Name returns the semantic convention name of the instrument. |
| 1389 |
func (FanSpeedLimit) Name() string { |
| 1390 |
return "hw.fan.speed.limit" |
| 1391 |
} |
| 1392 |
|
| 1393 |
// Unit returns the semantic convention unit of the instrument |
| 1394 |
func (FanSpeedLimit) Unit() string { |
| 1395 |
return "rpm" |
| 1396 |
} |
| 1397 |
|
| 1398 |
// Description returns the semantic convention description of the instrument |
| 1399 |
func (FanSpeedLimit) Description() string { |
| 1400 |
return "Speed limit in rpm." |
| 1401 |
} |
| 1402 |
|
| 1403 |
// Record records val to the current distribution for attrs. |
| 1404 |
// |
| 1405 |
// The id is the an identifier for the hardware component, unique within the |
| 1406 |
// monitored host |
| 1407 |
// |
| 1408 |
// All additional attrs passed are included in the recorded value. |
| 1409 |
func (m FanSpeedLimit) Record( |
| 1410 |
ctx context.Context, |
| 1411 |
val int64, |
| 1412 |
id string, |
| 1413 |
attrs ...attribute.KeyValue, |
| 1414 |
) { |
| 1415 |
if len(attrs) == 0 { |
| 1416 |
m.Int64Gauge.Record(ctx, val) |
| 1417 |
return |
| 1418 |
} |
| 1419 |
|
| 1420 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 1421 |
defer func() { |
| 1422 |
*o = (*o)[:0] |
| 1423 |
recOptPool.Put(o) |
| 1424 |
}() |
| 1425 |
|
| 1426 |
*o = append( |
| 1427 |
*o, |
| 1428 |
metric.WithAttributes( |
| 1429 |
append( |
| 1430 |
attrs, |
| 1431 |
attribute.String("hw.id", id), |
| 1432 |
)..., |
| 1433 |
), |
| 1434 |
) |
| 1435 |
|
| 1436 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 1437 |
} |
| 1438 |
|
| 1439 |
// RecordSet records val to the current distribution for set. |
| 1440 |
func (m FanSpeedLimit) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 1441 |
if set.Len() == 0 { |
| 1442 |
m.Int64Gauge.Record(ctx, val) |
| 1443 |
return |
| 1444 |
} |
| 1445 |
|
| 1446 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 1447 |
defer func() { |
| 1448 |
*o = (*o)[:0] |
| 1449 |
recOptPool.Put(o) |
| 1450 |
}() |
| 1451 |
|
| 1452 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1453 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 1454 |
} |
| 1455 |
|
| 1456 |
// AttrLimitType returns an optional attribute for the "hw.limit_type" semantic |
| 1457 |
// convention. It represents the type of limit for hardware components. |
| 1458 |
func (FanSpeedLimit) AttrLimitType(val LimitTypeAttr) attribute.KeyValue { |
| 1459 |
return attribute.String("hw.limit_type", string(val)) |
| 1460 |
} |
| 1461 |
|
| 1462 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 1463 |
// It represents an easily-recognizable name for the hardware component. |
| 1464 |
func (FanSpeedLimit) AttrName(val string) attribute.KeyValue { |
| 1465 |
return attribute.String("hw.name", val) |
| 1466 |
} |
| 1467 |
|
| 1468 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 1469 |
// convention. It represents the unique identifier of the parent component |
| 1470 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 1471 |
func (FanSpeedLimit) AttrParent(val string) attribute.KeyValue { |
| 1472 |
return attribute.String("hw.parent", val) |
| 1473 |
} |
| 1474 |
|
| 1475 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 1476 |
// semantic convention. It represents the location of the sensor. |
| 1477 |
func (FanSpeedLimit) AttrSensorLocation(val string) attribute.KeyValue { |
| 1478 |
return attribute.String("hw.sensor_location", val) |
| 1479 |
} |
| 1480 |
|
| 1481 |
// FanSpeedRatio is an instrument used to record metric values conforming to the |
| 1482 |
// "hw.fan.speed_ratio" semantic conventions. It represents the fan speed |
| 1483 |
// expressed as a fraction of its maximum speed. |
| 1484 |
type FanSpeedRatio struct { |
| 1485 |
metric.Int64Gauge |
| 1486 |
} |
| 1487 |
|
| 1488 |
var newFanSpeedRatioOpts = []metric.Int64GaugeOption{ |
| 1489 |
metric.WithDescription("Fan speed expressed as a fraction of its maximum speed."), |
| 1490 |
metric.WithUnit("1"), |
| 1491 |
} |
| 1492 |
|
| 1493 |
// NewFanSpeedRatio returns a new FanSpeedRatio instrument. |
| 1494 |
func NewFanSpeedRatio( |
| 1495 |
m metric.Meter, |
| 1496 |
opt ...metric.Int64GaugeOption, |
| 1497 |
) (FanSpeedRatio, error) { |
| 1498 |
// Check if the meter is nil. |
| 1499 |
if m == nil { |
| 1500 |
return FanSpeedRatio{noop.Int64Gauge{}}, nil |
| 1501 |
} |
| 1502 |
|
| 1503 |
if len(opt) == 0 { |
| 1504 |
opt = newFanSpeedRatioOpts |
| 1505 |
} else { |
| 1506 |
opt = append(opt, newFanSpeedRatioOpts...) |
| 1507 |
} |
| 1508 |
|
| 1509 |
i, err := m.Int64Gauge( |
| 1510 |
"hw.fan.speed_ratio", |
| 1511 |
opt..., |
| 1512 |
) |
| 1513 |
if err != nil { |
| 1514 |
return FanSpeedRatio{noop.Int64Gauge{}}, err |
| 1515 |
} |
| 1516 |
return FanSpeedRatio{i}, nil |
| 1517 |
} |
| 1518 |
|
| 1519 |
// Inst returns the underlying metric instrument. |
| 1520 |
func (m FanSpeedRatio) Inst() metric.Int64Gauge { |
| 1521 |
return m.Int64Gauge |
| 1522 |
} |
| 1523 |
|
| 1524 |
// Name returns the semantic convention name of the instrument. |
| 1525 |
func (FanSpeedRatio) Name() string { |
| 1526 |
return "hw.fan.speed_ratio" |
| 1527 |
} |
| 1528 |
|
| 1529 |
// Unit returns the semantic convention unit of the instrument |
| 1530 |
func (FanSpeedRatio) Unit() string { |
| 1531 |
return "1" |
| 1532 |
} |
| 1533 |
|
| 1534 |
// Description returns the semantic convention description of the instrument |
| 1535 |
func (FanSpeedRatio) Description() string { |
| 1536 |
return "Fan speed expressed as a fraction of its maximum speed." |
| 1537 |
} |
| 1538 |
|
| 1539 |
// Record records val to the current distribution for attrs. |
| 1540 |
// |
| 1541 |
// The id is the an identifier for the hardware component, unique within the |
| 1542 |
// monitored host |
| 1543 |
// |
| 1544 |
// All additional attrs passed are included in the recorded value. |
| 1545 |
func (m FanSpeedRatio) Record( |
| 1546 |
ctx context.Context, |
| 1547 |
val int64, |
| 1548 |
id string, |
| 1549 |
attrs ...attribute.KeyValue, |
| 1550 |
) { |
| 1551 |
if len(attrs) == 0 { |
| 1552 |
m.Int64Gauge.Record(ctx, val) |
| 1553 |
return |
| 1554 |
} |
| 1555 |
|
| 1556 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 1557 |
defer func() { |
| 1558 |
*o = (*o)[:0] |
| 1559 |
recOptPool.Put(o) |
| 1560 |
}() |
| 1561 |
|
| 1562 |
*o = append( |
| 1563 |
*o, |
| 1564 |
metric.WithAttributes( |
| 1565 |
append( |
| 1566 |
attrs, |
| 1567 |
attribute.String("hw.id", id), |
| 1568 |
)..., |
| 1569 |
), |
| 1570 |
) |
| 1571 |
|
| 1572 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 1573 |
} |
| 1574 |
|
| 1575 |
// RecordSet records val to the current distribution for set. |
| 1576 |
func (m FanSpeedRatio) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 1577 |
if set.Len() == 0 { |
| 1578 |
m.Int64Gauge.Record(ctx, val) |
| 1579 |
return |
| 1580 |
} |
| 1581 |
|
| 1582 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 1583 |
defer func() { |
| 1584 |
*o = (*o)[:0] |
| 1585 |
recOptPool.Put(o) |
| 1586 |
}() |
| 1587 |
|
| 1588 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1589 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 1590 |
} |
| 1591 |
|
| 1592 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 1593 |
// It represents an easily-recognizable name for the hardware component. |
| 1594 |
func (FanSpeedRatio) AttrName(val string) attribute.KeyValue { |
| 1595 |
return attribute.String("hw.name", val) |
| 1596 |
} |
| 1597 |
|
| 1598 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 1599 |
// convention. It represents the unique identifier of the parent component |
| 1600 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 1601 |
func (FanSpeedRatio) AttrParent(val string) attribute.KeyValue { |
| 1602 |
return attribute.String("hw.parent", val) |
| 1603 |
} |
| 1604 |
|
| 1605 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 1606 |
// semantic convention. It represents the location of the sensor. |
| 1607 |
func (FanSpeedRatio) AttrSensorLocation(val string) attribute.KeyValue { |
| 1608 |
return attribute.String("hw.sensor_location", val) |
| 1609 |
} |
| 1610 |
|
| 1611 |
// GpuIO is an instrument used to record metric values conforming to the |
| 1612 |
// "hw.gpu.io" semantic conventions. It represents the received and transmitted |
| 1613 |
// bytes by the GPU. |
| 1614 |
type GpuIO struct { |
| 1615 |
metric.Int64Counter |
| 1616 |
} |
| 1617 |
|
| 1618 |
var newGpuIOOpts = []metric.Int64CounterOption{ |
| 1619 |
metric.WithDescription("Received and transmitted bytes by the GPU."), |
| 1620 |
metric.WithUnit("By"), |
| 1621 |
} |
| 1622 |
|
| 1623 |
// NewGpuIO returns a new GpuIO instrument. |
| 1624 |
func NewGpuIO( |
| 1625 |
m metric.Meter, |
| 1626 |
opt ...metric.Int64CounterOption, |
| 1627 |
) (GpuIO, error) { |
| 1628 |
// Check if the meter is nil. |
| 1629 |
if m == nil { |
| 1630 |
return GpuIO{noop.Int64Counter{}}, nil |
| 1631 |
} |
| 1632 |
|
| 1633 |
if len(opt) == 0 { |
| 1634 |
opt = newGpuIOOpts |
| 1635 |
} else { |
| 1636 |
opt = append(opt, newGpuIOOpts...) |
| 1637 |
} |
| 1638 |
|
| 1639 |
i, err := m.Int64Counter( |
| 1640 |
"hw.gpu.io", |
| 1641 |
opt..., |
| 1642 |
) |
| 1643 |
if err != nil { |
| 1644 |
return GpuIO{noop.Int64Counter{}}, err |
| 1645 |
} |
| 1646 |
return GpuIO{i}, nil |
| 1647 |
} |
| 1648 |
|
| 1649 |
// Inst returns the underlying metric instrument. |
| 1650 |
func (m GpuIO) Inst() metric.Int64Counter { |
| 1651 |
return m.Int64Counter |
| 1652 |
} |
| 1653 |
|
| 1654 |
// Name returns the semantic convention name of the instrument. |
| 1655 |
func (GpuIO) Name() string { |
| 1656 |
return "hw.gpu.io" |
| 1657 |
} |
| 1658 |
|
| 1659 |
// Unit returns the semantic convention unit of the instrument |
| 1660 |
func (GpuIO) Unit() string { |
| 1661 |
return "By" |
| 1662 |
} |
| 1663 |
|
| 1664 |
// Description returns the semantic convention description of the instrument |
| 1665 |
func (GpuIO) Description() string { |
| 1666 |
return "Received and transmitted bytes by the GPU." |
| 1667 |
} |
| 1668 |
|
| 1669 |
// Add adds incr to the existing count for attrs. |
| 1670 |
// |
| 1671 |
// The id is the an identifier for the hardware component, unique within the |
| 1672 |
// monitored host |
| 1673 |
// |
| 1674 |
// The networkIoDirection is the the network IO operation direction. |
| 1675 |
// |
| 1676 |
// All additional attrs passed are included in the recorded value. |
| 1677 |
func (m GpuIO) Add( |
| 1678 |
ctx context.Context, |
| 1679 |
incr int64, |
| 1680 |
id string, |
| 1681 |
networkIoDirection NetworkIODirectionAttr, |
| 1682 |
attrs ...attribute.KeyValue, |
| 1683 |
) { |
| 1684 |
if len(attrs) == 0 { |
| 1685 |
m.Int64Counter.Add(ctx, incr) |
| 1686 |
return |
| 1687 |
} |
| 1688 |
|
| 1689 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1690 |
defer func() { |
| 1691 |
*o = (*o)[:0] |
| 1692 |
addOptPool.Put(o) |
| 1693 |
}() |
| 1694 |
|
| 1695 |
*o = append( |
| 1696 |
*o, |
| 1697 |
metric.WithAttributes( |
| 1698 |
append( |
| 1699 |
attrs, |
| 1700 |
attribute.String("hw.id", id), |
| 1701 |
attribute.String("network.io.direction", string(networkIoDirection)), |
| 1702 |
)..., |
| 1703 |
), |
| 1704 |
) |
| 1705 |
|
| 1706 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 1707 |
} |
| 1708 |
|
| 1709 |
// AddSet adds incr to the existing count for set. |
| 1710 |
func (m GpuIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1711 |
if set.Len() == 0 { |
| 1712 |
m.Int64Counter.Add(ctx, incr) |
| 1713 |
return |
| 1714 |
} |
| 1715 |
|
| 1716 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1717 |
defer func() { |
| 1718 |
*o = (*o)[:0] |
| 1719 |
addOptPool.Put(o) |
| 1720 |
}() |
| 1721 |
|
| 1722 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1723 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 1724 |
} |
| 1725 |
|
| 1726 |
// AttrDriverVersion returns an optional attribute for the "hw.driver_version" |
| 1727 |
// semantic convention. It represents the driver version for the hardware |
| 1728 |
// component. |
| 1729 |
func (GpuIO) AttrDriverVersion(val string) attribute.KeyValue { |
| 1730 |
return attribute.String("hw.driver_version", val) |
| 1731 |
} |
| 1732 |
|
| 1733 |
// AttrFirmwareVersion returns an optional attribute for the |
| 1734 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 1735 |
// of the hardware component. |
| 1736 |
func (GpuIO) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 1737 |
return attribute.String("hw.firmware_version", val) |
| 1738 |
} |
| 1739 |
|
| 1740 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 1741 |
// convention. It represents the descriptive model name of the hardware |
| 1742 |
// component. |
| 1743 |
func (GpuIO) AttrModel(val string) attribute.KeyValue { |
| 1744 |
return attribute.String("hw.model", val) |
| 1745 |
} |
| 1746 |
|
| 1747 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 1748 |
// It represents an easily-recognizable name for the hardware component. |
| 1749 |
func (GpuIO) AttrName(val string) attribute.KeyValue { |
| 1750 |
return attribute.String("hw.name", val) |
| 1751 |
} |
| 1752 |
|
| 1753 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 1754 |
// convention. It represents the unique identifier of the parent component |
| 1755 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 1756 |
func (GpuIO) AttrParent(val string) attribute.KeyValue { |
| 1757 |
return attribute.String("hw.parent", val) |
| 1758 |
} |
| 1759 |
|
| 1760 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 1761 |
// semantic convention. It represents the serial number of the hardware |
| 1762 |
// component. |
| 1763 |
func (GpuIO) AttrSerialNumber(val string) attribute.KeyValue { |
| 1764 |
return attribute.String("hw.serial_number", val) |
| 1765 |
} |
| 1766 |
|
| 1767 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 1768 |
// convention. It represents the vendor name of the hardware component. |
| 1769 |
func (GpuIO) AttrVendor(val string) attribute.KeyValue { |
| 1770 |
return attribute.String("hw.vendor", val) |
| 1771 |
} |
| 1772 |
|
| 1773 |
// GpuMemoryLimit is an instrument used to record metric values conforming to the |
| 1774 |
// "hw.gpu.memory.limit" semantic conventions. It represents the size of the GPU |
| 1775 |
// memory. |
| 1776 |
type GpuMemoryLimit struct { |
| 1777 |
metric.Int64UpDownCounter |
| 1778 |
} |
| 1779 |
|
| 1780 |
var newGpuMemoryLimitOpts = []metric.Int64UpDownCounterOption{ |
| 1781 |
metric.WithDescription("Size of the GPU memory."), |
| 1782 |
metric.WithUnit("By"), |
| 1783 |
} |
| 1784 |
|
| 1785 |
// NewGpuMemoryLimit returns a new GpuMemoryLimit instrument. |
| 1786 |
func NewGpuMemoryLimit( |
| 1787 |
m metric.Meter, |
| 1788 |
opt ...metric.Int64UpDownCounterOption, |
| 1789 |
) (GpuMemoryLimit, error) { |
| 1790 |
// Check if the meter is nil. |
| 1791 |
if m == nil { |
| 1792 |
return GpuMemoryLimit{noop.Int64UpDownCounter{}}, nil |
| 1793 |
} |
| 1794 |
|
| 1795 |
if len(opt) == 0 { |
| 1796 |
opt = newGpuMemoryLimitOpts |
| 1797 |
} else { |
| 1798 |
opt = append(opt, newGpuMemoryLimitOpts...) |
| 1799 |
} |
| 1800 |
|
| 1801 |
i, err := m.Int64UpDownCounter( |
| 1802 |
"hw.gpu.memory.limit", |
| 1803 |
opt..., |
| 1804 |
) |
| 1805 |
if err != nil { |
| 1806 |
return GpuMemoryLimit{noop.Int64UpDownCounter{}}, err |
| 1807 |
} |
| 1808 |
return GpuMemoryLimit{i}, nil |
| 1809 |
} |
| 1810 |
|
| 1811 |
// Inst returns the underlying metric instrument. |
| 1812 |
func (m GpuMemoryLimit) Inst() metric.Int64UpDownCounter { |
| 1813 |
return m.Int64UpDownCounter |
| 1814 |
} |
| 1815 |
|
| 1816 |
// Name returns the semantic convention name of the instrument. |
| 1817 |
func (GpuMemoryLimit) Name() string { |
| 1818 |
return "hw.gpu.memory.limit" |
| 1819 |
} |
| 1820 |
|
| 1821 |
// Unit returns the semantic convention unit of the instrument |
| 1822 |
func (GpuMemoryLimit) Unit() string { |
| 1823 |
return "By" |
| 1824 |
} |
| 1825 |
|
| 1826 |
// Description returns the semantic convention description of the instrument |
| 1827 |
func (GpuMemoryLimit) Description() string { |
| 1828 |
return "Size of the GPU memory." |
| 1829 |
} |
| 1830 |
|
| 1831 |
// Add adds incr to the existing count for attrs. |
| 1832 |
// |
| 1833 |
// The id is the an identifier for the hardware component, unique within the |
| 1834 |
// monitored host |
| 1835 |
// |
| 1836 |
// All additional attrs passed are included in the recorded value. |
| 1837 |
func (m GpuMemoryLimit) Add( |
| 1838 |
ctx context.Context, |
| 1839 |
incr int64, |
| 1840 |
id string, |
| 1841 |
attrs ...attribute.KeyValue, |
| 1842 |
) { |
| 1843 |
if len(attrs) == 0 { |
| 1844 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1845 |
return |
| 1846 |
} |
| 1847 |
|
| 1848 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1849 |
defer func() { |
| 1850 |
*o = (*o)[:0] |
| 1851 |
addOptPool.Put(o) |
| 1852 |
}() |
| 1853 |
|
| 1854 |
*o = append( |
| 1855 |
*o, |
| 1856 |
metric.WithAttributes( |
| 1857 |
append( |
| 1858 |
attrs, |
| 1859 |
attribute.String("hw.id", id), |
| 1860 |
)..., |
| 1861 |
), |
| 1862 |
) |
| 1863 |
|
| 1864 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1865 |
} |
| 1866 |
|
| 1867 |
// AddSet adds incr to the existing count for set. |
| 1868 |
func (m GpuMemoryLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 1869 |
if set.Len() == 0 { |
| 1870 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 1871 |
return |
| 1872 |
} |
| 1873 |
|
| 1874 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 1875 |
defer func() { |
| 1876 |
*o = (*o)[:0] |
| 1877 |
addOptPool.Put(o) |
| 1878 |
}() |
| 1879 |
|
| 1880 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 1881 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 1882 |
} |
| 1883 |
|
| 1884 |
// AttrDriverVersion returns an optional attribute for the "hw.driver_version" |
| 1885 |
// semantic convention. It represents the driver version for the hardware |
| 1886 |
// component. |
| 1887 |
func (GpuMemoryLimit) AttrDriverVersion(val string) attribute.KeyValue { |
| 1888 |
return attribute.String("hw.driver_version", val) |
| 1889 |
} |
| 1890 |
|
| 1891 |
// AttrFirmwareVersion returns an optional attribute for the |
| 1892 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 1893 |
// of the hardware component. |
| 1894 |
func (GpuMemoryLimit) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 1895 |
return attribute.String("hw.firmware_version", val) |
| 1896 |
} |
| 1897 |
|
| 1898 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 1899 |
// convention. It represents the descriptive model name of the hardware |
| 1900 |
// component. |
| 1901 |
func (GpuMemoryLimit) AttrModel(val string) attribute.KeyValue { |
| 1902 |
return attribute.String("hw.model", val) |
| 1903 |
} |
| 1904 |
|
| 1905 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 1906 |
// It represents an easily-recognizable name for the hardware component. |
| 1907 |
func (GpuMemoryLimit) AttrName(val string) attribute.KeyValue { |
| 1908 |
return attribute.String("hw.name", val) |
| 1909 |
} |
| 1910 |
|
| 1911 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 1912 |
// convention. It represents the unique identifier of the parent component |
| 1913 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 1914 |
func (GpuMemoryLimit) AttrParent(val string) attribute.KeyValue { |
| 1915 |
return attribute.String("hw.parent", val) |
| 1916 |
} |
| 1917 |
|
| 1918 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 1919 |
// semantic convention. It represents the serial number of the hardware |
| 1920 |
// component. |
| 1921 |
func (GpuMemoryLimit) AttrSerialNumber(val string) attribute.KeyValue { |
| 1922 |
return attribute.String("hw.serial_number", val) |
| 1923 |
} |
| 1924 |
|
| 1925 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 1926 |
// convention. It represents the vendor name of the hardware component. |
| 1927 |
func (GpuMemoryLimit) AttrVendor(val string) attribute.KeyValue { |
| 1928 |
return attribute.String("hw.vendor", val) |
| 1929 |
} |
| 1930 |
|
| 1931 |
// GpuMemoryUsage is an instrument used to record metric values conforming to the |
| 1932 |
// "hw.gpu.memory.usage" semantic conventions. It represents the GPU memory used. |
| 1933 |
type GpuMemoryUsage struct { |
| 1934 |
metric.Int64UpDownCounter |
| 1935 |
} |
| 1936 |
|
| 1937 |
var newGpuMemoryUsageOpts = []metric.Int64UpDownCounterOption{ |
| 1938 |
metric.WithDescription("GPU memory used."), |
| 1939 |
metric.WithUnit("By"), |
| 1940 |
} |
| 1941 |
|
| 1942 |
// NewGpuMemoryUsage returns a new GpuMemoryUsage instrument. |
| 1943 |
func NewGpuMemoryUsage( |
| 1944 |
m metric.Meter, |
| 1945 |
opt ...metric.Int64UpDownCounterOption, |
| 1946 |
) (GpuMemoryUsage, error) { |
| 1947 |
// Check if the meter is nil. |
| 1948 |
if m == nil { |
| 1949 |
return GpuMemoryUsage{noop.Int64UpDownCounter{}}, nil |
| 1950 |
} |
| 1951 |
|
| 1952 |
if len(opt) == 0 { |
| 1953 |
opt = newGpuMemoryUsageOpts |
| 1954 |
} else { |
| 1955 |
opt = append(opt, newGpuMemoryUsageOpts...) |
| 1956 |
} |
| 1957 |
|
| 1958 |
i, err := m.Int64UpDownCounter( |
| 1959 |
"hw.gpu.memory.usage", |
| 1960 |
opt..., |
| 1961 |
) |
| 1962 |
if err != nil { |
| 1963 |
return GpuMemoryUsage{noop.Int64UpDownCounter{}}, err |
| 1964 |
} |
| 1965 |
return GpuMemoryUsage{i}, nil |
| 1966 |
} |
| 1967 |
|
| 1968 |
// Inst returns the underlying metric instrument. |
| 1969 |
func (m GpuMemoryUsage) Inst() metric.Int64UpDownCounter { |
| 1970 |
return m.Int64UpDownCounter |
| 1971 |
} |
| 1972 |
|
| 1973 |
// Name returns the semantic convention name of the instrument. |
| 1974 |
func (GpuMemoryUsage) Name() string { |
| 1975 |
return "hw.gpu.memory.usage" |
| 1976 |
} |
| 1977 |
|
| 1978 |
// Unit returns the semantic convention unit of the instrument |
| 1979 |
func (GpuMemoryUsage) Unit() string { |
| 1980 |
return "By" |
| 1981 |
} |
| 1982 |
|
| 1983 |
// Description returns the semantic convention description of the instrument |
| 1984 |
func (GpuMemoryUsage) Description() string { |
| 1985 |
return "GPU memory used." |
| 1986 |
} |
| 1987 |
|
| 1988 |
// Add adds incr to the existing count for attrs. |
| 1989 |
// |
| 1990 |
// The id is the an identifier for the hardware component, unique within the |
| 1991 |
// monitored host |
| 1992 |
// |
| 1993 |
// All additional attrs passed are included in the recorded value. |
| 1994 |
func (m GpuMemoryUsage) Add( |
| 1995 |
ctx context.Context, |
| 1996 |
incr int64, |
| 1997 |
id string, |
| 1998 |
attrs ...attribute.KeyValue, |
| 1999 |
) { |
| 2000 |
if len(attrs) == 0 { |
| 2001 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2002 |
return |
| 2003 |
} |
| 2004 |
|
| 2005 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2006 |
defer func() { |
| 2007 |
*o = (*o)[:0] |
| 2008 |
addOptPool.Put(o) |
| 2009 |
}() |
| 2010 |
|
| 2011 |
*o = append( |
| 2012 |
*o, |
| 2013 |
metric.WithAttributes( |
| 2014 |
append( |
| 2015 |
attrs, |
| 2016 |
attribute.String("hw.id", id), |
| 2017 |
)..., |
| 2018 |
), |
| 2019 |
) |
| 2020 |
|
| 2021 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2022 |
} |
| 2023 |
|
| 2024 |
// AddSet adds incr to the existing count for set. |
| 2025 |
func (m GpuMemoryUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2026 |
if set.Len() == 0 { |
| 2027 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2028 |
return |
| 2029 |
} |
| 2030 |
|
| 2031 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2032 |
defer func() { |
| 2033 |
*o = (*o)[:0] |
| 2034 |
addOptPool.Put(o) |
| 2035 |
}() |
| 2036 |
|
| 2037 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2038 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 2039 |
} |
| 2040 |
|
| 2041 |
// AttrDriverVersion returns an optional attribute for the "hw.driver_version" |
| 2042 |
// semantic convention. It represents the driver version for the hardware |
| 2043 |
// component. |
| 2044 |
func (GpuMemoryUsage) AttrDriverVersion(val string) attribute.KeyValue { |
| 2045 |
return attribute.String("hw.driver_version", val) |
| 2046 |
} |
| 2047 |
|
| 2048 |
// AttrFirmwareVersion returns an optional attribute for the |
| 2049 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 2050 |
// of the hardware component. |
| 2051 |
func (GpuMemoryUsage) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 2052 |
return attribute.String("hw.firmware_version", val) |
| 2053 |
} |
| 2054 |
|
| 2055 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 2056 |
// convention. It represents the descriptive model name of the hardware |
| 2057 |
// component. |
| 2058 |
func (GpuMemoryUsage) AttrModel(val string) attribute.KeyValue { |
| 2059 |
return attribute.String("hw.model", val) |
| 2060 |
} |
| 2061 |
|
| 2062 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 2063 |
// It represents an easily-recognizable name for the hardware component. |
| 2064 |
func (GpuMemoryUsage) AttrName(val string) attribute.KeyValue { |
| 2065 |
return attribute.String("hw.name", val) |
| 2066 |
} |
| 2067 |
|
| 2068 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 2069 |
// convention. It represents the unique identifier of the parent component |
| 2070 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 2071 |
func (GpuMemoryUsage) AttrParent(val string) attribute.KeyValue { |
| 2072 |
return attribute.String("hw.parent", val) |
| 2073 |
} |
| 2074 |
|
| 2075 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 2076 |
// semantic convention. It represents the serial number of the hardware |
| 2077 |
// component. |
| 2078 |
func (GpuMemoryUsage) AttrSerialNumber(val string) attribute.KeyValue { |
| 2079 |
return attribute.String("hw.serial_number", val) |
| 2080 |
} |
| 2081 |
|
| 2082 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 2083 |
// convention. It represents the vendor name of the hardware component. |
| 2084 |
func (GpuMemoryUsage) AttrVendor(val string) attribute.KeyValue { |
| 2085 |
return attribute.String("hw.vendor", val) |
| 2086 |
} |
| 2087 |
|
| 2088 |
// GpuMemoryUtilization is an instrument used to record metric values conforming |
| 2089 |
// to the "hw.gpu.memory.utilization" semantic conventions. It represents the |
| 2090 |
// fraction of GPU memory used. |
| 2091 |
type GpuMemoryUtilization struct { |
| 2092 |
metric.Int64Gauge |
| 2093 |
} |
| 2094 |
|
| 2095 |
var newGpuMemoryUtilizationOpts = []metric.Int64GaugeOption{ |
| 2096 |
metric.WithDescription("Fraction of GPU memory used."), |
| 2097 |
metric.WithUnit("1"), |
| 2098 |
} |
| 2099 |
|
| 2100 |
// NewGpuMemoryUtilization returns a new GpuMemoryUtilization instrument. |
| 2101 |
func NewGpuMemoryUtilization( |
| 2102 |
m metric.Meter, |
| 2103 |
opt ...metric.Int64GaugeOption, |
| 2104 |
) (GpuMemoryUtilization, error) { |
| 2105 |
// Check if the meter is nil. |
| 2106 |
if m == nil { |
| 2107 |
return GpuMemoryUtilization{noop.Int64Gauge{}}, nil |
| 2108 |
} |
| 2109 |
|
| 2110 |
if len(opt) == 0 { |
| 2111 |
opt = newGpuMemoryUtilizationOpts |
| 2112 |
} else { |
| 2113 |
opt = append(opt, newGpuMemoryUtilizationOpts...) |
| 2114 |
} |
| 2115 |
|
| 2116 |
i, err := m.Int64Gauge( |
| 2117 |
"hw.gpu.memory.utilization", |
| 2118 |
opt..., |
| 2119 |
) |
| 2120 |
if err != nil { |
| 2121 |
return GpuMemoryUtilization{noop.Int64Gauge{}}, err |
| 2122 |
} |
| 2123 |
return GpuMemoryUtilization{i}, nil |
| 2124 |
} |
| 2125 |
|
| 2126 |
// Inst returns the underlying metric instrument. |
| 2127 |
func (m GpuMemoryUtilization) Inst() metric.Int64Gauge { |
| 2128 |
return m.Int64Gauge |
| 2129 |
} |
| 2130 |
|
| 2131 |
// Name returns the semantic convention name of the instrument. |
| 2132 |
func (GpuMemoryUtilization) Name() string { |
| 2133 |
return "hw.gpu.memory.utilization" |
| 2134 |
} |
| 2135 |
|
| 2136 |
// Unit returns the semantic convention unit of the instrument |
| 2137 |
func (GpuMemoryUtilization) Unit() string { |
| 2138 |
return "1" |
| 2139 |
} |
| 2140 |
|
| 2141 |
// Description returns the semantic convention description of the instrument |
| 2142 |
func (GpuMemoryUtilization) Description() string { |
| 2143 |
return "Fraction of GPU memory used." |
| 2144 |
} |
| 2145 |
|
| 2146 |
// Record records val to the current distribution for attrs. |
| 2147 |
// |
| 2148 |
// The id is the an identifier for the hardware component, unique within the |
| 2149 |
// monitored host |
| 2150 |
// |
| 2151 |
// All additional attrs passed are included in the recorded value. |
| 2152 |
func (m GpuMemoryUtilization) Record( |
| 2153 |
ctx context.Context, |
| 2154 |
val int64, |
| 2155 |
id string, |
| 2156 |
attrs ...attribute.KeyValue, |
| 2157 |
) { |
| 2158 |
if len(attrs) == 0 { |
| 2159 |
m.Int64Gauge.Record(ctx, val) |
| 2160 |
return |
| 2161 |
} |
| 2162 |
|
| 2163 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2164 |
defer func() { |
| 2165 |
*o = (*o)[:0] |
| 2166 |
recOptPool.Put(o) |
| 2167 |
}() |
| 2168 |
|
| 2169 |
*o = append( |
| 2170 |
*o, |
| 2171 |
metric.WithAttributes( |
| 2172 |
append( |
| 2173 |
attrs, |
| 2174 |
attribute.String("hw.id", id), |
| 2175 |
)..., |
| 2176 |
), |
| 2177 |
) |
| 2178 |
|
| 2179 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2180 |
} |
| 2181 |
|
| 2182 |
// RecordSet records val to the current distribution for set. |
| 2183 |
func (m GpuMemoryUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2184 |
if set.Len() == 0 { |
| 2185 |
m.Int64Gauge.Record(ctx, val) |
| 2186 |
return |
| 2187 |
} |
| 2188 |
|
| 2189 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2190 |
defer func() { |
| 2191 |
*o = (*o)[:0] |
| 2192 |
recOptPool.Put(o) |
| 2193 |
}() |
| 2194 |
|
| 2195 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2196 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2197 |
} |
| 2198 |
|
| 2199 |
// AttrDriverVersion returns an optional attribute for the "hw.driver_version" |
| 2200 |
// semantic convention. It represents the driver version for the hardware |
| 2201 |
// component. |
| 2202 |
func (GpuMemoryUtilization) AttrDriverVersion(val string) attribute.KeyValue { |
| 2203 |
return attribute.String("hw.driver_version", val) |
| 2204 |
} |
| 2205 |
|
| 2206 |
// AttrFirmwareVersion returns an optional attribute for the |
| 2207 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 2208 |
// of the hardware component. |
| 2209 |
func (GpuMemoryUtilization) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 2210 |
return attribute.String("hw.firmware_version", val) |
| 2211 |
} |
| 2212 |
|
| 2213 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 2214 |
// convention. It represents the descriptive model name of the hardware |
| 2215 |
// component. |
| 2216 |
func (GpuMemoryUtilization) AttrModel(val string) attribute.KeyValue { |
| 2217 |
return attribute.String("hw.model", val) |
| 2218 |
} |
| 2219 |
|
| 2220 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 2221 |
// It represents an easily-recognizable name for the hardware component. |
| 2222 |
func (GpuMemoryUtilization) AttrName(val string) attribute.KeyValue { |
| 2223 |
return attribute.String("hw.name", val) |
| 2224 |
} |
| 2225 |
|
| 2226 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 2227 |
// convention. It represents the unique identifier of the parent component |
| 2228 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 2229 |
func (GpuMemoryUtilization) AttrParent(val string) attribute.KeyValue { |
| 2230 |
return attribute.String("hw.parent", val) |
| 2231 |
} |
| 2232 |
|
| 2233 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 2234 |
// semantic convention. It represents the serial number of the hardware |
| 2235 |
// component. |
| 2236 |
func (GpuMemoryUtilization) AttrSerialNumber(val string) attribute.KeyValue { |
| 2237 |
return attribute.String("hw.serial_number", val) |
| 2238 |
} |
| 2239 |
|
| 2240 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 2241 |
// convention. It represents the vendor name of the hardware component. |
| 2242 |
func (GpuMemoryUtilization) AttrVendor(val string) attribute.KeyValue { |
| 2243 |
return attribute.String("hw.vendor", val) |
| 2244 |
} |
| 2245 |
|
| 2246 |
// GpuUtilization is an instrument used to record metric values conforming to the |
| 2247 |
// "hw.gpu.utilization" semantic conventions. It represents the fraction of time |
| 2248 |
// spent in a specific task. |
| 2249 |
type GpuUtilization struct { |
| 2250 |
metric.Int64Gauge |
| 2251 |
} |
| 2252 |
|
| 2253 |
var newGpuUtilizationOpts = []metric.Int64GaugeOption{ |
| 2254 |
metric.WithDescription("Fraction of time spent in a specific task."), |
| 2255 |
metric.WithUnit("1"), |
| 2256 |
} |
| 2257 |
|
| 2258 |
// NewGpuUtilization returns a new GpuUtilization instrument. |
| 2259 |
func NewGpuUtilization( |
| 2260 |
m metric.Meter, |
| 2261 |
opt ...metric.Int64GaugeOption, |
| 2262 |
) (GpuUtilization, error) { |
| 2263 |
// Check if the meter is nil. |
| 2264 |
if m == nil { |
| 2265 |
return GpuUtilization{noop.Int64Gauge{}}, nil |
| 2266 |
} |
| 2267 |
|
| 2268 |
if len(opt) == 0 { |
| 2269 |
opt = newGpuUtilizationOpts |
| 2270 |
} else { |
| 2271 |
opt = append(opt, newGpuUtilizationOpts...) |
| 2272 |
} |
| 2273 |
|
| 2274 |
i, err := m.Int64Gauge( |
| 2275 |
"hw.gpu.utilization", |
| 2276 |
opt..., |
| 2277 |
) |
| 2278 |
if err != nil { |
| 2279 |
return GpuUtilization{noop.Int64Gauge{}}, err |
| 2280 |
} |
| 2281 |
return GpuUtilization{i}, nil |
| 2282 |
} |
| 2283 |
|
| 2284 |
// Inst returns the underlying metric instrument. |
| 2285 |
func (m GpuUtilization) Inst() metric.Int64Gauge { |
| 2286 |
return m.Int64Gauge |
| 2287 |
} |
| 2288 |
|
| 2289 |
// Name returns the semantic convention name of the instrument. |
| 2290 |
func (GpuUtilization) Name() string { |
| 2291 |
return "hw.gpu.utilization" |
| 2292 |
} |
| 2293 |
|
| 2294 |
// Unit returns the semantic convention unit of the instrument |
| 2295 |
func (GpuUtilization) Unit() string { |
| 2296 |
return "1" |
| 2297 |
} |
| 2298 |
|
| 2299 |
// Description returns the semantic convention description of the instrument |
| 2300 |
func (GpuUtilization) Description() string { |
| 2301 |
return "Fraction of time spent in a specific task." |
| 2302 |
} |
| 2303 |
|
| 2304 |
// Record records val to the current distribution for attrs. |
| 2305 |
// |
| 2306 |
// The id is the an identifier for the hardware component, unique within the |
| 2307 |
// monitored host |
| 2308 |
// |
| 2309 |
// All additional attrs passed are included in the recorded value. |
| 2310 |
func (m GpuUtilization) Record( |
| 2311 |
ctx context.Context, |
| 2312 |
val int64, |
| 2313 |
id string, |
| 2314 |
attrs ...attribute.KeyValue, |
| 2315 |
) { |
| 2316 |
if len(attrs) == 0 { |
| 2317 |
m.Int64Gauge.Record(ctx, val) |
| 2318 |
return |
| 2319 |
} |
| 2320 |
|
| 2321 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2322 |
defer func() { |
| 2323 |
*o = (*o)[:0] |
| 2324 |
recOptPool.Put(o) |
| 2325 |
}() |
| 2326 |
|
| 2327 |
*o = append( |
| 2328 |
*o, |
| 2329 |
metric.WithAttributes( |
| 2330 |
append( |
| 2331 |
attrs, |
| 2332 |
attribute.String("hw.id", id), |
| 2333 |
)..., |
| 2334 |
), |
| 2335 |
) |
| 2336 |
|
| 2337 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2338 |
} |
| 2339 |
|
| 2340 |
// RecordSet records val to the current distribution for set. |
| 2341 |
func (m GpuUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2342 |
if set.Len() == 0 { |
| 2343 |
m.Int64Gauge.Record(ctx, val) |
| 2344 |
return |
| 2345 |
} |
| 2346 |
|
| 2347 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2348 |
defer func() { |
| 2349 |
*o = (*o)[:0] |
| 2350 |
recOptPool.Put(o) |
| 2351 |
}() |
| 2352 |
|
| 2353 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2354 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2355 |
} |
| 2356 |
|
| 2357 |
// AttrDriverVersion returns an optional attribute for the "hw.driver_version" |
| 2358 |
// semantic convention. It represents the driver version for the hardware |
| 2359 |
// component. |
| 2360 |
func (GpuUtilization) AttrDriverVersion(val string) attribute.KeyValue { |
| 2361 |
return attribute.String("hw.driver_version", val) |
| 2362 |
} |
| 2363 |
|
| 2364 |
// AttrFirmwareVersion returns an optional attribute for the |
| 2365 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 2366 |
// of the hardware component. |
| 2367 |
func (GpuUtilization) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 2368 |
return attribute.String("hw.firmware_version", val) |
| 2369 |
} |
| 2370 |
|
| 2371 |
// AttrGpuTask returns an optional attribute for the "hw.gpu.task" semantic |
| 2372 |
// convention. It represents the type of task the GPU is performing. |
| 2373 |
func (GpuUtilization) AttrGpuTask(val GpuTaskAttr) attribute.KeyValue { |
| 2374 |
return attribute.String("hw.gpu.task", string(val)) |
| 2375 |
} |
| 2376 |
|
| 2377 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 2378 |
// convention. It represents the descriptive model name of the hardware |
| 2379 |
// component. |
| 2380 |
func (GpuUtilization) AttrModel(val string) attribute.KeyValue { |
| 2381 |
return attribute.String("hw.model", val) |
| 2382 |
} |
| 2383 |
|
| 2384 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 2385 |
// It represents an easily-recognizable name for the hardware component. |
| 2386 |
func (GpuUtilization) AttrName(val string) attribute.KeyValue { |
| 2387 |
return attribute.String("hw.name", val) |
| 2388 |
} |
| 2389 |
|
| 2390 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 2391 |
// convention. It represents the unique identifier of the parent component |
| 2392 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 2393 |
func (GpuUtilization) AttrParent(val string) attribute.KeyValue { |
| 2394 |
return attribute.String("hw.parent", val) |
| 2395 |
} |
| 2396 |
|
| 2397 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 2398 |
// semantic convention. It represents the serial number of the hardware |
| 2399 |
// component. |
| 2400 |
func (GpuUtilization) AttrSerialNumber(val string) attribute.KeyValue { |
| 2401 |
return attribute.String("hw.serial_number", val) |
| 2402 |
} |
| 2403 |
|
| 2404 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 2405 |
// convention. It represents the vendor name of the hardware component. |
| 2406 |
func (GpuUtilization) AttrVendor(val string) attribute.KeyValue { |
| 2407 |
return attribute.String("hw.vendor", val) |
| 2408 |
} |
| 2409 |
|
| 2410 |
// HostAmbientTemperature is an instrument used to record metric values |
| 2411 |
// conforming to the "hw.host.ambient_temperature" semantic conventions. It |
| 2412 |
// represents the ambient (external) temperature of the physical host. |
| 2413 |
type HostAmbientTemperature struct { |
| 2414 |
metric.Int64Gauge |
| 2415 |
} |
| 2416 |
|
| 2417 |
var newHostAmbientTemperatureOpts = []metric.Int64GaugeOption{ |
| 2418 |
metric.WithDescription("Ambient (external) temperature of the physical host."), |
| 2419 |
metric.WithUnit("Cel"), |
| 2420 |
} |
| 2421 |
|
| 2422 |
// NewHostAmbientTemperature returns a new HostAmbientTemperature instrument. |
| 2423 |
func NewHostAmbientTemperature( |
| 2424 |
m metric.Meter, |
| 2425 |
opt ...metric.Int64GaugeOption, |
| 2426 |
) (HostAmbientTemperature, error) { |
| 2427 |
// Check if the meter is nil. |
| 2428 |
if m == nil { |
| 2429 |
return HostAmbientTemperature{noop.Int64Gauge{}}, nil |
| 2430 |
} |
| 2431 |
|
| 2432 |
if len(opt) == 0 { |
| 2433 |
opt = newHostAmbientTemperatureOpts |
| 2434 |
} else { |
| 2435 |
opt = append(opt, newHostAmbientTemperatureOpts...) |
| 2436 |
} |
| 2437 |
|
| 2438 |
i, err := m.Int64Gauge( |
| 2439 |
"hw.host.ambient_temperature", |
| 2440 |
opt..., |
| 2441 |
) |
| 2442 |
if err != nil { |
| 2443 |
return HostAmbientTemperature{noop.Int64Gauge{}}, err |
| 2444 |
} |
| 2445 |
return HostAmbientTemperature{i}, nil |
| 2446 |
} |
| 2447 |
|
| 2448 |
// Inst returns the underlying metric instrument. |
| 2449 |
func (m HostAmbientTemperature) Inst() metric.Int64Gauge { |
| 2450 |
return m.Int64Gauge |
| 2451 |
} |
| 2452 |
|
| 2453 |
// Name returns the semantic convention name of the instrument. |
| 2454 |
func (HostAmbientTemperature) Name() string { |
| 2455 |
return "hw.host.ambient_temperature" |
| 2456 |
} |
| 2457 |
|
| 2458 |
// Unit returns the semantic convention unit of the instrument |
| 2459 |
func (HostAmbientTemperature) Unit() string { |
| 2460 |
return "Cel" |
| 2461 |
} |
| 2462 |
|
| 2463 |
// Description returns the semantic convention description of the instrument |
| 2464 |
func (HostAmbientTemperature) Description() string { |
| 2465 |
return "Ambient (external) temperature of the physical host." |
| 2466 |
} |
| 2467 |
|
| 2468 |
// Record records val to the current distribution for attrs. |
| 2469 |
// |
| 2470 |
// The id is the an identifier for the hardware component, unique within the |
| 2471 |
// monitored host |
| 2472 |
// |
| 2473 |
// All additional attrs passed are included in the recorded value. |
| 2474 |
func (m HostAmbientTemperature) Record( |
| 2475 |
ctx context.Context, |
| 2476 |
val int64, |
| 2477 |
id string, |
| 2478 |
attrs ...attribute.KeyValue, |
| 2479 |
) { |
| 2480 |
if len(attrs) == 0 { |
| 2481 |
m.Int64Gauge.Record(ctx, val) |
| 2482 |
return |
| 2483 |
} |
| 2484 |
|
| 2485 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2486 |
defer func() { |
| 2487 |
*o = (*o)[:0] |
| 2488 |
recOptPool.Put(o) |
| 2489 |
}() |
| 2490 |
|
| 2491 |
*o = append( |
| 2492 |
*o, |
| 2493 |
metric.WithAttributes( |
| 2494 |
append( |
| 2495 |
attrs, |
| 2496 |
attribute.String("hw.id", id), |
| 2497 |
)..., |
| 2498 |
), |
| 2499 |
) |
| 2500 |
|
| 2501 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2502 |
} |
| 2503 |
|
| 2504 |
// RecordSet records val to the current distribution for set. |
| 2505 |
func (m HostAmbientTemperature) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2506 |
if set.Len() == 0 { |
| 2507 |
m.Int64Gauge.Record(ctx, val) |
| 2508 |
return |
| 2509 |
} |
| 2510 |
|
| 2511 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2512 |
defer func() { |
| 2513 |
*o = (*o)[:0] |
| 2514 |
recOptPool.Put(o) |
| 2515 |
}() |
| 2516 |
|
| 2517 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2518 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2519 |
} |
| 2520 |
|
| 2521 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 2522 |
// It represents an easily-recognizable name for the hardware component. |
| 2523 |
func (HostAmbientTemperature) AttrName(val string) attribute.KeyValue { |
| 2524 |
return attribute.String("hw.name", val) |
| 2525 |
} |
| 2526 |
|
| 2527 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 2528 |
// convention. It represents the unique identifier of the parent component |
| 2529 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 2530 |
func (HostAmbientTemperature) AttrParent(val string) attribute.KeyValue { |
| 2531 |
return attribute.String("hw.parent", val) |
| 2532 |
} |
| 2533 |
|
| 2534 |
// HostEnergy is an instrument used to record metric values conforming to the |
| 2535 |
// "hw.host.energy" semantic conventions. It represents the total energy consumed |
| 2536 |
// by the entire physical host, in joules. |
| 2537 |
type HostEnergy struct { |
| 2538 |
metric.Int64Counter |
| 2539 |
} |
| 2540 |
|
| 2541 |
var newHostEnergyOpts = []metric.Int64CounterOption{ |
| 2542 |
metric.WithDescription("Total energy consumed by the entire physical host, in joules."), |
| 2543 |
metric.WithUnit("J"), |
| 2544 |
} |
| 2545 |
|
| 2546 |
// NewHostEnergy returns a new HostEnergy instrument. |
| 2547 |
func NewHostEnergy( |
| 2548 |
m metric.Meter, |
| 2549 |
opt ...metric.Int64CounterOption, |
| 2550 |
) (HostEnergy, error) { |
| 2551 |
// Check if the meter is nil. |
| 2552 |
if m == nil { |
| 2553 |
return HostEnergy{noop.Int64Counter{}}, nil |
| 2554 |
} |
| 2555 |
|
| 2556 |
if len(opt) == 0 { |
| 2557 |
opt = newHostEnergyOpts |
| 2558 |
} else { |
| 2559 |
opt = append(opt, newHostEnergyOpts...) |
| 2560 |
} |
| 2561 |
|
| 2562 |
i, err := m.Int64Counter( |
| 2563 |
"hw.host.energy", |
| 2564 |
opt..., |
| 2565 |
) |
| 2566 |
if err != nil { |
| 2567 |
return HostEnergy{noop.Int64Counter{}}, err |
| 2568 |
} |
| 2569 |
return HostEnergy{i}, nil |
| 2570 |
} |
| 2571 |
|
| 2572 |
// Inst returns the underlying metric instrument. |
| 2573 |
func (m HostEnergy) Inst() metric.Int64Counter { |
| 2574 |
return m.Int64Counter |
| 2575 |
} |
| 2576 |
|
| 2577 |
// Name returns the semantic convention name of the instrument. |
| 2578 |
func (HostEnergy) Name() string { |
| 2579 |
return "hw.host.energy" |
| 2580 |
} |
| 2581 |
|
| 2582 |
// Unit returns the semantic convention unit of the instrument |
| 2583 |
func (HostEnergy) Unit() string { |
| 2584 |
return "J" |
| 2585 |
} |
| 2586 |
|
| 2587 |
// Description returns the semantic convention description of the instrument |
| 2588 |
func (HostEnergy) Description() string { |
| 2589 |
return "Total energy consumed by the entire physical host, in joules." |
| 2590 |
} |
| 2591 |
|
| 2592 |
// Add adds incr to the existing count for attrs. |
| 2593 |
// |
| 2594 |
// The id is the an identifier for the hardware component, unique within the |
| 2595 |
// monitored host |
| 2596 |
// |
| 2597 |
// All additional attrs passed are included in the recorded value. |
| 2598 |
// |
| 2599 |
// The overall energy usage of a host MUST be reported using the specific |
| 2600 |
// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic |
| 2601 |
// `hw.energy` and `hw.power` described in the previous section, to prevent |
| 2602 |
// summing up overlapping values. |
| 2603 |
func (m HostEnergy) Add( |
| 2604 |
ctx context.Context, |
| 2605 |
incr int64, |
| 2606 |
id string, |
| 2607 |
attrs ...attribute.KeyValue, |
| 2608 |
) { |
| 2609 |
if len(attrs) == 0 { |
| 2610 |
m.Int64Counter.Add(ctx, incr) |
| 2611 |
return |
| 2612 |
} |
| 2613 |
|
| 2614 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2615 |
defer func() { |
| 2616 |
*o = (*o)[:0] |
| 2617 |
addOptPool.Put(o) |
| 2618 |
}() |
| 2619 |
|
| 2620 |
*o = append( |
| 2621 |
*o, |
| 2622 |
metric.WithAttributes( |
| 2623 |
append( |
| 2624 |
attrs, |
| 2625 |
attribute.String("hw.id", id), |
| 2626 |
)..., |
| 2627 |
), |
| 2628 |
) |
| 2629 |
|
| 2630 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 2631 |
} |
| 2632 |
|
| 2633 |
// AddSet adds incr to the existing count for set. |
| 2634 |
// |
| 2635 |
// The overall energy usage of a host MUST be reported using the specific |
| 2636 |
// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic |
| 2637 |
// `hw.energy` and `hw.power` described in the previous section, to prevent |
| 2638 |
// summing up overlapping values. |
| 2639 |
func (m HostEnergy) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 2640 |
if set.Len() == 0 { |
| 2641 |
m.Int64Counter.Add(ctx, incr) |
| 2642 |
return |
| 2643 |
} |
| 2644 |
|
| 2645 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 2646 |
defer func() { |
| 2647 |
*o = (*o)[:0] |
| 2648 |
addOptPool.Put(o) |
| 2649 |
}() |
| 2650 |
|
| 2651 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2652 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 2653 |
} |
| 2654 |
|
| 2655 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 2656 |
// It represents an easily-recognizable name for the hardware component. |
| 2657 |
func (HostEnergy) AttrName(val string) attribute.KeyValue { |
| 2658 |
return attribute.String("hw.name", val) |
| 2659 |
} |
| 2660 |
|
| 2661 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 2662 |
// convention. It represents the unique identifier of the parent component |
| 2663 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 2664 |
func (HostEnergy) AttrParent(val string) attribute.KeyValue { |
| 2665 |
return attribute.String("hw.parent", val) |
| 2666 |
} |
| 2667 |
|
| 2668 |
// HostHeatingMargin is an instrument used to record metric values conforming to |
| 2669 |
// the "hw.host.heating_margin" semantic conventions. It represents the by how |
| 2670 |
// many degrees Celsius the temperature of the physical host can be increased, |
| 2671 |
// before reaching a warning threshold on one of the internal sensors. |
| 2672 |
type HostHeatingMargin struct { |
| 2673 |
metric.Int64Gauge |
| 2674 |
} |
| 2675 |
|
| 2676 |
var newHostHeatingMarginOpts = []metric.Int64GaugeOption{ |
| 2677 |
metric.WithDescription("By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors."), |
| 2678 |
metric.WithUnit("Cel"), |
| 2679 |
} |
| 2680 |
|
| 2681 |
// NewHostHeatingMargin returns a new HostHeatingMargin instrument. |
| 2682 |
func NewHostHeatingMargin( |
| 2683 |
m metric.Meter, |
| 2684 |
opt ...metric.Int64GaugeOption, |
| 2685 |
) (HostHeatingMargin, error) { |
| 2686 |
// Check if the meter is nil. |
| 2687 |
if m == nil { |
| 2688 |
return HostHeatingMargin{noop.Int64Gauge{}}, nil |
| 2689 |
} |
| 2690 |
|
| 2691 |
if len(opt) == 0 { |
| 2692 |
opt = newHostHeatingMarginOpts |
| 2693 |
} else { |
| 2694 |
opt = append(opt, newHostHeatingMarginOpts...) |
| 2695 |
} |
| 2696 |
|
| 2697 |
i, err := m.Int64Gauge( |
| 2698 |
"hw.host.heating_margin", |
| 2699 |
opt..., |
| 2700 |
) |
| 2701 |
if err != nil { |
| 2702 |
return HostHeatingMargin{noop.Int64Gauge{}}, err |
| 2703 |
} |
| 2704 |
return HostHeatingMargin{i}, nil |
| 2705 |
} |
| 2706 |
|
| 2707 |
// Inst returns the underlying metric instrument. |
| 2708 |
func (m HostHeatingMargin) Inst() metric.Int64Gauge { |
| 2709 |
return m.Int64Gauge |
| 2710 |
} |
| 2711 |
|
| 2712 |
// Name returns the semantic convention name of the instrument. |
| 2713 |
func (HostHeatingMargin) Name() string { |
| 2714 |
return "hw.host.heating_margin" |
| 2715 |
} |
| 2716 |
|
| 2717 |
// Unit returns the semantic convention unit of the instrument |
| 2718 |
func (HostHeatingMargin) Unit() string { |
| 2719 |
return "Cel" |
| 2720 |
} |
| 2721 |
|
| 2722 |
// Description returns the semantic convention description of the instrument |
| 2723 |
func (HostHeatingMargin) Description() string { |
| 2724 |
return "By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors." |
| 2725 |
} |
| 2726 |
|
| 2727 |
// Record records val to the current distribution for attrs. |
| 2728 |
// |
| 2729 |
// The id is the an identifier for the hardware component, unique within the |
| 2730 |
// monitored host |
| 2731 |
// |
| 2732 |
// All additional attrs passed are included in the recorded value. |
| 2733 |
func (m HostHeatingMargin) Record( |
| 2734 |
ctx context.Context, |
| 2735 |
val int64, |
| 2736 |
id string, |
| 2737 |
attrs ...attribute.KeyValue, |
| 2738 |
) { |
| 2739 |
if len(attrs) == 0 { |
| 2740 |
m.Int64Gauge.Record(ctx, val) |
| 2741 |
return |
| 2742 |
} |
| 2743 |
|
| 2744 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2745 |
defer func() { |
| 2746 |
*o = (*o)[:0] |
| 2747 |
recOptPool.Put(o) |
| 2748 |
}() |
| 2749 |
|
| 2750 |
*o = append( |
| 2751 |
*o, |
| 2752 |
metric.WithAttributes( |
| 2753 |
append( |
| 2754 |
attrs, |
| 2755 |
attribute.String("hw.id", id), |
| 2756 |
)..., |
| 2757 |
), |
| 2758 |
) |
| 2759 |
|
| 2760 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2761 |
} |
| 2762 |
|
| 2763 |
// RecordSet records val to the current distribution for set. |
| 2764 |
func (m HostHeatingMargin) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2765 |
if set.Len() == 0 { |
| 2766 |
m.Int64Gauge.Record(ctx, val) |
| 2767 |
return |
| 2768 |
} |
| 2769 |
|
| 2770 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2771 |
defer func() { |
| 2772 |
*o = (*o)[:0] |
| 2773 |
recOptPool.Put(o) |
| 2774 |
}() |
| 2775 |
|
| 2776 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2777 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2778 |
} |
| 2779 |
|
| 2780 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 2781 |
// It represents an easily-recognizable name for the hardware component. |
| 2782 |
func (HostHeatingMargin) AttrName(val string) attribute.KeyValue { |
| 2783 |
return attribute.String("hw.name", val) |
| 2784 |
} |
| 2785 |
|
| 2786 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 2787 |
// convention. It represents the unique identifier of the parent component |
| 2788 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 2789 |
func (HostHeatingMargin) AttrParent(val string) attribute.KeyValue { |
| 2790 |
return attribute.String("hw.parent", val) |
| 2791 |
} |
| 2792 |
|
| 2793 |
// HostPower is an instrument used to record metric values conforming to the |
| 2794 |
// "hw.host.power" semantic conventions. It represents the instantaneous power |
| 2795 |
// consumed by the entire physical host in Watts (`hw.host.energy` is preferred). |
| 2796 |
type HostPower struct { |
| 2797 |
metric.Int64Gauge |
| 2798 |
} |
| 2799 |
|
| 2800 |
var newHostPowerOpts = []metric.Int64GaugeOption{ |
| 2801 |
metric.WithDescription("Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)."), |
| 2802 |
metric.WithUnit("W"), |
| 2803 |
} |
| 2804 |
|
| 2805 |
// NewHostPower returns a new HostPower instrument. |
| 2806 |
func NewHostPower( |
| 2807 |
m metric.Meter, |
| 2808 |
opt ...metric.Int64GaugeOption, |
| 2809 |
) (HostPower, error) { |
| 2810 |
// Check if the meter is nil. |
| 2811 |
if m == nil { |
| 2812 |
return HostPower{noop.Int64Gauge{}}, nil |
| 2813 |
} |
| 2814 |
|
| 2815 |
if len(opt) == 0 { |
| 2816 |
opt = newHostPowerOpts |
| 2817 |
} else { |
| 2818 |
opt = append(opt, newHostPowerOpts...) |
| 2819 |
} |
| 2820 |
|
| 2821 |
i, err := m.Int64Gauge( |
| 2822 |
"hw.host.power", |
| 2823 |
opt..., |
| 2824 |
) |
| 2825 |
if err != nil { |
| 2826 |
return HostPower{noop.Int64Gauge{}}, err |
| 2827 |
} |
| 2828 |
return HostPower{i}, nil |
| 2829 |
} |
| 2830 |
|
| 2831 |
// Inst returns the underlying metric instrument. |
| 2832 |
func (m HostPower) Inst() metric.Int64Gauge { |
| 2833 |
return m.Int64Gauge |
| 2834 |
} |
| 2835 |
|
| 2836 |
// Name returns the semantic convention name of the instrument. |
| 2837 |
func (HostPower) Name() string { |
| 2838 |
return "hw.host.power" |
| 2839 |
} |
| 2840 |
|
| 2841 |
// Unit returns the semantic convention unit of the instrument |
| 2842 |
func (HostPower) Unit() string { |
| 2843 |
return "W" |
| 2844 |
} |
| 2845 |
|
| 2846 |
// Description returns the semantic convention description of the instrument |
| 2847 |
func (HostPower) Description() string { |
| 2848 |
return "Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)." |
| 2849 |
} |
| 2850 |
|
| 2851 |
// Record records val to the current distribution for attrs. |
| 2852 |
// |
| 2853 |
// The id is the an identifier for the hardware component, unique within the |
| 2854 |
// monitored host |
| 2855 |
// |
| 2856 |
// All additional attrs passed are included in the recorded value. |
| 2857 |
// |
| 2858 |
// The overall energy usage of a host MUST be reported using the specific |
| 2859 |
// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic |
| 2860 |
// `hw.energy` and `hw.power` described in the previous section, to prevent |
| 2861 |
// summing up overlapping values. |
| 2862 |
func (m HostPower) Record( |
| 2863 |
ctx context.Context, |
| 2864 |
val int64, |
| 2865 |
id string, |
| 2866 |
attrs ...attribute.KeyValue, |
| 2867 |
) { |
| 2868 |
if len(attrs) == 0 { |
| 2869 |
m.Int64Gauge.Record(ctx, val) |
| 2870 |
return |
| 2871 |
} |
| 2872 |
|
| 2873 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2874 |
defer func() { |
| 2875 |
*o = (*o)[:0] |
| 2876 |
recOptPool.Put(o) |
| 2877 |
}() |
| 2878 |
|
| 2879 |
*o = append( |
| 2880 |
*o, |
| 2881 |
metric.WithAttributes( |
| 2882 |
append( |
| 2883 |
attrs, |
| 2884 |
attribute.String("hw.id", id), |
| 2885 |
)..., |
| 2886 |
), |
| 2887 |
) |
| 2888 |
|
| 2889 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2890 |
} |
| 2891 |
|
| 2892 |
// RecordSet records val to the current distribution for set. |
| 2893 |
// |
| 2894 |
// The overall energy usage of a host MUST be reported using the specific |
| 2895 |
// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic |
| 2896 |
// `hw.energy` and `hw.power` described in the previous section, to prevent |
| 2897 |
// summing up overlapping values. |
| 2898 |
func (m HostPower) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 2899 |
if set.Len() == 0 { |
| 2900 |
m.Int64Gauge.Record(ctx, val) |
| 2901 |
return |
| 2902 |
} |
| 2903 |
|
| 2904 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 2905 |
defer func() { |
| 2906 |
*o = (*o)[:0] |
| 2907 |
recOptPool.Put(o) |
| 2908 |
}() |
| 2909 |
|
| 2910 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 2911 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 2912 |
} |
| 2913 |
|
| 2914 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 2915 |
// It represents an easily-recognizable name for the hardware component. |
| 2916 |
func (HostPower) AttrName(val string) attribute.KeyValue { |
| 2917 |
return attribute.String("hw.name", val) |
| 2918 |
} |
| 2919 |
|
| 2920 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 2921 |
// convention. It represents the unique identifier of the parent component |
| 2922 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 2923 |
func (HostPower) AttrParent(val string) attribute.KeyValue { |
| 2924 |
return attribute.String("hw.parent", val) |
| 2925 |
} |
| 2926 |
|
| 2927 |
// LogicalDiskLimit is an instrument used to record metric values conforming to |
| 2928 |
// the "hw.logical_disk.limit" semantic conventions. It represents the size of |
| 2929 |
// the logical disk. |
| 2930 |
type LogicalDiskLimit struct { |
| 2931 |
metric.Int64UpDownCounter |
| 2932 |
} |
| 2933 |
|
| 2934 |
var newLogicalDiskLimitOpts = []metric.Int64UpDownCounterOption{ |
| 2935 |
metric.WithDescription("Size of the logical disk."), |
| 2936 |
metric.WithUnit("By"), |
| 2937 |
} |
| 2938 |
|
| 2939 |
// NewLogicalDiskLimit returns a new LogicalDiskLimit instrument. |
| 2940 |
func NewLogicalDiskLimit( |
| 2941 |
m metric.Meter, |
| 2942 |
opt ...metric.Int64UpDownCounterOption, |
| 2943 |
) (LogicalDiskLimit, error) { |
| 2944 |
// Check if the meter is nil. |
| 2945 |
if m == nil { |
| 2946 |
return LogicalDiskLimit{noop.Int64UpDownCounter{}}, nil |
| 2947 |
} |
| 2948 |
|
| 2949 |
if len(opt) == 0 { |
| 2950 |
opt = newLogicalDiskLimitOpts |
| 2951 |
} else { |
| 2952 |
opt = append(opt, newLogicalDiskLimitOpts...) |
| 2953 |
} |
| 2954 |
|
| 2955 |
i, err := m.Int64UpDownCounter( |
| 2956 |
"hw.logical_disk.limit", |
| 2957 |
opt..., |
| 2958 |
) |
| 2959 |
if err != nil { |
| 2960 |
return LogicalDiskLimit{noop.Int64UpDownCounter{}}, err |
| 2961 |
} |
| 2962 |
return LogicalDiskLimit{i}, nil |
| 2963 |
} |
| 2964 |
|
| 2965 |
// Inst returns the underlying metric instrument. |
| 2966 |
func (m LogicalDiskLimit) Inst() metric.Int64UpDownCounter { |
| 2967 |
return m.Int64UpDownCounter |
| 2968 |
} |
| 2969 |
|
| 2970 |
// Name returns the semantic convention name of the instrument. |
| 2971 |
func (LogicalDiskLimit) Name() string { |
| 2972 |
return "hw.logical_disk.limit" |
| 2973 |
} |
| 2974 |
|
| 2975 |
// Unit returns the semantic convention unit of the instrument |
| 2976 |
func (LogicalDiskLimit) Unit() string { |
| 2977 |
return "By" |
| 2978 |
} |
| 2979 |
|
| 2980 |
// Description returns the semantic convention description of the instrument |
| 2981 |
func (LogicalDiskLimit) Description() string { |
| 2982 |
return "Size of the logical disk." |
| 2983 |
} |
| 2984 |
|
| 2985 |
// Add adds incr to the existing count for attrs. |
| 2986 |
// |
| 2987 |
// The id is the an identifier for the hardware component, unique within the |
| 2988 |
// monitored host |
| 2989 |
// |
| 2990 |
// All additional attrs passed are included in the recorded value. |
| 2991 |
func (m LogicalDiskLimit) Add( |
| 2992 |
ctx context.Context, |
| 2993 |
incr int64, |
| 2994 |
id string, |
| 2995 |
attrs ...attribute.KeyValue, |
| 2996 |
) { |
| 2997 |
if len(attrs) == 0 { |
| 2998 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 2999 |
return |
| 3000 |
} |
| 3001 |
|
| 3002 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3003 |
defer func() { |
| 3004 |
*o = (*o)[:0] |
| 3005 |
addOptPool.Put(o) |
| 3006 |
}() |
| 3007 |
|
| 3008 |
*o = append( |
| 3009 |
*o, |
| 3010 |
metric.WithAttributes( |
| 3011 |
append( |
| 3012 |
attrs, |
| 3013 |
attribute.String("hw.id", id), |
| 3014 |
)..., |
| 3015 |
), |
| 3016 |
) |
| 3017 |
|
| 3018 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3019 |
} |
| 3020 |
|
| 3021 |
// AddSet adds incr to the existing count for set. |
| 3022 |
func (m LogicalDiskLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3023 |
if set.Len() == 0 { |
| 3024 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3025 |
return |
| 3026 |
} |
| 3027 |
|
| 3028 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3029 |
defer func() { |
| 3030 |
*o = (*o)[:0] |
| 3031 |
addOptPool.Put(o) |
| 3032 |
}() |
| 3033 |
|
| 3034 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3035 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3036 |
} |
| 3037 |
|
| 3038 |
// AttrLogicalDiskRaidLevel returns an optional attribute for the |
| 3039 |
// "hw.logical_disk.raid_level" semantic convention. It represents the RAID Level |
| 3040 |
// of the logical disk. |
| 3041 |
func (LogicalDiskLimit) AttrLogicalDiskRaidLevel(val string) attribute.KeyValue { |
| 3042 |
return attribute.String("hw.logical_disk.raid_level", val) |
| 3043 |
} |
| 3044 |
|
| 3045 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 3046 |
// It represents an easily-recognizable name for the hardware component. |
| 3047 |
func (LogicalDiskLimit) AttrName(val string) attribute.KeyValue { |
| 3048 |
return attribute.String("hw.name", val) |
| 3049 |
} |
| 3050 |
|
| 3051 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 3052 |
// convention. It represents the unique identifier of the parent component |
| 3053 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 3054 |
func (LogicalDiskLimit) AttrParent(val string) attribute.KeyValue { |
| 3055 |
return attribute.String("hw.parent", val) |
| 3056 |
} |
| 3057 |
|
| 3058 |
// LogicalDiskUsage is an instrument used to record metric values conforming to |
| 3059 |
// the "hw.logical_disk.usage" semantic conventions. It represents the logical |
| 3060 |
// disk space usage. |
| 3061 |
type LogicalDiskUsage struct { |
| 3062 |
metric.Int64UpDownCounter |
| 3063 |
} |
| 3064 |
|
| 3065 |
var newLogicalDiskUsageOpts = []metric.Int64UpDownCounterOption{ |
| 3066 |
metric.WithDescription("Logical disk space usage."), |
| 3067 |
metric.WithUnit("By"), |
| 3068 |
} |
| 3069 |
|
| 3070 |
// NewLogicalDiskUsage returns a new LogicalDiskUsage instrument. |
| 3071 |
func NewLogicalDiskUsage( |
| 3072 |
m metric.Meter, |
| 3073 |
opt ...metric.Int64UpDownCounterOption, |
| 3074 |
) (LogicalDiskUsage, error) { |
| 3075 |
// Check if the meter is nil. |
| 3076 |
if m == nil { |
| 3077 |
return LogicalDiskUsage{noop.Int64UpDownCounter{}}, nil |
| 3078 |
} |
| 3079 |
|
| 3080 |
if len(opt) == 0 { |
| 3081 |
opt = newLogicalDiskUsageOpts |
| 3082 |
} else { |
| 3083 |
opt = append(opt, newLogicalDiskUsageOpts...) |
| 3084 |
} |
| 3085 |
|
| 3086 |
i, err := m.Int64UpDownCounter( |
| 3087 |
"hw.logical_disk.usage", |
| 3088 |
opt..., |
| 3089 |
) |
| 3090 |
if err != nil { |
| 3091 |
return LogicalDiskUsage{noop.Int64UpDownCounter{}}, err |
| 3092 |
} |
| 3093 |
return LogicalDiskUsage{i}, nil |
| 3094 |
} |
| 3095 |
|
| 3096 |
// Inst returns the underlying metric instrument. |
| 3097 |
func (m LogicalDiskUsage) Inst() metric.Int64UpDownCounter { |
| 3098 |
return m.Int64UpDownCounter |
| 3099 |
} |
| 3100 |
|
| 3101 |
// Name returns the semantic convention name of the instrument. |
| 3102 |
func (LogicalDiskUsage) Name() string { |
| 3103 |
return "hw.logical_disk.usage" |
| 3104 |
} |
| 3105 |
|
| 3106 |
// Unit returns the semantic convention unit of the instrument |
| 3107 |
func (LogicalDiskUsage) Unit() string { |
| 3108 |
return "By" |
| 3109 |
} |
| 3110 |
|
| 3111 |
// Description returns the semantic convention description of the instrument |
| 3112 |
func (LogicalDiskUsage) Description() string { |
| 3113 |
return "Logical disk space usage." |
| 3114 |
} |
| 3115 |
|
| 3116 |
// Add adds incr to the existing count for attrs. |
| 3117 |
// |
| 3118 |
// The id is the an identifier for the hardware component, unique within the |
| 3119 |
// monitored host |
| 3120 |
// |
| 3121 |
// The logicalDiskState is the state of the logical disk space usage |
| 3122 |
// |
| 3123 |
// All additional attrs passed are included in the recorded value. |
| 3124 |
func (m LogicalDiskUsage) Add( |
| 3125 |
ctx context.Context, |
| 3126 |
incr int64, |
| 3127 |
id string, |
| 3128 |
logicalDiskState LogicalDiskStateAttr, |
| 3129 |
attrs ...attribute.KeyValue, |
| 3130 |
) { |
| 3131 |
if len(attrs) == 0 { |
| 3132 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3133 |
return |
| 3134 |
} |
| 3135 |
|
| 3136 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3137 |
defer func() { |
| 3138 |
*o = (*o)[:0] |
| 3139 |
addOptPool.Put(o) |
| 3140 |
}() |
| 3141 |
|
| 3142 |
*o = append( |
| 3143 |
*o, |
| 3144 |
metric.WithAttributes( |
| 3145 |
append( |
| 3146 |
attrs, |
| 3147 |
attribute.String("hw.id", id), |
| 3148 |
attribute.String("hw.logical_disk.state", string(logicalDiskState)), |
| 3149 |
)..., |
| 3150 |
), |
| 3151 |
) |
| 3152 |
|
| 3153 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3154 |
} |
| 3155 |
|
| 3156 |
// AddSet adds incr to the existing count for set. |
| 3157 |
func (m LogicalDiskUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3158 |
if set.Len() == 0 { |
| 3159 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3160 |
return |
| 3161 |
} |
| 3162 |
|
| 3163 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3164 |
defer func() { |
| 3165 |
*o = (*o)[:0] |
| 3166 |
addOptPool.Put(o) |
| 3167 |
}() |
| 3168 |
|
| 3169 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3170 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3171 |
} |
| 3172 |
|
| 3173 |
// AttrLogicalDiskRaidLevel returns an optional attribute for the |
| 3174 |
// "hw.logical_disk.raid_level" semantic convention. It represents the RAID Level |
| 3175 |
// of the logical disk. |
| 3176 |
func (LogicalDiskUsage) AttrLogicalDiskRaidLevel(val string) attribute.KeyValue { |
| 3177 |
return attribute.String("hw.logical_disk.raid_level", val) |
| 3178 |
} |
| 3179 |
|
| 3180 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 3181 |
// It represents an easily-recognizable name for the hardware component. |
| 3182 |
func (LogicalDiskUsage) AttrName(val string) attribute.KeyValue { |
| 3183 |
return attribute.String("hw.name", val) |
| 3184 |
} |
| 3185 |
|
| 3186 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 3187 |
// convention. It represents the unique identifier of the parent component |
| 3188 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 3189 |
func (LogicalDiskUsage) AttrParent(val string) attribute.KeyValue { |
| 3190 |
return attribute.String("hw.parent", val) |
| 3191 |
} |
| 3192 |
|
| 3193 |
// LogicalDiskUtilization is an instrument used to record metric values |
| 3194 |
// conforming to the "hw.logical_disk.utilization" semantic conventions. It |
| 3195 |
// represents the logical disk space utilization as a fraction. |
| 3196 |
type LogicalDiskUtilization struct { |
| 3197 |
metric.Int64Gauge |
| 3198 |
} |
| 3199 |
|
| 3200 |
var newLogicalDiskUtilizationOpts = []metric.Int64GaugeOption{ |
| 3201 |
metric.WithDescription("Logical disk space utilization as a fraction."), |
| 3202 |
metric.WithUnit("1"), |
| 3203 |
} |
| 3204 |
|
| 3205 |
// NewLogicalDiskUtilization returns a new LogicalDiskUtilization instrument. |
| 3206 |
func NewLogicalDiskUtilization( |
| 3207 |
m metric.Meter, |
| 3208 |
opt ...metric.Int64GaugeOption, |
| 3209 |
) (LogicalDiskUtilization, error) { |
| 3210 |
// Check if the meter is nil. |
| 3211 |
if m == nil { |
| 3212 |
return LogicalDiskUtilization{noop.Int64Gauge{}}, nil |
| 3213 |
} |
| 3214 |
|
| 3215 |
if len(opt) == 0 { |
| 3216 |
opt = newLogicalDiskUtilizationOpts |
| 3217 |
} else { |
| 3218 |
opt = append(opt, newLogicalDiskUtilizationOpts...) |
| 3219 |
} |
| 3220 |
|
| 3221 |
i, err := m.Int64Gauge( |
| 3222 |
"hw.logical_disk.utilization", |
| 3223 |
opt..., |
| 3224 |
) |
| 3225 |
if err != nil { |
| 3226 |
return LogicalDiskUtilization{noop.Int64Gauge{}}, err |
| 3227 |
} |
| 3228 |
return LogicalDiskUtilization{i}, nil |
| 3229 |
} |
| 3230 |
|
| 3231 |
// Inst returns the underlying metric instrument. |
| 3232 |
func (m LogicalDiskUtilization) Inst() metric.Int64Gauge { |
| 3233 |
return m.Int64Gauge |
| 3234 |
} |
| 3235 |
|
| 3236 |
// Name returns the semantic convention name of the instrument. |
| 3237 |
func (LogicalDiskUtilization) Name() string { |
| 3238 |
return "hw.logical_disk.utilization" |
| 3239 |
} |
| 3240 |
|
| 3241 |
// Unit returns the semantic convention unit of the instrument |
| 3242 |
func (LogicalDiskUtilization) Unit() string { |
| 3243 |
return "1" |
| 3244 |
} |
| 3245 |
|
| 3246 |
// Description returns the semantic convention description of the instrument |
| 3247 |
func (LogicalDiskUtilization) Description() string { |
| 3248 |
return "Logical disk space utilization as a fraction." |
| 3249 |
} |
| 3250 |
|
| 3251 |
// Record records val to the current distribution for attrs. |
| 3252 |
// |
| 3253 |
// The id is the an identifier for the hardware component, unique within the |
| 3254 |
// monitored host |
| 3255 |
// |
| 3256 |
// The logicalDiskState is the state of the logical disk space usage |
| 3257 |
// |
| 3258 |
// All additional attrs passed are included in the recorded value. |
| 3259 |
func (m LogicalDiskUtilization) Record( |
| 3260 |
ctx context.Context, |
| 3261 |
val int64, |
| 3262 |
id string, |
| 3263 |
logicalDiskState LogicalDiskStateAttr, |
| 3264 |
attrs ...attribute.KeyValue, |
| 3265 |
) { |
| 3266 |
if len(attrs) == 0 { |
| 3267 |
m.Int64Gauge.Record(ctx, val) |
| 3268 |
return |
| 3269 |
} |
| 3270 |
|
| 3271 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 3272 |
defer func() { |
| 3273 |
*o = (*o)[:0] |
| 3274 |
recOptPool.Put(o) |
| 3275 |
}() |
| 3276 |
|
| 3277 |
*o = append( |
| 3278 |
*o, |
| 3279 |
metric.WithAttributes( |
| 3280 |
append( |
| 3281 |
attrs, |
| 3282 |
attribute.String("hw.id", id), |
| 3283 |
attribute.String("hw.logical_disk.state", string(logicalDiskState)), |
| 3284 |
)..., |
| 3285 |
), |
| 3286 |
) |
| 3287 |
|
| 3288 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 3289 |
} |
| 3290 |
|
| 3291 |
// RecordSet records val to the current distribution for set. |
| 3292 |
func (m LogicalDiskUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 3293 |
if set.Len() == 0 { |
| 3294 |
m.Int64Gauge.Record(ctx, val) |
| 3295 |
return |
| 3296 |
} |
| 3297 |
|
| 3298 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 3299 |
defer func() { |
| 3300 |
*o = (*o)[:0] |
| 3301 |
recOptPool.Put(o) |
| 3302 |
}() |
| 3303 |
|
| 3304 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3305 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 3306 |
} |
| 3307 |
|
| 3308 |
// AttrLogicalDiskRaidLevel returns an optional attribute for the |
| 3309 |
// "hw.logical_disk.raid_level" semantic convention. It represents the RAID Level |
| 3310 |
// of the logical disk. |
| 3311 |
func (LogicalDiskUtilization) AttrLogicalDiskRaidLevel(val string) attribute.KeyValue { |
| 3312 |
return attribute.String("hw.logical_disk.raid_level", val) |
| 3313 |
} |
| 3314 |
|
| 3315 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 3316 |
// It represents an easily-recognizable name for the hardware component. |
| 3317 |
func (LogicalDiskUtilization) AttrName(val string) attribute.KeyValue { |
| 3318 |
return attribute.String("hw.name", val) |
| 3319 |
} |
| 3320 |
|
| 3321 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 3322 |
// convention. It represents the unique identifier of the parent component |
| 3323 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 3324 |
func (LogicalDiskUtilization) AttrParent(val string) attribute.KeyValue { |
| 3325 |
return attribute.String("hw.parent", val) |
| 3326 |
} |
| 3327 |
|
| 3328 |
// MemorySize is an instrument used to record metric values conforming to the |
| 3329 |
// "hw.memory.size" semantic conventions. It represents the size of the memory |
| 3330 |
// module. |
| 3331 |
type MemorySize struct { |
| 3332 |
metric.Int64UpDownCounter |
| 3333 |
} |
| 3334 |
|
| 3335 |
var newMemorySizeOpts = []metric.Int64UpDownCounterOption{ |
| 3336 |
metric.WithDescription("Size of the memory module."), |
| 3337 |
metric.WithUnit("By"), |
| 3338 |
} |
| 3339 |
|
| 3340 |
// NewMemorySize returns a new MemorySize instrument. |
| 3341 |
func NewMemorySize( |
| 3342 |
m metric.Meter, |
| 3343 |
opt ...metric.Int64UpDownCounterOption, |
| 3344 |
) (MemorySize, error) { |
| 3345 |
// Check if the meter is nil. |
| 3346 |
if m == nil { |
| 3347 |
return MemorySize{noop.Int64UpDownCounter{}}, nil |
| 3348 |
} |
| 3349 |
|
| 3350 |
if len(opt) == 0 { |
| 3351 |
opt = newMemorySizeOpts |
| 3352 |
} else { |
| 3353 |
opt = append(opt, newMemorySizeOpts...) |
| 3354 |
} |
| 3355 |
|
| 3356 |
i, err := m.Int64UpDownCounter( |
| 3357 |
"hw.memory.size", |
| 3358 |
opt..., |
| 3359 |
) |
| 3360 |
if err != nil { |
| 3361 |
return MemorySize{noop.Int64UpDownCounter{}}, err |
| 3362 |
} |
| 3363 |
return MemorySize{i}, nil |
| 3364 |
} |
| 3365 |
|
| 3366 |
// Inst returns the underlying metric instrument. |
| 3367 |
func (m MemorySize) Inst() metric.Int64UpDownCounter { |
| 3368 |
return m.Int64UpDownCounter |
| 3369 |
} |
| 3370 |
|
| 3371 |
// Name returns the semantic convention name of the instrument. |
| 3372 |
func (MemorySize) Name() string { |
| 3373 |
return "hw.memory.size" |
| 3374 |
} |
| 3375 |
|
| 3376 |
// Unit returns the semantic convention unit of the instrument |
| 3377 |
func (MemorySize) Unit() string { |
| 3378 |
return "By" |
| 3379 |
} |
| 3380 |
|
| 3381 |
// Description returns the semantic convention description of the instrument |
| 3382 |
func (MemorySize) Description() string { |
| 3383 |
return "Size of the memory module." |
| 3384 |
} |
| 3385 |
|
| 3386 |
// Add adds incr to the existing count for attrs. |
| 3387 |
// |
| 3388 |
// The id is the an identifier for the hardware component, unique within the |
| 3389 |
// monitored host |
| 3390 |
// |
| 3391 |
// All additional attrs passed are included in the recorded value. |
| 3392 |
func (m MemorySize) Add( |
| 3393 |
ctx context.Context, |
| 3394 |
incr int64, |
| 3395 |
id string, |
| 3396 |
attrs ...attribute.KeyValue, |
| 3397 |
) { |
| 3398 |
if len(attrs) == 0 { |
| 3399 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3400 |
return |
| 3401 |
} |
| 3402 |
|
| 3403 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3404 |
defer func() { |
| 3405 |
*o = (*o)[:0] |
| 3406 |
addOptPool.Put(o) |
| 3407 |
}() |
| 3408 |
|
| 3409 |
*o = append( |
| 3410 |
*o, |
| 3411 |
metric.WithAttributes( |
| 3412 |
append( |
| 3413 |
attrs, |
| 3414 |
attribute.String("hw.id", id), |
| 3415 |
)..., |
| 3416 |
), |
| 3417 |
) |
| 3418 |
|
| 3419 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3420 |
} |
| 3421 |
|
| 3422 |
// AddSet adds incr to the existing count for set. |
| 3423 |
func (m MemorySize) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3424 |
if set.Len() == 0 { |
| 3425 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3426 |
return |
| 3427 |
} |
| 3428 |
|
| 3429 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3430 |
defer func() { |
| 3431 |
*o = (*o)[:0] |
| 3432 |
addOptPool.Put(o) |
| 3433 |
}() |
| 3434 |
|
| 3435 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3436 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3437 |
} |
| 3438 |
|
| 3439 |
// AttrMemoryType returns an optional attribute for the "hw.memory.type" semantic |
| 3440 |
// convention. It represents the type of the memory module. |
| 3441 |
func (MemorySize) AttrMemoryType(val string) attribute.KeyValue { |
| 3442 |
return attribute.String("hw.memory.type", val) |
| 3443 |
} |
| 3444 |
|
| 3445 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 3446 |
// convention. It represents the descriptive model name of the hardware |
| 3447 |
// component. |
| 3448 |
func (MemorySize) AttrModel(val string) attribute.KeyValue { |
| 3449 |
return attribute.String("hw.model", val) |
| 3450 |
} |
| 3451 |
|
| 3452 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 3453 |
// It represents an easily-recognizable name for the hardware component. |
| 3454 |
func (MemorySize) AttrName(val string) attribute.KeyValue { |
| 3455 |
return attribute.String("hw.name", val) |
| 3456 |
} |
| 3457 |
|
| 3458 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 3459 |
// convention. It represents the unique identifier of the parent component |
| 3460 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 3461 |
func (MemorySize) AttrParent(val string) attribute.KeyValue { |
| 3462 |
return attribute.String("hw.parent", val) |
| 3463 |
} |
| 3464 |
|
| 3465 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 3466 |
// semantic convention. It represents the serial number of the hardware |
| 3467 |
// component. |
| 3468 |
func (MemorySize) AttrSerialNumber(val string) attribute.KeyValue { |
| 3469 |
return attribute.String("hw.serial_number", val) |
| 3470 |
} |
| 3471 |
|
| 3472 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 3473 |
// convention. It represents the vendor name of the hardware component. |
| 3474 |
func (MemorySize) AttrVendor(val string) attribute.KeyValue { |
| 3475 |
return attribute.String("hw.vendor", val) |
| 3476 |
} |
| 3477 |
|
| 3478 |
// NetworkBandwidthLimit is an instrument used to record metric values conforming |
| 3479 |
// to the "hw.network.bandwidth.limit" semantic conventions. It represents the |
| 3480 |
// link speed. |
| 3481 |
type NetworkBandwidthLimit struct { |
| 3482 |
metric.Int64UpDownCounter |
| 3483 |
} |
| 3484 |
|
| 3485 |
var newNetworkBandwidthLimitOpts = []metric.Int64UpDownCounterOption{ |
| 3486 |
metric.WithDescription("Link speed."), |
| 3487 |
metric.WithUnit("By/s"), |
| 3488 |
} |
| 3489 |
|
| 3490 |
// NewNetworkBandwidthLimit returns a new NetworkBandwidthLimit instrument. |
| 3491 |
func NewNetworkBandwidthLimit( |
| 3492 |
m metric.Meter, |
| 3493 |
opt ...metric.Int64UpDownCounterOption, |
| 3494 |
) (NetworkBandwidthLimit, error) { |
| 3495 |
// Check if the meter is nil. |
| 3496 |
if m == nil { |
| 3497 |
return NetworkBandwidthLimit{noop.Int64UpDownCounter{}}, nil |
| 3498 |
} |
| 3499 |
|
| 3500 |
if len(opt) == 0 { |
| 3501 |
opt = newNetworkBandwidthLimitOpts |
| 3502 |
} else { |
| 3503 |
opt = append(opt, newNetworkBandwidthLimitOpts...) |
| 3504 |
} |
| 3505 |
|
| 3506 |
i, err := m.Int64UpDownCounter( |
| 3507 |
"hw.network.bandwidth.limit", |
| 3508 |
opt..., |
| 3509 |
) |
| 3510 |
if err != nil { |
| 3511 |
return NetworkBandwidthLimit{noop.Int64UpDownCounter{}}, err |
| 3512 |
} |
| 3513 |
return NetworkBandwidthLimit{i}, nil |
| 3514 |
} |
| 3515 |
|
| 3516 |
// Inst returns the underlying metric instrument. |
| 3517 |
func (m NetworkBandwidthLimit) Inst() metric.Int64UpDownCounter { |
| 3518 |
return m.Int64UpDownCounter |
| 3519 |
} |
| 3520 |
|
| 3521 |
// Name returns the semantic convention name of the instrument. |
| 3522 |
func (NetworkBandwidthLimit) Name() string { |
| 3523 |
return "hw.network.bandwidth.limit" |
| 3524 |
} |
| 3525 |
|
| 3526 |
// Unit returns the semantic convention unit of the instrument |
| 3527 |
func (NetworkBandwidthLimit) Unit() string { |
| 3528 |
return "By/s" |
| 3529 |
} |
| 3530 |
|
| 3531 |
// Description returns the semantic convention description of the instrument |
| 3532 |
func (NetworkBandwidthLimit) Description() string { |
| 3533 |
return "Link speed." |
| 3534 |
} |
| 3535 |
|
| 3536 |
// Add adds incr to the existing count for attrs. |
| 3537 |
// |
| 3538 |
// The id is the an identifier for the hardware component, unique within the |
| 3539 |
// monitored host |
| 3540 |
// |
| 3541 |
// All additional attrs passed are included in the recorded value. |
| 3542 |
func (m NetworkBandwidthLimit) Add( |
| 3543 |
ctx context.Context, |
| 3544 |
incr int64, |
| 3545 |
id string, |
| 3546 |
attrs ...attribute.KeyValue, |
| 3547 |
) { |
| 3548 |
if len(attrs) == 0 { |
| 3549 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3550 |
return |
| 3551 |
} |
| 3552 |
|
| 3553 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3554 |
defer func() { |
| 3555 |
*o = (*o)[:0] |
| 3556 |
addOptPool.Put(o) |
| 3557 |
}() |
| 3558 |
|
| 3559 |
*o = append( |
| 3560 |
*o, |
| 3561 |
metric.WithAttributes( |
| 3562 |
append( |
| 3563 |
attrs, |
| 3564 |
attribute.String("hw.id", id), |
| 3565 |
)..., |
| 3566 |
), |
| 3567 |
) |
| 3568 |
|
| 3569 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3570 |
} |
| 3571 |
|
| 3572 |
// AddSet adds incr to the existing count for set. |
| 3573 |
func (m NetworkBandwidthLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3574 |
if set.Len() == 0 { |
| 3575 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 3576 |
return |
| 3577 |
} |
| 3578 |
|
| 3579 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3580 |
defer func() { |
| 3581 |
*o = (*o)[:0] |
| 3582 |
addOptPool.Put(o) |
| 3583 |
}() |
| 3584 |
|
| 3585 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3586 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 3587 |
} |
| 3588 |
|
| 3589 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 3590 |
// convention. It represents the descriptive model name of the hardware |
| 3591 |
// component. |
| 3592 |
func (NetworkBandwidthLimit) AttrModel(val string) attribute.KeyValue { |
| 3593 |
return attribute.String("hw.model", val) |
| 3594 |
} |
| 3595 |
|
| 3596 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 3597 |
// It represents an easily-recognizable name for the hardware component. |
| 3598 |
func (NetworkBandwidthLimit) AttrName(val string) attribute.KeyValue { |
| 3599 |
return attribute.String("hw.name", val) |
| 3600 |
} |
| 3601 |
|
| 3602 |
// AttrNetworkLogicalAddresses returns an optional attribute for the |
| 3603 |
// "hw.network.logical_addresses" semantic convention. It represents the logical |
| 3604 |
// addresses of the adapter (e.g. IP address, or WWPN). |
| 3605 |
func (NetworkBandwidthLimit) AttrNetworkLogicalAddresses(val ...string) attribute.KeyValue { |
| 3606 |
return attribute.StringSlice("hw.network.logical_addresses", val) |
| 3607 |
} |
| 3608 |
|
| 3609 |
// AttrNetworkPhysicalAddress returns an optional attribute for the |
| 3610 |
// "hw.network.physical_address" semantic convention. It represents the physical |
| 3611 |
// address of the adapter (e.g. MAC address, or WWNN). |
| 3612 |
func (NetworkBandwidthLimit) AttrNetworkPhysicalAddress(val string) attribute.KeyValue { |
| 3613 |
return attribute.String("hw.network.physical_address", val) |
| 3614 |
} |
| 3615 |
|
| 3616 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 3617 |
// convention. It represents the unique identifier of the parent component |
| 3618 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 3619 |
func (NetworkBandwidthLimit) AttrParent(val string) attribute.KeyValue { |
| 3620 |
return attribute.String("hw.parent", val) |
| 3621 |
} |
| 3622 |
|
| 3623 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 3624 |
// semantic convention. It represents the serial number of the hardware |
| 3625 |
// component. |
| 3626 |
func (NetworkBandwidthLimit) AttrSerialNumber(val string) attribute.KeyValue { |
| 3627 |
return attribute.String("hw.serial_number", val) |
| 3628 |
} |
| 3629 |
|
| 3630 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 3631 |
// convention. It represents the vendor name of the hardware component. |
| 3632 |
func (NetworkBandwidthLimit) AttrVendor(val string) attribute.KeyValue { |
| 3633 |
return attribute.String("hw.vendor", val) |
| 3634 |
} |
| 3635 |
|
| 3636 |
// NetworkBandwidthUtilization is an instrument used to record metric values |
| 3637 |
// conforming to the "hw.network.bandwidth.utilization" semantic conventions. It |
| 3638 |
// represents the utilization of the network bandwidth as a fraction. |
| 3639 |
type NetworkBandwidthUtilization struct { |
| 3640 |
metric.Int64Gauge |
| 3641 |
} |
| 3642 |
|
| 3643 |
var newNetworkBandwidthUtilizationOpts = []metric.Int64GaugeOption{ |
| 3644 |
metric.WithDescription("Utilization of the network bandwidth as a fraction."), |
| 3645 |
metric.WithUnit("1"), |
| 3646 |
} |
| 3647 |
|
| 3648 |
// NewNetworkBandwidthUtilization returns a new NetworkBandwidthUtilization |
| 3649 |
// instrument. |
| 3650 |
func NewNetworkBandwidthUtilization( |
| 3651 |
m metric.Meter, |
| 3652 |
opt ...metric.Int64GaugeOption, |
| 3653 |
) (NetworkBandwidthUtilization, error) { |
| 3654 |
// Check if the meter is nil. |
| 3655 |
if m == nil { |
| 3656 |
return NetworkBandwidthUtilization{noop.Int64Gauge{}}, nil |
| 3657 |
} |
| 3658 |
|
| 3659 |
if len(opt) == 0 { |
| 3660 |
opt = newNetworkBandwidthUtilizationOpts |
| 3661 |
} else { |
| 3662 |
opt = append(opt, newNetworkBandwidthUtilizationOpts...) |
| 3663 |
} |
| 3664 |
|
| 3665 |
i, err := m.Int64Gauge( |
| 3666 |
"hw.network.bandwidth.utilization", |
| 3667 |
opt..., |
| 3668 |
) |
| 3669 |
if err != nil { |
| 3670 |
return NetworkBandwidthUtilization{noop.Int64Gauge{}}, err |
| 3671 |
} |
| 3672 |
return NetworkBandwidthUtilization{i}, nil |
| 3673 |
} |
| 3674 |
|
| 3675 |
// Inst returns the underlying metric instrument. |
| 3676 |
func (m NetworkBandwidthUtilization) Inst() metric.Int64Gauge { |
| 3677 |
return m.Int64Gauge |
| 3678 |
} |
| 3679 |
|
| 3680 |
// Name returns the semantic convention name of the instrument. |
| 3681 |
func (NetworkBandwidthUtilization) Name() string { |
| 3682 |
return "hw.network.bandwidth.utilization" |
| 3683 |
} |
| 3684 |
|
| 3685 |
// Unit returns the semantic convention unit of the instrument |
| 3686 |
func (NetworkBandwidthUtilization) Unit() string { |
| 3687 |
return "1" |
| 3688 |
} |
| 3689 |
|
| 3690 |
// Description returns the semantic convention description of the instrument |
| 3691 |
func (NetworkBandwidthUtilization) Description() string { |
| 3692 |
return "Utilization of the network bandwidth as a fraction." |
| 3693 |
} |
| 3694 |
|
| 3695 |
// Record records val to the current distribution for attrs. |
| 3696 |
// |
| 3697 |
// The id is the an identifier for the hardware component, unique within the |
| 3698 |
// monitored host |
| 3699 |
// |
| 3700 |
// All additional attrs passed are included in the recorded value. |
| 3701 |
func (m NetworkBandwidthUtilization) Record( |
| 3702 |
ctx context.Context, |
| 3703 |
val int64, |
| 3704 |
id string, |
| 3705 |
attrs ...attribute.KeyValue, |
| 3706 |
) { |
| 3707 |
if len(attrs) == 0 { |
| 3708 |
m.Int64Gauge.Record(ctx, val) |
| 3709 |
return |
| 3710 |
} |
| 3711 |
|
| 3712 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 3713 |
defer func() { |
| 3714 |
*o = (*o)[:0] |
| 3715 |
recOptPool.Put(o) |
| 3716 |
}() |
| 3717 |
|
| 3718 |
*o = append( |
| 3719 |
*o, |
| 3720 |
metric.WithAttributes( |
| 3721 |
append( |
| 3722 |
attrs, |
| 3723 |
attribute.String("hw.id", id), |
| 3724 |
)..., |
| 3725 |
), |
| 3726 |
) |
| 3727 |
|
| 3728 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 3729 |
} |
| 3730 |
|
| 3731 |
// RecordSet records val to the current distribution for set. |
| 3732 |
func (m NetworkBandwidthUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 3733 |
if set.Len() == 0 { |
| 3734 |
m.Int64Gauge.Record(ctx, val) |
| 3735 |
return |
| 3736 |
} |
| 3737 |
|
| 3738 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 3739 |
defer func() { |
| 3740 |
*o = (*o)[:0] |
| 3741 |
recOptPool.Put(o) |
| 3742 |
}() |
| 3743 |
|
| 3744 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3745 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 3746 |
} |
| 3747 |
|
| 3748 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 3749 |
// convention. It represents the descriptive model name of the hardware |
| 3750 |
// component. |
| 3751 |
func (NetworkBandwidthUtilization) AttrModel(val string) attribute.KeyValue { |
| 3752 |
return attribute.String("hw.model", val) |
| 3753 |
} |
| 3754 |
|
| 3755 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 3756 |
// It represents an easily-recognizable name for the hardware component. |
| 3757 |
func (NetworkBandwidthUtilization) AttrName(val string) attribute.KeyValue { |
| 3758 |
return attribute.String("hw.name", val) |
| 3759 |
} |
| 3760 |
|
| 3761 |
// AttrNetworkLogicalAddresses returns an optional attribute for the |
| 3762 |
// "hw.network.logical_addresses" semantic convention. It represents the logical |
| 3763 |
// addresses of the adapter (e.g. IP address, or WWPN). |
| 3764 |
func (NetworkBandwidthUtilization) AttrNetworkLogicalAddresses(val ...string) attribute.KeyValue { |
| 3765 |
return attribute.StringSlice("hw.network.logical_addresses", val) |
| 3766 |
} |
| 3767 |
|
| 3768 |
// AttrNetworkPhysicalAddress returns an optional attribute for the |
| 3769 |
// "hw.network.physical_address" semantic convention. It represents the physical |
| 3770 |
// address of the adapter (e.g. MAC address, or WWNN). |
| 3771 |
func (NetworkBandwidthUtilization) AttrNetworkPhysicalAddress(val string) attribute.KeyValue { |
| 3772 |
return attribute.String("hw.network.physical_address", val) |
| 3773 |
} |
| 3774 |
|
| 3775 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 3776 |
// convention. It represents the unique identifier of the parent component |
| 3777 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 3778 |
func (NetworkBandwidthUtilization) AttrParent(val string) attribute.KeyValue { |
| 3779 |
return attribute.String("hw.parent", val) |
| 3780 |
} |
| 3781 |
|
| 3782 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 3783 |
// semantic convention. It represents the serial number of the hardware |
| 3784 |
// component. |
| 3785 |
func (NetworkBandwidthUtilization) AttrSerialNumber(val string) attribute.KeyValue { |
| 3786 |
return attribute.String("hw.serial_number", val) |
| 3787 |
} |
| 3788 |
|
| 3789 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 3790 |
// convention. It represents the vendor name of the hardware component. |
| 3791 |
func (NetworkBandwidthUtilization) AttrVendor(val string) attribute.KeyValue { |
| 3792 |
return attribute.String("hw.vendor", val) |
| 3793 |
} |
| 3794 |
|
| 3795 |
// NetworkIO is an instrument used to record metric values conforming to the |
| 3796 |
// "hw.network.io" semantic conventions. It represents the received and |
| 3797 |
// transmitted network traffic in bytes. |
| 3798 |
type NetworkIO struct { |
| 3799 |
metric.Int64Counter |
| 3800 |
} |
| 3801 |
|
| 3802 |
var newNetworkIOOpts = []metric.Int64CounterOption{ |
| 3803 |
metric.WithDescription("Received and transmitted network traffic in bytes."), |
| 3804 |
metric.WithUnit("By"), |
| 3805 |
} |
| 3806 |
|
| 3807 |
// NewNetworkIO returns a new NetworkIO instrument. |
| 3808 |
func NewNetworkIO( |
| 3809 |
m metric.Meter, |
| 3810 |
opt ...metric.Int64CounterOption, |
| 3811 |
) (NetworkIO, error) { |
| 3812 |
// Check if the meter is nil. |
| 3813 |
if m == nil { |
| 3814 |
return NetworkIO{noop.Int64Counter{}}, nil |
| 3815 |
} |
| 3816 |
|
| 3817 |
if len(opt) == 0 { |
| 3818 |
opt = newNetworkIOOpts |
| 3819 |
} else { |
| 3820 |
opt = append(opt, newNetworkIOOpts...) |
| 3821 |
} |
| 3822 |
|
| 3823 |
i, err := m.Int64Counter( |
| 3824 |
"hw.network.io", |
| 3825 |
opt..., |
| 3826 |
) |
| 3827 |
if err != nil { |
| 3828 |
return NetworkIO{noop.Int64Counter{}}, err |
| 3829 |
} |
| 3830 |
return NetworkIO{i}, nil |
| 3831 |
} |
| 3832 |
|
| 3833 |
// Inst returns the underlying metric instrument. |
| 3834 |
func (m NetworkIO) Inst() metric.Int64Counter { |
| 3835 |
return m.Int64Counter |
| 3836 |
} |
| 3837 |
|
| 3838 |
// Name returns the semantic convention name of the instrument. |
| 3839 |
func (NetworkIO) Name() string { |
| 3840 |
return "hw.network.io" |
| 3841 |
} |
| 3842 |
|
| 3843 |
// Unit returns the semantic convention unit of the instrument |
| 3844 |
func (NetworkIO) Unit() string { |
| 3845 |
return "By" |
| 3846 |
} |
| 3847 |
|
| 3848 |
// Description returns the semantic convention description of the instrument |
| 3849 |
func (NetworkIO) Description() string { |
| 3850 |
return "Received and transmitted network traffic in bytes." |
| 3851 |
} |
| 3852 |
|
| 3853 |
// Add adds incr to the existing count for attrs. |
| 3854 |
// |
| 3855 |
// The id is the an identifier for the hardware component, unique within the |
| 3856 |
// monitored host |
| 3857 |
// |
| 3858 |
// The networkIoDirection is the the network IO operation direction. |
| 3859 |
// |
| 3860 |
// All additional attrs passed are included in the recorded value. |
| 3861 |
func (m NetworkIO) Add( |
| 3862 |
ctx context.Context, |
| 3863 |
incr int64, |
| 3864 |
id string, |
| 3865 |
networkIoDirection NetworkIODirectionAttr, |
| 3866 |
attrs ...attribute.KeyValue, |
| 3867 |
) { |
| 3868 |
if len(attrs) == 0 { |
| 3869 |
m.Int64Counter.Add(ctx, incr) |
| 3870 |
return |
| 3871 |
} |
| 3872 |
|
| 3873 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3874 |
defer func() { |
| 3875 |
*o = (*o)[:0] |
| 3876 |
addOptPool.Put(o) |
| 3877 |
}() |
| 3878 |
|
| 3879 |
*o = append( |
| 3880 |
*o, |
| 3881 |
metric.WithAttributes( |
| 3882 |
append( |
| 3883 |
attrs, |
| 3884 |
attribute.String("hw.id", id), |
| 3885 |
attribute.String("network.io.direction", string(networkIoDirection)), |
| 3886 |
)..., |
| 3887 |
), |
| 3888 |
) |
| 3889 |
|
| 3890 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 3891 |
} |
| 3892 |
|
| 3893 |
// AddSet adds incr to the existing count for set. |
| 3894 |
func (m NetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 3895 |
if set.Len() == 0 { |
| 3896 |
m.Int64Counter.Add(ctx, incr) |
| 3897 |
return |
| 3898 |
} |
| 3899 |
|
| 3900 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 3901 |
defer func() { |
| 3902 |
*o = (*o)[:0] |
| 3903 |
addOptPool.Put(o) |
| 3904 |
}() |
| 3905 |
|
| 3906 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 3907 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 3908 |
} |
| 3909 |
|
| 3910 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 3911 |
// convention. It represents the descriptive model name of the hardware |
| 3912 |
// component. |
| 3913 |
func (NetworkIO) AttrModel(val string) attribute.KeyValue { |
| 3914 |
return attribute.String("hw.model", val) |
| 3915 |
} |
| 3916 |
|
| 3917 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 3918 |
// It represents an easily-recognizable name for the hardware component. |
| 3919 |
func (NetworkIO) AttrName(val string) attribute.KeyValue { |
| 3920 |
return attribute.String("hw.name", val) |
| 3921 |
} |
| 3922 |
|
| 3923 |
// AttrNetworkLogicalAddresses returns an optional attribute for the |
| 3924 |
// "hw.network.logical_addresses" semantic convention. It represents the logical |
| 3925 |
// addresses of the adapter (e.g. IP address, or WWPN). |
| 3926 |
func (NetworkIO) AttrNetworkLogicalAddresses(val ...string) attribute.KeyValue { |
| 3927 |
return attribute.StringSlice("hw.network.logical_addresses", val) |
| 3928 |
} |
| 3929 |
|
| 3930 |
// AttrNetworkPhysicalAddress returns an optional attribute for the |
| 3931 |
// "hw.network.physical_address" semantic convention. It represents the physical |
| 3932 |
// address of the adapter (e.g. MAC address, or WWNN). |
| 3933 |
func (NetworkIO) AttrNetworkPhysicalAddress(val string) attribute.KeyValue { |
| 3934 |
return attribute.String("hw.network.physical_address", val) |
| 3935 |
} |
| 3936 |
|
| 3937 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 3938 |
// convention. It represents the unique identifier of the parent component |
| 3939 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 3940 |
func (NetworkIO) AttrParent(val string) attribute.KeyValue { |
| 3941 |
return attribute.String("hw.parent", val) |
| 3942 |
} |
| 3943 |
|
| 3944 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 3945 |
// semantic convention. It represents the serial number of the hardware |
| 3946 |
// component. |
| 3947 |
func (NetworkIO) AttrSerialNumber(val string) attribute.KeyValue { |
| 3948 |
return attribute.String("hw.serial_number", val) |
| 3949 |
} |
| 3950 |
|
| 3951 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 3952 |
// convention. It represents the vendor name of the hardware component. |
| 3953 |
func (NetworkIO) AttrVendor(val string) attribute.KeyValue { |
| 3954 |
return attribute.String("hw.vendor", val) |
| 3955 |
} |
| 3956 |
|
| 3957 |
// NetworkPackets is an instrument used to record metric values conforming to the |
| 3958 |
// "hw.network.packets" semantic conventions. It represents the received and |
| 3959 |
// transmitted network traffic in packets (or frames). |
| 3960 |
type NetworkPackets struct { |
| 3961 |
metric.Int64Counter |
| 3962 |
} |
| 3963 |
|
| 3964 |
var newNetworkPacketsOpts = []metric.Int64CounterOption{ |
| 3965 |
metric.WithDescription("Received and transmitted network traffic in packets (or frames)."), |
| 3966 |
metric.WithUnit("{packet}"), |
| 3967 |
} |
| 3968 |
|
| 3969 |
// NewNetworkPackets returns a new NetworkPackets instrument. |
| 3970 |
func NewNetworkPackets( |
| 3971 |
m metric.Meter, |
| 3972 |
opt ...metric.Int64CounterOption, |
| 3973 |
) (NetworkPackets, error) { |
| 3974 |
// Check if the meter is nil. |
| 3975 |
if m == nil { |
| 3976 |
return NetworkPackets{noop.Int64Counter{}}, nil |
| 3977 |
} |
| 3978 |
|
| 3979 |
if len(opt) == 0 { |
| 3980 |
opt = newNetworkPacketsOpts |
| 3981 |
} else { |
| 3982 |
opt = append(opt, newNetworkPacketsOpts...) |
| 3983 |
} |
| 3984 |
|
| 3985 |
i, err := m.Int64Counter( |
| 3986 |
"hw.network.packets", |
| 3987 |
opt..., |
| 3988 |
) |
| 3989 |
if err != nil { |
| 3990 |
return NetworkPackets{noop.Int64Counter{}}, err |
| 3991 |
} |
| 3992 |
return NetworkPackets{i}, nil |
| 3993 |
} |
| 3994 |
|
| 3995 |
// Inst returns the underlying metric instrument. |
| 3996 |
func (m NetworkPackets) Inst() metric.Int64Counter { |
| 3997 |
return m.Int64Counter |
| 3998 |
} |
| 3999 |
|
| 4000 |
// Name returns the semantic convention name of the instrument. |
| 4001 |
func (NetworkPackets) Name() string { |
| 4002 |
return "hw.network.packets" |
| 4003 |
} |
| 4004 |
|
| 4005 |
// Unit returns the semantic convention unit of the instrument |
| 4006 |
func (NetworkPackets) Unit() string { |
| 4007 |
return "{packet}" |
| 4008 |
} |
| 4009 |
|
| 4010 |
// Description returns the semantic convention description of the instrument |
| 4011 |
func (NetworkPackets) Description() string { |
| 4012 |
return "Received and transmitted network traffic in packets (or frames)." |
| 4013 |
} |
| 4014 |
|
| 4015 |
// Add adds incr to the existing count for attrs. |
| 4016 |
// |
| 4017 |
// The id is the an identifier for the hardware component, unique within the |
| 4018 |
// monitored host |
| 4019 |
// |
| 4020 |
// The networkIoDirection is the the network IO operation direction. |
| 4021 |
// |
| 4022 |
// All additional attrs passed are included in the recorded value. |
| 4023 |
func (m NetworkPackets) Add( |
| 4024 |
ctx context.Context, |
| 4025 |
incr int64, |
| 4026 |
id string, |
| 4027 |
networkIoDirection NetworkIODirectionAttr, |
| 4028 |
attrs ...attribute.KeyValue, |
| 4029 |
) { |
| 4030 |
if len(attrs) == 0 { |
| 4031 |
m.Int64Counter.Add(ctx, incr) |
| 4032 |
return |
| 4033 |
} |
| 4034 |
|
| 4035 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4036 |
defer func() { |
| 4037 |
*o = (*o)[:0] |
| 4038 |
addOptPool.Put(o) |
| 4039 |
}() |
| 4040 |
|
| 4041 |
*o = append( |
| 4042 |
*o, |
| 4043 |
metric.WithAttributes( |
| 4044 |
append( |
| 4045 |
attrs, |
| 4046 |
attribute.String("hw.id", id), |
| 4047 |
attribute.String("network.io.direction", string(networkIoDirection)), |
| 4048 |
)..., |
| 4049 |
), |
| 4050 |
) |
| 4051 |
|
| 4052 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4053 |
} |
| 4054 |
|
| 4055 |
// AddSet adds incr to the existing count for set. |
| 4056 |
func (m NetworkPackets) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4057 |
if set.Len() == 0 { |
| 4058 |
m.Int64Counter.Add(ctx, incr) |
| 4059 |
return |
| 4060 |
} |
| 4061 |
|
| 4062 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4063 |
defer func() { |
| 4064 |
*o = (*o)[:0] |
| 4065 |
addOptPool.Put(o) |
| 4066 |
}() |
| 4067 |
|
| 4068 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4069 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 4070 |
} |
| 4071 |
|
| 4072 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 4073 |
// convention. It represents the descriptive model name of the hardware |
| 4074 |
// component. |
| 4075 |
func (NetworkPackets) AttrModel(val string) attribute.KeyValue { |
| 4076 |
return attribute.String("hw.model", val) |
| 4077 |
} |
| 4078 |
|
| 4079 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 4080 |
// It represents an easily-recognizable name for the hardware component. |
| 4081 |
func (NetworkPackets) AttrName(val string) attribute.KeyValue { |
| 4082 |
return attribute.String("hw.name", val) |
| 4083 |
} |
| 4084 |
|
| 4085 |
// AttrNetworkLogicalAddresses returns an optional attribute for the |
| 4086 |
// "hw.network.logical_addresses" semantic convention. It represents the logical |
| 4087 |
// addresses of the adapter (e.g. IP address, or WWPN). |
| 4088 |
func (NetworkPackets) AttrNetworkLogicalAddresses(val ...string) attribute.KeyValue { |
| 4089 |
return attribute.StringSlice("hw.network.logical_addresses", val) |
| 4090 |
} |
| 4091 |
|
| 4092 |
// AttrNetworkPhysicalAddress returns an optional attribute for the |
| 4093 |
// "hw.network.physical_address" semantic convention. It represents the physical |
| 4094 |
// address of the adapter (e.g. MAC address, or WWNN). |
| 4095 |
func (NetworkPackets) AttrNetworkPhysicalAddress(val string) attribute.KeyValue { |
| 4096 |
return attribute.String("hw.network.physical_address", val) |
| 4097 |
} |
| 4098 |
|
| 4099 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 4100 |
// convention. It represents the unique identifier of the parent component |
| 4101 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 4102 |
func (NetworkPackets) AttrParent(val string) attribute.KeyValue { |
| 4103 |
return attribute.String("hw.parent", val) |
| 4104 |
} |
| 4105 |
|
| 4106 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 4107 |
// semantic convention. It represents the serial number of the hardware |
| 4108 |
// component. |
| 4109 |
func (NetworkPackets) AttrSerialNumber(val string) attribute.KeyValue { |
| 4110 |
return attribute.String("hw.serial_number", val) |
| 4111 |
} |
| 4112 |
|
| 4113 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 4114 |
// convention. It represents the vendor name of the hardware component. |
| 4115 |
func (NetworkPackets) AttrVendor(val string) attribute.KeyValue { |
| 4116 |
return attribute.String("hw.vendor", val) |
| 4117 |
} |
| 4118 |
|
| 4119 |
// NetworkUp is an instrument used to record metric values conforming to the |
| 4120 |
// "hw.network.up" semantic conventions. It represents the link status: `1` (up) |
| 4121 |
// or `0` (down). |
| 4122 |
type NetworkUp struct { |
| 4123 |
metric.Int64UpDownCounter |
| 4124 |
} |
| 4125 |
|
| 4126 |
var newNetworkUpOpts = []metric.Int64UpDownCounterOption{ |
| 4127 |
metric.WithDescription("Link status: `1` (up) or `0` (down)."), |
| 4128 |
metric.WithUnit("1"), |
| 4129 |
} |
| 4130 |
|
| 4131 |
// NewNetworkUp returns a new NetworkUp instrument. |
| 4132 |
func NewNetworkUp( |
| 4133 |
m metric.Meter, |
| 4134 |
opt ...metric.Int64UpDownCounterOption, |
| 4135 |
) (NetworkUp, error) { |
| 4136 |
// Check if the meter is nil. |
| 4137 |
if m == nil { |
| 4138 |
return NetworkUp{noop.Int64UpDownCounter{}}, nil |
| 4139 |
} |
| 4140 |
|
| 4141 |
if len(opt) == 0 { |
| 4142 |
opt = newNetworkUpOpts |
| 4143 |
} else { |
| 4144 |
opt = append(opt, newNetworkUpOpts...) |
| 4145 |
} |
| 4146 |
|
| 4147 |
i, err := m.Int64UpDownCounter( |
| 4148 |
"hw.network.up", |
| 4149 |
opt..., |
| 4150 |
) |
| 4151 |
if err != nil { |
| 4152 |
return NetworkUp{noop.Int64UpDownCounter{}}, err |
| 4153 |
} |
| 4154 |
return NetworkUp{i}, nil |
| 4155 |
} |
| 4156 |
|
| 4157 |
// Inst returns the underlying metric instrument. |
| 4158 |
func (m NetworkUp) Inst() metric.Int64UpDownCounter { |
| 4159 |
return m.Int64UpDownCounter |
| 4160 |
} |
| 4161 |
|
| 4162 |
// Name returns the semantic convention name of the instrument. |
| 4163 |
func (NetworkUp) Name() string { |
| 4164 |
return "hw.network.up" |
| 4165 |
} |
| 4166 |
|
| 4167 |
// Unit returns the semantic convention unit of the instrument |
| 4168 |
func (NetworkUp) Unit() string { |
| 4169 |
return "1" |
| 4170 |
} |
| 4171 |
|
| 4172 |
// Description returns the semantic convention description of the instrument |
| 4173 |
func (NetworkUp) Description() string { |
| 4174 |
return "Link status: `1` (up) or `0` (down)." |
| 4175 |
} |
| 4176 |
|
| 4177 |
// Add adds incr to the existing count for attrs. |
| 4178 |
// |
| 4179 |
// The id is the an identifier for the hardware component, unique within the |
| 4180 |
// monitored host |
| 4181 |
// |
| 4182 |
// All additional attrs passed are included in the recorded value. |
| 4183 |
func (m NetworkUp) Add( |
| 4184 |
ctx context.Context, |
| 4185 |
incr int64, |
| 4186 |
id string, |
| 4187 |
attrs ...attribute.KeyValue, |
| 4188 |
) { |
| 4189 |
if len(attrs) == 0 { |
| 4190 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4191 |
return |
| 4192 |
} |
| 4193 |
|
| 4194 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4195 |
defer func() { |
| 4196 |
*o = (*o)[:0] |
| 4197 |
addOptPool.Put(o) |
| 4198 |
}() |
| 4199 |
|
| 4200 |
*o = append( |
| 4201 |
*o, |
| 4202 |
metric.WithAttributes( |
| 4203 |
append( |
| 4204 |
attrs, |
| 4205 |
attribute.String("hw.id", id), |
| 4206 |
)..., |
| 4207 |
), |
| 4208 |
) |
| 4209 |
|
| 4210 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4211 |
} |
| 4212 |
|
| 4213 |
// AddSet adds incr to the existing count for set. |
| 4214 |
func (m NetworkUp) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4215 |
if set.Len() == 0 { |
| 4216 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4217 |
return |
| 4218 |
} |
| 4219 |
|
| 4220 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4221 |
defer func() { |
| 4222 |
*o = (*o)[:0] |
| 4223 |
addOptPool.Put(o) |
| 4224 |
}() |
| 4225 |
|
| 4226 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4227 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4228 |
} |
| 4229 |
|
| 4230 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 4231 |
// convention. It represents the descriptive model name of the hardware |
| 4232 |
// component. |
| 4233 |
func (NetworkUp) AttrModel(val string) attribute.KeyValue { |
| 4234 |
return attribute.String("hw.model", val) |
| 4235 |
} |
| 4236 |
|
| 4237 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 4238 |
// It represents an easily-recognizable name for the hardware component. |
| 4239 |
func (NetworkUp) AttrName(val string) attribute.KeyValue { |
| 4240 |
return attribute.String("hw.name", val) |
| 4241 |
} |
| 4242 |
|
| 4243 |
// AttrNetworkLogicalAddresses returns an optional attribute for the |
| 4244 |
// "hw.network.logical_addresses" semantic convention. It represents the logical |
| 4245 |
// addresses of the adapter (e.g. IP address, or WWPN). |
| 4246 |
func (NetworkUp) AttrNetworkLogicalAddresses(val ...string) attribute.KeyValue { |
| 4247 |
return attribute.StringSlice("hw.network.logical_addresses", val) |
| 4248 |
} |
| 4249 |
|
| 4250 |
// AttrNetworkPhysicalAddress returns an optional attribute for the |
| 4251 |
// "hw.network.physical_address" semantic convention. It represents the physical |
| 4252 |
// address of the adapter (e.g. MAC address, or WWNN). |
| 4253 |
func (NetworkUp) AttrNetworkPhysicalAddress(val string) attribute.KeyValue { |
| 4254 |
return attribute.String("hw.network.physical_address", val) |
| 4255 |
} |
| 4256 |
|
| 4257 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 4258 |
// convention. It represents the unique identifier of the parent component |
| 4259 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 4260 |
func (NetworkUp) AttrParent(val string) attribute.KeyValue { |
| 4261 |
return attribute.String("hw.parent", val) |
| 4262 |
} |
| 4263 |
|
| 4264 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 4265 |
// semantic convention. It represents the serial number of the hardware |
| 4266 |
// component. |
| 4267 |
func (NetworkUp) AttrSerialNumber(val string) attribute.KeyValue { |
| 4268 |
return attribute.String("hw.serial_number", val) |
| 4269 |
} |
| 4270 |
|
| 4271 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 4272 |
// convention. It represents the vendor name of the hardware component. |
| 4273 |
func (NetworkUp) AttrVendor(val string) attribute.KeyValue { |
| 4274 |
return attribute.String("hw.vendor", val) |
| 4275 |
} |
| 4276 |
|
| 4277 |
// PhysicalDiskEnduranceUtilization is an instrument used to record metric values |
| 4278 |
// conforming to the "hw.physical_disk.endurance_utilization" semantic |
| 4279 |
// conventions. It represents the endurance remaining for this SSD disk. |
| 4280 |
type PhysicalDiskEnduranceUtilization struct { |
| 4281 |
metric.Int64Gauge |
| 4282 |
} |
| 4283 |
|
| 4284 |
var newPhysicalDiskEnduranceUtilizationOpts = []metric.Int64GaugeOption{ |
| 4285 |
metric.WithDescription("Endurance remaining for this SSD disk."), |
| 4286 |
metric.WithUnit("1"), |
| 4287 |
} |
| 4288 |
|
| 4289 |
// NewPhysicalDiskEnduranceUtilization returns a new |
| 4290 |
// PhysicalDiskEnduranceUtilization instrument. |
| 4291 |
func NewPhysicalDiskEnduranceUtilization( |
| 4292 |
m metric.Meter, |
| 4293 |
opt ...metric.Int64GaugeOption, |
| 4294 |
) (PhysicalDiskEnduranceUtilization, error) { |
| 4295 |
// Check if the meter is nil. |
| 4296 |
if m == nil { |
| 4297 |
return PhysicalDiskEnduranceUtilization{noop.Int64Gauge{}}, nil |
| 4298 |
} |
| 4299 |
|
| 4300 |
if len(opt) == 0 { |
| 4301 |
opt = newPhysicalDiskEnduranceUtilizationOpts |
| 4302 |
} else { |
| 4303 |
opt = append(opt, newPhysicalDiskEnduranceUtilizationOpts...) |
| 4304 |
} |
| 4305 |
|
| 4306 |
i, err := m.Int64Gauge( |
| 4307 |
"hw.physical_disk.endurance_utilization", |
| 4308 |
opt..., |
| 4309 |
) |
| 4310 |
if err != nil { |
| 4311 |
return PhysicalDiskEnduranceUtilization{noop.Int64Gauge{}}, err |
| 4312 |
} |
| 4313 |
return PhysicalDiskEnduranceUtilization{i}, nil |
| 4314 |
} |
| 4315 |
|
| 4316 |
// Inst returns the underlying metric instrument. |
| 4317 |
func (m PhysicalDiskEnduranceUtilization) Inst() metric.Int64Gauge { |
| 4318 |
return m.Int64Gauge |
| 4319 |
} |
| 4320 |
|
| 4321 |
// Name returns the semantic convention name of the instrument. |
| 4322 |
func (PhysicalDiskEnduranceUtilization) Name() string { |
| 4323 |
return "hw.physical_disk.endurance_utilization" |
| 4324 |
} |
| 4325 |
|
| 4326 |
// Unit returns the semantic convention unit of the instrument |
| 4327 |
func (PhysicalDiskEnduranceUtilization) Unit() string { |
| 4328 |
return "1" |
| 4329 |
} |
| 4330 |
|
| 4331 |
// Description returns the semantic convention description of the instrument |
| 4332 |
func (PhysicalDiskEnduranceUtilization) Description() string { |
| 4333 |
return "Endurance remaining for this SSD disk." |
| 4334 |
} |
| 4335 |
|
| 4336 |
// Record records val to the current distribution for attrs. |
| 4337 |
// |
| 4338 |
// The id is the an identifier for the hardware component, unique within the |
| 4339 |
// monitored host |
| 4340 |
// |
| 4341 |
// The physicalDiskState is the state of the physical disk endurance utilization |
| 4342 |
// |
| 4343 |
// All additional attrs passed are included in the recorded value. |
| 4344 |
func (m PhysicalDiskEnduranceUtilization) Record( |
| 4345 |
ctx context.Context, |
| 4346 |
val int64, |
| 4347 |
id string, |
| 4348 |
physicalDiskState PhysicalDiskStateAttr, |
| 4349 |
attrs ...attribute.KeyValue, |
| 4350 |
) { |
| 4351 |
if len(attrs) == 0 { |
| 4352 |
m.Int64Gauge.Record(ctx, val) |
| 4353 |
return |
| 4354 |
} |
| 4355 |
|
| 4356 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4357 |
defer func() { |
| 4358 |
*o = (*o)[:0] |
| 4359 |
recOptPool.Put(o) |
| 4360 |
}() |
| 4361 |
|
| 4362 |
*o = append( |
| 4363 |
*o, |
| 4364 |
metric.WithAttributes( |
| 4365 |
append( |
| 4366 |
attrs, |
| 4367 |
attribute.String("hw.id", id), |
| 4368 |
attribute.String("hw.physical_disk.state", string(physicalDiskState)), |
| 4369 |
)..., |
| 4370 |
), |
| 4371 |
) |
| 4372 |
|
| 4373 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4374 |
} |
| 4375 |
|
| 4376 |
// RecordSet records val to the current distribution for set. |
| 4377 |
func (m PhysicalDiskEnduranceUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 4378 |
if set.Len() == 0 { |
| 4379 |
m.Int64Gauge.Record(ctx, val) |
| 4380 |
return |
| 4381 |
} |
| 4382 |
|
| 4383 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4384 |
defer func() { |
| 4385 |
*o = (*o)[:0] |
| 4386 |
recOptPool.Put(o) |
| 4387 |
}() |
| 4388 |
|
| 4389 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4390 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4391 |
} |
| 4392 |
|
| 4393 |
// AttrFirmwareVersion returns an optional attribute for the |
| 4394 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 4395 |
// of the hardware component. |
| 4396 |
func (PhysicalDiskEnduranceUtilization) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 4397 |
return attribute.String("hw.firmware_version", val) |
| 4398 |
} |
| 4399 |
|
| 4400 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 4401 |
// convention. It represents the descriptive model name of the hardware |
| 4402 |
// component. |
| 4403 |
func (PhysicalDiskEnduranceUtilization) AttrModel(val string) attribute.KeyValue { |
| 4404 |
return attribute.String("hw.model", val) |
| 4405 |
} |
| 4406 |
|
| 4407 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 4408 |
// It represents an easily-recognizable name for the hardware component. |
| 4409 |
func (PhysicalDiskEnduranceUtilization) AttrName(val string) attribute.KeyValue { |
| 4410 |
return attribute.String("hw.name", val) |
| 4411 |
} |
| 4412 |
|
| 4413 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 4414 |
// convention. It represents the unique identifier of the parent component |
| 4415 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 4416 |
func (PhysicalDiskEnduranceUtilization) AttrParent(val string) attribute.KeyValue { |
| 4417 |
return attribute.String("hw.parent", val) |
| 4418 |
} |
| 4419 |
|
| 4420 |
// AttrPhysicalDiskType returns an optional attribute for the |
| 4421 |
// "hw.physical_disk.type" semantic convention. It represents the type of the |
| 4422 |
// physical disk. |
| 4423 |
func (PhysicalDiskEnduranceUtilization) AttrPhysicalDiskType(val string) attribute.KeyValue { |
| 4424 |
return attribute.String("hw.physical_disk.type", val) |
| 4425 |
} |
| 4426 |
|
| 4427 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 4428 |
// semantic convention. It represents the serial number of the hardware |
| 4429 |
// component. |
| 4430 |
func (PhysicalDiskEnduranceUtilization) AttrSerialNumber(val string) attribute.KeyValue { |
| 4431 |
return attribute.String("hw.serial_number", val) |
| 4432 |
} |
| 4433 |
|
| 4434 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 4435 |
// convention. It represents the vendor name of the hardware component. |
| 4436 |
func (PhysicalDiskEnduranceUtilization) AttrVendor(val string) attribute.KeyValue { |
| 4437 |
return attribute.String("hw.vendor", val) |
| 4438 |
} |
| 4439 |
|
| 4440 |
// PhysicalDiskSize is an instrument used to record metric values conforming to |
| 4441 |
// the "hw.physical_disk.size" semantic conventions. It represents the size of |
| 4442 |
// the disk. |
| 4443 |
type PhysicalDiskSize struct { |
| 4444 |
metric.Int64UpDownCounter |
| 4445 |
} |
| 4446 |
|
| 4447 |
var newPhysicalDiskSizeOpts = []metric.Int64UpDownCounterOption{ |
| 4448 |
metric.WithDescription("Size of the disk."), |
| 4449 |
metric.WithUnit("By"), |
| 4450 |
} |
| 4451 |
|
| 4452 |
// NewPhysicalDiskSize returns a new PhysicalDiskSize instrument. |
| 4453 |
func NewPhysicalDiskSize( |
| 4454 |
m metric.Meter, |
| 4455 |
opt ...metric.Int64UpDownCounterOption, |
| 4456 |
) (PhysicalDiskSize, error) { |
| 4457 |
// Check if the meter is nil. |
| 4458 |
if m == nil { |
| 4459 |
return PhysicalDiskSize{noop.Int64UpDownCounter{}}, nil |
| 4460 |
} |
| 4461 |
|
| 4462 |
if len(opt) == 0 { |
| 4463 |
opt = newPhysicalDiskSizeOpts |
| 4464 |
} else { |
| 4465 |
opt = append(opt, newPhysicalDiskSizeOpts...) |
| 4466 |
} |
| 4467 |
|
| 4468 |
i, err := m.Int64UpDownCounter( |
| 4469 |
"hw.physical_disk.size", |
| 4470 |
opt..., |
| 4471 |
) |
| 4472 |
if err != nil { |
| 4473 |
return PhysicalDiskSize{noop.Int64UpDownCounter{}}, err |
| 4474 |
} |
| 4475 |
return PhysicalDiskSize{i}, nil |
| 4476 |
} |
| 4477 |
|
| 4478 |
// Inst returns the underlying metric instrument. |
| 4479 |
func (m PhysicalDiskSize) Inst() metric.Int64UpDownCounter { |
| 4480 |
return m.Int64UpDownCounter |
| 4481 |
} |
| 4482 |
|
| 4483 |
// Name returns the semantic convention name of the instrument. |
| 4484 |
func (PhysicalDiskSize) Name() string { |
| 4485 |
return "hw.physical_disk.size" |
| 4486 |
} |
| 4487 |
|
| 4488 |
// Unit returns the semantic convention unit of the instrument |
| 4489 |
func (PhysicalDiskSize) Unit() string { |
| 4490 |
return "By" |
| 4491 |
} |
| 4492 |
|
| 4493 |
// Description returns the semantic convention description of the instrument |
| 4494 |
func (PhysicalDiskSize) Description() string { |
| 4495 |
return "Size of the disk." |
| 4496 |
} |
| 4497 |
|
| 4498 |
// Add adds incr to the existing count for attrs. |
| 4499 |
// |
| 4500 |
// The id is the an identifier for the hardware component, unique within the |
| 4501 |
// monitored host |
| 4502 |
// |
| 4503 |
// All additional attrs passed are included in the recorded value. |
| 4504 |
func (m PhysicalDiskSize) Add( |
| 4505 |
ctx context.Context, |
| 4506 |
incr int64, |
| 4507 |
id string, |
| 4508 |
attrs ...attribute.KeyValue, |
| 4509 |
) { |
| 4510 |
if len(attrs) == 0 { |
| 4511 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4512 |
return |
| 4513 |
} |
| 4514 |
|
| 4515 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4516 |
defer func() { |
| 4517 |
*o = (*o)[:0] |
| 4518 |
addOptPool.Put(o) |
| 4519 |
}() |
| 4520 |
|
| 4521 |
*o = append( |
| 4522 |
*o, |
| 4523 |
metric.WithAttributes( |
| 4524 |
append( |
| 4525 |
attrs, |
| 4526 |
attribute.String("hw.id", id), |
| 4527 |
)..., |
| 4528 |
), |
| 4529 |
) |
| 4530 |
|
| 4531 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4532 |
} |
| 4533 |
|
| 4534 |
// AddSet adds incr to the existing count for set. |
| 4535 |
func (m PhysicalDiskSize) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4536 |
if set.Len() == 0 { |
| 4537 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4538 |
return |
| 4539 |
} |
| 4540 |
|
| 4541 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4542 |
defer func() { |
| 4543 |
*o = (*o)[:0] |
| 4544 |
addOptPool.Put(o) |
| 4545 |
}() |
| 4546 |
|
| 4547 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4548 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4549 |
} |
| 4550 |
|
| 4551 |
// AttrFirmwareVersion returns an optional attribute for the |
| 4552 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 4553 |
// of the hardware component. |
| 4554 |
func (PhysicalDiskSize) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 4555 |
return attribute.String("hw.firmware_version", val) |
| 4556 |
} |
| 4557 |
|
| 4558 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 4559 |
// convention. It represents the descriptive model name of the hardware |
| 4560 |
// component. |
| 4561 |
func (PhysicalDiskSize) AttrModel(val string) attribute.KeyValue { |
| 4562 |
return attribute.String("hw.model", val) |
| 4563 |
} |
| 4564 |
|
| 4565 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 4566 |
// It represents an easily-recognizable name for the hardware component. |
| 4567 |
func (PhysicalDiskSize) AttrName(val string) attribute.KeyValue { |
| 4568 |
return attribute.String("hw.name", val) |
| 4569 |
} |
| 4570 |
|
| 4571 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 4572 |
// convention. It represents the unique identifier of the parent component |
| 4573 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 4574 |
func (PhysicalDiskSize) AttrParent(val string) attribute.KeyValue { |
| 4575 |
return attribute.String("hw.parent", val) |
| 4576 |
} |
| 4577 |
|
| 4578 |
// AttrPhysicalDiskType returns an optional attribute for the |
| 4579 |
// "hw.physical_disk.type" semantic convention. It represents the type of the |
| 4580 |
// physical disk. |
| 4581 |
func (PhysicalDiskSize) AttrPhysicalDiskType(val string) attribute.KeyValue { |
| 4582 |
return attribute.String("hw.physical_disk.type", val) |
| 4583 |
} |
| 4584 |
|
| 4585 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 4586 |
// semantic convention. It represents the serial number of the hardware |
| 4587 |
// component. |
| 4588 |
func (PhysicalDiskSize) AttrSerialNumber(val string) attribute.KeyValue { |
| 4589 |
return attribute.String("hw.serial_number", val) |
| 4590 |
} |
| 4591 |
|
| 4592 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 4593 |
// convention. It represents the vendor name of the hardware component. |
| 4594 |
func (PhysicalDiskSize) AttrVendor(val string) attribute.KeyValue { |
| 4595 |
return attribute.String("hw.vendor", val) |
| 4596 |
} |
| 4597 |
|
| 4598 |
// PhysicalDiskSmart is an instrument used to record metric values conforming to |
| 4599 |
// the "hw.physical_disk.smart" semantic conventions. It represents the value of |
| 4600 |
// the corresponding [S.M.A.R.T.] (Self-Monitoring, Analysis, and Reporting |
| 4601 |
// Technology) attribute. |
| 4602 |
// |
| 4603 |
// [S.M.A.R.T.]: https://wikipedia.org/wiki/S.M.A.R.T. |
| 4604 |
type PhysicalDiskSmart struct { |
| 4605 |
metric.Int64Gauge |
| 4606 |
} |
| 4607 |
|
| 4608 |
var newPhysicalDiskSmartOpts = []metric.Int64GaugeOption{ |
| 4609 |
metric.WithDescription("Value of the corresponding [S.M.A.R.T.](https://wikipedia.org/wiki/S.M.A.R.T.) (Self-Monitoring, Analysis, and Reporting Technology) attribute."), |
| 4610 |
metric.WithUnit("1"), |
| 4611 |
} |
| 4612 |
|
| 4613 |
// NewPhysicalDiskSmart returns a new PhysicalDiskSmart instrument. |
| 4614 |
func NewPhysicalDiskSmart( |
| 4615 |
m metric.Meter, |
| 4616 |
opt ...metric.Int64GaugeOption, |
| 4617 |
) (PhysicalDiskSmart, error) { |
| 4618 |
// Check if the meter is nil. |
| 4619 |
if m == nil { |
| 4620 |
return PhysicalDiskSmart{noop.Int64Gauge{}}, nil |
| 4621 |
} |
| 4622 |
|
| 4623 |
if len(opt) == 0 { |
| 4624 |
opt = newPhysicalDiskSmartOpts |
| 4625 |
} else { |
| 4626 |
opt = append(opt, newPhysicalDiskSmartOpts...) |
| 4627 |
} |
| 4628 |
|
| 4629 |
i, err := m.Int64Gauge( |
| 4630 |
"hw.physical_disk.smart", |
| 4631 |
opt..., |
| 4632 |
) |
| 4633 |
if err != nil { |
| 4634 |
return PhysicalDiskSmart{noop.Int64Gauge{}}, err |
| 4635 |
} |
| 4636 |
return PhysicalDiskSmart{i}, nil |
| 4637 |
} |
| 4638 |
|
| 4639 |
// Inst returns the underlying metric instrument. |
| 4640 |
func (m PhysicalDiskSmart) Inst() metric.Int64Gauge { |
| 4641 |
return m.Int64Gauge |
| 4642 |
} |
| 4643 |
|
| 4644 |
// Name returns the semantic convention name of the instrument. |
| 4645 |
func (PhysicalDiskSmart) Name() string { |
| 4646 |
return "hw.physical_disk.smart" |
| 4647 |
} |
| 4648 |
|
| 4649 |
// Unit returns the semantic convention unit of the instrument |
| 4650 |
func (PhysicalDiskSmart) Unit() string { |
| 4651 |
return "1" |
| 4652 |
} |
| 4653 |
|
| 4654 |
// Description returns the semantic convention description of the instrument |
| 4655 |
func (PhysicalDiskSmart) Description() string { |
| 4656 |
return "Value of the corresponding [S.M.A.R.T.](https://wikipedia.org/wiki/S.M.A.R.T.) (Self-Monitoring, Analysis, and Reporting Technology) attribute." |
| 4657 |
} |
| 4658 |
|
| 4659 |
// Record records val to the current distribution for attrs. |
| 4660 |
// |
| 4661 |
// The id is the an identifier for the hardware component, unique within the |
| 4662 |
// monitored host |
| 4663 |
// |
| 4664 |
// All additional attrs passed are included in the recorded value. |
| 4665 |
func (m PhysicalDiskSmart) Record( |
| 4666 |
ctx context.Context, |
| 4667 |
val int64, |
| 4668 |
id string, |
| 4669 |
attrs ...attribute.KeyValue, |
| 4670 |
) { |
| 4671 |
if len(attrs) == 0 { |
| 4672 |
m.Int64Gauge.Record(ctx, val) |
| 4673 |
return |
| 4674 |
} |
| 4675 |
|
| 4676 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4677 |
defer func() { |
| 4678 |
*o = (*o)[:0] |
| 4679 |
recOptPool.Put(o) |
| 4680 |
}() |
| 4681 |
|
| 4682 |
*o = append( |
| 4683 |
*o, |
| 4684 |
metric.WithAttributes( |
| 4685 |
append( |
| 4686 |
attrs, |
| 4687 |
attribute.String("hw.id", id), |
| 4688 |
)..., |
| 4689 |
), |
| 4690 |
) |
| 4691 |
|
| 4692 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4693 |
} |
| 4694 |
|
| 4695 |
// RecordSet records val to the current distribution for set. |
| 4696 |
func (m PhysicalDiskSmart) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 4697 |
if set.Len() == 0 { |
| 4698 |
m.Int64Gauge.Record(ctx, val) |
| 4699 |
return |
| 4700 |
} |
| 4701 |
|
| 4702 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4703 |
defer func() { |
| 4704 |
*o = (*o)[:0] |
| 4705 |
recOptPool.Put(o) |
| 4706 |
}() |
| 4707 |
|
| 4708 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4709 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4710 |
} |
| 4711 |
|
| 4712 |
// AttrFirmwareVersion returns an optional attribute for the |
| 4713 |
// "hw.firmware_version" semantic convention. It represents the firmware version |
| 4714 |
// of the hardware component. |
| 4715 |
func (PhysicalDiskSmart) AttrFirmwareVersion(val string) attribute.KeyValue { |
| 4716 |
return attribute.String("hw.firmware_version", val) |
| 4717 |
} |
| 4718 |
|
| 4719 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 4720 |
// convention. It represents the descriptive model name of the hardware |
| 4721 |
// component. |
| 4722 |
func (PhysicalDiskSmart) AttrModel(val string) attribute.KeyValue { |
| 4723 |
return attribute.String("hw.model", val) |
| 4724 |
} |
| 4725 |
|
| 4726 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 4727 |
// It represents an easily-recognizable name for the hardware component. |
| 4728 |
func (PhysicalDiskSmart) AttrName(val string) attribute.KeyValue { |
| 4729 |
return attribute.String("hw.name", val) |
| 4730 |
} |
| 4731 |
|
| 4732 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 4733 |
// convention. It represents the unique identifier of the parent component |
| 4734 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 4735 |
func (PhysicalDiskSmart) AttrParent(val string) attribute.KeyValue { |
| 4736 |
return attribute.String("hw.parent", val) |
| 4737 |
} |
| 4738 |
|
| 4739 |
// AttrPhysicalDiskSmartAttribute returns an optional attribute for the |
| 4740 |
// "hw.physical_disk.smart_attribute" semantic convention. It represents the |
| 4741 |
// [S.M.A.R.T.] (Self-Monitoring, Analysis, and Reporting Technology) attribute |
| 4742 |
// of the physical disk. |
| 4743 |
// |
| 4744 |
// [S.M.A.R.T.]: https://wikipedia.org/wiki/S.M.A.R.T. |
| 4745 |
func (PhysicalDiskSmart) AttrPhysicalDiskSmartAttribute(val string) attribute.KeyValue { |
| 4746 |
return attribute.String("hw.physical_disk.smart_attribute", val) |
| 4747 |
} |
| 4748 |
|
| 4749 |
// AttrPhysicalDiskType returns an optional attribute for the |
| 4750 |
// "hw.physical_disk.type" semantic convention. It represents the type of the |
| 4751 |
// physical disk. |
| 4752 |
func (PhysicalDiskSmart) AttrPhysicalDiskType(val string) attribute.KeyValue { |
| 4753 |
return attribute.String("hw.physical_disk.type", val) |
| 4754 |
} |
| 4755 |
|
| 4756 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 4757 |
// semantic convention. It represents the serial number of the hardware |
| 4758 |
// component. |
| 4759 |
func (PhysicalDiskSmart) AttrSerialNumber(val string) attribute.KeyValue { |
| 4760 |
return attribute.String("hw.serial_number", val) |
| 4761 |
} |
| 4762 |
|
| 4763 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 4764 |
// convention. It represents the vendor name of the hardware component. |
| 4765 |
func (PhysicalDiskSmart) AttrVendor(val string) attribute.KeyValue { |
| 4766 |
return attribute.String("hw.vendor", val) |
| 4767 |
} |
| 4768 |
|
| 4769 |
// Power is an instrument used to record metric values conforming to the |
| 4770 |
// "hw.power" semantic conventions. It represents the instantaneous power |
| 4771 |
// consumed by the component. |
| 4772 |
type Power struct { |
| 4773 |
metric.Int64Gauge |
| 4774 |
} |
| 4775 |
|
| 4776 |
var newPowerOpts = []metric.Int64GaugeOption{ |
| 4777 |
metric.WithDescription("Instantaneous power consumed by the component."), |
| 4778 |
metric.WithUnit("W"), |
| 4779 |
} |
| 4780 |
|
| 4781 |
// NewPower returns a new Power instrument. |
| 4782 |
func NewPower( |
| 4783 |
m metric.Meter, |
| 4784 |
opt ...metric.Int64GaugeOption, |
| 4785 |
) (Power, error) { |
| 4786 |
// Check if the meter is nil. |
| 4787 |
if m == nil { |
| 4788 |
return Power{noop.Int64Gauge{}}, nil |
| 4789 |
} |
| 4790 |
|
| 4791 |
if len(opt) == 0 { |
| 4792 |
opt = newPowerOpts |
| 4793 |
} else { |
| 4794 |
opt = append(opt, newPowerOpts...) |
| 4795 |
} |
| 4796 |
|
| 4797 |
i, err := m.Int64Gauge( |
| 4798 |
"hw.power", |
| 4799 |
opt..., |
| 4800 |
) |
| 4801 |
if err != nil { |
| 4802 |
return Power{noop.Int64Gauge{}}, err |
| 4803 |
} |
| 4804 |
return Power{i}, nil |
| 4805 |
} |
| 4806 |
|
| 4807 |
// Inst returns the underlying metric instrument. |
| 4808 |
func (m Power) Inst() metric.Int64Gauge { |
| 4809 |
return m.Int64Gauge |
| 4810 |
} |
| 4811 |
|
| 4812 |
// Name returns the semantic convention name of the instrument. |
| 4813 |
func (Power) Name() string { |
| 4814 |
return "hw.power" |
| 4815 |
} |
| 4816 |
|
| 4817 |
// Unit returns the semantic convention unit of the instrument |
| 4818 |
func (Power) Unit() string { |
| 4819 |
return "W" |
| 4820 |
} |
| 4821 |
|
| 4822 |
// Description returns the semantic convention description of the instrument |
| 4823 |
func (Power) Description() string { |
| 4824 |
return "Instantaneous power consumed by the component." |
| 4825 |
} |
| 4826 |
|
| 4827 |
// Record records val to the current distribution for attrs. |
| 4828 |
// |
| 4829 |
// The id is the an identifier for the hardware component, unique within the |
| 4830 |
// monitored host |
| 4831 |
// |
| 4832 |
// The hwType is the type of the component |
| 4833 |
// |
| 4834 |
// All additional attrs passed are included in the recorded value. |
| 4835 |
// |
| 4836 |
// It is recommended to report `hw.energy` instead of `hw.power` when possible. |
| 4837 |
func (m Power) Record( |
| 4838 |
ctx context.Context, |
| 4839 |
val int64, |
| 4840 |
id string, |
| 4841 |
hwType TypeAttr, |
| 4842 |
attrs ...attribute.KeyValue, |
| 4843 |
) { |
| 4844 |
if len(attrs) == 0 { |
| 4845 |
m.Int64Gauge.Record(ctx, val) |
| 4846 |
return |
| 4847 |
} |
| 4848 |
|
| 4849 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4850 |
defer func() { |
| 4851 |
*o = (*o)[:0] |
| 4852 |
recOptPool.Put(o) |
| 4853 |
}() |
| 4854 |
|
| 4855 |
*o = append( |
| 4856 |
*o, |
| 4857 |
metric.WithAttributes( |
| 4858 |
append( |
| 4859 |
attrs, |
| 4860 |
attribute.String("hw.id", id), |
| 4861 |
attribute.String("hw.type", string(hwType)), |
| 4862 |
)..., |
| 4863 |
), |
| 4864 |
) |
| 4865 |
|
| 4866 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4867 |
} |
| 4868 |
|
| 4869 |
// RecordSet records val to the current distribution for set. |
| 4870 |
// |
| 4871 |
// It is recommended to report `hw.energy` instead of `hw.power` when possible. |
| 4872 |
func (m Power) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 4873 |
if set.Len() == 0 { |
| 4874 |
m.Int64Gauge.Record(ctx, val) |
| 4875 |
return |
| 4876 |
} |
| 4877 |
|
| 4878 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 4879 |
defer func() { |
| 4880 |
*o = (*o)[:0] |
| 4881 |
recOptPool.Put(o) |
| 4882 |
}() |
| 4883 |
|
| 4884 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 4885 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 4886 |
} |
| 4887 |
|
| 4888 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 4889 |
// It represents an easily-recognizable name for the hardware component. |
| 4890 |
func (Power) AttrName(val string) attribute.KeyValue { |
| 4891 |
return attribute.String("hw.name", val) |
| 4892 |
} |
| 4893 |
|
| 4894 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 4895 |
// convention. It represents the unique identifier of the parent component |
| 4896 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 4897 |
func (Power) AttrParent(val string) attribute.KeyValue { |
| 4898 |
return attribute.String("hw.parent", val) |
| 4899 |
} |
| 4900 |
|
| 4901 |
// PowerSupplyLimit is an instrument used to record metric values conforming to |
| 4902 |
// the "hw.power_supply.limit" semantic conventions. It represents the maximum |
| 4903 |
// power output of the power supply. |
| 4904 |
type PowerSupplyLimit struct { |
| 4905 |
metric.Int64UpDownCounter |
| 4906 |
} |
| 4907 |
|
| 4908 |
var newPowerSupplyLimitOpts = []metric.Int64UpDownCounterOption{ |
| 4909 |
metric.WithDescription("Maximum power output of the power supply."), |
| 4910 |
metric.WithUnit("W"), |
| 4911 |
} |
| 4912 |
|
| 4913 |
// NewPowerSupplyLimit returns a new PowerSupplyLimit instrument. |
| 4914 |
func NewPowerSupplyLimit( |
| 4915 |
m metric.Meter, |
| 4916 |
opt ...metric.Int64UpDownCounterOption, |
| 4917 |
) (PowerSupplyLimit, error) { |
| 4918 |
// Check if the meter is nil. |
| 4919 |
if m == nil { |
| 4920 |
return PowerSupplyLimit{noop.Int64UpDownCounter{}}, nil |
| 4921 |
} |
| 4922 |
|
| 4923 |
if len(opt) == 0 { |
| 4924 |
opt = newPowerSupplyLimitOpts |
| 4925 |
} else { |
| 4926 |
opt = append(opt, newPowerSupplyLimitOpts...) |
| 4927 |
} |
| 4928 |
|
| 4929 |
i, err := m.Int64UpDownCounter( |
| 4930 |
"hw.power_supply.limit", |
| 4931 |
opt..., |
| 4932 |
) |
| 4933 |
if err != nil { |
| 4934 |
return PowerSupplyLimit{noop.Int64UpDownCounter{}}, err |
| 4935 |
} |
| 4936 |
return PowerSupplyLimit{i}, nil |
| 4937 |
} |
| 4938 |
|
| 4939 |
// Inst returns the underlying metric instrument. |
| 4940 |
func (m PowerSupplyLimit) Inst() metric.Int64UpDownCounter { |
| 4941 |
return m.Int64UpDownCounter |
| 4942 |
} |
| 4943 |
|
| 4944 |
// Name returns the semantic convention name of the instrument. |
| 4945 |
func (PowerSupplyLimit) Name() string { |
| 4946 |
return "hw.power_supply.limit" |
| 4947 |
} |
| 4948 |
|
| 4949 |
// Unit returns the semantic convention unit of the instrument |
| 4950 |
func (PowerSupplyLimit) Unit() string { |
| 4951 |
return "W" |
| 4952 |
} |
| 4953 |
|
| 4954 |
// Description returns the semantic convention description of the instrument |
| 4955 |
func (PowerSupplyLimit) Description() string { |
| 4956 |
return "Maximum power output of the power supply." |
| 4957 |
} |
| 4958 |
|
| 4959 |
// Add adds incr to the existing count for attrs. |
| 4960 |
// |
| 4961 |
// The id is the an identifier for the hardware component, unique within the |
| 4962 |
// monitored host |
| 4963 |
// |
| 4964 |
// All additional attrs passed are included in the recorded value. |
| 4965 |
func (m PowerSupplyLimit) Add( |
| 4966 |
ctx context.Context, |
| 4967 |
incr int64, |
| 4968 |
id string, |
| 4969 |
attrs ...attribute.KeyValue, |
| 4970 |
) { |
| 4971 |
if len(attrs) == 0 { |
| 4972 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4973 |
return |
| 4974 |
} |
| 4975 |
|
| 4976 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 4977 |
defer func() { |
| 4978 |
*o = (*o)[:0] |
| 4979 |
addOptPool.Put(o) |
| 4980 |
}() |
| 4981 |
|
| 4982 |
*o = append( |
| 4983 |
*o, |
| 4984 |
metric.WithAttributes( |
| 4985 |
append( |
| 4986 |
attrs, |
| 4987 |
attribute.String("hw.id", id), |
| 4988 |
)..., |
| 4989 |
), |
| 4990 |
) |
| 4991 |
|
| 4992 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 4993 |
} |
| 4994 |
|
| 4995 |
// AddSet adds incr to the existing count for set. |
| 4996 |
func (m PowerSupplyLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 4997 |
if set.Len() == 0 { |
| 4998 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 4999 |
return |
| 5000 |
} |
| 5001 |
|
| 5002 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5003 |
defer func() { |
| 5004 |
*o = (*o)[:0] |
| 5005 |
addOptPool.Put(o) |
| 5006 |
}() |
| 5007 |
|
| 5008 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5009 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5010 |
} |
| 5011 |
|
| 5012 |
// AttrLimitType returns an optional attribute for the "hw.limit_type" semantic |
| 5013 |
// convention. It represents the type of limit for hardware components. |
| 5014 |
func (PowerSupplyLimit) AttrLimitType(val LimitTypeAttr) attribute.KeyValue { |
| 5015 |
return attribute.String("hw.limit_type", string(val)) |
| 5016 |
} |
| 5017 |
|
| 5018 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 5019 |
// convention. It represents the descriptive model name of the hardware |
| 5020 |
// component. |
| 5021 |
func (PowerSupplyLimit) AttrModel(val string) attribute.KeyValue { |
| 5022 |
return attribute.String("hw.model", val) |
| 5023 |
} |
| 5024 |
|
| 5025 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 5026 |
// It represents an easily-recognizable name for the hardware component. |
| 5027 |
func (PowerSupplyLimit) AttrName(val string) attribute.KeyValue { |
| 5028 |
return attribute.String("hw.name", val) |
| 5029 |
} |
| 5030 |
|
| 5031 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 5032 |
// convention. It represents the unique identifier of the parent component |
| 5033 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 5034 |
func (PowerSupplyLimit) AttrParent(val string) attribute.KeyValue { |
| 5035 |
return attribute.String("hw.parent", val) |
| 5036 |
} |
| 5037 |
|
| 5038 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 5039 |
// semantic convention. It represents the serial number of the hardware |
| 5040 |
// component. |
| 5041 |
func (PowerSupplyLimit) AttrSerialNumber(val string) attribute.KeyValue { |
| 5042 |
return attribute.String("hw.serial_number", val) |
| 5043 |
} |
| 5044 |
|
| 5045 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 5046 |
// convention. It represents the vendor name of the hardware component. |
| 5047 |
func (PowerSupplyLimit) AttrVendor(val string) attribute.KeyValue { |
| 5048 |
return attribute.String("hw.vendor", val) |
| 5049 |
} |
| 5050 |
|
| 5051 |
// PowerSupplyUsage is an instrument used to record metric values conforming to |
| 5052 |
// the "hw.power_supply.usage" semantic conventions. It represents the current |
| 5053 |
// power output of the power supply. |
| 5054 |
type PowerSupplyUsage struct { |
| 5055 |
metric.Int64UpDownCounter |
| 5056 |
} |
| 5057 |
|
| 5058 |
var newPowerSupplyUsageOpts = []metric.Int64UpDownCounterOption{ |
| 5059 |
metric.WithDescription("Current power output of the power supply."), |
| 5060 |
metric.WithUnit("W"), |
| 5061 |
} |
| 5062 |
|
| 5063 |
// NewPowerSupplyUsage returns a new PowerSupplyUsage instrument. |
| 5064 |
func NewPowerSupplyUsage( |
| 5065 |
m metric.Meter, |
| 5066 |
opt ...metric.Int64UpDownCounterOption, |
| 5067 |
) (PowerSupplyUsage, error) { |
| 5068 |
// Check if the meter is nil. |
| 5069 |
if m == nil { |
| 5070 |
return PowerSupplyUsage{noop.Int64UpDownCounter{}}, nil |
| 5071 |
} |
| 5072 |
|
| 5073 |
if len(opt) == 0 { |
| 5074 |
opt = newPowerSupplyUsageOpts |
| 5075 |
} else { |
| 5076 |
opt = append(opt, newPowerSupplyUsageOpts...) |
| 5077 |
} |
| 5078 |
|
| 5079 |
i, err := m.Int64UpDownCounter( |
| 5080 |
"hw.power_supply.usage", |
| 5081 |
opt..., |
| 5082 |
) |
| 5083 |
if err != nil { |
| 5084 |
return PowerSupplyUsage{noop.Int64UpDownCounter{}}, err |
| 5085 |
} |
| 5086 |
return PowerSupplyUsage{i}, nil |
| 5087 |
} |
| 5088 |
|
| 5089 |
// Inst returns the underlying metric instrument. |
| 5090 |
func (m PowerSupplyUsage) Inst() metric.Int64UpDownCounter { |
| 5091 |
return m.Int64UpDownCounter |
| 5092 |
} |
| 5093 |
|
| 5094 |
// Name returns the semantic convention name of the instrument. |
| 5095 |
func (PowerSupplyUsage) Name() string { |
| 5096 |
return "hw.power_supply.usage" |
| 5097 |
} |
| 5098 |
|
| 5099 |
// Unit returns the semantic convention unit of the instrument |
| 5100 |
func (PowerSupplyUsage) Unit() string { |
| 5101 |
return "W" |
| 5102 |
} |
| 5103 |
|
| 5104 |
// Description returns the semantic convention description of the instrument |
| 5105 |
func (PowerSupplyUsage) Description() string { |
| 5106 |
return "Current power output of the power supply." |
| 5107 |
} |
| 5108 |
|
| 5109 |
// Add adds incr to the existing count for attrs. |
| 5110 |
// |
| 5111 |
// The id is the an identifier for the hardware component, unique within the |
| 5112 |
// monitored host |
| 5113 |
// |
| 5114 |
// All additional attrs passed are included in the recorded value. |
| 5115 |
func (m PowerSupplyUsage) Add( |
| 5116 |
ctx context.Context, |
| 5117 |
incr int64, |
| 5118 |
id string, |
| 5119 |
attrs ...attribute.KeyValue, |
| 5120 |
) { |
| 5121 |
if len(attrs) == 0 { |
| 5122 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5123 |
return |
| 5124 |
} |
| 5125 |
|
| 5126 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5127 |
defer func() { |
| 5128 |
*o = (*o)[:0] |
| 5129 |
addOptPool.Put(o) |
| 5130 |
}() |
| 5131 |
|
| 5132 |
*o = append( |
| 5133 |
*o, |
| 5134 |
metric.WithAttributes( |
| 5135 |
append( |
| 5136 |
attrs, |
| 5137 |
attribute.String("hw.id", id), |
| 5138 |
)..., |
| 5139 |
), |
| 5140 |
) |
| 5141 |
|
| 5142 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5143 |
} |
| 5144 |
|
| 5145 |
// AddSet adds incr to the existing count for set. |
| 5146 |
func (m PowerSupplyUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5147 |
if set.Len() == 0 { |
| 5148 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5149 |
return |
| 5150 |
} |
| 5151 |
|
| 5152 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5153 |
defer func() { |
| 5154 |
*o = (*o)[:0] |
| 5155 |
addOptPool.Put(o) |
| 5156 |
}() |
| 5157 |
|
| 5158 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5159 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5160 |
} |
| 5161 |
|
| 5162 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 5163 |
// convention. It represents the descriptive model name of the hardware |
| 5164 |
// component. |
| 5165 |
func (PowerSupplyUsage) AttrModel(val string) attribute.KeyValue { |
| 5166 |
return attribute.String("hw.model", val) |
| 5167 |
} |
| 5168 |
|
| 5169 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 5170 |
// It represents an easily-recognizable name for the hardware component. |
| 5171 |
func (PowerSupplyUsage) AttrName(val string) attribute.KeyValue { |
| 5172 |
return attribute.String("hw.name", val) |
| 5173 |
} |
| 5174 |
|
| 5175 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 5176 |
// convention. It represents the unique identifier of the parent component |
| 5177 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 5178 |
func (PowerSupplyUsage) AttrParent(val string) attribute.KeyValue { |
| 5179 |
return attribute.String("hw.parent", val) |
| 5180 |
} |
| 5181 |
|
| 5182 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 5183 |
// semantic convention. It represents the serial number of the hardware |
| 5184 |
// component. |
| 5185 |
func (PowerSupplyUsage) AttrSerialNumber(val string) attribute.KeyValue { |
| 5186 |
return attribute.String("hw.serial_number", val) |
| 5187 |
} |
| 5188 |
|
| 5189 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 5190 |
// convention. It represents the vendor name of the hardware component. |
| 5191 |
func (PowerSupplyUsage) AttrVendor(val string) attribute.KeyValue { |
| 5192 |
return attribute.String("hw.vendor", val) |
| 5193 |
} |
| 5194 |
|
| 5195 |
// PowerSupplyUtilization is an instrument used to record metric values |
| 5196 |
// conforming to the "hw.power_supply.utilization" semantic conventions. It |
| 5197 |
// represents the utilization of the power supply as a fraction of its maximum |
| 5198 |
// output. |
| 5199 |
type PowerSupplyUtilization struct { |
| 5200 |
metric.Int64Gauge |
| 5201 |
} |
| 5202 |
|
| 5203 |
var newPowerSupplyUtilizationOpts = []metric.Int64GaugeOption{ |
| 5204 |
metric.WithDescription("Utilization of the power supply as a fraction of its maximum output."), |
| 5205 |
metric.WithUnit("1"), |
| 5206 |
} |
| 5207 |
|
| 5208 |
// NewPowerSupplyUtilization returns a new PowerSupplyUtilization instrument. |
| 5209 |
func NewPowerSupplyUtilization( |
| 5210 |
m metric.Meter, |
| 5211 |
opt ...metric.Int64GaugeOption, |
| 5212 |
) (PowerSupplyUtilization, error) { |
| 5213 |
// Check if the meter is nil. |
| 5214 |
if m == nil { |
| 5215 |
return PowerSupplyUtilization{noop.Int64Gauge{}}, nil |
| 5216 |
} |
| 5217 |
|
| 5218 |
if len(opt) == 0 { |
| 5219 |
opt = newPowerSupplyUtilizationOpts |
| 5220 |
} else { |
| 5221 |
opt = append(opt, newPowerSupplyUtilizationOpts...) |
| 5222 |
} |
| 5223 |
|
| 5224 |
i, err := m.Int64Gauge( |
| 5225 |
"hw.power_supply.utilization", |
| 5226 |
opt..., |
| 5227 |
) |
| 5228 |
if err != nil { |
| 5229 |
return PowerSupplyUtilization{noop.Int64Gauge{}}, err |
| 5230 |
} |
| 5231 |
return PowerSupplyUtilization{i}, nil |
| 5232 |
} |
| 5233 |
|
| 5234 |
// Inst returns the underlying metric instrument. |
| 5235 |
func (m PowerSupplyUtilization) Inst() metric.Int64Gauge { |
| 5236 |
return m.Int64Gauge |
| 5237 |
} |
| 5238 |
|
| 5239 |
// Name returns the semantic convention name of the instrument. |
| 5240 |
func (PowerSupplyUtilization) Name() string { |
| 5241 |
return "hw.power_supply.utilization" |
| 5242 |
} |
| 5243 |
|
| 5244 |
// Unit returns the semantic convention unit of the instrument |
| 5245 |
func (PowerSupplyUtilization) Unit() string { |
| 5246 |
return "1" |
| 5247 |
} |
| 5248 |
|
| 5249 |
// Description returns the semantic convention description of the instrument |
| 5250 |
func (PowerSupplyUtilization) Description() string { |
| 5251 |
return "Utilization of the power supply as a fraction of its maximum output." |
| 5252 |
} |
| 5253 |
|
| 5254 |
// Record records val to the current distribution for attrs. |
| 5255 |
// |
| 5256 |
// The id is the an identifier for the hardware component, unique within the |
| 5257 |
// monitored host |
| 5258 |
// |
| 5259 |
// All additional attrs passed are included in the recorded value. |
| 5260 |
func (m PowerSupplyUtilization) Record( |
| 5261 |
ctx context.Context, |
| 5262 |
val int64, |
| 5263 |
id string, |
| 5264 |
attrs ...attribute.KeyValue, |
| 5265 |
) { |
| 5266 |
if len(attrs) == 0 { |
| 5267 |
m.Int64Gauge.Record(ctx, val) |
| 5268 |
return |
| 5269 |
} |
| 5270 |
|
| 5271 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5272 |
defer func() { |
| 5273 |
*o = (*o)[:0] |
| 5274 |
recOptPool.Put(o) |
| 5275 |
}() |
| 5276 |
|
| 5277 |
*o = append( |
| 5278 |
*o, |
| 5279 |
metric.WithAttributes( |
| 5280 |
append( |
| 5281 |
attrs, |
| 5282 |
attribute.String("hw.id", id), |
| 5283 |
)..., |
| 5284 |
), |
| 5285 |
) |
| 5286 |
|
| 5287 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5288 |
} |
| 5289 |
|
| 5290 |
// RecordSet records val to the current distribution for set. |
| 5291 |
func (m PowerSupplyUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 5292 |
if set.Len() == 0 { |
| 5293 |
m.Int64Gauge.Record(ctx, val) |
| 5294 |
return |
| 5295 |
} |
| 5296 |
|
| 5297 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5298 |
defer func() { |
| 5299 |
*o = (*o)[:0] |
| 5300 |
recOptPool.Put(o) |
| 5301 |
}() |
| 5302 |
|
| 5303 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5304 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5305 |
} |
| 5306 |
|
| 5307 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 5308 |
// convention. It represents the descriptive model name of the hardware |
| 5309 |
// component. |
| 5310 |
func (PowerSupplyUtilization) AttrModel(val string) attribute.KeyValue { |
| 5311 |
return attribute.String("hw.model", val) |
| 5312 |
} |
| 5313 |
|
| 5314 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 5315 |
// It represents an easily-recognizable name for the hardware component. |
| 5316 |
func (PowerSupplyUtilization) AttrName(val string) attribute.KeyValue { |
| 5317 |
return attribute.String("hw.name", val) |
| 5318 |
} |
| 5319 |
|
| 5320 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 5321 |
// convention. It represents the unique identifier of the parent component |
| 5322 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 5323 |
func (PowerSupplyUtilization) AttrParent(val string) attribute.KeyValue { |
| 5324 |
return attribute.String("hw.parent", val) |
| 5325 |
} |
| 5326 |
|
| 5327 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 5328 |
// semantic convention. It represents the serial number of the hardware |
| 5329 |
// component. |
| 5330 |
func (PowerSupplyUtilization) AttrSerialNumber(val string) attribute.KeyValue { |
| 5331 |
return attribute.String("hw.serial_number", val) |
| 5332 |
} |
| 5333 |
|
| 5334 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 5335 |
// convention. It represents the vendor name of the hardware component. |
| 5336 |
func (PowerSupplyUtilization) AttrVendor(val string) attribute.KeyValue { |
| 5337 |
return attribute.String("hw.vendor", val) |
| 5338 |
} |
| 5339 |
|
| 5340 |
// Status is an instrument used to record metric values conforming to the |
| 5341 |
// "hw.status" semantic conventions. It represents the operational status: `1` |
| 5342 |
// (true) or `0` (false) for each of the possible states. |
| 5343 |
type Status struct { |
| 5344 |
metric.Int64UpDownCounter |
| 5345 |
} |
| 5346 |
|
| 5347 |
var newStatusOpts = []metric.Int64UpDownCounterOption{ |
| 5348 |
metric.WithDescription("Operational status: `1` (true) or `0` (false) for each of the possible states."), |
| 5349 |
metric.WithUnit("1"), |
| 5350 |
} |
| 5351 |
|
| 5352 |
// NewStatus returns a new Status instrument. |
| 5353 |
func NewStatus( |
| 5354 |
m metric.Meter, |
| 5355 |
opt ...metric.Int64UpDownCounterOption, |
| 5356 |
) (Status, error) { |
| 5357 |
// Check if the meter is nil. |
| 5358 |
if m == nil { |
| 5359 |
return Status{noop.Int64UpDownCounter{}}, nil |
| 5360 |
} |
| 5361 |
|
| 5362 |
if len(opt) == 0 { |
| 5363 |
opt = newStatusOpts |
| 5364 |
} else { |
| 5365 |
opt = append(opt, newStatusOpts...) |
| 5366 |
} |
| 5367 |
|
| 5368 |
i, err := m.Int64UpDownCounter( |
| 5369 |
"hw.status", |
| 5370 |
opt..., |
| 5371 |
) |
| 5372 |
if err != nil { |
| 5373 |
return Status{noop.Int64UpDownCounter{}}, err |
| 5374 |
} |
| 5375 |
return Status{i}, nil |
| 5376 |
} |
| 5377 |
|
| 5378 |
// Inst returns the underlying metric instrument. |
| 5379 |
func (m Status) Inst() metric.Int64UpDownCounter { |
| 5380 |
return m.Int64UpDownCounter |
| 5381 |
} |
| 5382 |
|
| 5383 |
// Name returns the semantic convention name of the instrument. |
| 5384 |
func (Status) Name() string { |
| 5385 |
return "hw.status" |
| 5386 |
} |
| 5387 |
|
| 5388 |
// Unit returns the semantic convention unit of the instrument |
| 5389 |
func (Status) Unit() string { |
| 5390 |
return "1" |
| 5391 |
} |
| 5392 |
|
| 5393 |
// Description returns the semantic convention description of the instrument |
| 5394 |
func (Status) Description() string { |
| 5395 |
return "Operational status: `1` (true) or `0` (false) for each of the possible states." |
| 5396 |
} |
| 5397 |
|
| 5398 |
// Add adds incr to the existing count for attrs. |
| 5399 |
// |
| 5400 |
// The id is the an identifier for the hardware component, unique within the |
| 5401 |
// monitored host |
| 5402 |
// |
| 5403 |
// The state is the the current state of the component |
| 5404 |
// |
| 5405 |
// The hwType is the type of the component |
| 5406 |
// |
| 5407 |
// All additional attrs passed are included in the recorded value. |
| 5408 |
// |
| 5409 |
// `hw.status` is currently specified as an *UpDownCounter* but would ideally be |
| 5410 |
// represented using a [*StateSet* as defined in OpenMetrics]. This semantic |
| 5411 |
// convention will be updated once *StateSet* is specified in OpenTelemetry. This |
| 5412 |
// planned change is not expected to have any consequence on the way users query |
| 5413 |
// their timeseries backend to retrieve the values of `hw.status` over time. |
| 5414 |
// |
| 5415 |
// [ [*StateSet* as defined in OpenMetrics]: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#stateset |
| 5416 |
func (m Status) Add( |
| 5417 |
ctx context.Context, |
| 5418 |
incr int64, |
| 5419 |
id string, |
| 5420 |
state StateAttr, |
| 5421 |
hwType TypeAttr, |
| 5422 |
attrs ...attribute.KeyValue, |
| 5423 |
) { |
| 5424 |
if len(attrs) == 0 { |
| 5425 |
m.Int64UpDownCounter.Add(ctx, incr) |
| 5426 |
return |
| 5427 |
} |
| 5428 |
|
| 5429 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5430 |
defer func() { |
| 5431 |
*o = (*o)[:0] |
| 5432 |
addOptPool.Put(o) |
| 5433 |
}() |
| 5434 |
|
| 5435 |
*o = append( |
| 5436 |
*o, |
| 5437 |
metric.WithAttributes( |
| 5438 |
append( |
| 5439 |
attrs, |
| 5440 |
attribute.String("hw.id", id), |
| 5441 |
attribute.String("hw.state", string(state)), |
| 5442 |
attribute.String("hw.type", string(hwType)), |
| 5443 |
)..., |
| 5444 |
), |
| 5445 |
) |
| 5446 |
|
| 5447 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5448 |
} |
| 5449 |
|
| 5450 |
// AddSet adds incr to the existing count for set. |
| 5451 |
// |
| 5452 |
// `hw.status` is currently specified as an *UpDownCounter* but would ideally be |
| 5453 |
// represented using a [*StateSet* as defined in OpenMetrics]. This semantic |
| 5454 |
// convention will be updated once *StateSet* is specified in OpenTelemetry. This |
| 5455 |
// planned change is not expected to have any consequence on the way users query |
| 5456 |
// their timeseries backend to retrieve the values of `hw.status` over time. |
| 5457 |
// |
| 5458 |
// [ [*StateSet* as defined in OpenMetrics]: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#stateset |
| 5459 |
func (m Status) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5460 |
if set.Len() == 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.WithAttributeSet(set)) |
| 5472 |
m.Int64UpDownCounter.Add(ctx, incr, *o...) |
| 5473 |
} |
| 5474 |
|
| 5475 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 5476 |
// It represents an easily-recognizable name for the hardware component. |
| 5477 |
func (Status) AttrName(val string) attribute.KeyValue { |
| 5478 |
return attribute.String("hw.name", val) |
| 5479 |
} |
| 5480 |
|
| 5481 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 5482 |
// convention. It represents the unique identifier of the parent component |
| 5483 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 5484 |
func (Status) AttrParent(val string) attribute.KeyValue { |
| 5485 |
return attribute.String("hw.parent", val) |
| 5486 |
} |
| 5487 |
|
| 5488 |
// TapeDriveOperations is an instrument used to record metric values conforming |
| 5489 |
// to the "hw.tape_drive.operations" semantic conventions. It represents the |
| 5490 |
// operations performed by the tape drive. |
| 5491 |
type TapeDriveOperations struct { |
| 5492 |
metric.Int64Counter |
| 5493 |
} |
| 5494 |
|
| 5495 |
var newTapeDriveOperationsOpts = []metric.Int64CounterOption{ |
| 5496 |
metric.WithDescription("Operations performed by the tape drive."), |
| 5497 |
metric.WithUnit("{operation}"), |
| 5498 |
} |
| 5499 |
|
| 5500 |
// NewTapeDriveOperations returns a new TapeDriveOperations instrument. |
| 5501 |
func NewTapeDriveOperations( |
| 5502 |
m metric.Meter, |
| 5503 |
opt ...metric.Int64CounterOption, |
| 5504 |
) (TapeDriveOperations, error) { |
| 5505 |
// Check if the meter is nil. |
| 5506 |
if m == nil { |
| 5507 |
return TapeDriveOperations{noop.Int64Counter{}}, nil |
| 5508 |
} |
| 5509 |
|
| 5510 |
if len(opt) == 0 { |
| 5511 |
opt = newTapeDriveOperationsOpts |
| 5512 |
} else { |
| 5513 |
opt = append(opt, newTapeDriveOperationsOpts...) |
| 5514 |
} |
| 5515 |
|
| 5516 |
i, err := m.Int64Counter( |
| 5517 |
"hw.tape_drive.operations", |
| 5518 |
opt..., |
| 5519 |
) |
| 5520 |
if err != nil { |
| 5521 |
return TapeDriveOperations{noop.Int64Counter{}}, err |
| 5522 |
} |
| 5523 |
return TapeDriveOperations{i}, nil |
| 5524 |
} |
| 5525 |
|
| 5526 |
// Inst returns the underlying metric instrument. |
| 5527 |
func (m TapeDriveOperations) Inst() metric.Int64Counter { |
| 5528 |
return m.Int64Counter |
| 5529 |
} |
| 5530 |
|
| 5531 |
// Name returns the semantic convention name of the instrument. |
| 5532 |
func (TapeDriveOperations) Name() string { |
| 5533 |
return "hw.tape_drive.operations" |
| 5534 |
} |
| 5535 |
|
| 5536 |
// Unit returns the semantic convention unit of the instrument |
| 5537 |
func (TapeDriveOperations) Unit() string { |
| 5538 |
return "{operation}" |
| 5539 |
} |
| 5540 |
|
| 5541 |
// Description returns the semantic convention description of the instrument |
| 5542 |
func (TapeDriveOperations) Description() string { |
| 5543 |
return "Operations performed by the tape drive." |
| 5544 |
} |
| 5545 |
|
| 5546 |
// Add adds incr to the existing count for attrs. |
| 5547 |
// |
| 5548 |
// The id is the an identifier for the hardware component, unique within the |
| 5549 |
// monitored host |
| 5550 |
// |
| 5551 |
// All additional attrs passed are included in the recorded value. |
| 5552 |
func (m TapeDriveOperations) Add( |
| 5553 |
ctx context.Context, |
| 5554 |
incr int64, |
| 5555 |
id string, |
| 5556 |
attrs ...attribute.KeyValue, |
| 5557 |
) { |
| 5558 |
if len(attrs) == 0 { |
| 5559 |
m.Int64Counter.Add(ctx, incr) |
| 5560 |
return |
| 5561 |
} |
| 5562 |
|
| 5563 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5564 |
defer func() { |
| 5565 |
*o = (*o)[:0] |
| 5566 |
addOptPool.Put(o) |
| 5567 |
}() |
| 5568 |
|
| 5569 |
*o = append( |
| 5570 |
*o, |
| 5571 |
metric.WithAttributes( |
| 5572 |
append( |
| 5573 |
attrs, |
| 5574 |
attribute.String("hw.id", id), |
| 5575 |
)..., |
| 5576 |
), |
| 5577 |
) |
| 5578 |
|
| 5579 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 5580 |
} |
| 5581 |
|
| 5582 |
// AddSet adds incr to the existing count for set. |
| 5583 |
func (m TapeDriveOperations) AddSet(ctx context.Context, incr int64, set attribute.Set) { |
| 5584 |
if set.Len() == 0 { |
| 5585 |
m.Int64Counter.Add(ctx, incr) |
| 5586 |
return |
| 5587 |
} |
| 5588 |
|
| 5589 |
o := addOptPool.Get().(*[]metric.AddOption) |
| 5590 |
defer func() { |
| 5591 |
*o = (*o)[:0] |
| 5592 |
addOptPool.Put(o) |
| 5593 |
}() |
| 5594 |
|
| 5595 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5596 |
m.Int64Counter.Add(ctx, incr, *o...) |
| 5597 |
} |
| 5598 |
|
| 5599 |
// AttrModel returns an optional attribute for the "hw.model" semantic |
| 5600 |
// convention. It represents the descriptive model name of the hardware |
| 5601 |
// component. |
| 5602 |
func (TapeDriveOperations) AttrModel(val string) attribute.KeyValue { |
| 5603 |
return attribute.String("hw.model", val) |
| 5604 |
} |
| 5605 |
|
| 5606 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 5607 |
// It represents an easily-recognizable name for the hardware component. |
| 5608 |
func (TapeDriveOperations) AttrName(val string) attribute.KeyValue { |
| 5609 |
return attribute.String("hw.name", val) |
| 5610 |
} |
| 5611 |
|
| 5612 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 5613 |
// convention. It represents the unique identifier of the parent component |
| 5614 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 5615 |
func (TapeDriveOperations) AttrParent(val string) attribute.KeyValue { |
| 5616 |
return attribute.String("hw.parent", val) |
| 5617 |
} |
| 5618 |
|
| 5619 |
// AttrSerialNumber returns an optional attribute for the "hw.serial_number" |
| 5620 |
// semantic convention. It represents the serial number of the hardware |
| 5621 |
// component. |
| 5622 |
func (TapeDriveOperations) AttrSerialNumber(val string) attribute.KeyValue { |
| 5623 |
return attribute.String("hw.serial_number", val) |
| 5624 |
} |
| 5625 |
|
| 5626 |
// AttrTapeDriveOperationType returns an optional attribute for the |
| 5627 |
// "hw.tape_drive.operation_type" semantic convention. It represents the type of |
| 5628 |
// tape drive operation. |
| 5629 |
func (TapeDriveOperations) AttrTapeDriveOperationType(val TapeDriveOperationTypeAttr) attribute.KeyValue { |
| 5630 |
return attribute.String("hw.tape_drive.operation_type", string(val)) |
| 5631 |
} |
| 5632 |
|
| 5633 |
// AttrVendor returns an optional attribute for the "hw.vendor" semantic |
| 5634 |
// convention. It represents the vendor name of the hardware component. |
| 5635 |
func (TapeDriveOperations) AttrVendor(val string) attribute.KeyValue { |
| 5636 |
return attribute.String("hw.vendor", val) |
| 5637 |
} |
| 5638 |
|
| 5639 |
// Temperature is an instrument used to record metric values conforming to the |
| 5640 |
// "hw.temperature" semantic conventions. It represents the temperature in |
| 5641 |
// degrees Celsius. |
| 5642 |
type Temperature struct { |
| 5643 |
metric.Int64Gauge |
| 5644 |
} |
| 5645 |
|
| 5646 |
var newTemperatureOpts = []metric.Int64GaugeOption{ |
| 5647 |
metric.WithDescription("Temperature in degrees Celsius."), |
| 5648 |
metric.WithUnit("Cel"), |
| 5649 |
} |
| 5650 |
|
| 5651 |
// NewTemperature returns a new Temperature instrument. |
| 5652 |
func NewTemperature( |
| 5653 |
m metric.Meter, |
| 5654 |
opt ...metric.Int64GaugeOption, |
| 5655 |
) (Temperature, error) { |
| 5656 |
// Check if the meter is nil. |
| 5657 |
if m == nil { |
| 5658 |
return Temperature{noop.Int64Gauge{}}, nil |
| 5659 |
} |
| 5660 |
|
| 5661 |
if len(opt) == 0 { |
| 5662 |
opt = newTemperatureOpts |
| 5663 |
} else { |
| 5664 |
opt = append(opt, newTemperatureOpts...) |
| 5665 |
} |
| 5666 |
|
| 5667 |
i, err := m.Int64Gauge( |
| 5668 |
"hw.temperature", |
| 5669 |
opt..., |
| 5670 |
) |
| 5671 |
if err != nil { |
| 5672 |
return Temperature{noop.Int64Gauge{}}, err |
| 5673 |
} |
| 5674 |
return Temperature{i}, nil |
| 5675 |
} |
| 5676 |
|
| 5677 |
// Inst returns the underlying metric instrument. |
| 5678 |
func (m Temperature) Inst() metric.Int64Gauge { |
| 5679 |
return m.Int64Gauge |
| 5680 |
} |
| 5681 |
|
| 5682 |
// Name returns the semantic convention name of the instrument. |
| 5683 |
func (Temperature) Name() string { |
| 5684 |
return "hw.temperature" |
| 5685 |
} |
| 5686 |
|
| 5687 |
// Unit returns the semantic convention unit of the instrument |
| 5688 |
func (Temperature) Unit() string { |
| 5689 |
return "Cel" |
| 5690 |
} |
| 5691 |
|
| 5692 |
// Description returns the semantic convention description of the instrument |
| 5693 |
func (Temperature) Description() string { |
| 5694 |
return "Temperature in degrees Celsius." |
| 5695 |
} |
| 5696 |
|
| 5697 |
// Record records val to the current distribution for attrs. |
| 5698 |
// |
| 5699 |
// The id is the an identifier for the hardware component, unique within the |
| 5700 |
// monitored host |
| 5701 |
// |
| 5702 |
// All additional attrs passed are included in the recorded value. |
| 5703 |
func (m Temperature) Record( |
| 5704 |
ctx context.Context, |
| 5705 |
val int64, |
| 5706 |
id string, |
| 5707 |
attrs ...attribute.KeyValue, |
| 5708 |
) { |
| 5709 |
if len(attrs) == 0 { |
| 5710 |
m.Int64Gauge.Record(ctx, val) |
| 5711 |
return |
| 5712 |
} |
| 5713 |
|
| 5714 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5715 |
defer func() { |
| 5716 |
*o = (*o)[:0] |
| 5717 |
recOptPool.Put(o) |
| 5718 |
}() |
| 5719 |
|
| 5720 |
*o = append( |
| 5721 |
*o, |
| 5722 |
metric.WithAttributes( |
| 5723 |
append( |
| 5724 |
attrs, |
| 5725 |
attribute.String("hw.id", id), |
| 5726 |
)..., |
| 5727 |
), |
| 5728 |
) |
| 5729 |
|
| 5730 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5731 |
} |
| 5732 |
|
| 5733 |
// RecordSet records val to the current distribution for set. |
| 5734 |
func (m Temperature) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 5735 |
if set.Len() == 0 { |
| 5736 |
m.Int64Gauge.Record(ctx, val) |
| 5737 |
return |
| 5738 |
} |
| 5739 |
|
| 5740 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5741 |
defer func() { |
| 5742 |
*o = (*o)[:0] |
| 5743 |
recOptPool.Put(o) |
| 5744 |
}() |
| 5745 |
|
| 5746 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5747 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5748 |
} |
| 5749 |
|
| 5750 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 5751 |
// It represents an easily-recognizable name for the hardware component. |
| 5752 |
func (Temperature) AttrName(val string) attribute.KeyValue { |
| 5753 |
return attribute.String("hw.name", val) |
| 5754 |
} |
| 5755 |
|
| 5756 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 5757 |
// convention. It represents the unique identifier of the parent component |
| 5758 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 5759 |
func (Temperature) AttrParent(val string) attribute.KeyValue { |
| 5760 |
return attribute.String("hw.parent", val) |
| 5761 |
} |
| 5762 |
|
| 5763 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 5764 |
// semantic convention. It represents the location of the sensor. |
| 5765 |
func (Temperature) AttrSensorLocation(val string) attribute.KeyValue { |
| 5766 |
return attribute.String("hw.sensor_location", val) |
| 5767 |
} |
| 5768 |
|
| 5769 |
// TemperatureLimit is an instrument used to record metric values conforming to |
| 5770 |
// the "hw.temperature.limit" semantic conventions. It represents the temperature |
| 5771 |
// limit in degrees Celsius. |
| 5772 |
type TemperatureLimit struct { |
| 5773 |
metric.Int64Gauge |
| 5774 |
} |
| 5775 |
|
| 5776 |
var newTemperatureLimitOpts = []metric.Int64GaugeOption{ |
| 5777 |
metric.WithDescription("Temperature limit in degrees Celsius."), |
| 5778 |
metric.WithUnit("Cel"), |
| 5779 |
} |
| 5780 |
|
| 5781 |
// NewTemperatureLimit returns a new TemperatureLimit instrument. |
| 5782 |
func NewTemperatureLimit( |
| 5783 |
m metric.Meter, |
| 5784 |
opt ...metric.Int64GaugeOption, |
| 5785 |
) (TemperatureLimit, error) { |
| 5786 |
// Check if the meter is nil. |
| 5787 |
if m == nil { |
| 5788 |
return TemperatureLimit{noop.Int64Gauge{}}, nil |
| 5789 |
} |
| 5790 |
|
| 5791 |
if len(opt) == 0 { |
| 5792 |
opt = newTemperatureLimitOpts |
| 5793 |
} else { |
| 5794 |
opt = append(opt, newTemperatureLimitOpts...) |
| 5795 |
} |
| 5796 |
|
| 5797 |
i, err := m.Int64Gauge( |
| 5798 |
"hw.temperature.limit", |
| 5799 |
opt..., |
| 5800 |
) |
| 5801 |
if err != nil { |
| 5802 |
return TemperatureLimit{noop.Int64Gauge{}}, err |
| 5803 |
} |
| 5804 |
return TemperatureLimit{i}, nil |
| 5805 |
} |
| 5806 |
|
| 5807 |
// Inst returns the underlying metric instrument. |
| 5808 |
func (m TemperatureLimit) Inst() metric.Int64Gauge { |
| 5809 |
return m.Int64Gauge |
| 5810 |
} |
| 5811 |
|
| 5812 |
// Name returns the semantic convention name of the instrument. |
| 5813 |
func (TemperatureLimit) Name() string { |
| 5814 |
return "hw.temperature.limit" |
| 5815 |
} |
| 5816 |
|
| 5817 |
// Unit returns the semantic convention unit of the instrument |
| 5818 |
func (TemperatureLimit) Unit() string { |
| 5819 |
return "Cel" |
| 5820 |
} |
| 5821 |
|
| 5822 |
// Description returns the semantic convention description of the instrument |
| 5823 |
func (TemperatureLimit) Description() string { |
| 5824 |
return "Temperature limit in degrees Celsius." |
| 5825 |
} |
| 5826 |
|
| 5827 |
// Record records val to the current distribution for attrs. |
| 5828 |
// |
| 5829 |
// The id is the an identifier for the hardware component, unique within the |
| 5830 |
// monitored host |
| 5831 |
// |
| 5832 |
// All additional attrs passed are included in the recorded value. |
| 5833 |
func (m TemperatureLimit) Record( |
| 5834 |
ctx context.Context, |
| 5835 |
val int64, |
| 5836 |
id string, |
| 5837 |
attrs ...attribute.KeyValue, |
| 5838 |
) { |
| 5839 |
if len(attrs) == 0 { |
| 5840 |
m.Int64Gauge.Record(ctx, val) |
| 5841 |
return |
| 5842 |
} |
| 5843 |
|
| 5844 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5845 |
defer func() { |
| 5846 |
*o = (*o)[:0] |
| 5847 |
recOptPool.Put(o) |
| 5848 |
}() |
| 5849 |
|
| 5850 |
*o = append( |
| 5851 |
*o, |
| 5852 |
metric.WithAttributes( |
| 5853 |
append( |
| 5854 |
attrs, |
| 5855 |
attribute.String("hw.id", id), |
| 5856 |
)..., |
| 5857 |
), |
| 5858 |
) |
| 5859 |
|
| 5860 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5861 |
} |
| 5862 |
|
| 5863 |
// RecordSet records val to the current distribution for set. |
| 5864 |
func (m TemperatureLimit) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 5865 |
if set.Len() == 0 { |
| 5866 |
m.Int64Gauge.Record(ctx, val) |
| 5867 |
return |
| 5868 |
} |
| 5869 |
|
| 5870 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5871 |
defer func() { |
| 5872 |
*o = (*o)[:0] |
| 5873 |
recOptPool.Put(o) |
| 5874 |
}() |
| 5875 |
|
| 5876 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 5877 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5878 |
} |
| 5879 |
|
| 5880 |
// AttrLimitType returns an optional attribute for the "hw.limit_type" semantic |
| 5881 |
// convention. It represents the type of limit for hardware components. |
| 5882 |
func (TemperatureLimit) AttrLimitType(val LimitTypeAttr) attribute.KeyValue { |
| 5883 |
return attribute.String("hw.limit_type", string(val)) |
| 5884 |
} |
| 5885 |
|
| 5886 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 5887 |
// It represents an easily-recognizable name for the hardware component. |
| 5888 |
func (TemperatureLimit) AttrName(val string) attribute.KeyValue { |
| 5889 |
return attribute.String("hw.name", val) |
| 5890 |
} |
| 5891 |
|
| 5892 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 5893 |
// convention. It represents the unique identifier of the parent component |
| 5894 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 5895 |
func (TemperatureLimit) AttrParent(val string) attribute.KeyValue { |
| 5896 |
return attribute.String("hw.parent", val) |
| 5897 |
} |
| 5898 |
|
| 5899 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 5900 |
// semantic convention. It represents the location of the sensor. |
| 5901 |
func (TemperatureLimit) AttrSensorLocation(val string) attribute.KeyValue { |
| 5902 |
return attribute.String("hw.sensor_location", val) |
| 5903 |
} |
| 5904 |
|
| 5905 |
// Voltage is an instrument used to record metric values conforming to the |
| 5906 |
// "hw.voltage" semantic conventions. It represents the voltage measured by the |
| 5907 |
// sensor. |
| 5908 |
type Voltage struct { |
| 5909 |
metric.Int64Gauge |
| 5910 |
} |
| 5911 |
|
| 5912 |
var newVoltageOpts = []metric.Int64GaugeOption{ |
| 5913 |
metric.WithDescription("Voltage measured by the sensor."), |
| 5914 |
metric.WithUnit("V"), |
| 5915 |
} |
| 5916 |
|
| 5917 |
// NewVoltage returns a new Voltage instrument. |
| 5918 |
func NewVoltage( |
| 5919 |
m metric.Meter, |
| 5920 |
opt ...metric.Int64GaugeOption, |
| 5921 |
) (Voltage, error) { |
| 5922 |
// Check if the meter is nil. |
| 5923 |
if m == nil { |
| 5924 |
return Voltage{noop.Int64Gauge{}}, nil |
| 5925 |
} |
| 5926 |
|
| 5927 |
if len(opt) == 0 { |
| 5928 |
opt = newVoltageOpts |
| 5929 |
} else { |
| 5930 |
opt = append(opt, newVoltageOpts...) |
| 5931 |
} |
| 5932 |
|
| 5933 |
i, err := m.Int64Gauge( |
| 5934 |
"hw.voltage", |
| 5935 |
opt..., |
| 5936 |
) |
| 5937 |
if err != nil { |
| 5938 |
return Voltage{noop.Int64Gauge{}}, err |
| 5939 |
} |
| 5940 |
return Voltage{i}, nil |
| 5941 |
} |
| 5942 |
|
| 5943 |
// Inst returns the underlying metric instrument. |
| 5944 |
func (m Voltage) Inst() metric.Int64Gauge { |
| 5945 |
return m.Int64Gauge |
| 5946 |
} |
| 5947 |
|
| 5948 |
// Name returns the semantic convention name of the instrument. |
| 5949 |
func (Voltage) Name() string { |
| 5950 |
return "hw.voltage" |
| 5951 |
} |
| 5952 |
|
| 5953 |
// Unit returns the semantic convention unit of the instrument |
| 5954 |
func (Voltage) Unit() string { |
| 5955 |
return "V" |
| 5956 |
} |
| 5957 |
|
| 5958 |
// Description returns the semantic convention description of the instrument |
| 5959 |
func (Voltage) Description() string { |
| 5960 |
return "Voltage measured by the sensor." |
| 5961 |
} |
| 5962 |
|
| 5963 |
// Record records val to the current distribution for attrs. |
| 5964 |
// |
| 5965 |
// The id is the an identifier for the hardware component, unique within the |
| 5966 |
// monitored host |
| 5967 |
// |
| 5968 |
// All additional attrs passed are included in the recorded value. |
| 5969 |
func (m Voltage) Record( |
| 5970 |
ctx context.Context, |
| 5971 |
val int64, |
| 5972 |
id string, |
| 5973 |
attrs ...attribute.KeyValue, |
| 5974 |
) { |
| 5975 |
if len(attrs) == 0 { |
| 5976 |
m.Int64Gauge.Record(ctx, val) |
| 5977 |
return |
| 5978 |
} |
| 5979 |
|
| 5980 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 5981 |
defer func() { |
| 5982 |
*o = (*o)[:0] |
| 5983 |
recOptPool.Put(o) |
| 5984 |
}() |
| 5985 |
|
| 5986 |
*o = append( |
| 5987 |
*o, |
| 5988 |
metric.WithAttributes( |
| 5989 |
append( |
| 5990 |
attrs, |
| 5991 |
attribute.String("hw.id", id), |
| 5992 |
)..., |
| 5993 |
), |
| 5994 |
) |
| 5995 |
|
| 5996 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 5997 |
} |
| 5998 |
|
| 5999 |
// RecordSet records val to the current distribution for set. |
| 6000 |
func (m Voltage) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 6001 |
if set.Len() == 0 { |
| 6002 |
m.Int64Gauge.Record(ctx, val) |
| 6003 |
return |
| 6004 |
} |
| 6005 |
|
| 6006 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 6007 |
defer func() { |
| 6008 |
*o = (*o)[:0] |
| 6009 |
recOptPool.Put(o) |
| 6010 |
}() |
| 6011 |
|
| 6012 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6013 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 6014 |
} |
| 6015 |
|
| 6016 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 6017 |
// It represents an easily-recognizable name for the hardware component. |
| 6018 |
func (Voltage) AttrName(val string) attribute.KeyValue { |
| 6019 |
return attribute.String("hw.name", val) |
| 6020 |
} |
| 6021 |
|
| 6022 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 6023 |
// convention. It represents the unique identifier of the parent component |
| 6024 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 6025 |
func (Voltage) AttrParent(val string) attribute.KeyValue { |
| 6026 |
return attribute.String("hw.parent", val) |
| 6027 |
} |
| 6028 |
|
| 6029 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 6030 |
// semantic convention. It represents the location of the sensor. |
| 6031 |
func (Voltage) AttrSensorLocation(val string) attribute.KeyValue { |
| 6032 |
return attribute.String("hw.sensor_location", val) |
| 6033 |
} |
| 6034 |
|
| 6035 |
// VoltageLimit is an instrument used to record metric values conforming to the |
| 6036 |
// "hw.voltage.limit" semantic conventions. It represents the voltage limit in |
| 6037 |
// Volts. |
| 6038 |
type VoltageLimit struct { |
| 6039 |
metric.Int64Gauge |
| 6040 |
} |
| 6041 |
|
| 6042 |
var newVoltageLimitOpts = []metric.Int64GaugeOption{ |
| 6043 |
metric.WithDescription("Voltage limit in Volts."), |
| 6044 |
metric.WithUnit("V"), |
| 6045 |
} |
| 6046 |
|
| 6047 |
// NewVoltageLimit returns a new VoltageLimit instrument. |
| 6048 |
func NewVoltageLimit( |
| 6049 |
m metric.Meter, |
| 6050 |
opt ...metric.Int64GaugeOption, |
| 6051 |
) (VoltageLimit, error) { |
| 6052 |
// Check if the meter is nil. |
| 6053 |
if m == nil { |
| 6054 |
return VoltageLimit{noop.Int64Gauge{}}, nil |
| 6055 |
} |
| 6056 |
|
| 6057 |
if len(opt) == 0 { |
| 6058 |
opt = newVoltageLimitOpts |
| 6059 |
} else { |
| 6060 |
opt = append(opt, newVoltageLimitOpts...) |
| 6061 |
} |
| 6062 |
|
| 6063 |
i, err := m.Int64Gauge( |
| 6064 |
"hw.voltage.limit", |
| 6065 |
opt..., |
| 6066 |
) |
| 6067 |
if err != nil { |
| 6068 |
return VoltageLimit{noop.Int64Gauge{}}, err |
| 6069 |
} |
| 6070 |
return VoltageLimit{i}, nil |
| 6071 |
} |
| 6072 |
|
| 6073 |
// Inst returns the underlying metric instrument. |
| 6074 |
func (m VoltageLimit) Inst() metric.Int64Gauge { |
| 6075 |
return m.Int64Gauge |
| 6076 |
} |
| 6077 |
|
| 6078 |
// Name returns the semantic convention name of the instrument. |
| 6079 |
func (VoltageLimit) Name() string { |
| 6080 |
return "hw.voltage.limit" |
| 6081 |
} |
| 6082 |
|
| 6083 |
// Unit returns the semantic convention unit of the instrument |
| 6084 |
func (VoltageLimit) Unit() string { |
| 6085 |
return "V" |
| 6086 |
} |
| 6087 |
|
| 6088 |
// Description returns the semantic convention description of the instrument |
| 6089 |
func (VoltageLimit) Description() string { |
| 6090 |
return "Voltage limit in Volts." |
| 6091 |
} |
| 6092 |
|
| 6093 |
// Record records val to the current distribution for attrs. |
| 6094 |
// |
| 6095 |
// The id is the an identifier for the hardware component, unique within the |
| 6096 |
// monitored host |
| 6097 |
// |
| 6098 |
// All additional attrs passed are included in the recorded value. |
| 6099 |
func (m VoltageLimit) Record( |
| 6100 |
ctx context.Context, |
| 6101 |
val int64, |
| 6102 |
id string, |
| 6103 |
attrs ...attribute.KeyValue, |
| 6104 |
) { |
| 6105 |
if len(attrs) == 0 { |
| 6106 |
m.Int64Gauge.Record(ctx, val) |
| 6107 |
return |
| 6108 |
} |
| 6109 |
|
| 6110 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 6111 |
defer func() { |
| 6112 |
*o = (*o)[:0] |
| 6113 |
recOptPool.Put(o) |
| 6114 |
}() |
| 6115 |
|
| 6116 |
*o = append( |
| 6117 |
*o, |
| 6118 |
metric.WithAttributes( |
| 6119 |
append( |
| 6120 |
attrs, |
| 6121 |
attribute.String("hw.id", id), |
| 6122 |
)..., |
| 6123 |
), |
| 6124 |
) |
| 6125 |
|
| 6126 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 6127 |
} |
| 6128 |
|
| 6129 |
// RecordSet records val to the current distribution for set. |
| 6130 |
func (m VoltageLimit) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 6131 |
if set.Len() == 0 { |
| 6132 |
m.Int64Gauge.Record(ctx, val) |
| 6133 |
return |
| 6134 |
} |
| 6135 |
|
| 6136 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 6137 |
defer func() { |
| 6138 |
*o = (*o)[:0] |
| 6139 |
recOptPool.Put(o) |
| 6140 |
}() |
| 6141 |
|
| 6142 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6143 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 6144 |
} |
| 6145 |
|
| 6146 |
// AttrLimitType returns an optional attribute for the "hw.limit_type" semantic |
| 6147 |
// convention. It represents the type of limit for hardware components. |
| 6148 |
func (VoltageLimit) AttrLimitType(val LimitTypeAttr) attribute.KeyValue { |
| 6149 |
return attribute.String("hw.limit_type", string(val)) |
| 6150 |
} |
| 6151 |
|
| 6152 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 6153 |
// It represents an easily-recognizable name for the hardware component. |
| 6154 |
func (VoltageLimit) AttrName(val string) attribute.KeyValue { |
| 6155 |
return attribute.String("hw.name", val) |
| 6156 |
} |
| 6157 |
|
| 6158 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 6159 |
// convention. It represents the unique identifier of the parent component |
| 6160 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 6161 |
func (VoltageLimit) AttrParent(val string) attribute.KeyValue { |
| 6162 |
return attribute.String("hw.parent", val) |
| 6163 |
} |
| 6164 |
|
| 6165 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 6166 |
// semantic convention. It represents the location of the sensor. |
| 6167 |
func (VoltageLimit) AttrSensorLocation(val string) attribute.KeyValue { |
| 6168 |
return attribute.String("hw.sensor_location", val) |
| 6169 |
} |
| 6170 |
|
| 6171 |
// VoltageNominal is an instrument used to record metric values conforming to the |
| 6172 |
// "hw.voltage.nominal" semantic conventions. It represents the nominal |
| 6173 |
// (expected) voltage. |
| 6174 |
type VoltageNominal struct { |
| 6175 |
metric.Int64Gauge |
| 6176 |
} |
| 6177 |
|
| 6178 |
var newVoltageNominalOpts = []metric.Int64GaugeOption{ |
| 6179 |
metric.WithDescription("Nominal (expected) voltage."), |
| 6180 |
metric.WithUnit("V"), |
| 6181 |
} |
| 6182 |
|
| 6183 |
// NewVoltageNominal returns a new VoltageNominal instrument. |
| 6184 |
func NewVoltageNominal( |
| 6185 |
m metric.Meter, |
| 6186 |
opt ...metric.Int64GaugeOption, |
| 6187 |
) (VoltageNominal, error) { |
| 6188 |
// Check if the meter is nil. |
| 6189 |
if m == nil { |
| 6190 |
return VoltageNominal{noop.Int64Gauge{}}, nil |
| 6191 |
} |
| 6192 |
|
| 6193 |
if len(opt) == 0 { |
| 6194 |
opt = newVoltageNominalOpts |
| 6195 |
} else { |
| 6196 |
opt = append(opt, newVoltageNominalOpts...) |
| 6197 |
} |
| 6198 |
|
| 6199 |
i, err := m.Int64Gauge( |
| 6200 |
"hw.voltage.nominal", |
| 6201 |
opt..., |
| 6202 |
) |
| 6203 |
if err != nil { |
| 6204 |
return VoltageNominal{noop.Int64Gauge{}}, err |
| 6205 |
} |
| 6206 |
return VoltageNominal{i}, nil |
| 6207 |
} |
| 6208 |
|
| 6209 |
// Inst returns the underlying metric instrument. |
| 6210 |
func (m VoltageNominal) Inst() metric.Int64Gauge { |
| 6211 |
return m.Int64Gauge |
| 6212 |
} |
| 6213 |
|
| 6214 |
// Name returns the semantic convention name of the instrument. |
| 6215 |
func (VoltageNominal) Name() string { |
| 6216 |
return "hw.voltage.nominal" |
| 6217 |
} |
| 6218 |
|
| 6219 |
// Unit returns the semantic convention unit of the instrument |
| 6220 |
func (VoltageNominal) Unit() string { |
| 6221 |
return "V" |
| 6222 |
} |
| 6223 |
|
| 6224 |
// Description returns the semantic convention description of the instrument |
| 6225 |
func (VoltageNominal) Description() string { |
| 6226 |
return "Nominal (expected) voltage." |
| 6227 |
} |
| 6228 |
|
| 6229 |
// Record records val to the current distribution for attrs. |
| 6230 |
// |
| 6231 |
// The id is the an identifier for the hardware component, unique within the |
| 6232 |
// monitored host |
| 6233 |
// |
| 6234 |
// All additional attrs passed are included in the recorded value. |
| 6235 |
func (m VoltageNominal) Record( |
| 6236 |
ctx context.Context, |
| 6237 |
val int64, |
| 6238 |
id string, |
| 6239 |
attrs ...attribute.KeyValue, |
| 6240 |
) { |
| 6241 |
if len(attrs) == 0 { |
| 6242 |
m.Int64Gauge.Record(ctx, val) |
| 6243 |
return |
| 6244 |
} |
| 6245 |
|
| 6246 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 6247 |
defer func() { |
| 6248 |
*o = (*o)[:0] |
| 6249 |
recOptPool.Put(o) |
| 6250 |
}() |
| 6251 |
|
| 6252 |
*o = append( |
| 6253 |
*o, |
| 6254 |
metric.WithAttributes( |
| 6255 |
append( |
| 6256 |
attrs, |
| 6257 |
attribute.String("hw.id", id), |
| 6258 |
)..., |
| 6259 |
), |
| 6260 |
) |
| 6261 |
|
| 6262 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 6263 |
} |
| 6264 |
|
| 6265 |
// RecordSet records val to the current distribution for set. |
| 6266 |
func (m VoltageNominal) RecordSet(ctx context.Context, val int64, set attribute.Set) { |
| 6267 |
if set.Len() == 0 { |
| 6268 |
m.Int64Gauge.Record(ctx, val) |
| 6269 |
return |
| 6270 |
} |
| 6271 |
|
| 6272 |
o := recOptPool.Get().(*[]metric.RecordOption) |
| 6273 |
defer func() { |
| 6274 |
*o = (*o)[:0] |
| 6275 |
recOptPool.Put(o) |
| 6276 |
}() |
| 6277 |
|
| 6278 |
*o = append(*o, metric.WithAttributeSet(set)) |
| 6279 |
m.Int64Gauge.Record(ctx, val, *o...) |
| 6280 |
} |
| 6281 |
|
| 6282 |
// AttrName returns an optional attribute for the "hw.name" semantic convention. |
| 6283 |
// It represents an easily-recognizable name for the hardware component. |
| 6284 |
func (VoltageNominal) AttrName(val string) attribute.KeyValue { |
| 6285 |
return attribute.String("hw.name", val) |
| 6286 |
} |
| 6287 |
|
| 6288 |
// AttrParent returns an optional attribute for the "hw.parent" semantic |
| 6289 |
// convention. It represents the unique identifier of the parent component |
| 6290 |
// (typically the `hw.id` attribute of the enclosure, or disk controller). |
| 6291 |
func (VoltageNominal) AttrParent(val string) attribute.KeyValue { |
| 6292 |
return attribute.String("hw.parent", val) |
| 6293 |
} |
| 6294 |
|
| 6295 |
// AttrSensorLocation returns an optional attribute for the "hw.sensor_location" |
| 6296 |
// semantic convention. It represents the location of the sensor. |
| 6297 |
func (VoltageNominal) AttrSensorLocation(val string) attribute.KeyValue { |
| 6298 |
return attribute.String("hw.sensor_location", val) |
| 6299 |
} |