Debian Codegraph @

semconv/v1.39.0/hwconv/metric.go

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