Debian Codegraph @

semconv/v1.37.0/systemconv/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 systemconv provides types and functionality for OpenTelemetry semantic
7 // conventions in the "system" namespace.
8 package systemconv
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 // CPUModeAttr is an attribute conforming to the cpu.mode semantic conventions.
25 // It represents the mode of the CPU.
26 type CPUModeAttr string
27
28 var (
29 // CPUModeUser is the user.
30 CPUModeUser CPUModeAttr = "user"
31 // CPUModeSystem is the system.
32 CPUModeSystem CPUModeAttr = "system"
33 // CPUModeNice is the nice.
34 CPUModeNice CPUModeAttr = "nice"
35 // CPUModeIdle is the idle.
36 CPUModeIdle CPUModeAttr = "idle"
37 // CPUModeIOWait is the IO Wait.
38 CPUModeIOWait CPUModeAttr = "iowait"
39 // CPUModeInterrupt is the interrupt.
40 CPUModeInterrupt CPUModeAttr = "interrupt"
41 // CPUModeSteal is the steal.
42 CPUModeSteal CPUModeAttr = "steal"
43 // CPUModeKernel is the kernel.
44 CPUModeKernel CPUModeAttr = "kernel"
45 )
46
47 // DiskIODirectionAttr is an attribute conforming to the disk.io.direction
48 // semantic conventions. It represents the disk IO operation direction.
49 type DiskIODirectionAttr string
50
51 var (
52 // DiskIODirectionRead is the standardized value "read" of DiskIODirectionAttr.
53 DiskIODirectionRead DiskIODirectionAttr = "read"
54 // DiskIODirectionWrite is the standardized value "write" of
55 // DiskIODirectionAttr.
56 DiskIODirectionWrite DiskIODirectionAttr = "write"
57 )
58
59 // LinuxMemorySlabStateAttr is an attribute conforming to the
60 // linux.memory.slab.state semantic conventions. It represents the Linux Slab
61 // memory state.
62 type LinuxMemorySlabStateAttr string
63
64 var (
65 // LinuxMemorySlabStateReclaimable is the standardized value "reclaimable" of
66 // LinuxMemorySlabStateAttr.
67 LinuxMemorySlabStateReclaimable LinuxMemorySlabStateAttr = "reclaimable"
68 // LinuxMemorySlabStateUnreclaimable is the standardized value "unreclaimable"
69 // of LinuxMemorySlabStateAttr.
70 LinuxMemorySlabStateUnreclaimable LinuxMemorySlabStateAttr = "unreclaimable"
71 )
72
73 // NetworkConnectionStateAttr is an attribute conforming to the
74 // network.connection.state semantic conventions. It represents the state of
75 // network connection.
76 type NetworkConnectionStateAttr string
77
78 var (
79 // NetworkConnectionStateClosed is the standardized value "closed" of
80 // NetworkConnectionStateAttr.
81 NetworkConnectionStateClosed NetworkConnectionStateAttr = "closed"
82 // NetworkConnectionStateCloseWait is the standardized value "close_wait" of
83 // NetworkConnectionStateAttr.
84 NetworkConnectionStateCloseWait NetworkConnectionStateAttr = "close_wait"
85 // NetworkConnectionStateClosing is the standardized value "closing" of
86 // NetworkConnectionStateAttr.
87 NetworkConnectionStateClosing NetworkConnectionStateAttr = "closing"
88 // NetworkConnectionStateEstablished is the standardized value "established" of
89 // NetworkConnectionStateAttr.
90 NetworkConnectionStateEstablished NetworkConnectionStateAttr = "established"
91 // NetworkConnectionStateFinWait1 is the standardized value "fin_wait_1" of
92 // NetworkConnectionStateAttr.
93 NetworkConnectionStateFinWait1 NetworkConnectionStateAttr = "fin_wait_1"
94 // NetworkConnectionStateFinWait2 is the standardized value "fin_wait_2" of
95 // NetworkConnectionStateAttr.
96 NetworkConnectionStateFinWait2 NetworkConnectionStateAttr = "fin_wait_2"
97 // NetworkConnectionStateLastAck is the standardized value "last_ack" of
98 // NetworkConnectionStateAttr.
99 NetworkConnectionStateLastAck NetworkConnectionStateAttr = "last_ack"
100 // NetworkConnectionStateListen is the standardized value "listen" of
101 // NetworkConnectionStateAttr.
102 NetworkConnectionStateListen NetworkConnectionStateAttr = "listen"
103 // NetworkConnectionStateSynReceived is the standardized value "syn_received" of
104 // NetworkConnectionStateAttr.
105 NetworkConnectionStateSynReceived NetworkConnectionStateAttr = "syn_received"
106 // NetworkConnectionStateSynSent is the standardized value "syn_sent" of
107 // NetworkConnectionStateAttr.
108 NetworkConnectionStateSynSent NetworkConnectionStateAttr = "syn_sent"
109 // NetworkConnectionStateTimeWait is the standardized value "time_wait" of
110 // NetworkConnectionStateAttr.
111 NetworkConnectionStateTimeWait NetworkConnectionStateAttr = "time_wait"
112 )
113
114 // NetworkIODirectionAttr is an attribute conforming to the network.io.direction
115 // semantic conventions. It represents the network IO operation direction.
116 type NetworkIODirectionAttr string
117
118 var (
119 // NetworkIODirectionTransmit is the standardized value "transmit" of
120 // NetworkIODirectionAttr.
121 NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit"
122 // NetworkIODirectionReceive is the standardized value "receive" of
123 // NetworkIODirectionAttr.
124 NetworkIODirectionReceive NetworkIODirectionAttr = "receive"
125 )
126
127 // NetworkTransportAttr is an attribute conforming to the network.transport
128 // semantic conventions. It represents the [OSI transport layer] or
129 // [inter-process communication method].
130 //
131 // [OSI transport layer]: https://wikipedia.org/wiki/Transport_layer
132 // [inter-process communication method]: https://wikipedia.org/wiki/Inter-process_communication
133 type NetworkTransportAttr string
134
135 var (
136 // NetworkTransportTCP is the TCP.
137 NetworkTransportTCP NetworkTransportAttr = "tcp"
138 // NetworkTransportUDP is the UDP.
139 NetworkTransportUDP NetworkTransportAttr = "udp"
140 // NetworkTransportPipe is the named or anonymous pipe.
141 NetworkTransportPipe NetworkTransportAttr = "pipe"
142 // NetworkTransportUnix is the unix domain socket.
143 NetworkTransportUnix NetworkTransportAttr = "unix"
144 // NetworkTransportQUIC is the QUIC.
145 NetworkTransportQUIC NetworkTransportAttr = "quic"
146 )
147
148 // FilesystemStateAttr is an attribute conforming to the system.filesystem.state
149 // semantic conventions. It represents the filesystem state.
150 type FilesystemStateAttr string
151
152 var (
153 // FilesystemStateUsed is the standardized value "used" of FilesystemStateAttr.
154 FilesystemStateUsed FilesystemStateAttr = "used"
155 // FilesystemStateFree is the standardized value "free" of FilesystemStateAttr.
156 FilesystemStateFree FilesystemStateAttr = "free"
157 // FilesystemStateReserved is the standardized value "reserved" of
158 // FilesystemStateAttr.
159 FilesystemStateReserved FilesystemStateAttr = "reserved"
160 )
161
162 // FilesystemTypeAttr is an attribute conforming to the system.filesystem.type
163 // semantic conventions. It represents the filesystem type.
164 type FilesystemTypeAttr string
165
166 var (
167 // FilesystemTypeFat32 is the standardized value "fat32" of FilesystemTypeAttr.
168 FilesystemTypeFat32 FilesystemTypeAttr = "fat32"
169 // FilesystemTypeExfat is the standardized value "exfat" of FilesystemTypeAttr.
170 FilesystemTypeExfat FilesystemTypeAttr = "exfat"
171 // FilesystemTypeNtfs is the standardized value "ntfs" of FilesystemTypeAttr.
172 FilesystemTypeNtfs FilesystemTypeAttr = "ntfs"
173 // FilesystemTypeRefs is the standardized value "refs" of FilesystemTypeAttr.
174 FilesystemTypeRefs FilesystemTypeAttr = "refs"
175 // FilesystemTypeHfsplus is the standardized value "hfsplus" of
176 // FilesystemTypeAttr.
177 FilesystemTypeHfsplus FilesystemTypeAttr = "hfsplus"
178 // FilesystemTypeExt4 is the standardized value "ext4" of FilesystemTypeAttr.
179 FilesystemTypeExt4 FilesystemTypeAttr = "ext4"
180 )
181
182 // MemoryStateAttr is an attribute conforming to the system.memory.state semantic
183 // conventions. It represents the memory state.
184 type MemoryStateAttr string
185
186 var (
187 // MemoryStateUsed is the actual used virtual memory in bytes.
188 MemoryStateUsed MemoryStateAttr = "used"
189 // MemoryStateFree is the standardized value "free" of MemoryStateAttr.
190 MemoryStateFree MemoryStateAttr = "free"
191 // MemoryStateBuffers is the standardized value "buffers" of MemoryStateAttr.
192 MemoryStateBuffers MemoryStateAttr = "buffers"
193 // MemoryStateCached is the standardized value "cached" of MemoryStateAttr.
194 MemoryStateCached MemoryStateAttr = "cached"
195 )
196
197 // PagingDirectionAttr is an attribute conforming to the system.paging.direction
198 // semantic conventions. It represents the paging access direction.
199 type PagingDirectionAttr string
200
201 var (
202 // PagingDirectionIn is the standardized value "in" of PagingDirectionAttr.
203 PagingDirectionIn PagingDirectionAttr = "in"
204 // PagingDirectionOut is the standardized value "out" of PagingDirectionAttr.
205 PagingDirectionOut PagingDirectionAttr = "out"
206 )
207
208 // PagingStateAttr is an attribute conforming to the system.paging.state semantic
209 // conventions. It represents the memory paging state.
210 type PagingStateAttr string
211
212 var (
213 // PagingStateUsed is the standardized value "used" of PagingStateAttr.
214 PagingStateUsed PagingStateAttr = "used"
215 // PagingStateFree is the standardized value "free" of PagingStateAttr.
216 PagingStateFree PagingStateAttr = "free"
217 )
218
219 // PagingTypeAttr is an attribute conforming to the system.paging.type semantic
220 // conventions. It represents the memory paging type.
221 type PagingTypeAttr string
222
223 var (
224 // PagingTypeMajor is the standardized value "major" of PagingTypeAttr.
225 PagingTypeMajor PagingTypeAttr = "major"
226 // PagingTypeMinor is the standardized value "minor" of PagingTypeAttr.
227 PagingTypeMinor PagingTypeAttr = "minor"
228 )
229
230 // ProcessStatusAttr is an attribute conforming to the system.process.status
231 // semantic conventions. It represents the process state, e.g.,
232 // [Linux Process State Codes].
233 //
234 // [Linux Process State Codes]: https://man7.org/linux/man-pages/man1/ps.1.html#PROCESS_STATE_CODES
235 type ProcessStatusAttr string
236
237 var (
238 // ProcessStatusRunning is the standardized value "running" of
239 // ProcessStatusAttr.
240 ProcessStatusRunning ProcessStatusAttr = "running"
241 // ProcessStatusSleeping is the standardized value "sleeping" of
242 // ProcessStatusAttr.
243 ProcessStatusSleeping ProcessStatusAttr = "sleeping"
244 // ProcessStatusStopped is the standardized value "stopped" of
245 // ProcessStatusAttr.
246 ProcessStatusStopped ProcessStatusAttr = "stopped"
247 // ProcessStatusDefunct is the standardized value "defunct" of
248 // ProcessStatusAttr.
249 ProcessStatusDefunct ProcessStatusAttr = "defunct"
250 )
251
252 // CPUFrequency is an instrument used to record metric values conforming to the
253 // "system.cpu.frequency" semantic conventions. It represents the operating
254 // frequency of the logical CPU in Hertz.
255 type CPUFrequency struct {
256 metric.Int64Gauge
257 }
258
259 var newCPUFrequencyOpts = []metric.Int64GaugeOption{
260 metric.WithDescription("Operating frequency of the logical CPU in Hertz."),
261 metric.WithUnit("Hz"),
262 }
263
264 // NewCPUFrequency returns a new CPUFrequency instrument.
265 func NewCPUFrequency(
266 m metric.Meter,
267 opt ...metric.Int64GaugeOption,
268 ) (CPUFrequency, error) {
269 // Check if the meter is nil.
270 if m == nil {
271 return CPUFrequency{noop.Int64Gauge{}}, nil
272 }
273
274 if len(opt) == 0 {
275 opt = newCPUFrequencyOpts
276 } else {
277 opt = append(opt, newCPUFrequencyOpts...)
278 }
279
280 i, err := m.Int64Gauge(
281 "system.cpu.frequency",
282 opt...,
283 )
284 if err != nil {
285 return CPUFrequency{noop.Int64Gauge{}}, err
286 }
287 return CPUFrequency{i}, nil
288 }
289
290 // Inst returns the underlying metric instrument.
291 func (m CPUFrequency) Inst() metric.Int64Gauge {
292 return m.Int64Gauge
293 }
294
295 // Name returns the semantic convention name of the instrument.
296 func (CPUFrequency) Name() string {
297 return "system.cpu.frequency"
298 }
299
300 // Unit returns the semantic convention unit of the instrument
301 func (CPUFrequency) Unit() string {
302 return "Hz"
303 }
304
305 // Description returns the semantic convention description of the instrument
306 func (CPUFrequency) Description() string {
307 return "Operating frequency of the logical CPU in Hertz."
308 }
309
310 // Record records val to the current distribution for attrs.
311 //
312 // All additional attrs passed are included in the recorded value.
313 func (m CPUFrequency) Record(
314 ctx context.Context,
315 val int64,
316 attrs ...attribute.KeyValue,
317 ) {
318 if len(attrs) == 0 {
319 m.Int64Gauge.Record(ctx, val)
320 return
321 }
322
323 o := recOptPool.Get().(*[]metric.RecordOption)
324 defer func() {
325 *o = (*o)[:0]
326 recOptPool.Put(o)
327 }()
328
329 *o = append(
330 *o,
331 metric.WithAttributes(
332 attrs...,
333 ),
334 )
335
336 m.Int64Gauge.Record(ctx, val, *o...)
337 }
338
339 // RecordSet records val to the current distribution for set.
340 func (m CPUFrequency) RecordSet(ctx context.Context, val int64, set attribute.Set) {
341 if set.Len() == 0 {
342 m.Int64Gauge.Record(ctx, val)
343 return
344 }
345
346 o := recOptPool.Get().(*[]metric.RecordOption)
347 defer func() {
348 *o = (*o)[:0]
349 recOptPool.Put(o)
350 }()
351
352 *o = append(*o, metric.WithAttributeSet(set))
353 m.Int64Gauge.Record(ctx, val, *o...)
354 }
355
356 // AttrCPULogicalNumber returns an optional attribute for the
357 // "cpu.logical_number" semantic convention. It represents the logical CPU number
358 // [0..n-1].
359 func (CPUFrequency) AttrCPULogicalNumber(val int) attribute.KeyValue {
360 return attribute.Int("cpu.logical_number", val)
361 }
362
363 // CPULogicalCount is an instrument used to record metric values conforming to
364 // the "system.cpu.logical.count" semantic conventions. It represents the reports
365 // the number of logical (virtual) processor cores created by the operating
366 // system to manage multitasking.
367 type CPULogicalCount struct {
368 metric.Int64UpDownCounter
369 }
370
371 var newCPULogicalCountOpts = []metric.Int64UpDownCounterOption{
372 metric.WithDescription("Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking."),
373 metric.WithUnit("{cpu}"),
374 }
375
376 // NewCPULogicalCount returns a new CPULogicalCount instrument.
377 func NewCPULogicalCount(
378 m metric.Meter,
379 opt ...metric.Int64UpDownCounterOption,
380 ) (CPULogicalCount, error) {
381 // Check if the meter is nil.
382 if m == nil {
383 return CPULogicalCount{noop.Int64UpDownCounter{}}, nil
384 }
385
386 if len(opt) == 0 {
387 opt = newCPULogicalCountOpts
388 } else {
389 opt = append(opt, newCPULogicalCountOpts...)
390 }
391
392 i, err := m.Int64UpDownCounter(
393 "system.cpu.logical.count",
394 opt...,
395 )
396 if err != nil {
397 return CPULogicalCount{noop.Int64UpDownCounter{}}, err
398 }
399 return CPULogicalCount{i}, nil
400 }
401
402 // Inst returns the underlying metric instrument.
403 func (m CPULogicalCount) Inst() metric.Int64UpDownCounter {
404 return m.Int64UpDownCounter
405 }
406
407 // Name returns the semantic convention name of the instrument.
408 func (CPULogicalCount) Name() string {
409 return "system.cpu.logical.count"
410 }
411
412 // Unit returns the semantic convention unit of the instrument
413 func (CPULogicalCount) Unit() string {
414 return "{cpu}"
415 }
416
417 // Description returns the semantic convention description of the instrument
418 func (CPULogicalCount) Description() string {
419 return "Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking."
420 }
421
422 // Add adds incr to the existing count for attrs.
423 //
424 // Calculated by multiplying the number of sockets by the number of cores per
425 // socket, and then by the number of threads per core
426 func (m CPULogicalCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
427 if len(attrs) == 0 {
428 m.Int64UpDownCounter.Add(ctx, incr)
429 return
430 }
431
432 o := addOptPool.Get().(*[]metric.AddOption)
433 defer func() {
434 *o = (*o)[:0]
435 addOptPool.Put(o)
436 }()
437
438 *o = append(*o, metric.WithAttributes(attrs...))
439 m.Int64UpDownCounter.Add(ctx, incr, *o...)
440 }
441
442 // AddSet adds incr to the existing count for set.
443 //
444 // Calculated by multiplying the number of sockets by the number of cores per
445 // socket, and then by the number of threads per core
446 func (m CPULogicalCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
447 if set.Len() == 0 {
448 m.Int64UpDownCounter.Add(ctx, incr)
449 return
450 }
451
452 o := addOptPool.Get().(*[]metric.AddOption)
453 defer func() {
454 *o = (*o)[:0]
455 addOptPool.Put(o)
456 }()
457
458 *o = append(*o, metric.WithAttributeSet(set))
459 m.Int64UpDownCounter.Add(ctx, incr, *o...)
460 }
461
462 // CPUPhysicalCount is an instrument used to record metric values conforming to
463 // the "system.cpu.physical.count" semantic conventions. It represents the
464 // reports the number of actual physical processor cores on the hardware.
465 type CPUPhysicalCount struct {
466 metric.Int64UpDownCounter
467 }
468
469 var newCPUPhysicalCountOpts = []metric.Int64UpDownCounterOption{
470 metric.WithDescription("Reports the number of actual physical processor cores on the hardware."),
471 metric.WithUnit("{cpu}"),
472 }
473
474 // NewCPUPhysicalCount returns a new CPUPhysicalCount instrument.
475 func NewCPUPhysicalCount(
476 m metric.Meter,
477 opt ...metric.Int64UpDownCounterOption,
478 ) (CPUPhysicalCount, error) {
479 // Check if the meter is nil.
480 if m == nil {
481 return CPUPhysicalCount{noop.Int64UpDownCounter{}}, nil
482 }
483
484 if len(opt) == 0 {
485 opt = newCPUPhysicalCountOpts
486 } else {
487 opt = append(opt, newCPUPhysicalCountOpts...)
488 }
489
490 i, err := m.Int64UpDownCounter(
491 "system.cpu.physical.count",
492 opt...,
493 )
494 if err != nil {
495 return CPUPhysicalCount{noop.Int64UpDownCounter{}}, err
496 }
497 return CPUPhysicalCount{i}, nil
498 }
499
500 // Inst returns the underlying metric instrument.
501 func (m CPUPhysicalCount) Inst() metric.Int64UpDownCounter {
502 return m.Int64UpDownCounter
503 }
504
505 // Name returns the semantic convention name of the instrument.
506 func (CPUPhysicalCount) Name() string {
507 return "system.cpu.physical.count"
508 }
509
510 // Unit returns the semantic convention unit of the instrument
511 func (CPUPhysicalCount) Unit() string {
512 return "{cpu}"
513 }
514
515 // Description returns the semantic convention description of the instrument
516 func (CPUPhysicalCount) Description() string {
517 return "Reports the number of actual physical processor cores on the hardware."
518 }
519
520 // Add adds incr to the existing count for attrs.
521 //
522 // Calculated by multiplying the number of sockets by the number of cores per
523 // socket
524 func (m CPUPhysicalCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
525 if len(attrs) == 0 {
526 m.Int64UpDownCounter.Add(ctx, incr)
527 return
528 }
529
530 o := addOptPool.Get().(*[]metric.AddOption)
531 defer func() {
532 *o = (*o)[:0]
533 addOptPool.Put(o)
534 }()
535
536 *o = append(*o, metric.WithAttributes(attrs...))
537 m.Int64UpDownCounter.Add(ctx, incr, *o...)
538 }
539
540 // AddSet adds incr to the existing count for set.
541 //
542 // Calculated by multiplying the number of sockets by the number of cores per
543 // socket
544 func (m CPUPhysicalCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
545 if set.Len() == 0 {
546 m.Int64UpDownCounter.Add(ctx, incr)
547 return
548 }
549
550 o := addOptPool.Get().(*[]metric.AddOption)
551 defer func() {
552 *o = (*o)[:0]
553 addOptPool.Put(o)
554 }()
555
556 *o = append(*o, metric.WithAttributeSet(set))
557 m.Int64UpDownCounter.Add(ctx, incr, *o...)
558 }
559
560 // CPUTime is an instrument used to record metric values conforming to the
561 // "system.cpu.time" semantic conventions. It represents the seconds each logical
562 // CPU spent on each mode.
563 type CPUTime struct {
564 metric.Float64ObservableCounter
565 }
566
567 var newCPUTimeOpts = []metric.Float64ObservableCounterOption{
568 metric.WithDescription("Seconds each logical CPU spent on each mode."),
569 metric.WithUnit("s"),
570 }
571
572 // NewCPUTime returns a new CPUTime instrument.
573 func NewCPUTime(
574 m metric.Meter,
575 opt ...metric.Float64ObservableCounterOption,
576 ) (CPUTime, error) {
577 // Check if the meter is nil.
578 if m == nil {
579 return CPUTime{noop.Float64ObservableCounter{}}, nil
580 }
581
582 if len(opt) == 0 {
583 opt = newCPUTimeOpts
584 } else {
585 opt = append(opt, newCPUTimeOpts...)
586 }
587
588 i, err := m.Float64ObservableCounter(
589 "system.cpu.time",
590 opt...,
591 )
592 if err != nil {
593 return CPUTime{noop.Float64ObservableCounter{}}, err
594 }
595 return CPUTime{i}, nil
596 }
597
598 // Inst returns the underlying metric instrument.
599 func (m CPUTime) Inst() metric.Float64ObservableCounter {
600 return m.Float64ObservableCounter
601 }
602
603 // Name returns the semantic convention name of the instrument.
604 func (CPUTime) Name() string {
605 return "system.cpu.time"
606 }
607
608 // Unit returns the semantic convention unit of the instrument
609 func (CPUTime) Unit() string {
610 return "s"
611 }
612
613 // Description returns the semantic convention description of the instrument
614 func (CPUTime) Description() string {
615 return "Seconds each logical CPU spent on each mode."
616 }
617
618 // AttrCPULogicalNumber returns an optional attribute for the
619 // "cpu.logical_number" semantic convention. It represents the logical CPU number
620 // [0..n-1].
621 func (CPUTime) AttrCPULogicalNumber(val int) attribute.KeyValue {
622 return attribute.Int("cpu.logical_number", val)
623 }
624
625 // AttrCPUMode returns an optional attribute for the "cpu.mode" semantic
626 // convention. It represents the mode of the CPU.
627 func (CPUTime) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
628 return attribute.String("cpu.mode", string(val))
629 }
630
631 // CPUUtilization is an instrument used to record metric values conforming to the
632 // "system.cpu.utilization" semantic conventions. It represents the for each
633 // logical CPU, the utilization is calculated as the change in cumulative CPU
634 // time (cpu.time) over a measurement interval, divided by the elapsed time.
635 type CPUUtilization struct {
636 metric.Int64Gauge
637 }
638
639 var newCPUUtilizationOpts = []metric.Int64GaugeOption{
640 metric.WithDescription("For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time."),
641 metric.WithUnit("1"),
642 }
643
644 // NewCPUUtilization returns a new CPUUtilization instrument.
645 func NewCPUUtilization(
646 m metric.Meter,
647 opt ...metric.Int64GaugeOption,
648 ) (CPUUtilization, error) {
649 // Check if the meter is nil.
650 if m == nil {
651 return CPUUtilization{noop.Int64Gauge{}}, nil
652 }
653
654 if len(opt) == 0 {
655 opt = newCPUUtilizationOpts
656 } else {
657 opt = append(opt, newCPUUtilizationOpts...)
658 }
659
660 i, err := m.Int64Gauge(
661 "system.cpu.utilization",
662 opt...,
663 )
664 if err != nil {
665 return CPUUtilization{noop.Int64Gauge{}}, err
666 }
667 return CPUUtilization{i}, nil
668 }
669
670 // Inst returns the underlying metric instrument.
671 func (m CPUUtilization) Inst() metric.Int64Gauge {
672 return m.Int64Gauge
673 }
674
675 // Name returns the semantic convention name of the instrument.
676 func (CPUUtilization) Name() string {
677 return "system.cpu.utilization"
678 }
679
680 // Unit returns the semantic convention unit of the instrument
681 func (CPUUtilization) Unit() string {
682 return "1"
683 }
684
685 // Description returns the semantic convention description of the instrument
686 func (CPUUtilization) Description() string {
687 return "For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time."
688 }
689
690 // Record records val to the current distribution for attrs.
691 //
692 // All additional attrs passed are included in the recorded value.
693 func (m CPUUtilization) Record(
694 ctx context.Context,
695 val int64,
696 attrs ...attribute.KeyValue,
697 ) {
698 if len(attrs) == 0 {
699 m.Int64Gauge.Record(ctx, val)
700 return
701 }
702
703 o := recOptPool.Get().(*[]metric.RecordOption)
704 defer func() {
705 *o = (*o)[:0]
706 recOptPool.Put(o)
707 }()
708
709 *o = append(
710 *o,
711 metric.WithAttributes(
712 attrs...,
713 ),
714 )
715
716 m.Int64Gauge.Record(ctx, val, *o...)
717 }
718
719 // RecordSet records val to the current distribution for set.
720 func (m CPUUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) {
721 if set.Len() == 0 {
722 m.Int64Gauge.Record(ctx, val)
723 return
724 }
725
726 o := recOptPool.Get().(*[]metric.RecordOption)
727 defer func() {
728 *o = (*o)[:0]
729 recOptPool.Put(o)
730 }()
731
732 *o = append(*o, metric.WithAttributeSet(set))
733 m.Int64Gauge.Record(ctx, val, *o...)
734 }
735
736 // AttrCPULogicalNumber returns an optional attribute for the
737 // "cpu.logical_number" semantic convention. It represents the logical CPU number
738 // [0..n-1].
739 func (CPUUtilization) AttrCPULogicalNumber(val int) attribute.KeyValue {
740 return attribute.Int("cpu.logical_number", val)
741 }
742
743 // AttrCPUMode returns an optional attribute for the "cpu.mode" semantic
744 // convention. It represents the mode of the CPU.
745 func (CPUUtilization) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
746 return attribute.String("cpu.mode", string(val))
747 }
748
749 // DiskIO is an instrument used to record metric values conforming to the
750 // "system.disk.io" semantic conventions. It represents the TODO.
751 type DiskIO struct {
752 metric.Int64Counter
753 }
754
755 var newDiskIOOpts = []metric.Int64CounterOption{
756 metric.WithDescription("TODO."),
757 metric.WithUnit("By"),
758 }
759
760 // NewDiskIO returns a new DiskIO instrument.
761 func NewDiskIO(
762 m metric.Meter,
763 opt ...metric.Int64CounterOption,
764 ) (DiskIO, error) {
765 // Check if the meter is nil.
766 if m == nil {
767 return DiskIO{noop.Int64Counter{}}, nil
768 }
769
770 if len(opt) == 0 {
771 opt = newDiskIOOpts
772 } else {
773 opt = append(opt, newDiskIOOpts...)
774 }
775
776 i, err := m.Int64Counter(
777 "system.disk.io",
778 opt...,
779 )
780 if err != nil {
781 return DiskIO{noop.Int64Counter{}}, err
782 }
783 return DiskIO{i}, nil
784 }
785
786 // Inst returns the underlying metric instrument.
787 func (m DiskIO) Inst() metric.Int64Counter {
788 return m.Int64Counter
789 }
790
791 // Name returns the semantic convention name of the instrument.
792 func (DiskIO) Name() string {
793 return "system.disk.io"
794 }
795
796 // Unit returns the semantic convention unit of the instrument
797 func (DiskIO) Unit() string {
798 return "By"
799 }
800
801 // Description returns the semantic convention description of the instrument
802 func (DiskIO) Description() string {
803 return "TODO."
804 }
805
806 // Add adds incr to the existing count for attrs.
807 //
808 // All additional attrs passed are included in the recorded value.
809 func (m DiskIO) Add(
810 ctx context.Context,
811 incr int64,
812 attrs ...attribute.KeyValue,
813 ) {
814 if len(attrs) == 0 {
815 m.Int64Counter.Add(ctx, incr)
816 return
817 }
818
819 o := addOptPool.Get().(*[]metric.AddOption)
820 defer func() {
821 *o = (*o)[:0]
822 addOptPool.Put(o)
823 }()
824
825 *o = append(
826 *o,
827 metric.WithAttributes(
828 attrs...,
829 ),
830 )
831
832 m.Int64Counter.Add(ctx, incr, *o...)
833 }
834
835 // AddSet adds incr to the existing count for set.
836 func (m DiskIO) AddSet(ctx context.Context, incr int64, set attribute.Set) {
837 if set.Len() == 0 {
838 m.Int64Counter.Add(ctx, incr)
839 return
840 }
841
842 o := addOptPool.Get().(*[]metric.AddOption)
843 defer func() {
844 *o = (*o)[:0]
845 addOptPool.Put(o)
846 }()
847
848 *o = append(*o, metric.WithAttributeSet(set))
849 m.Int64Counter.Add(ctx, incr, *o...)
850 }
851
852 // AttrDiskIODirection returns an optional attribute for the "disk.io.direction"
853 // semantic convention. It represents the disk IO operation direction.
854 func (DiskIO) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue {
855 return attribute.String("disk.io.direction", string(val))
856 }
857
858 // AttrDevice returns an optional attribute for the "system.device" semantic
859 // convention. It represents the device identifier.
860 func (DiskIO) AttrDevice(val string) attribute.KeyValue {
861 return attribute.String("system.device", val)
862 }
863
864 // DiskIOTime is an instrument used to record metric values conforming to the
865 // "system.disk.io_time" semantic conventions. It represents the time disk spent
866 // activated.
867 type DiskIOTime struct {
868 metric.Float64Counter
869 }
870
871 var newDiskIOTimeOpts = []metric.Float64CounterOption{
872 metric.WithDescription("Time disk spent activated."),
873 metric.WithUnit("s"),
874 }
875
876 // NewDiskIOTime returns a new DiskIOTime instrument.
877 func NewDiskIOTime(
878 m metric.Meter,
879 opt ...metric.Float64CounterOption,
880 ) (DiskIOTime, error) {
881 // Check if the meter is nil.
882 if m == nil {
883 return DiskIOTime{noop.Float64Counter{}}, nil
884 }
885
886 if len(opt) == 0 {
887 opt = newDiskIOTimeOpts
888 } else {
889 opt = append(opt, newDiskIOTimeOpts...)
890 }
891
892 i, err := m.Float64Counter(
893 "system.disk.io_time",
894 opt...,
895 )
896 if err != nil {
897 return DiskIOTime{noop.Float64Counter{}}, err
898 }
899 return DiskIOTime{i}, nil
900 }
901
902 // Inst returns the underlying metric instrument.
903 func (m DiskIOTime) Inst() metric.Float64Counter {
904 return m.Float64Counter
905 }
906
907 // Name returns the semantic convention name of the instrument.
908 func (DiskIOTime) Name() string {
909 return "system.disk.io_time"
910 }
911
912 // Unit returns the semantic convention unit of the instrument
913 func (DiskIOTime) Unit() string {
914 return "s"
915 }
916
917 // Description returns the semantic convention description of the instrument
918 func (DiskIOTime) Description() string {
919 return "Time disk spent activated."
920 }
921
922 // Add adds incr to the existing count for attrs.
923 //
924 // All additional attrs passed are included in the recorded value.
925 //
926 // The real elapsed time ("wall clock") used in the I/O path (time from
927 // operations running in parallel are not counted). Measured as:
928 //
929 // - Linux: Field 13 from [procfs-diskstats]
930 // - Windows: The complement of
931 // ["Disk% Idle Time"]
932 // performance counter: `uptime * (100 - "Disk\% Idle Time") / 100`
933 //
934 //
935 // [procfs-diskstats]: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
936 // ["Disk% Idle Time"]: https://learn.microsoft.com/archive/blogs/askcore/windows-performance-monitor-disk-counters-explained#windows-performance-monitor-disk-counters-explained
937 func (m DiskIOTime) Add(
938 ctx context.Context,
939 incr float64,
940 attrs ...attribute.KeyValue,
941 ) {
942 if len(attrs) == 0 {
943 m.Float64Counter.Add(ctx, incr)
944 return
945 }
946
947 o := addOptPool.Get().(*[]metric.AddOption)
948 defer func() {
949 *o = (*o)[:0]
950 addOptPool.Put(o)
951 }()
952
953 *o = append(
954 *o,
955 metric.WithAttributes(
956 attrs...,
957 ),
958 )
959
960 m.Float64Counter.Add(ctx, incr, *o...)
961 }
962
963 // AddSet adds incr to the existing count for set.
964 //
965 // The real elapsed time ("wall clock") used in the I/O path (time from
966 // operations running in parallel are not counted). Measured as:
967 //
968 // - Linux: Field 13 from [procfs-diskstats]
969 // - Windows: The complement of
970 // ["Disk% Idle Time"]
971 // performance counter: `uptime * (100 - "Disk\% Idle Time") / 100`
972 //
973 //
974 // [procfs-diskstats]: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
975 // ["Disk% Idle Time"]: https://learn.microsoft.com/archive/blogs/askcore/windows-performance-monitor-disk-counters-explained#windows-performance-monitor-disk-counters-explained
976 func (m DiskIOTime) AddSet(ctx context.Context, incr float64, set attribute.Set) {
977 if set.Len() == 0 {
978 m.Float64Counter.Add(ctx, incr)
979 return
980 }
981
982 o := addOptPool.Get().(*[]metric.AddOption)
983 defer func() {
984 *o = (*o)[:0]
985 addOptPool.Put(o)
986 }()
987
988 *o = append(*o, metric.WithAttributeSet(set))
989 m.Float64Counter.Add(ctx, incr, *o...)
990 }
991
992 // AttrDevice returns an optional attribute for the "system.device" semantic
993 // convention. It represents the device identifier.
994 func (DiskIOTime) AttrDevice(val string) attribute.KeyValue {
995 return attribute.String("system.device", val)
996 }
997
998 // DiskLimit is an instrument used to record metric values conforming to the
999 // "system.disk.limit" semantic conventions. It represents the total storage
1000 // capacity of the disk.
1001 type DiskLimit struct {
1002 metric.Int64UpDownCounter
1003 }
1004
1005 var newDiskLimitOpts = []metric.Int64UpDownCounterOption{
1006 metric.WithDescription("The total storage capacity of the disk."),
1007 metric.WithUnit("By"),
1008 }
1009
1010 // NewDiskLimit returns a new DiskLimit instrument.
1011 func NewDiskLimit(
1012 m metric.Meter,
1013 opt ...metric.Int64UpDownCounterOption,
1014 ) (DiskLimit, error) {
1015 // Check if the meter is nil.
1016 if m == nil {
1017 return DiskLimit{noop.Int64UpDownCounter{}}, nil
1018 }
1019
1020 if len(opt) == 0 {
1021 opt = newDiskLimitOpts
1022 } else {
1023 opt = append(opt, newDiskLimitOpts...)
1024 }
1025
1026 i, err := m.Int64UpDownCounter(
1027 "system.disk.limit",
1028 opt...,
1029 )
1030 if err != nil {
1031 return DiskLimit{noop.Int64UpDownCounter{}}, err
1032 }
1033 return DiskLimit{i}, nil
1034 }
1035
1036 // Inst returns the underlying metric instrument.
1037 func (m DiskLimit) Inst() metric.Int64UpDownCounter {
1038 return m.Int64UpDownCounter
1039 }
1040
1041 // Name returns the semantic convention name of the instrument.
1042 func (DiskLimit) Name() string {
1043 return "system.disk.limit"
1044 }
1045
1046 // Unit returns the semantic convention unit of the instrument
1047 func (DiskLimit) Unit() string {
1048 return "By"
1049 }
1050
1051 // Description returns the semantic convention description of the instrument
1052 func (DiskLimit) Description() string {
1053 return "The total storage capacity of the disk."
1054 }
1055
1056 // Add adds incr to the existing count for attrs.
1057 //
1058 // All additional attrs passed are included in the recorded value.
1059 func (m DiskLimit) Add(
1060 ctx context.Context,
1061 incr int64,
1062 attrs ...attribute.KeyValue,
1063 ) {
1064 if len(attrs) == 0 {
1065 m.Int64UpDownCounter.Add(ctx, incr)
1066 return
1067 }
1068
1069 o := addOptPool.Get().(*[]metric.AddOption)
1070 defer func() {
1071 *o = (*o)[:0]
1072 addOptPool.Put(o)
1073 }()
1074
1075 *o = append(
1076 *o,
1077 metric.WithAttributes(
1078 attrs...,
1079 ),
1080 )
1081
1082 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1083 }
1084
1085 // AddSet adds incr to the existing count for set.
1086 func (m DiskLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1087 if set.Len() == 0 {
1088 m.Int64UpDownCounter.Add(ctx, incr)
1089 return
1090 }
1091
1092 o := addOptPool.Get().(*[]metric.AddOption)
1093 defer func() {
1094 *o = (*o)[:0]
1095 addOptPool.Put(o)
1096 }()
1097
1098 *o = append(*o, metric.WithAttributeSet(set))
1099 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1100 }
1101
1102 // AttrDevice returns an optional attribute for the "system.device" semantic
1103 // convention. It represents the device identifier.
1104 func (DiskLimit) AttrDevice(val string) attribute.KeyValue {
1105 return attribute.String("system.device", val)
1106 }
1107
1108 // DiskMerged is an instrument used to record metric values conforming to the
1109 // "system.disk.merged" semantic conventions. It represents the TODO.
1110 type DiskMerged struct {
1111 metric.Int64Counter
1112 }
1113
1114 var newDiskMergedOpts = []metric.Int64CounterOption{
1115 metric.WithDescription("TODO."),
1116 metric.WithUnit("{operation}"),
1117 }
1118
1119 // NewDiskMerged returns a new DiskMerged instrument.
1120 func NewDiskMerged(
1121 m metric.Meter,
1122 opt ...metric.Int64CounterOption,
1123 ) (DiskMerged, error) {
1124 // Check if the meter is nil.
1125 if m == nil {
1126 return DiskMerged{noop.Int64Counter{}}, nil
1127 }
1128
1129 if len(opt) == 0 {
1130 opt = newDiskMergedOpts
1131 } else {
1132 opt = append(opt, newDiskMergedOpts...)
1133 }
1134
1135 i, err := m.Int64Counter(
1136 "system.disk.merged",
1137 opt...,
1138 )
1139 if err != nil {
1140 return DiskMerged{noop.Int64Counter{}}, err
1141 }
1142 return DiskMerged{i}, nil
1143 }
1144
1145 // Inst returns the underlying metric instrument.
1146 func (m DiskMerged) Inst() metric.Int64Counter {
1147 return m.Int64Counter
1148 }
1149
1150 // Name returns the semantic convention name of the instrument.
1151 func (DiskMerged) Name() string {
1152 return "system.disk.merged"
1153 }
1154
1155 // Unit returns the semantic convention unit of the instrument
1156 func (DiskMerged) Unit() string {
1157 return "{operation}"
1158 }
1159
1160 // Description returns the semantic convention description of the instrument
1161 func (DiskMerged) Description() string {
1162 return "TODO."
1163 }
1164
1165 // Add adds incr to the existing count for attrs.
1166 //
1167 // All additional attrs passed are included in the recorded value.
1168 func (m DiskMerged) Add(
1169 ctx context.Context,
1170 incr int64,
1171 attrs ...attribute.KeyValue,
1172 ) {
1173 if len(attrs) == 0 {
1174 m.Int64Counter.Add(ctx, incr)
1175 return
1176 }
1177
1178 o := addOptPool.Get().(*[]metric.AddOption)
1179 defer func() {
1180 *o = (*o)[:0]
1181 addOptPool.Put(o)
1182 }()
1183
1184 *o = append(
1185 *o,
1186 metric.WithAttributes(
1187 attrs...,
1188 ),
1189 )
1190
1191 m.Int64Counter.Add(ctx, incr, *o...)
1192 }
1193
1194 // AddSet adds incr to the existing count for set.
1195 func (m DiskMerged) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1196 if set.Len() == 0 {
1197 m.Int64Counter.Add(ctx, incr)
1198 return
1199 }
1200
1201 o := addOptPool.Get().(*[]metric.AddOption)
1202 defer func() {
1203 *o = (*o)[:0]
1204 addOptPool.Put(o)
1205 }()
1206
1207 *o = append(*o, metric.WithAttributeSet(set))
1208 m.Int64Counter.Add(ctx, incr, *o...)
1209 }
1210
1211 // AttrDiskIODirection returns an optional attribute for the "disk.io.direction"
1212 // semantic convention. It represents the disk IO operation direction.
1213 func (DiskMerged) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue {
1214 return attribute.String("disk.io.direction", string(val))
1215 }
1216
1217 // AttrDevice returns an optional attribute for the "system.device" semantic
1218 // convention. It represents the device identifier.
1219 func (DiskMerged) AttrDevice(val string) attribute.KeyValue {
1220 return attribute.String("system.device", val)
1221 }
1222
1223 // DiskOperationTime is an instrument used to record metric values conforming to
1224 // the "system.disk.operation_time" semantic conventions. It represents the sum
1225 // of the time each operation took to complete.
1226 type DiskOperationTime struct {
1227 metric.Float64Counter
1228 }
1229
1230 var newDiskOperationTimeOpts = []metric.Float64CounterOption{
1231 metric.WithDescription("Sum of the time each operation took to complete."),
1232 metric.WithUnit("s"),
1233 }
1234
1235 // NewDiskOperationTime returns a new DiskOperationTime instrument.
1236 func NewDiskOperationTime(
1237 m metric.Meter,
1238 opt ...metric.Float64CounterOption,
1239 ) (DiskOperationTime, error) {
1240 // Check if the meter is nil.
1241 if m == nil {
1242 return DiskOperationTime{noop.Float64Counter{}}, nil
1243 }
1244
1245 if len(opt) == 0 {
1246 opt = newDiskOperationTimeOpts
1247 } else {
1248 opt = append(opt, newDiskOperationTimeOpts...)
1249 }
1250
1251 i, err := m.Float64Counter(
1252 "system.disk.operation_time",
1253 opt...,
1254 )
1255 if err != nil {
1256 return DiskOperationTime{noop.Float64Counter{}}, err
1257 }
1258 return DiskOperationTime{i}, nil
1259 }
1260
1261 // Inst returns the underlying metric instrument.
1262 func (m DiskOperationTime) Inst() metric.Float64Counter {
1263 return m.Float64Counter
1264 }
1265
1266 // Name returns the semantic convention name of the instrument.
1267 func (DiskOperationTime) Name() string {
1268 return "system.disk.operation_time"
1269 }
1270
1271 // Unit returns the semantic convention unit of the instrument
1272 func (DiskOperationTime) Unit() string {
1273 return "s"
1274 }
1275
1276 // Description returns the semantic convention description of the instrument
1277 func (DiskOperationTime) Description() string {
1278 return "Sum of the time each operation took to complete."
1279 }
1280
1281 // Add adds incr to the existing count for attrs.
1282 //
1283 // All additional attrs passed are included in the recorded value.
1284 //
1285 // Because it is the sum of time each request took, parallel-issued requests each
1286 // contribute to make the count grow. Measured as:
1287 //
1288 // - Linux: Fields 7 & 11 from [procfs-diskstats]
1289 // - Windows: "Avg. Disk sec/Read" perf counter multiplied by "Disk Reads/sec"
1290 // perf counter (similar for Writes)
1291 //
1292 //
1293 // [procfs-diskstats]: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
1294 func (m DiskOperationTime) Add(
1295 ctx context.Context,
1296 incr float64,
1297 attrs ...attribute.KeyValue,
1298 ) {
1299 if len(attrs) == 0 {
1300 m.Float64Counter.Add(ctx, incr)
1301 return
1302 }
1303
1304 o := addOptPool.Get().(*[]metric.AddOption)
1305 defer func() {
1306 *o = (*o)[:0]
1307 addOptPool.Put(o)
1308 }()
1309
1310 *o = append(
1311 *o,
1312 metric.WithAttributes(
1313 attrs...,
1314 ),
1315 )
1316
1317 m.Float64Counter.Add(ctx, incr, *o...)
1318 }
1319
1320 // AddSet adds incr to the existing count for set.
1321 //
1322 // Because it is the sum of time each request took, parallel-issued requests each
1323 // contribute to make the count grow. Measured as:
1324 //
1325 // - Linux: Fields 7 & 11 from [procfs-diskstats]
1326 // - Windows: "Avg. Disk sec/Read" perf counter multiplied by "Disk Reads/sec"
1327 // perf counter (similar for Writes)
1328 //
1329 //
1330 // [procfs-diskstats]: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
1331 func (m DiskOperationTime) AddSet(ctx context.Context, incr float64, set attribute.Set) {
1332 if set.Len() == 0 {
1333 m.Float64Counter.Add(ctx, incr)
1334 return
1335 }
1336
1337 o := addOptPool.Get().(*[]metric.AddOption)
1338 defer func() {
1339 *o = (*o)[:0]
1340 addOptPool.Put(o)
1341 }()
1342
1343 *o = append(*o, metric.WithAttributeSet(set))
1344 m.Float64Counter.Add(ctx, incr, *o...)
1345 }
1346
1347 // AttrDiskIODirection returns an optional attribute for the "disk.io.direction"
1348 // semantic convention. It represents the disk IO operation direction.
1349 func (DiskOperationTime) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue {
1350 return attribute.String("disk.io.direction", string(val))
1351 }
1352
1353 // AttrDevice returns an optional attribute for the "system.device" semantic
1354 // convention. It represents the device identifier.
1355 func (DiskOperationTime) AttrDevice(val string) attribute.KeyValue {
1356 return attribute.String("system.device", val)
1357 }
1358
1359 // DiskOperations is an instrument used to record metric values conforming to the
1360 // "system.disk.operations" semantic conventions. It represents the TODO.
1361 type DiskOperations struct {
1362 metric.Int64Counter
1363 }
1364
1365 var newDiskOperationsOpts = []metric.Int64CounterOption{
1366 metric.WithDescription("TODO."),
1367 metric.WithUnit("{operation}"),
1368 }
1369
1370 // NewDiskOperations returns a new DiskOperations instrument.
1371 func NewDiskOperations(
1372 m metric.Meter,
1373 opt ...metric.Int64CounterOption,
1374 ) (DiskOperations, error) {
1375 // Check if the meter is nil.
1376 if m == nil {
1377 return DiskOperations{noop.Int64Counter{}}, nil
1378 }
1379
1380 if len(opt) == 0 {
1381 opt = newDiskOperationsOpts
1382 } else {
1383 opt = append(opt, newDiskOperationsOpts...)
1384 }
1385
1386 i, err := m.Int64Counter(
1387 "system.disk.operations",
1388 opt...,
1389 )
1390 if err != nil {
1391 return DiskOperations{noop.Int64Counter{}}, err
1392 }
1393 return DiskOperations{i}, nil
1394 }
1395
1396 // Inst returns the underlying metric instrument.
1397 func (m DiskOperations) Inst() metric.Int64Counter {
1398 return m.Int64Counter
1399 }
1400
1401 // Name returns the semantic convention name of the instrument.
1402 func (DiskOperations) Name() string {
1403 return "system.disk.operations"
1404 }
1405
1406 // Unit returns the semantic convention unit of the instrument
1407 func (DiskOperations) Unit() string {
1408 return "{operation}"
1409 }
1410
1411 // Description returns the semantic convention description of the instrument
1412 func (DiskOperations) Description() string {
1413 return "TODO."
1414 }
1415
1416 // Add adds incr to the existing count for attrs.
1417 //
1418 // All additional attrs passed are included in the recorded value.
1419 func (m DiskOperations) Add(
1420 ctx context.Context,
1421 incr int64,
1422 attrs ...attribute.KeyValue,
1423 ) {
1424 if len(attrs) == 0 {
1425 m.Int64Counter.Add(ctx, incr)
1426 return
1427 }
1428
1429 o := addOptPool.Get().(*[]metric.AddOption)
1430 defer func() {
1431 *o = (*o)[:0]
1432 addOptPool.Put(o)
1433 }()
1434
1435 *o = append(
1436 *o,
1437 metric.WithAttributes(
1438 attrs...,
1439 ),
1440 )
1441
1442 m.Int64Counter.Add(ctx, incr, *o...)
1443 }
1444
1445 // AddSet adds incr to the existing count for set.
1446 func (m DiskOperations) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1447 if set.Len() == 0 {
1448 m.Int64Counter.Add(ctx, incr)
1449 return
1450 }
1451
1452 o := addOptPool.Get().(*[]metric.AddOption)
1453 defer func() {
1454 *o = (*o)[:0]
1455 addOptPool.Put(o)
1456 }()
1457
1458 *o = append(*o, metric.WithAttributeSet(set))
1459 m.Int64Counter.Add(ctx, incr, *o...)
1460 }
1461
1462 // AttrDiskIODirection returns an optional attribute for the "disk.io.direction"
1463 // semantic convention. It represents the disk IO operation direction.
1464 func (DiskOperations) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue {
1465 return attribute.String("disk.io.direction", string(val))
1466 }
1467
1468 // AttrDevice returns an optional attribute for the "system.device" semantic
1469 // convention. It represents the device identifier.
1470 func (DiskOperations) AttrDevice(val string) attribute.KeyValue {
1471 return attribute.String("system.device", val)
1472 }
1473
1474 // FilesystemLimit is an instrument used to record metric values conforming to
1475 // the "system.filesystem.limit" semantic conventions. It represents the total
1476 // storage capacity of the filesystem.
1477 type FilesystemLimit struct {
1478 metric.Int64UpDownCounter
1479 }
1480
1481 var newFilesystemLimitOpts = []metric.Int64UpDownCounterOption{
1482 metric.WithDescription("The total storage capacity of the filesystem."),
1483 metric.WithUnit("By"),
1484 }
1485
1486 // NewFilesystemLimit returns a new FilesystemLimit instrument.
1487 func NewFilesystemLimit(
1488 m metric.Meter,
1489 opt ...metric.Int64UpDownCounterOption,
1490 ) (FilesystemLimit, error) {
1491 // Check if the meter is nil.
1492 if m == nil {
1493 return FilesystemLimit{noop.Int64UpDownCounter{}}, nil
1494 }
1495
1496 if len(opt) == 0 {
1497 opt = newFilesystemLimitOpts
1498 } else {
1499 opt = append(opt, newFilesystemLimitOpts...)
1500 }
1501
1502 i, err := m.Int64UpDownCounter(
1503 "system.filesystem.limit",
1504 opt...,
1505 )
1506 if err != nil {
1507 return FilesystemLimit{noop.Int64UpDownCounter{}}, err
1508 }
1509 return FilesystemLimit{i}, nil
1510 }
1511
1512 // Inst returns the underlying metric instrument.
1513 func (m FilesystemLimit) Inst() metric.Int64UpDownCounter {
1514 return m.Int64UpDownCounter
1515 }
1516
1517 // Name returns the semantic convention name of the instrument.
1518 func (FilesystemLimit) Name() string {
1519 return "system.filesystem.limit"
1520 }
1521
1522 // Unit returns the semantic convention unit of the instrument
1523 func (FilesystemLimit) Unit() string {
1524 return "By"
1525 }
1526
1527 // Description returns the semantic convention description of the instrument
1528 func (FilesystemLimit) Description() string {
1529 return "The total storage capacity of the filesystem."
1530 }
1531
1532 // Add adds incr to the existing count for attrs.
1533 //
1534 // All additional attrs passed are included in the recorded value.
1535 func (m FilesystemLimit) Add(
1536 ctx context.Context,
1537 incr int64,
1538 attrs ...attribute.KeyValue,
1539 ) {
1540 if len(attrs) == 0 {
1541 m.Int64UpDownCounter.Add(ctx, incr)
1542 return
1543 }
1544
1545 o := addOptPool.Get().(*[]metric.AddOption)
1546 defer func() {
1547 *o = (*o)[:0]
1548 addOptPool.Put(o)
1549 }()
1550
1551 *o = append(
1552 *o,
1553 metric.WithAttributes(
1554 attrs...,
1555 ),
1556 )
1557
1558 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1559 }
1560
1561 // AddSet adds incr to the existing count for set.
1562 func (m FilesystemLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1563 if set.Len() == 0 {
1564 m.Int64UpDownCounter.Add(ctx, incr)
1565 return
1566 }
1567
1568 o := addOptPool.Get().(*[]metric.AddOption)
1569 defer func() {
1570 *o = (*o)[:0]
1571 addOptPool.Put(o)
1572 }()
1573
1574 *o = append(*o, metric.WithAttributeSet(set))
1575 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1576 }
1577
1578 // AttrDevice returns an optional attribute for the "system.device" semantic
1579 // convention. It represents the identifier for the device where the filesystem
1580 // resides.
1581 func (FilesystemLimit) AttrDevice(val string) attribute.KeyValue {
1582 return attribute.String("system.device", val)
1583 }
1584
1585 // AttrFilesystemMode returns an optional attribute for the
1586 // "system.filesystem.mode" semantic convention. It represents the filesystem
1587 // mode.
1588 func (FilesystemLimit) AttrFilesystemMode(val string) attribute.KeyValue {
1589 return attribute.String("system.filesystem.mode", val)
1590 }
1591
1592 // AttrFilesystemMountpoint returns an optional attribute for the
1593 // "system.filesystem.mountpoint" semantic convention. It represents the
1594 // filesystem mount path.
1595 func (FilesystemLimit) AttrFilesystemMountpoint(val string) attribute.KeyValue {
1596 return attribute.String("system.filesystem.mountpoint", val)
1597 }
1598
1599 // AttrFilesystemType returns an optional attribute for the
1600 // "system.filesystem.type" semantic convention. It represents the filesystem
1601 // type.
1602 func (FilesystemLimit) AttrFilesystemType(val FilesystemTypeAttr) attribute.KeyValue {
1603 return attribute.String("system.filesystem.type", string(val))
1604 }
1605
1606 // FilesystemUsage is an instrument used to record metric values conforming to
1607 // the "system.filesystem.usage" semantic conventions. It represents the reports
1608 // a filesystem's space usage across different states.
1609 type FilesystemUsage struct {
1610 metric.Int64UpDownCounter
1611 }
1612
1613 var newFilesystemUsageOpts = []metric.Int64UpDownCounterOption{
1614 metric.WithDescription("Reports a filesystem's space usage across different states."),
1615 metric.WithUnit("By"),
1616 }
1617
1618 // NewFilesystemUsage returns a new FilesystemUsage instrument.
1619 func NewFilesystemUsage(
1620 m metric.Meter,
1621 opt ...metric.Int64UpDownCounterOption,
1622 ) (FilesystemUsage, error) {
1623 // Check if the meter is nil.
1624 if m == nil {
1625 return FilesystemUsage{noop.Int64UpDownCounter{}}, nil
1626 }
1627
1628 if len(opt) == 0 {
1629 opt = newFilesystemUsageOpts
1630 } else {
1631 opt = append(opt, newFilesystemUsageOpts...)
1632 }
1633
1634 i, err := m.Int64UpDownCounter(
1635 "system.filesystem.usage",
1636 opt...,
1637 )
1638 if err != nil {
1639 return FilesystemUsage{noop.Int64UpDownCounter{}}, err
1640 }
1641 return FilesystemUsage{i}, nil
1642 }
1643
1644 // Inst returns the underlying metric instrument.
1645 func (m FilesystemUsage) Inst() metric.Int64UpDownCounter {
1646 return m.Int64UpDownCounter
1647 }
1648
1649 // Name returns the semantic convention name of the instrument.
1650 func (FilesystemUsage) Name() string {
1651 return "system.filesystem.usage"
1652 }
1653
1654 // Unit returns the semantic convention unit of the instrument
1655 func (FilesystemUsage) Unit() string {
1656 return "By"
1657 }
1658
1659 // Description returns the semantic convention description of the instrument
1660 func (FilesystemUsage) Description() string {
1661 return "Reports a filesystem's space usage across different states."
1662 }
1663
1664 // Add adds incr to the existing count for attrs.
1665 //
1666 // All additional attrs passed are included in the recorded value.
1667 //
1668 // The sum of all `system.filesystem.usage` values over the different
1669 // `system.filesystem.state` attributes
1670 // SHOULD equal the total storage capacity of the filesystem, that is
1671 // `system.filesystem.limit`.
1672 func (m FilesystemUsage) Add(
1673 ctx context.Context,
1674 incr int64,
1675 attrs ...attribute.KeyValue,
1676 ) {
1677 if len(attrs) == 0 {
1678 m.Int64UpDownCounter.Add(ctx, incr)
1679 return
1680 }
1681
1682 o := addOptPool.Get().(*[]metric.AddOption)
1683 defer func() {
1684 *o = (*o)[:0]
1685 addOptPool.Put(o)
1686 }()
1687
1688 *o = append(
1689 *o,
1690 metric.WithAttributes(
1691 attrs...,
1692 ),
1693 )
1694
1695 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1696 }
1697
1698 // AddSet adds incr to the existing count for set.
1699 //
1700 // The sum of all `system.filesystem.usage` values over the different
1701 // `system.filesystem.state` attributes
1702 // SHOULD equal the total storage capacity of the filesystem, that is
1703 // `system.filesystem.limit`.
1704 func (m FilesystemUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1705 if set.Len() == 0 {
1706 m.Int64UpDownCounter.Add(ctx, incr)
1707 return
1708 }
1709
1710 o := addOptPool.Get().(*[]metric.AddOption)
1711 defer func() {
1712 *o = (*o)[:0]
1713 addOptPool.Put(o)
1714 }()
1715
1716 *o = append(*o, metric.WithAttributeSet(set))
1717 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1718 }
1719
1720 // AttrDevice returns an optional attribute for the "system.device" semantic
1721 // convention. It represents the identifier for the device where the filesystem
1722 // resides.
1723 func (FilesystemUsage) AttrDevice(val string) attribute.KeyValue {
1724 return attribute.String("system.device", val)
1725 }
1726
1727 // AttrFilesystemMode returns an optional attribute for the
1728 // "system.filesystem.mode" semantic convention. It represents the filesystem
1729 // mode.
1730 func (FilesystemUsage) AttrFilesystemMode(val string) attribute.KeyValue {
1731 return attribute.String("system.filesystem.mode", val)
1732 }
1733
1734 // AttrFilesystemMountpoint returns an optional attribute for the
1735 // "system.filesystem.mountpoint" semantic convention. It represents the
1736 // filesystem mount path.
1737 func (FilesystemUsage) AttrFilesystemMountpoint(val string) attribute.KeyValue {
1738 return attribute.String("system.filesystem.mountpoint", val)
1739 }
1740
1741 // AttrFilesystemState returns an optional attribute for the
1742 // "system.filesystem.state" semantic convention. It represents the filesystem
1743 // state.
1744 func (FilesystemUsage) AttrFilesystemState(val FilesystemStateAttr) attribute.KeyValue {
1745 return attribute.String("system.filesystem.state", string(val))
1746 }
1747
1748 // AttrFilesystemType returns an optional attribute for the
1749 // "system.filesystem.type" semantic convention. It represents the filesystem
1750 // type.
1751 func (FilesystemUsage) AttrFilesystemType(val FilesystemTypeAttr) attribute.KeyValue {
1752 return attribute.String("system.filesystem.type", string(val))
1753 }
1754
1755 // FilesystemUtilization is an instrument used to record metric values conforming
1756 // to the "system.filesystem.utilization" semantic conventions. It represents the
1757 // TODO.
1758 type FilesystemUtilization struct {
1759 metric.Int64Gauge
1760 }
1761
1762 var newFilesystemUtilizationOpts = []metric.Int64GaugeOption{
1763 metric.WithDescription("TODO."),
1764 metric.WithUnit("1"),
1765 }
1766
1767 // NewFilesystemUtilization returns a new FilesystemUtilization instrument.
1768 func NewFilesystemUtilization(
1769 m metric.Meter,
1770 opt ...metric.Int64GaugeOption,
1771 ) (FilesystemUtilization, error) {
1772 // Check if the meter is nil.
1773 if m == nil {
1774 return FilesystemUtilization{noop.Int64Gauge{}}, nil
1775 }
1776
1777 if len(opt) == 0 {
1778 opt = newFilesystemUtilizationOpts
1779 } else {
1780 opt = append(opt, newFilesystemUtilizationOpts...)
1781 }
1782
1783 i, err := m.Int64Gauge(
1784 "system.filesystem.utilization",
1785 opt...,
1786 )
1787 if err != nil {
1788 return FilesystemUtilization{noop.Int64Gauge{}}, err
1789 }
1790 return FilesystemUtilization{i}, nil
1791 }
1792
1793 // Inst returns the underlying metric instrument.
1794 func (m FilesystemUtilization) Inst() metric.Int64Gauge {
1795 return m.Int64Gauge
1796 }
1797
1798 // Name returns the semantic convention name of the instrument.
1799 func (FilesystemUtilization) Name() string {
1800 return "system.filesystem.utilization"
1801 }
1802
1803 // Unit returns the semantic convention unit of the instrument
1804 func (FilesystemUtilization) Unit() string {
1805 return "1"
1806 }
1807
1808 // Description returns the semantic convention description of the instrument
1809 func (FilesystemUtilization) Description() string {
1810 return "TODO."
1811 }
1812
1813 // Record records val to the current distribution for attrs.
1814 //
1815 // All additional attrs passed are included in the recorded value.
1816 func (m FilesystemUtilization) Record(
1817 ctx context.Context,
1818 val int64,
1819 attrs ...attribute.KeyValue,
1820 ) {
1821 if len(attrs) == 0 {
1822 m.Int64Gauge.Record(ctx, val)
1823 return
1824 }
1825
1826 o := recOptPool.Get().(*[]metric.RecordOption)
1827 defer func() {
1828 *o = (*o)[:0]
1829 recOptPool.Put(o)
1830 }()
1831
1832 *o = append(
1833 *o,
1834 metric.WithAttributes(
1835 attrs...,
1836 ),
1837 )
1838
1839 m.Int64Gauge.Record(ctx, val, *o...)
1840 }
1841
1842 // RecordSet records val to the current distribution for set.
1843 func (m FilesystemUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) {
1844 if set.Len() == 0 {
1845 m.Int64Gauge.Record(ctx, val)
1846 return
1847 }
1848
1849 o := recOptPool.Get().(*[]metric.RecordOption)
1850 defer func() {
1851 *o = (*o)[:0]
1852 recOptPool.Put(o)
1853 }()
1854
1855 *o = append(*o, metric.WithAttributeSet(set))
1856 m.Int64Gauge.Record(ctx, val, *o...)
1857 }
1858
1859 // AttrDevice returns an optional attribute for the "system.device" semantic
1860 // convention. It represents the identifier for the device where the filesystem
1861 // resides.
1862 func (FilesystemUtilization) AttrDevice(val string) attribute.KeyValue {
1863 return attribute.String("system.device", val)
1864 }
1865
1866 // AttrFilesystemMode returns an optional attribute for the
1867 // "system.filesystem.mode" semantic convention. It represents the filesystem
1868 // mode.
1869 func (FilesystemUtilization) AttrFilesystemMode(val string) attribute.KeyValue {
1870 return attribute.String("system.filesystem.mode", val)
1871 }
1872
1873 // AttrFilesystemMountpoint returns an optional attribute for the
1874 // "system.filesystem.mountpoint" semantic convention. It represents the
1875 // filesystem mount path.
1876 func (FilesystemUtilization) AttrFilesystemMountpoint(val string) attribute.KeyValue {
1877 return attribute.String("system.filesystem.mountpoint", val)
1878 }
1879
1880 // AttrFilesystemState returns an optional attribute for the
1881 // "system.filesystem.state" semantic convention. It represents the filesystem
1882 // state.
1883 func (FilesystemUtilization) AttrFilesystemState(val FilesystemStateAttr) attribute.KeyValue {
1884 return attribute.String("system.filesystem.state", string(val))
1885 }
1886
1887 // AttrFilesystemType returns an optional attribute for the
1888 // "system.filesystem.type" semantic convention. It represents the filesystem
1889 // type.
1890 func (FilesystemUtilization) AttrFilesystemType(val FilesystemTypeAttr) attribute.KeyValue {
1891 return attribute.String("system.filesystem.type", string(val))
1892 }
1893
1894 // LinuxMemoryAvailable is an instrument used to record metric values conforming
1895 // to the "system.linux.memory.available" semantic conventions. It represents an
1896 // estimate of how much memory is available for starting new applications,
1897 // without causing swapping.
1898 type LinuxMemoryAvailable struct {
1899 metric.Int64UpDownCounter
1900 }
1901
1902 var newLinuxMemoryAvailableOpts = []metric.Int64UpDownCounterOption{
1903 metric.WithDescription("An estimate of how much memory is available for starting new applications, without causing swapping."),
1904 metric.WithUnit("By"),
1905 }
1906
1907 // NewLinuxMemoryAvailable returns a new LinuxMemoryAvailable instrument.
1908 func NewLinuxMemoryAvailable(
1909 m metric.Meter,
1910 opt ...metric.Int64UpDownCounterOption,
1911 ) (LinuxMemoryAvailable, error) {
1912 // Check if the meter is nil.
1913 if m == nil {
1914 return LinuxMemoryAvailable{noop.Int64UpDownCounter{}}, nil
1915 }
1916
1917 if len(opt) == 0 {
1918 opt = newLinuxMemoryAvailableOpts
1919 } else {
1920 opt = append(opt, newLinuxMemoryAvailableOpts...)
1921 }
1922
1923 i, err := m.Int64UpDownCounter(
1924 "system.linux.memory.available",
1925 opt...,
1926 )
1927 if err != nil {
1928 return LinuxMemoryAvailable{noop.Int64UpDownCounter{}}, err
1929 }
1930 return LinuxMemoryAvailable{i}, nil
1931 }
1932
1933 // Inst returns the underlying metric instrument.
1934 func (m LinuxMemoryAvailable) Inst() metric.Int64UpDownCounter {
1935 return m.Int64UpDownCounter
1936 }
1937
1938 // Name returns the semantic convention name of the instrument.
1939 func (LinuxMemoryAvailable) Name() string {
1940 return "system.linux.memory.available"
1941 }
1942
1943 // Unit returns the semantic convention unit of the instrument
1944 func (LinuxMemoryAvailable) Unit() string {
1945 return "By"
1946 }
1947
1948 // Description returns the semantic convention description of the instrument
1949 func (LinuxMemoryAvailable) Description() string {
1950 return "An estimate of how much memory is available for starting new applications, without causing swapping."
1951 }
1952
1953 // Add adds incr to the existing count for attrs.
1954 //
1955 // This is an alternative to `system.memory.usage` metric with `state=free`.
1956 // Linux starting from 3.14 exports "available" memory. It takes "free" memory as
1957 // a baseline, and then factors in kernel-specific values.
1958 // This is supposed to be more accurate than just "free" memory.
1959 // For reference, see the calculations [here].
1960 // See also `MemAvailable` in [/proc/meminfo].
1961 //
1962 // [here]: https://superuser.com/a/980821
1963 // [/proc/meminfo]: https://man7.org/linux/man-pages/man5/proc.5.html
1964 func (m LinuxMemoryAvailable) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
1965 if len(attrs) == 0 {
1966 m.Int64UpDownCounter.Add(ctx, incr)
1967 return
1968 }
1969
1970 o := addOptPool.Get().(*[]metric.AddOption)
1971 defer func() {
1972 *o = (*o)[:0]
1973 addOptPool.Put(o)
1974 }()
1975
1976 *o = append(*o, metric.WithAttributes(attrs...))
1977 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1978 }
1979
1980 // AddSet adds incr to the existing count for set.
1981 //
1982 // This is an alternative to `system.memory.usage` metric with `state=free`.
1983 // Linux starting from 3.14 exports "available" memory. It takes "free" memory as
1984 // a baseline, and then factors in kernel-specific values.
1985 // This is supposed to be more accurate than just "free" memory.
1986 // For reference, see the calculations [here].
1987 // See also `MemAvailable` in [/proc/meminfo].
1988 //
1989 // [here]: https://superuser.com/a/980821
1990 // [/proc/meminfo]: https://man7.org/linux/man-pages/man5/proc.5.html
1991 func (m LinuxMemoryAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) {
1992 if set.Len() == 0 {
1993 m.Int64UpDownCounter.Add(ctx, incr)
1994 return
1995 }
1996
1997 o := addOptPool.Get().(*[]metric.AddOption)
1998 defer func() {
1999 *o = (*o)[:0]
2000 addOptPool.Put(o)
2001 }()
2002
2003 *o = append(*o, metric.WithAttributeSet(set))
2004 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2005 }
2006
2007 // LinuxMemorySlabUsage is an instrument used to record metric values conforming
2008 // to the "system.linux.memory.slab.usage" semantic conventions. It represents
2009 // the reports the memory used by the Linux kernel for managing caches of
2010 // frequently used objects.
2011 type LinuxMemorySlabUsage struct {
2012 metric.Int64UpDownCounter
2013 }
2014
2015 var newLinuxMemorySlabUsageOpts = []metric.Int64UpDownCounterOption{
2016 metric.WithDescription("Reports the memory used by the Linux kernel for managing caches of frequently used objects."),
2017 metric.WithUnit("By"),
2018 }
2019
2020 // NewLinuxMemorySlabUsage returns a new LinuxMemorySlabUsage instrument.
2021 func NewLinuxMemorySlabUsage(
2022 m metric.Meter,
2023 opt ...metric.Int64UpDownCounterOption,
2024 ) (LinuxMemorySlabUsage, error) {
2025 // Check if the meter is nil.
2026 if m == nil {
2027 return LinuxMemorySlabUsage{noop.Int64UpDownCounter{}}, nil
2028 }
2029
2030 if len(opt) == 0 {
2031 opt = newLinuxMemorySlabUsageOpts
2032 } else {
2033 opt = append(opt, newLinuxMemorySlabUsageOpts...)
2034 }
2035
2036 i, err := m.Int64UpDownCounter(
2037 "system.linux.memory.slab.usage",
2038 opt...,
2039 )
2040 if err != nil {
2041 return LinuxMemorySlabUsage{noop.Int64UpDownCounter{}}, err
2042 }
2043 return LinuxMemorySlabUsage{i}, nil
2044 }
2045
2046 // Inst returns the underlying metric instrument.
2047 func (m LinuxMemorySlabUsage) Inst() metric.Int64UpDownCounter {
2048 return m.Int64UpDownCounter
2049 }
2050
2051 // Name returns the semantic convention name of the instrument.
2052 func (LinuxMemorySlabUsage) Name() string {
2053 return "system.linux.memory.slab.usage"
2054 }
2055
2056 // Unit returns the semantic convention unit of the instrument
2057 func (LinuxMemorySlabUsage) Unit() string {
2058 return "By"
2059 }
2060
2061 // Description returns the semantic convention description of the instrument
2062 func (LinuxMemorySlabUsage) Description() string {
2063 return "Reports the memory used by the Linux kernel for managing caches of frequently used objects."
2064 }
2065
2066 // Add adds incr to the existing count for attrs.
2067 //
2068 // All additional attrs passed are included in the recorded value.
2069 //
2070 // The sum over the `reclaimable` and `unreclaimable` state values in
2071 // `linux.memory.slab.usage` SHOULD be equal to the total slab memory available
2072 // on the system.
2073 // Note that the total slab memory is not constant and may vary over time.
2074 // See also the [Slab allocator] and `Slab` in [/proc/meminfo].
2075 //
2076 // [Slab allocator]: https://blogs.oracle.com/linux/post/understanding-linux-kernel-memory-statistics
2077 // [/proc/meminfo]: https://man7.org/linux/man-pages/man5/proc.5.html
2078 func (m LinuxMemorySlabUsage) Add(
2079 ctx context.Context,
2080 incr int64,
2081 attrs ...attribute.KeyValue,
2082 ) {
2083 if len(attrs) == 0 {
2084 m.Int64UpDownCounter.Add(ctx, incr)
2085 return
2086 }
2087
2088 o := addOptPool.Get().(*[]metric.AddOption)
2089 defer func() {
2090 *o = (*o)[:0]
2091 addOptPool.Put(o)
2092 }()
2093
2094 *o = append(
2095 *o,
2096 metric.WithAttributes(
2097 attrs...,
2098 ),
2099 )
2100
2101 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2102 }
2103
2104 // AddSet adds incr to the existing count for set.
2105 //
2106 // The sum over the `reclaimable` and `unreclaimable` state values in
2107 // `linux.memory.slab.usage` SHOULD be equal to the total slab memory available
2108 // on the system.
2109 // Note that the total slab memory is not constant and may vary over time.
2110 // See also the [Slab allocator] and `Slab` in [/proc/meminfo].
2111 //
2112 // [Slab allocator]: https://blogs.oracle.com/linux/post/understanding-linux-kernel-memory-statistics
2113 // [/proc/meminfo]: https://man7.org/linux/man-pages/man5/proc.5.html
2114 func (m LinuxMemorySlabUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2115 if set.Len() == 0 {
2116 m.Int64UpDownCounter.Add(ctx, incr)
2117 return
2118 }
2119
2120 o := addOptPool.Get().(*[]metric.AddOption)
2121 defer func() {
2122 *o = (*o)[:0]
2123 addOptPool.Put(o)
2124 }()
2125
2126 *o = append(*o, metric.WithAttributeSet(set))
2127 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2128 }
2129
2130 // AttrLinuxMemorySlabState returns an optional attribute for the
2131 // "linux.memory.slab.state" semantic convention. It represents the Linux Slab
2132 // memory state.
2133 func (LinuxMemorySlabUsage) AttrLinuxMemorySlabState(val LinuxMemorySlabStateAttr) attribute.KeyValue {
2134 return attribute.String("linux.memory.slab.state", string(val))
2135 }
2136
2137 // MemoryLimit is an instrument used to record metric values conforming to the
2138 // "system.memory.limit" semantic conventions. It represents the total virtual
2139 // memory available in the system.
2140 type MemoryLimit struct {
2141 metric.Int64UpDownCounter
2142 }
2143
2144 var newMemoryLimitOpts = []metric.Int64UpDownCounterOption{
2145 metric.WithDescription("Total virtual memory available in the system."),
2146 metric.WithUnit("By"),
2147 }
2148
2149 // NewMemoryLimit returns a new MemoryLimit instrument.
2150 func NewMemoryLimit(
2151 m metric.Meter,
2152 opt ...metric.Int64UpDownCounterOption,
2153 ) (MemoryLimit, error) {
2154 // Check if the meter is nil.
2155 if m == nil {
2156 return MemoryLimit{noop.Int64UpDownCounter{}}, nil
2157 }
2158
2159 if len(opt) == 0 {
2160 opt = newMemoryLimitOpts
2161 } else {
2162 opt = append(opt, newMemoryLimitOpts...)
2163 }
2164
2165 i, err := m.Int64UpDownCounter(
2166 "system.memory.limit",
2167 opt...,
2168 )
2169 if err != nil {
2170 return MemoryLimit{noop.Int64UpDownCounter{}}, err
2171 }
2172 return MemoryLimit{i}, nil
2173 }
2174
2175 // Inst returns the underlying metric instrument.
2176 func (m MemoryLimit) Inst() metric.Int64UpDownCounter {
2177 return m.Int64UpDownCounter
2178 }
2179
2180 // Name returns the semantic convention name of the instrument.
2181 func (MemoryLimit) Name() string {
2182 return "system.memory.limit"
2183 }
2184
2185 // Unit returns the semantic convention unit of the instrument
2186 func (MemoryLimit) Unit() string {
2187 return "By"
2188 }
2189
2190 // Description returns the semantic convention description of the instrument
2191 func (MemoryLimit) Description() string {
2192 return "Total virtual memory available in the system."
2193 }
2194
2195 // Add adds incr to the existing count for attrs.
2196 func (m MemoryLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2197 if len(attrs) == 0 {
2198 m.Int64UpDownCounter.Add(ctx, incr)
2199 return
2200 }
2201
2202 o := addOptPool.Get().(*[]metric.AddOption)
2203 defer func() {
2204 *o = (*o)[:0]
2205 addOptPool.Put(o)
2206 }()
2207
2208 *o = append(*o, metric.WithAttributes(attrs...))
2209 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2210 }
2211
2212 // AddSet adds incr to the existing count for set.
2213 func (m MemoryLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2214 if set.Len() == 0 {
2215 m.Int64UpDownCounter.Add(ctx, incr)
2216 return
2217 }
2218
2219 o := addOptPool.Get().(*[]metric.AddOption)
2220 defer func() {
2221 *o = (*o)[:0]
2222 addOptPool.Put(o)
2223 }()
2224
2225 *o = append(*o, metric.WithAttributeSet(set))
2226 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2227 }
2228
2229 // MemoryShared is an instrument used to record metric values conforming to the
2230 // "system.memory.shared" semantic conventions. It represents the shared memory
2231 // used (mostly by tmpfs).
2232 type MemoryShared struct {
2233 metric.Int64UpDownCounter
2234 }
2235
2236 var newMemorySharedOpts = []metric.Int64UpDownCounterOption{
2237 metric.WithDescription("Shared memory used (mostly by tmpfs)."),
2238 metric.WithUnit("By"),
2239 }
2240
2241 // NewMemoryShared returns a new MemoryShared instrument.
2242 func NewMemoryShared(
2243 m metric.Meter,
2244 opt ...metric.Int64UpDownCounterOption,
2245 ) (MemoryShared, error) {
2246 // Check if the meter is nil.
2247 if m == nil {
2248 return MemoryShared{noop.Int64UpDownCounter{}}, nil
2249 }
2250
2251 if len(opt) == 0 {
2252 opt = newMemorySharedOpts
2253 } else {
2254 opt = append(opt, newMemorySharedOpts...)
2255 }
2256
2257 i, err := m.Int64UpDownCounter(
2258 "system.memory.shared",
2259 opt...,
2260 )
2261 if err != nil {
2262 return MemoryShared{noop.Int64UpDownCounter{}}, err
2263 }
2264 return MemoryShared{i}, nil
2265 }
2266
2267 // Inst returns the underlying metric instrument.
2268 func (m MemoryShared) Inst() metric.Int64UpDownCounter {
2269 return m.Int64UpDownCounter
2270 }
2271
2272 // Name returns the semantic convention name of the instrument.
2273 func (MemoryShared) Name() string {
2274 return "system.memory.shared"
2275 }
2276
2277 // Unit returns the semantic convention unit of the instrument
2278 func (MemoryShared) Unit() string {
2279 return "By"
2280 }
2281
2282 // Description returns the semantic convention description of the instrument
2283 func (MemoryShared) Description() string {
2284 return "Shared memory used (mostly by tmpfs)."
2285 }
2286
2287 // Add adds incr to the existing count for attrs.
2288 //
2289 // Equivalent of `shared` from [`free` command] or
2290 // `Shmem` from [`/proc/meminfo`]"
2291 //
2292 // [`free` command]: https://man7.org/linux/man-pages/man1/free.1.html
2293 // [`/proc/meminfo`]: https://man7.org/linux/man-pages/man5/proc.5.html
2294 func (m MemoryShared) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
2295 if len(attrs) == 0 {
2296 m.Int64UpDownCounter.Add(ctx, incr)
2297 return
2298 }
2299
2300 o := addOptPool.Get().(*[]metric.AddOption)
2301 defer func() {
2302 *o = (*o)[:0]
2303 addOptPool.Put(o)
2304 }()
2305
2306 *o = append(*o, metric.WithAttributes(attrs...))
2307 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2308 }
2309
2310 // AddSet adds incr to the existing count for set.
2311 //
2312 // Equivalent of `shared` from [`free` command] or
2313 // `Shmem` from [`/proc/meminfo`]"
2314 //
2315 // [`free` command]: https://man7.org/linux/man-pages/man1/free.1.html
2316 // [`/proc/meminfo`]: https://man7.org/linux/man-pages/man5/proc.5.html
2317 func (m MemoryShared) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2318 if set.Len() == 0 {
2319 m.Int64UpDownCounter.Add(ctx, incr)
2320 return
2321 }
2322
2323 o := addOptPool.Get().(*[]metric.AddOption)
2324 defer func() {
2325 *o = (*o)[:0]
2326 addOptPool.Put(o)
2327 }()
2328
2329 *o = append(*o, metric.WithAttributeSet(set))
2330 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2331 }
2332
2333 // MemoryUsage is an instrument used to record metric values conforming to the
2334 // "system.memory.usage" semantic conventions. It represents the reports memory
2335 // in use by state.
2336 type MemoryUsage struct {
2337 metric.Int64ObservableUpDownCounter
2338 }
2339
2340 var newMemoryUsageOpts = []metric.Int64ObservableUpDownCounterOption{
2341 metric.WithDescription("Reports memory in use by state."),
2342 metric.WithUnit("By"),
2343 }
2344
2345 // NewMemoryUsage returns a new MemoryUsage instrument.
2346 func NewMemoryUsage(
2347 m metric.Meter,
2348 opt ...metric.Int64ObservableUpDownCounterOption,
2349 ) (MemoryUsage, error) {
2350 // Check if the meter is nil.
2351 if m == nil {
2352 return MemoryUsage{noop.Int64ObservableUpDownCounter{}}, nil
2353 }
2354
2355 if len(opt) == 0 {
2356 opt = newMemoryUsageOpts
2357 } else {
2358 opt = append(opt, newMemoryUsageOpts...)
2359 }
2360
2361 i, err := m.Int64ObservableUpDownCounter(
2362 "system.memory.usage",
2363 opt...,
2364 )
2365 if err != nil {
2366 return MemoryUsage{noop.Int64ObservableUpDownCounter{}}, err
2367 }
2368 return MemoryUsage{i}, nil
2369 }
2370
2371 // Inst returns the underlying metric instrument.
2372 func (m MemoryUsage) Inst() metric.Int64ObservableUpDownCounter {
2373 return m.Int64ObservableUpDownCounter
2374 }
2375
2376 // Name returns the semantic convention name of the instrument.
2377 func (MemoryUsage) Name() string {
2378 return "system.memory.usage"
2379 }
2380
2381 // Unit returns the semantic convention unit of the instrument
2382 func (MemoryUsage) Unit() string {
2383 return "By"
2384 }
2385
2386 // Description returns the semantic convention description of the instrument
2387 func (MemoryUsage) Description() string {
2388 return "Reports memory in use by state."
2389 }
2390
2391 // AttrMemoryState returns an optional attribute for the "system.memory.state"
2392 // semantic convention. It represents the memory state.
2393 func (MemoryUsage) AttrMemoryState(val MemoryStateAttr) attribute.KeyValue {
2394 return attribute.String("system.memory.state", string(val))
2395 }
2396
2397 // MemoryUtilization is an instrument used to record metric values conforming to
2398 // the "system.memory.utilization" semantic conventions. It represents the TODO.
2399 type MemoryUtilization struct {
2400 metric.Float64ObservableGauge
2401 }
2402
2403 var newMemoryUtilizationOpts = []metric.Float64ObservableGaugeOption{
2404 metric.WithDescription("TODO."),
2405 metric.WithUnit("1"),
2406 }
2407
2408 // NewMemoryUtilization returns a new MemoryUtilization instrument.
2409 func NewMemoryUtilization(
2410 m metric.Meter,
2411 opt ...metric.Float64ObservableGaugeOption,
2412 ) (MemoryUtilization, error) {
2413 // Check if the meter is nil.
2414 if m == nil {
2415 return MemoryUtilization{noop.Float64ObservableGauge{}}, nil
2416 }
2417
2418 if len(opt) == 0 {
2419 opt = newMemoryUtilizationOpts
2420 } else {
2421 opt = append(opt, newMemoryUtilizationOpts...)
2422 }
2423
2424 i, err := m.Float64ObservableGauge(
2425 "system.memory.utilization",
2426 opt...,
2427 )
2428 if err != nil {
2429 return MemoryUtilization{noop.Float64ObservableGauge{}}, err
2430 }
2431 return MemoryUtilization{i}, nil
2432 }
2433
2434 // Inst returns the underlying metric instrument.
2435 func (m MemoryUtilization) Inst() metric.Float64ObservableGauge {
2436 return m.Float64ObservableGauge
2437 }
2438
2439 // Name returns the semantic convention name of the instrument.
2440 func (MemoryUtilization) Name() string {
2441 return "system.memory.utilization"
2442 }
2443
2444 // Unit returns the semantic convention unit of the instrument
2445 func (MemoryUtilization) Unit() string {
2446 return "1"
2447 }
2448
2449 // Description returns the semantic convention description of the instrument
2450 func (MemoryUtilization) Description() string {
2451 return "TODO."
2452 }
2453
2454 // AttrMemoryState returns an optional attribute for the "system.memory.state"
2455 // semantic convention. It represents the memory state.
2456 func (MemoryUtilization) AttrMemoryState(val MemoryStateAttr) attribute.KeyValue {
2457 return attribute.String("system.memory.state", string(val))
2458 }
2459
2460 // NetworkConnectionCount is an instrument used to record metric values
2461 // conforming to the "system.network.connection.count" semantic conventions. It
2462 // represents the TODO.
2463 type NetworkConnectionCount struct {
2464 metric.Int64UpDownCounter
2465 }
2466
2467 var newNetworkConnectionCountOpts = []metric.Int64UpDownCounterOption{
2468 metric.WithDescription("TODO."),
2469 metric.WithUnit("{connection}"),
2470 }
2471
2472 // NewNetworkConnectionCount returns a new NetworkConnectionCount instrument.
2473 func NewNetworkConnectionCount(
2474 m metric.Meter,
2475 opt ...metric.Int64UpDownCounterOption,
2476 ) (NetworkConnectionCount, error) {
2477 // Check if the meter is nil.
2478 if m == nil {
2479 return NetworkConnectionCount{noop.Int64UpDownCounter{}}, nil
2480 }
2481
2482 if len(opt) == 0 {
2483 opt = newNetworkConnectionCountOpts
2484 } else {
2485 opt = append(opt, newNetworkConnectionCountOpts...)
2486 }
2487
2488 i, err := m.Int64UpDownCounter(
2489 "system.network.connection.count",
2490 opt...,
2491 )
2492 if err != nil {
2493 return NetworkConnectionCount{noop.Int64UpDownCounter{}}, err
2494 }
2495 return NetworkConnectionCount{i}, nil
2496 }
2497
2498 // Inst returns the underlying metric instrument.
2499 func (m NetworkConnectionCount) Inst() metric.Int64UpDownCounter {
2500 return m.Int64UpDownCounter
2501 }
2502
2503 // Name returns the semantic convention name of the instrument.
2504 func (NetworkConnectionCount) Name() string {
2505 return "system.network.connection.count"
2506 }
2507
2508 // Unit returns the semantic convention unit of the instrument
2509 func (NetworkConnectionCount) Unit() string {
2510 return "{connection}"
2511 }
2512
2513 // Description returns the semantic convention description of the instrument
2514 func (NetworkConnectionCount) Description() string {
2515 return "TODO."
2516 }
2517
2518 // Add adds incr to the existing count for attrs.
2519 //
2520 // All additional attrs passed are included in the recorded value.
2521 func (m NetworkConnectionCount) Add(
2522 ctx context.Context,
2523 incr int64,
2524 attrs ...attribute.KeyValue,
2525 ) {
2526 if len(attrs) == 0 {
2527 m.Int64UpDownCounter.Add(ctx, incr)
2528 return
2529 }
2530
2531 o := addOptPool.Get().(*[]metric.AddOption)
2532 defer func() {
2533 *o = (*o)[:0]
2534 addOptPool.Put(o)
2535 }()
2536
2537 *o = append(
2538 *o,
2539 metric.WithAttributes(
2540 attrs...,
2541 ),
2542 )
2543
2544 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2545 }
2546
2547 // AddSet adds incr to the existing count for set.
2548 func (m NetworkConnectionCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2549 if set.Len() == 0 {
2550 m.Int64UpDownCounter.Add(ctx, incr)
2551 return
2552 }
2553
2554 o := addOptPool.Get().(*[]metric.AddOption)
2555 defer func() {
2556 *o = (*o)[:0]
2557 addOptPool.Put(o)
2558 }()
2559
2560 *o = append(*o, metric.WithAttributeSet(set))
2561 m.Int64UpDownCounter.Add(ctx, incr, *o...)
2562 }
2563
2564 // AttrNetworkConnectionState returns an optional attribute for the
2565 // "network.connection.state" semantic convention. It represents the state of
2566 // network connection.
2567 func (NetworkConnectionCount) AttrNetworkConnectionState(val NetworkConnectionStateAttr) attribute.KeyValue {
2568 return attribute.String("network.connection.state", string(val))
2569 }
2570
2571 // AttrNetworkInterfaceName returns an optional attribute for the
2572 // "network.interface.name" semantic convention. It represents the network
2573 // interface name.
2574 func (NetworkConnectionCount) AttrNetworkInterfaceName(val string) attribute.KeyValue {
2575 return attribute.String("network.interface.name", val)
2576 }
2577
2578 // AttrNetworkTransport returns an optional attribute for the "network.transport"
2579 // semantic convention. It represents the [OSI transport layer] or
2580 // [inter-process communication method].
2581 //
2582 // [OSI transport layer]: https://wikipedia.org/wiki/Transport_layer
2583 // [inter-process communication method]: https://wikipedia.org/wiki/Inter-process_communication
2584 func (NetworkConnectionCount) AttrNetworkTransport(val NetworkTransportAttr) attribute.KeyValue {
2585 return attribute.String("network.transport", string(val))
2586 }
2587
2588 // NetworkErrors is an instrument used to record metric values conforming to the
2589 // "system.network.errors" semantic conventions. It represents the count of
2590 // network errors detected.
2591 type NetworkErrors struct {
2592 metric.Int64Counter
2593 }
2594
2595 var newNetworkErrorsOpts = []metric.Int64CounterOption{
2596 metric.WithDescription("Count of network errors detected."),
2597 metric.WithUnit("{error}"),
2598 }
2599
2600 // NewNetworkErrors returns a new NetworkErrors instrument.
2601 func NewNetworkErrors(
2602 m metric.Meter,
2603 opt ...metric.Int64CounterOption,
2604 ) (NetworkErrors, error) {
2605 // Check if the meter is nil.
2606 if m == nil {
2607 return NetworkErrors{noop.Int64Counter{}}, nil
2608 }
2609
2610 if len(opt) == 0 {
2611 opt = newNetworkErrorsOpts
2612 } else {
2613 opt = append(opt, newNetworkErrorsOpts...)
2614 }
2615
2616 i, err := m.Int64Counter(
2617 "system.network.errors",
2618 opt...,
2619 )
2620 if err != nil {
2621 return NetworkErrors{noop.Int64Counter{}}, err
2622 }
2623 return NetworkErrors{i}, nil
2624 }
2625
2626 // Inst returns the underlying metric instrument.
2627 func (m NetworkErrors) Inst() metric.Int64Counter {
2628 return m.Int64Counter
2629 }
2630
2631 // Name returns the semantic convention name of the instrument.
2632 func (NetworkErrors) Name() string {
2633 return "system.network.errors"
2634 }
2635
2636 // Unit returns the semantic convention unit of the instrument
2637 func (NetworkErrors) Unit() string {
2638 return "{error}"
2639 }
2640
2641 // Description returns the semantic convention description of the instrument
2642 func (NetworkErrors) Description() string {
2643 return "Count of network errors detected."
2644 }
2645
2646 // Add adds incr to the existing count for attrs.
2647 //
2648 // All additional attrs passed are included in the recorded value.
2649 //
2650 // Measured as:
2651 //
2652 // - Linux: the `errs` column in `/proc/net/dev` ([source]).
2653 // - Windows: [`InErrors`/`OutErrors`]
2654 // from [`GetIfEntry2`].
2655 //
2656 //
2657 // [source]: https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html
2658 // [`InErrors`/`OutErrors`]: https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2
2659 // [`GetIfEntry2`]: https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2
2660 func (m NetworkErrors) Add(
2661 ctx context.Context,
2662 incr int64,
2663 attrs ...attribute.KeyValue,
2664 ) {
2665 if len(attrs) == 0 {
2666 m.Int64Counter.Add(ctx, incr)
2667 return
2668 }
2669
2670 o := addOptPool.Get().(*[]metric.AddOption)
2671 defer func() {
2672 *o = (*o)[:0]
2673 addOptPool.Put(o)
2674 }()
2675
2676 *o = append(
2677 *o,
2678 metric.WithAttributes(
2679 attrs...,
2680 ),
2681 )
2682
2683 m.Int64Counter.Add(ctx, incr, *o...)
2684 }
2685
2686 // AddSet adds incr to the existing count for set.
2687 //
2688 // Measured as:
2689 //
2690 // - Linux: the `errs` column in `/proc/net/dev` ([source]).
2691 // - Windows: [`InErrors`/`OutErrors`]
2692 // from [`GetIfEntry2`].
2693 //
2694 //
2695 // [source]: https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html
2696 // [`InErrors`/`OutErrors`]: https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2
2697 // [`GetIfEntry2`]: https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2
2698 func (m NetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2699 if set.Len() == 0 {
2700 m.Int64Counter.Add(ctx, incr)
2701 return
2702 }
2703
2704 o := addOptPool.Get().(*[]metric.AddOption)
2705 defer func() {
2706 *o = (*o)[:0]
2707 addOptPool.Put(o)
2708 }()
2709
2710 *o = append(*o, metric.WithAttributeSet(set))
2711 m.Int64Counter.Add(ctx, incr, *o...)
2712 }
2713
2714 // AttrNetworkInterfaceName returns an optional attribute for the
2715 // "network.interface.name" semantic convention. It represents the network
2716 // interface name.
2717 func (NetworkErrors) AttrNetworkInterfaceName(val string) attribute.KeyValue {
2718 return attribute.String("network.interface.name", val)
2719 }
2720
2721 // AttrNetworkIODirection returns an optional attribute for the
2722 // "network.io.direction" semantic convention. It represents the network IO
2723 // operation direction.
2724 func (NetworkErrors) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
2725 return attribute.String("network.io.direction", string(val))
2726 }
2727
2728 // NetworkIO is an instrument used to record metric values conforming to the
2729 // "system.network.io" semantic conventions. It represents the TODO.
2730 type NetworkIO struct {
2731 metric.Int64ObservableCounter
2732 }
2733
2734 var newNetworkIOOpts = []metric.Int64ObservableCounterOption{
2735 metric.WithDescription("TODO."),
2736 metric.WithUnit("By"),
2737 }
2738
2739 // NewNetworkIO returns a new NetworkIO instrument.
2740 func NewNetworkIO(
2741 m metric.Meter,
2742 opt ...metric.Int64ObservableCounterOption,
2743 ) (NetworkIO, error) {
2744 // Check if the meter is nil.
2745 if m == nil {
2746 return NetworkIO{noop.Int64ObservableCounter{}}, nil
2747 }
2748
2749 if len(opt) == 0 {
2750 opt = newNetworkIOOpts
2751 } else {
2752 opt = append(opt, newNetworkIOOpts...)
2753 }
2754
2755 i, err := m.Int64ObservableCounter(
2756 "system.network.io",
2757 opt...,
2758 )
2759 if err != nil {
2760 return NetworkIO{noop.Int64ObservableCounter{}}, err
2761 }
2762 return NetworkIO{i}, nil
2763 }
2764
2765 // Inst returns the underlying metric instrument.
2766 func (m NetworkIO) Inst() metric.Int64ObservableCounter {
2767 return m.Int64ObservableCounter
2768 }
2769
2770 // Name returns the semantic convention name of the instrument.
2771 func (NetworkIO) Name() string {
2772 return "system.network.io"
2773 }
2774
2775 // Unit returns the semantic convention unit of the instrument
2776 func (NetworkIO) Unit() string {
2777 return "By"
2778 }
2779
2780 // Description returns the semantic convention description of the instrument
2781 func (NetworkIO) Description() string {
2782 return "TODO."
2783 }
2784
2785 // AttrNetworkInterfaceName returns an optional attribute for the
2786 // "network.interface.name" semantic convention. It represents the network
2787 // interface name.
2788 func (NetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue {
2789 return attribute.String("network.interface.name", val)
2790 }
2791
2792 // AttrNetworkIODirection returns an optional attribute for the
2793 // "network.io.direction" semantic convention. It represents the network IO
2794 // operation direction.
2795 func (NetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
2796 return attribute.String("network.io.direction", string(val))
2797 }
2798
2799 // NetworkPacketCount is an instrument used to record metric values conforming to
2800 // the "system.network.packet.count" semantic conventions. It represents the
2801 // TODO.
2802 type NetworkPacketCount struct {
2803 metric.Int64Counter
2804 }
2805
2806 var newNetworkPacketCountOpts = []metric.Int64CounterOption{
2807 metric.WithDescription("TODO."),
2808 metric.WithUnit("{packet}"),
2809 }
2810
2811 // NewNetworkPacketCount returns a new NetworkPacketCount instrument.
2812 func NewNetworkPacketCount(
2813 m metric.Meter,
2814 opt ...metric.Int64CounterOption,
2815 ) (NetworkPacketCount, error) {
2816 // Check if the meter is nil.
2817 if m == nil {
2818 return NetworkPacketCount{noop.Int64Counter{}}, nil
2819 }
2820
2821 if len(opt) == 0 {
2822 opt = newNetworkPacketCountOpts
2823 } else {
2824 opt = append(opt, newNetworkPacketCountOpts...)
2825 }
2826
2827 i, err := m.Int64Counter(
2828 "system.network.packet.count",
2829 opt...,
2830 )
2831 if err != nil {
2832 return NetworkPacketCount{noop.Int64Counter{}}, err
2833 }
2834 return NetworkPacketCount{i}, nil
2835 }
2836
2837 // Inst returns the underlying metric instrument.
2838 func (m NetworkPacketCount) Inst() metric.Int64Counter {
2839 return m.Int64Counter
2840 }
2841
2842 // Name returns the semantic convention name of the instrument.
2843 func (NetworkPacketCount) Name() string {
2844 return "system.network.packet.count"
2845 }
2846
2847 // Unit returns the semantic convention unit of the instrument
2848 func (NetworkPacketCount) Unit() string {
2849 return "{packet}"
2850 }
2851
2852 // Description returns the semantic convention description of the instrument
2853 func (NetworkPacketCount) Description() string {
2854 return "TODO."
2855 }
2856
2857 // Add adds incr to the existing count for attrs.
2858 //
2859 // All additional attrs passed are included in the recorded value.
2860 func (m NetworkPacketCount) Add(
2861 ctx context.Context,
2862 incr int64,
2863 attrs ...attribute.KeyValue,
2864 ) {
2865 if len(attrs) == 0 {
2866 m.Int64Counter.Add(ctx, incr)
2867 return
2868 }
2869
2870 o := addOptPool.Get().(*[]metric.AddOption)
2871 defer func() {
2872 *o = (*o)[:0]
2873 addOptPool.Put(o)
2874 }()
2875
2876 *o = append(
2877 *o,
2878 metric.WithAttributes(
2879 attrs...,
2880 ),
2881 )
2882
2883 m.Int64Counter.Add(ctx, incr, *o...)
2884 }
2885
2886 // AddSet adds incr to the existing count for set.
2887 func (m NetworkPacketCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
2888 if set.Len() == 0 {
2889 m.Int64Counter.Add(ctx, incr)
2890 return
2891 }
2892
2893 o := addOptPool.Get().(*[]metric.AddOption)
2894 defer func() {
2895 *o = (*o)[:0]
2896 addOptPool.Put(o)
2897 }()
2898
2899 *o = append(*o, metric.WithAttributeSet(set))
2900 m.Int64Counter.Add(ctx, incr, *o...)
2901 }
2902
2903 // AttrNetworkIODirection returns an optional attribute for the
2904 // "network.io.direction" semantic convention. It represents the network IO
2905 // operation direction.
2906 func (NetworkPacketCount) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
2907 return attribute.String("network.io.direction", string(val))
2908 }
2909
2910 // AttrDevice returns an optional attribute for the "system.device" semantic
2911 // convention. It represents the device identifier.
2912 func (NetworkPacketCount) AttrDevice(val string) attribute.KeyValue {
2913 return attribute.String("system.device", val)
2914 }
2915
2916 // NetworkPacketDropped is an instrument used to record metric values conforming
2917 // to the "system.network.packet.dropped" semantic conventions. It represents the
2918 // count of packets that are dropped or discarded even though there was no error.
2919 type NetworkPacketDropped struct {
2920 metric.Int64Counter
2921 }
2922
2923 var newNetworkPacketDroppedOpts = []metric.Int64CounterOption{
2924 metric.WithDescription("Count of packets that are dropped or discarded even though there was no error."),
2925 metric.WithUnit("{packet}"),
2926 }
2927
2928 // NewNetworkPacketDropped returns a new NetworkPacketDropped instrument.
2929 func NewNetworkPacketDropped(
2930 m metric.Meter,
2931 opt ...metric.Int64CounterOption,
2932 ) (NetworkPacketDropped, error) {
2933 // Check if the meter is nil.
2934 if m == nil {
2935 return NetworkPacketDropped{noop.Int64Counter{}}, nil
2936 }
2937
2938 if len(opt) == 0 {
2939 opt = newNetworkPacketDroppedOpts
2940 } else {
2941 opt = append(opt, newNetworkPacketDroppedOpts...)
2942 }
2943
2944 i, err := m.Int64Counter(
2945 "system.network.packet.dropped",
2946 opt...,
2947 )
2948 if err != nil {
2949 return NetworkPacketDropped{noop.Int64Counter{}}, err
2950 }
2951 return NetworkPacketDropped{i}, nil
2952 }
2953
2954 // Inst returns the underlying metric instrument.
2955 func (m NetworkPacketDropped) Inst() metric.Int64Counter {
2956 return m.Int64Counter
2957 }
2958
2959 // Name returns the semantic convention name of the instrument.
2960 func (NetworkPacketDropped) Name() string {
2961 return "system.network.packet.dropped"
2962 }
2963
2964 // Unit returns the semantic convention unit of the instrument
2965 func (NetworkPacketDropped) Unit() string {
2966 return "{packet}"
2967 }
2968
2969 // Description returns the semantic convention description of the instrument
2970 func (NetworkPacketDropped) Description() string {
2971 return "Count of packets that are dropped or discarded even though there was no error."
2972 }
2973
2974 // Add adds incr to the existing count for attrs.
2975 //
2976 // All additional attrs passed are included in the recorded value.
2977 //
2978 // Measured as:
2979 //
2980 // - Linux: the `drop` column in `/proc/net/dev` ([source])
2981 // - Windows: [`InDiscards`/`OutDiscards`]
2982 // from [`GetIfEntry2`]
2983 //
2984 //
2985 // [source]: https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html
2986 // [`InDiscards`/`OutDiscards`]: https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2
2987 // [`GetIfEntry2`]: https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2
2988 func (m NetworkPacketDropped) Add(
2989 ctx context.Context,
2990 incr int64,
2991 attrs ...attribute.KeyValue,
2992 ) {
2993 if len(attrs) == 0 {
2994 m.Int64Counter.Add(ctx, incr)
2995 return
2996 }
2997
2998 o := addOptPool.Get().(*[]metric.AddOption)
2999 defer func() {
3000 *o = (*o)[:0]
3001 addOptPool.Put(o)
3002 }()
3003
3004 *o = append(
3005 *o,
3006 metric.WithAttributes(
3007 attrs...,
3008 ),
3009 )
3010
3011 m.Int64Counter.Add(ctx, incr, *o...)
3012 }
3013
3014 // AddSet adds incr to the existing count for set.
3015 //
3016 // Measured as:
3017 //
3018 // - Linux: the `drop` column in `/proc/net/dev` ([source])
3019 // - Windows: [`InDiscards`/`OutDiscards`]
3020 // from [`GetIfEntry2`]
3021 //
3022 //
3023 // [source]: https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html
3024 // [`InDiscards`/`OutDiscards`]: https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2
3025 // [`GetIfEntry2`]: https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2
3026 func (m NetworkPacketDropped) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3027 if set.Len() == 0 {
3028 m.Int64Counter.Add(ctx, incr)
3029 return
3030 }
3031
3032 o := addOptPool.Get().(*[]metric.AddOption)
3033 defer func() {
3034 *o = (*o)[:0]
3035 addOptPool.Put(o)
3036 }()
3037
3038 *o = append(*o, metric.WithAttributeSet(set))
3039 m.Int64Counter.Add(ctx, incr, *o...)
3040 }
3041
3042 // AttrNetworkInterfaceName returns an optional attribute for the
3043 // "network.interface.name" semantic convention. It represents the network
3044 // interface name.
3045 func (NetworkPacketDropped) AttrNetworkInterfaceName(val string) attribute.KeyValue {
3046 return attribute.String("network.interface.name", val)
3047 }
3048
3049 // AttrNetworkIODirection returns an optional attribute for the
3050 // "network.io.direction" semantic convention. It represents the network IO
3051 // operation direction.
3052 func (NetworkPacketDropped) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
3053 return attribute.String("network.io.direction", string(val))
3054 }
3055
3056 // PagingFaults is an instrument used to record metric values conforming to the
3057 // "system.paging.faults" semantic conventions. It represents the TODO.
3058 type PagingFaults struct {
3059 metric.Int64Counter
3060 }
3061
3062 var newPagingFaultsOpts = []metric.Int64CounterOption{
3063 metric.WithDescription("TODO."),
3064 metric.WithUnit("{fault}"),
3065 }
3066
3067 // NewPagingFaults returns a new PagingFaults instrument.
3068 func NewPagingFaults(
3069 m metric.Meter,
3070 opt ...metric.Int64CounterOption,
3071 ) (PagingFaults, error) {
3072 // Check if the meter is nil.
3073 if m == nil {
3074 return PagingFaults{noop.Int64Counter{}}, nil
3075 }
3076
3077 if len(opt) == 0 {
3078 opt = newPagingFaultsOpts
3079 } else {
3080 opt = append(opt, newPagingFaultsOpts...)
3081 }
3082
3083 i, err := m.Int64Counter(
3084 "system.paging.faults",
3085 opt...,
3086 )
3087 if err != nil {
3088 return PagingFaults{noop.Int64Counter{}}, err
3089 }
3090 return PagingFaults{i}, nil
3091 }
3092
3093 // Inst returns the underlying metric instrument.
3094 func (m PagingFaults) Inst() metric.Int64Counter {
3095 return m.Int64Counter
3096 }
3097
3098 // Name returns the semantic convention name of the instrument.
3099 func (PagingFaults) Name() string {
3100 return "system.paging.faults"
3101 }
3102
3103 // Unit returns the semantic convention unit of the instrument
3104 func (PagingFaults) Unit() string {
3105 return "{fault}"
3106 }
3107
3108 // Description returns the semantic convention description of the instrument
3109 func (PagingFaults) Description() string {
3110 return "TODO."
3111 }
3112
3113 // Add adds incr to the existing count for attrs.
3114 //
3115 // All additional attrs passed are included in the recorded value.
3116 func (m PagingFaults) Add(
3117 ctx context.Context,
3118 incr int64,
3119 attrs ...attribute.KeyValue,
3120 ) {
3121 if len(attrs) == 0 {
3122 m.Int64Counter.Add(ctx, incr)
3123 return
3124 }
3125
3126 o := addOptPool.Get().(*[]metric.AddOption)
3127 defer func() {
3128 *o = (*o)[:0]
3129 addOptPool.Put(o)
3130 }()
3131
3132 *o = append(
3133 *o,
3134 metric.WithAttributes(
3135 attrs...,
3136 ),
3137 )
3138
3139 m.Int64Counter.Add(ctx, incr, *o...)
3140 }
3141
3142 // AddSet adds incr to the existing count for set.
3143 func (m PagingFaults) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3144 if set.Len() == 0 {
3145 m.Int64Counter.Add(ctx, incr)
3146 return
3147 }
3148
3149 o := addOptPool.Get().(*[]metric.AddOption)
3150 defer func() {
3151 *o = (*o)[:0]
3152 addOptPool.Put(o)
3153 }()
3154
3155 *o = append(*o, metric.WithAttributeSet(set))
3156 m.Int64Counter.Add(ctx, incr, *o...)
3157 }
3158
3159 // AttrPagingType returns an optional attribute for the "system.paging.type"
3160 // semantic convention. It represents the memory paging type.
3161 func (PagingFaults) AttrPagingType(val PagingTypeAttr) attribute.KeyValue {
3162 return attribute.String("system.paging.type", string(val))
3163 }
3164
3165 // PagingOperations is an instrument used to record metric values conforming to
3166 // the "system.paging.operations" semantic conventions. It represents the TODO.
3167 type PagingOperations struct {
3168 metric.Int64Counter
3169 }
3170
3171 var newPagingOperationsOpts = []metric.Int64CounterOption{
3172 metric.WithDescription("TODO."),
3173 metric.WithUnit("{operation}"),
3174 }
3175
3176 // NewPagingOperations returns a new PagingOperations instrument.
3177 func NewPagingOperations(
3178 m metric.Meter,
3179 opt ...metric.Int64CounterOption,
3180 ) (PagingOperations, error) {
3181 // Check if the meter is nil.
3182 if m == nil {
3183 return PagingOperations{noop.Int64Counter{}}, nil
3184 }
3185
3186 if len(opt) == 0 {
3187 opt = newPagingOperationsOpts
3188 } else {
3189 opt = append(opt, newPagingOperationsOpts...)
3190 }
3191
3192 i, err := m.Int64Counter(
3193 "system.paging.operations",
3194 opt...,
3195 )
3196 if err != nil {
3197 return PagingOperations{noop.Int64Counter{}}, err
3198 }
3199 return PagingOperations{i}, nil
3200 }
3201
3202 // Inst returns the underlying metric instrument.
3203 func (m PagingOperations) Inst() metric.Int64Counter {
3204 return m.Int64Counter
3205 }
3206
3207 // Name returns the semantic convention name of the instrument.
3208 func (PagingOperations) Name() string {
3209 return "system.paging.operations"
3210 }
3211
3212 // Unit returns the semantic convention unit of the instrument
3213 func (PagingOperations) Unit() string {
3214 return "{operation}"
3215 }
3216
3217 // Description returns the semantic convention description of the instrument
3218 func (PagingOperations) Description() string {
3219 return "TODO."
3220 }
3221
3222 // Add adds incr to the existing count for attrs.
3223 //
3224 // All additional attrs passed are included in the recorded value.
3225 func (m PagingOperations) Add(
3226 ctx context.Context,
3227 incr int64,
3228 attrs ...attribute.KeyValue,
3229 ) {
3230 if len(attrs) == 0 {
3231 m.Int64Counter.Add(ctx, incr)
3232 return
3233 }
3234
3235 o := addOptPool.Get().(*[]metric.AddOption)
3236 defer func() {
3237 *o = (*o)[:0]
3238 addOptPool.Put(o)
3239 }()
3240
3241 *o = append(
3242 *o,
3243 metric.WithAttributes(
3244 attrs...,
3245 ),
3246 )
3247
3248 m.Int64Counter.Add(ctx, incr, *o...)
3249 }
3250
3251 // AddSet adds incr to the existing count for set.
3252 func (m PagingOperations) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3253 if set.Len() == 0 {
3254 m.Int64Counter.Add(ctx, incr)
3255 return
3256 }
3257
3258 o := addOptPool.Get().(*[]metric.AddOption)
3259 defer func() {
3260 *o = (*o)[:0]
3261 addOptPool.Put(o)
3262 }()
3263
3264 *o = append(*o, metric.WithAttributeSet(set))
3265 m.Int64Counter.Add(ctx, incr, *o...)
3266 }
3267
3268 // AttrPagingDirection returns an optional attribute for the
3269 // "system.paging.direction" semantic convention. It represents the paging access
3270 // direction.
3271 func (PagingOperations) AttrPagingDirection(val PagingDirectionAttr) attribute.KeyValue {
3272 return attribute.String("system.paging.direction", string(val))
3273 }
3274
3275 // AttrPagingType returns an optional attribute for the "system.paging.type"
3276 // semantic convention. It represents the memory paging type.
3277 func (PagingOperations) AttrPagingType(val PagingTypeAttr) attribute.KeyValue {
3278 return attribute.String("system.paging.type", string(val))
3279 }
3280
3281 // PagingUsage is an instrument used to record metric values conforming to the
3282 // "system.paging.usage" semantic conventions. It represents the unix swap or
3283 // windows pagefile usage.
3284 type PagingUsage struct {
3285 metric.Int64UpDownCounter
3286 }
3287
3288 var newPagingUsageOpts = []metric.Int64UpDownCounterOption{
3289 metric.WithDescription("Unix swap or windows pagefile usage."),
3290 metric.WithUnit("By"),
3291 }
3292
3293 // NewPagingUsage returns a new PagingUsage instrument.
3294 func NewPagingUsage(
3295 m metric.Meter,
3296 opt ...metric.Int64UpDownCounterOption,
3297 ) (PagingUsage, error) {
3298 // Check if the meter is nil.
3299 if m == nil {
3300 return PagingUsage{noop.Int64UpDownCounter{}}, nil
3301 }
3302
3303 if len(opt) == 0 {
3304 opt = newPagingUsageOpts
3305 } else {
3306 opt = append(opt, newPagingUsageOpts...)
3307 }
3308
3309 i, err := m.Int64UpDownCounter(
3310 "system.paging.usage",
3311 opt...,
3312 )
3313 if err != nil {
3314 return PagingUsage{noop.Int64UpDownCounter{}}, err
3315 }
3316 return PagingUsage{i}, nil
3317 }
3318
3319 // Inst returns the underlying metric instrument.
3320 func (m PagingUsage) Inst() metric.Int64UpDownCounter {
3321 return m.Int64UpDownCounter
3322 }
3323
3324 // Name returns the semantic convention name of the instrument.
3325 func (PagingUsage) Name() string {
3326 return "system.paging.usage"
3327 }
3328
3329 // Unit returns the semantic convention unit of the instrument
3330 func (PagingUsage) Unit() string {
3331 return "By"
3332 }
3333
3334 // Description returns the semantic convention description of the instrument
3335 func (PagingUsage) Description() string {
3336 return "Unix swap or windows pagefile usage."
3337 }
3338
3339 // Add adds incr to the existing count for attrs.
3340 //
3341 // All additional attrs passed are included in the recorded value.
3342 func (m PagingUsage) Add(
3343 ctx context.Context,
3344 incr int64,
3345 attrs ...attribute.KeyValue,
3346 ) {
3347 if len(attrs) == 0 {
3348 m.Int64UpDownCounter.Add(ctx, incr)
3349 return
3350 }
3351
3352 o := addOptPool.Get().(*[]metric.AddOption)
3353 defer func() {
3354 *o = (*o)[:0]
3355 addOptPool.Put(o)
3356 }()
3357
3358 *o = append(
3359 *o,
3360 metric.WithAttributes(
3361 attrs...,
3362 ),
3363 )
3364
3365 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3366 }
3367
3368 // AddSet adds incr to the existing count for set.
3369 func (m PagingUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3370 if set.Len() == 0 {
3371 m.Int64UpDownCounter.Add(ctx, incr)
3372 return
3373 }
3374
3375 o := addOptPool.Get().(*[]metric.AddOption)
3376 defer func() {
3377 *o = (*o)[:0]
3378 addOptPool.Put(o)
3379 }()
3380
3381 *o = append(*o, metric.WithAttributeSet(set))
3382 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3383 }
3384
3385 // AttrDevice returns an optional attribute for the "system.device" semantic
3386 // convention. It represents the unique identifier for the device responsible for
3387 // managing paging operations.
3388 func (PagingUsage) AttrDevice(val string) attribute.KeyValue {
3389 return attribute.String("system.device", val)
3390 }
3391
3392 // AttrPagingState returns an optional attribute for the "system.paging.state"
3393 // semantic convention. It represents the memory paging state.
3394 func (PagingUsage) AttrPagingState(val PagingStateAttr) attribute.KeyValue {
3395 return attribute.String("system.paging.state", string(val))
3396 }
3397
3398 // PagingUtilization is an instrument used to record metric values conforming to
3399 // the "system.paging.utilization" semantic conventions. It represents the TODO.
3400 type PagingUtilization struct {
3401 metric.Int64Gauge
3402 }
3403
3404 var newPagingUtilizationOpts = []metric.Int64GaugeOption{
3405 metric.WithDescription("TODO."),
3406 metric.WithUnit("1"),
3407 }
3408
3409 // NewPagingUtilization returns a new PagingUtilization instrument.
3410 func NewPagingUtilization(
3411 m metric.Meter,
3412 opt ...metric.Int64GaugeOption,
3413 ) (PagingUtilization, error) {
3414 // Check if the meter is nil.
3415 if m == nil {
3416 return PagingUtilization{noop.Int64Gauge{}}, nil
3417 }
3418
3419 if len(opt) == 0 {
3420 opt = newPagingUtilizationOpts
3421 } else {
3422 opt = append(opt, newPagingUtilizationOpts...)
3423 }
3424
3425 i, err := m.Int64Gauge(
3426 "system.paging.utilization",
3427 opt...,
3428 )
3429 if err != nil {
3430 return PagingUtilization{noop.Int64Gauge{}}, err
3431 }
3432 return PagingUtilization{i}, nil
3433 }
3434
3435 // Inst returns the underlying metric instrument.
3436 func (m PagingUtilization) Inst() metric.Int64Gauge {
3437 return m.Int64Gauge
3438 }
3439
3440 // Name returns the semantic convention name of the instrument.
3441 func (PagingUtilization) Name() string {
3442 return "system.paging.utilization"
3443 }
3444
3445 // Unit returns the semantic convention unit of the instrument
3446 func (PagingUtilization) Unit() string {
3447 return "1"
3448 }
3449
3450 // Description returns the semantic convention description of the instrument
3451 func (PagingUtilization) Description() string {
3452 return "TODO."
3453 }
3454
3455 // Record records val to the current distribution for attrs.
3456 //
3457 // All additional attrs passed are included in the recorded value.
3458 func (m PagingUtilization) Record(
3459 ctx context.Context,
3460 val int64,
3461 attrs ...attribute.KeyValue,
3462 ) {
3463 if len(attrs) == 0 {
3464 m.Int64Gauge.Record(ctx, val)
3465 return
3466 }
3467
3468 o := recOptPool.Get().(*[]metric.RecordOption)
3469 defer func() {
3470 *o = (*o)[:0]
3471 recOptPool.Put(o)
3472 }()
3473
3474 *o = append(
3475 *o,
3476 metric.WithAttributes(
3477 attrs...,
3478 ),
3479 )
3480
3481 m.Int64Gauge.Record(ctx, val, *o...)
3482 }
3483
3484 // RecordSet records val to the current distribution for set.
3485 func (m PagingUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) {
3486 if set.Len() == 0 {
3487 m.Int64Gauge.Record(ctx, val)
3488 return
3489 }
3490
3491 o := recOptPool.Get().(*[]metric.RecordOption)
3492 defer func() {
3493 *o = (*o)[:0]
3494 recOptPool.Put(o)
3495 }()
3496
3497 *o = append(*o, metric.WithAttributeSet(set))
3498 m.Int64Gauge.Record(ctx, val, *o...)
3499 }
3500
3501 // AttrDevice returns an optional attribute for the "system.device" semantic
3502 // convention. It represents the unique identifier for the device responsible for
3503 // managing paging operations.
3504 func (PagingUtilization) AttrDevice(val string) attribute.KeyValue {
3505 return attribute.String("system.device", val)
3506 }
3507
3508 // AttrPagingState returns an optional attribute for the "system.paging.state"
3509 // semantic convention. It represents the memory paging state.
3510 func (PagingUtilization) AttrPagingState(val PagingStateAttr) attribute.KeyValue {
3511 return attribute.String("system.paging.state", string(val))
3512 }
3513
3514 // ProcessCount is an instrument used to record metric values conforming to the
3515 // "system.process.count" semantic conventions. It represents the total number of
3516 // processes in each state.
3517 type ProcessCount struct {
3518 metric.Int64UpDownCounter
3519 }
3520
3521 var newProcessCountOpts = []metric.Int64UpDownCounterOption{
3522 metric.WithDescription("Total number of processes in each state."),
3523 metric.WithUnit("{process}"),
3524 }
3525
3526 // NewProcessCount returns a new ProcessCount instrument.
3527 func NewProcessCount(
3528 m metric.Meter,
3529 opt ...metric.Int64UpDownCounterOption,
3530 ) (ProcessCount, error) {
3531 // Check if the meter is nil.
3532 if m == nil {
3533 return ProcessCount{noop.Int64UpDownCounter{}}, nil
3534 }
3535
3536 if len(opt) == 0 {
3537 opt = newProcessCountOpts
3538 } else {
3539 opt = append(opt, newProcessCountOpts...)
3540 }
3541
3542 i, err := m.Int64UpDownCounter(
3543 "system.process.count",
3544 opt...,
3545 )
3546 if err != nil {
3547 return ProcessCount{noop.Int64UpDownCounter{}}, err
3548 }
3549 return ProcessCount{i}, nil
3550 }
3551
3552 // Inst returns the underlying metric instrument.
3553 func (m ProcessCount) Inst() metric.Int64UpDownCounter {
3554 return m.Int64UpDownCounter
3555 }
3556
3557 // Name returns the semantic convention name of the instrument.
3558 func (ProcessCount) Name() string {
3559 return "system.process.count"
3560 }
3561
3562 // Unit returns the semantic convention unit of the instrument
3563 func (ProcessCount) Unit() string {
3564 return "{process}"
3565 }
3566
3567 // Description returns the semantic convention description of the instrument
3568 func (ProcessCount) Description() string {
3569 return "Total number of processes in each state."
3570 }
3571
3572 // Add adds incr to the existing count for attrs.
3573 //
3574 // All additional attrs passed are included in the recorded value.
3575 func (m ProcessCount) Add(
3576 ctx context.Context,
3577 incr int64,
3578 attrs ...attribute.KeyValue,
3579 ) {
3580 if len(attrs) == 0 {
3581 m.Int64UpDownCounter.Add(ctx, incr)
3582 return
3583 }
3584
3585 o := addOptPool.Get().(*[]metric.AddOption)
3586 defer func() {
3587 *o = (*o)[:0]
3588 addOptPool.Put(o)
3589 }()
3590
3591 *o = append(
3592 *o,
3593 metric.WithAttributes(
3594 attrs...,
3595 ),
3596 )
3597
3598 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3599 }
3600
3601 // AddSet adds incr to the existing count for set.
3602 func (m ProcessCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3603 if set.Len() == 0 {
3604 m.Int64UpDownCounter.Add(ctx, incr)
3605 return
3606 }
3607
3608 o := addOptPool.Get().(*[]metric.AddOption)
3609 defer func() {
3610 *o = (*o)[:0]
3611 addOptPool.Put(o)
3612 }()
3613
3614 *o = append(*o, metric.WithAttributeSet(set))
3615 m.Int64UpDownCounter.Add(ctx, incr, *o...)
3616 }
3617
3618 // AttrProcessStatus returns an optional attribute for the
3619 // "system.process.status" semantic convention. It represents the process state,
3620 // e.g., [Linux Process State Codes].
3621 //
3622 // [Linux Process State Codes]: https://man7.org/linux/man-pages/man1/ps.1.html#PROCESS_STATE_CODES
3623 func (ProcessCount) AttrProcessStatus(val ProcessStatusAttr) attribute.KeyValue {
3624 return attribute.String("system.process.status", string(val))
3625 }
3626
3627 // ProcessCreated is an instrument used to record metric values conforming to the
3628 // "system.process.created" semantic conventions. It represents the total number
3629 // of processes created over uptime of the host.
3630 type ProcessCreated struct {
3631 metric.Int64Counter
3632 }
3633
3634 var newProcessCreatedOpts = []metric.Int64CounterOption{
3635 metric.WithDescription("Total number of processes created over uptime of the host."),
3636 metric.WithUnit("{process}"),
3637 }
3638
3639 // NewProcessCreated returns a new ProcessCreated instrument.
3640 func NewProcessCreated(
3641 m metric.Meter,
3642 opt ...metric.Int64CounterOption,
3643 ) (ProcessCreated, error) {
3644 // Check if the meter is nil.
3645 if m == nil {
3646 return ProcessCreated{noop.Int64Counter{}}, nil
3647 }
3648
3649 if len(opt) == 0 {
3650 opt = newProcessCreatedOpts
3651 } else {
3652 opt = append(opt, newProcessCreatedOpts...)
3653 }
3654
3655 i, err := m.Int64Counter(
3656 "system.process.created",
3657 opt...,
3658 )
3659 if err != nil {
3660 return ProcessCreated{noop.Int64Counter{}}, err
3661 }
3662 return ProcessCreated{i}, nil
3663 }
3664
3665 // Inst returns the underlying metric instrument.
3666 func (m ProcessCreated) Inst() metric.Int64Counter {
3667 return m.Int64Counter
3668 }
3669
3670 // Name returns the semantic convention name of the instrument.
3671 func (ProcessCreated) Name() string {
3672 return "system.process.created"
3673 }
3674
3675 // Unit returns the semantic convention unit of the instrument
3676 func (ProcessCreated) Unit() string {
3677 return "{process}"
3678 }
3679
3680 // Description returns the semantic convention description of the instrument
3681 func (ProcessCreated) Description() string {
3682 return "Total number of processes created over uptime of the host."
3683 }
3684
3685 // Add adds incr to the existing count for attrs.
3686 func (m ProcessCreated) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
3687 if len(attrs) == 0 {
3688 m.Int64Counter.Add(ctx, incr)
3689 return
3690 }
3691
3692 o := addOptPool.Get().(*[]metric.AddOption)
3693 defer func() {
3694 *o = (*o)[:0]
3695 addOptPool.Put(o)
3696 }()
3697
3698 *o = append(*o, metric.WithAttributes(attrs...))
3699 m.Int64Counter.Add(ctx, incr, *o...)
3700 }
3701
3702 // AddSet adds incr to the existing count for set.
3703 func (m ProcessCreated) AddSet(ctx context.Context, incr int64, set attribute.Set) {
3704 if set.Len() == 0 {
3705 m.Int64Counter.Add(ctx, incr)
3706 return
3707 }
3708
3709 o := addOptPool.Get().(*[]metric.AddOption)
3710 defer func() {
3711 *o = (*o)[:0]
3712 addOptPool.Put(o)
3713 }()
3714
3715 *o = append(*o, metric.WithAttributeSet(set))
3716 m.Int64Counter.Add(ctx, incr, *o...)
3717 }
3718
3719 // Uptime is an instrument used to record metric values conforming to the
3720 // "system.uptime" semantic conventions. It represents the time the system has
3721 // been running.
3722 type Uptime struct {
3723 metric.Float64Gauge
3724 }
3725
3726 var newUptimeOpts = []metric.Float64GaugeOption{
3727 metric.WithDescription("The time the system has been running."),
3728 metric.WithUnit("s"),
3729 }
3730
3731 // NewUptime returns a new Uptime instrument.
3732 func NewUptime(
3733 m metric.Meter,
3734 opt ...metric.Float64GaugeOption,
3735 ) (Uptime, error) {
3736 // Check if the meter is nil.
3737 if m == nil {
3738 return Uptime{noop.Float64Gauge{}}, nil
3739 }
3740
3741 if len(opt) == 0 {
3742 opt = newUptimeOpts
3743 } else {
3744 opt = append(opt, newUptimeOpts...)
3745 }
3746
3747 i, err := m.Float64Gauge(
3748 "system.uptime",
3749 opt...,
3750 )
3751 if err != nil {
3752 return Uptime{noop.Float64Gauge{}}, err
3753 }
3754 return Uptime{i}, nil
3755 }
3756
3757 // Inst returns the underlying metric instrument.
3758 func (m Uptime) Inst() metric.Float64Gauge {
3759 return m.Float64Gauge
3760 }
3761
3762 // Name returns the semantic convention name of the instrument.
3763 func (Uptime) Name() string {
3764 return "system.uptime"
3765 }
3766
3767 // Unit returns the semantic convention unit of the instrument
3768 func (Uptime) Unit() string {
3769 return "s"
3770 }
3771
3772 // Description returns the semantic convention description of the instrument
3773 func (Uptime) Description() string {
3774 return "The time the system has been running."
3775 }
3776
3777 // Record records val to the current distribution for attrs.
3778 //
3779 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
3780 // seconds as a floating point number with the highest precision available.
3781 // The actual accuracy would depend on the instrumentation and operating system.
3782 func (m Uptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
3783 if len(attrs) == 0 {
3784 m.Float64Gauge.Record(ctx, val)
3785 return
3786 }
3787
3788 o := recOptPool.Get().(*[]metric.RecordOption)
3789 defer func() {
3790 *o = (*o)[:0]
3791 recOptPool.Put(o)
3792 }()
3793
3794 *o = append(*o, metric.WithAttributes(attrs...))
3795 m.Float64Gauge.Record(ctx, val, *o...)
3796 }
3797
3798 // RecordSet records val to the current distribution for set.
3799 //
3800 // Instrumentations SHOULD use a gauge with type `double` and measure uptime in
3801 // seconds as a floating point number with the highest precision available.
3802 // The actual accuracy would depend on the instrumentation and operating system.
3803 func (m Uptime) RecordSet(ctx context.Context, val float64, set attribute.Set) {
3804 if set.Len() == 0 {
3805 m.Float64Gauge.Record(ctx, val)
3806 return
3807 }
3808
3809 o := recOptPool.Get().(*[]metric.RecordOption)
3810 defer func() {
3811 *o = (*o)[:0]
3812 recOptPool.Put(o)
3813 }()
3814
3815 *o = append(*o, metric.WithAttributeSet(set))
3816 m.Float64Gauge.Record(ctx, val, *o...)
3817 }