76
76
77
77
import psutil
78
78
79
- from opentelemetry ._metrics import Observation , get_meter
79
+ from opentelemetry ._metrics import CallbackOptions , Observation , get_meter
80
80
81
81
# FIXME Remove this pyling disabling line when Github issue is cleared
82
82
# pylint: disable=no-name-in-module
@@ -320,7 +320,9 @@ def _instrument(self, **kwargs):
320
320
def _uninstrument (self , ** __ ):
321
321
pass
322
322
323
- def _get_system_cpu_time (self ) -> Iterable [Observation ]:
323
+ def _get_system_cpu_time (
324
+ self , options : CallbackOptions
325
+ ) -> Iterable [Observation ]:
324
326
"""Observer callback for system CPU time"""
325
327
for cpu , times in enumerate (psutil .cpu_times (percpu = True )):
326
328
for metric in self ._config ["system.cpu.time" ]:
@@ -331,7 +333,9 @@ def _get_system_cpu_time(self) -> Iterable[Observation]:
331
333
getattr (times , metric ), self ._system_cpu_time_labels
332
334
)
333
335
334
- def _get_system_cpu_utilization (self ) -> Iterable [Observation ]:
336
+ def _get_system_cpu_utilization (
337
+ self , options : CallbackOptions
338
+ ) -> Iterable [Observation ]:
335
339
"""Observer callback for system CPU utilization"""
336
340
337
341
for cpu , times_percent in enumerate (
@@ -346,7 +350,9 @@ def _get_system_cpu_utilization(self) -> Iterable[Observation]:
346
350
self ._system_cpu_utilization_labels ,
347
351
)
348
352
349
- def _get_system_memory_usage (self ) -> Iterable [Observation ]:
353
+ def _get_system_memory_usage (
354
+ self , options : CallbackOptions
355
+ ) -> Iterable [Observation ]:
350
356
"""Observer callback for memory usage"""
351
357
virtual_memory = psutil .virtual_memory ()
352
358
for metric in self ._config ["system.memory.usage" ]:
@@ -357,7 +363,9 @@ def _get_system_memory_usage(self) -> Iterable[Observation]:
357
363
self ._system_memory_usage_labels ,
358
364
)
359
365
360
- def _get_system_memory_utilization (self ) -> Iterable [Observation ]:
366
+ def _get_system_memory_utilization (
367
+ self , options : CallbackOptions
368
+ ) -> Iterable [Observation ]:
361
369
"""Observer callback for memory utilization"""
362
370
system_memory = psutil .virtual_memory ()
363
371
@@ -369,7 +377,9 @@ def _get_system_memory_utilization(self) -> Iterable[Observation]:
369
377
self ._system_memory_utilization_labels ,
370
378
)
371
379
372
- def _get_system_swap_usage (self ) -> Iterable [Observation ]:
380
+ def _get_system_swap_usage (
381
+ self , options : CallbackOptions
382
+ ) -> Iterable [Observation ]:
373
383
"""Observer callback for swap usage"""
374
384
system_swap = psutil .swap_memory ()
375
385
@@ -381,7 +391,9 @@ def _get_system_swap_usage(self) -> Iterable[Observation]:
381
391
self ._system_swap_usage_labels ,
382
392
)
383
393
384
- def _get_system_swap_utilization (self ) -> Iterable [Observation ]:
394
+ def _get_system_swap_utilization (
395
+ self , options : CallbackOptions
396
+ ) -> Iterable [Observation ]:
385
397
"""Observer callback for swap utilization"""
386
398
system_swap = psutil .swap_memory ()
387
399
@@ -393,7 +405,9 @@ def _get_system_swap_utilization(self) -> Iterable[Observation]:
393
405
self ._system_swap_utilization_labels ,
394
406
)
395
407
396
- def _get_system_disk_io (self ) -> Iterable [Observation ]:
408
+ def _get_system_disk_io (
409
+ self , options : CallbackOptions
410
+ ) -> Iterable [Observation ]:
397
411
"""Observer callback for disk IO"""
398
412
for device , counters in psutil .disk_io_counters (perdisk = True ).items ():
399
413
for metric in self ._config ["system.disk.io" ]:
@@ -405,7 +419,9 @@ def _get_system_disk_io(self) -> Iterable[Observation]:
405
419
self ._system_disk_io_labels ,
406
420
)
407
421
408
- def _get_system_disk_operations (self ) -> Iterable [Observation ]:
422
+ def _get_system_disk_operations (
423
+ self , options : CallbackOptions
424
+ ) -> Iterable [Observation ]:
409
425
"""Observer callback for disk operations"""
410
426
for device , counters in psutil .disk_io_counters (perdisk = True ).items ():
411
427
for metric in self ._config ["system.disk.operations" ]:
@@ -417,7 +433,9 @@ def _get_system_disk_operations(self) -> Iterable[Observation]:
417
433
self ._system_disk_operations_labels ,
418
434
)
419
435
420
- def _get_system_disk_time (self ) -> Iterable [Observation ]:
436
+ def _get_system_disk_time (
437
+ self , options : CallbackOptions
438
+ ) -> Iterable [Observation ]:
421
439
"""Observer callback for disk time"""
422
440
for device , counters in psutil .disk_io_counters (perdisk = True ).items ():
423
441
for metric in self ._config ["system.disk.time" ]:
@@ -429,7 +447,9 @@ def _get_system_disk_time(self) -> Iterable[Observation]:
429
447
self ._system_disk_time_labels ,
430
448
)
431
449
432
- def _get_system_disk_merged (self ) -> Iterable [Observation ]:
450
+ def _get_system_disk_merged (
451
+ self , options : CallbackOptions
452
+ ) -> Iterable [Observation ]:
433
453
"""Observer callback for disk merged operations"""
434
454
435
455
# FIXME The units in the spec is 1, it seems like it should be
@@ -445,7 +465,9 @@ def _get_system_disk_merged(self) -> Iterable[Observation]:
445
465
self ._system_disk_merged_labels ,
446
466
)
447
467
448
- def _get_system_network_dropped_packets (self ) -> Iterable [Observation ]:
468
+ def _get_system_network_dropped_packets (
469
+ self , options : CallbackOptions
470
+ ) -> Iterable [Observation ]:
449
471
"""Observer callback for network dropped packets"""
450
472
451
473
for device , counters in psutil .net_io_counters (pernic = True ).items ():
@@ -463,7 +485,9 @@ def _get_system_network_dropped_packets(self) -> Iterable[Observation]:
463
485
self ._system_network_dropped_packets_labels ,
464
486
)
465
487
466
- def _get_system_network_packets (self ) -> Iterable [Observation ]:
488
+ def _get_system_network_packets (
489
+ self , options : CallbackOptions
490
+ ) -> Iterable [Observation ]:
467
491
"""Observer callback for network packets"""
468
492
469
493
for device , counters in psutil .net_io_counters (pernic = True ).items ():
@@ -477,7 +501,9 @@ def _get_system_network_packets(self) -> Iterable[Observation]:
477
501
self ._system_network_packets_labels ,
478
502
)
479
503
480
- def _get_system_network_errors (self ) -> Iterable [Observation ]:
504
+ def _get_system_network_errors (
505
+ self , options : CallbackOptions
506
+ ) -> Iterable [Observation ]:
481
507
"""Observer callback for network errors"""
482
508
for device , counters in psutil .net_io_counters (pernic = True ).items ():
483
509
for metric in self ._config ["system.network.errors" ]:
@@ -490,7 +516,9 @@ def _get_system_network_errors(self) -> Iterable[Observation]:
490
516
self ._system_network_errors_labels ,
491
517
)
492
518
493
- def _get_system_network_io (self ) -> Iterable [Observation ]:
519
+ def _get_system_network_io (
520
+ self , options : CallbackOptions
521
+ ) -> Iterable [Observation ]:
494
522
"""Observer callback for network IO"""
495
523
496
524
for device , counters in psutil .net_io_counters (pernic = True ).items ():
@@ -504,7 +532,9 @@ def _get_system_network_io(self) -> Iterable[Observation]:
504
532
self ._system_network_io_labels ,
505
533
)
506
534
507
- def _get_system_network_connections (self ) -> Iterable [Observation ]:
535
+ def _get_system_network_connections (
536
+ self , options : CallbackOptions
537
+ ) -> Iterable [Observation ]:
508
538
"""Observer callback for network connections"""
509
539
# TODO How to find the device identifier for a particular
510
540
# connection?
@@ -542,7 +572,9 @@ def _get_system_network_connections(self) -> Iterable[Observation]:
542
572
connection_counter ["labels" ],
543
573
)
544
574
545
- def _get_runtime_memory (self ) -> Iterable [Observation ]:
575
+ def _get_runtime_memory (
576
+ self , options : CallbackOptions
577
+ ) -> Iterable [Observation ]:
546
578
"""Observer callback for runtime memory"""
547
579
proc_memory = self ._proc .memory_info ()
548
580
for metric in self ._config ["runtime.memory" ]:
@@ -553,7 +585,9 @@ def _get_runtime_memory(self) -> Iterable[Observation]:
553
585
self ._runtime_memory_labels ,
554
586
)
555
587
556
- def _get_runtime_cpu_time (self ) -> Iterable [Observation ]:
588
+ def _get_runtime_cpu_time (
589
+ self , options : CallbackOptions
590
+ ) -> Iterable [Observation ]:
557
591
"""Observer callback for runtime CPU time"""
558
592
proc_cpu = self ._proc .cpu_times ()
559
593
for metric in self ._config ["runtime.cpu.time" ]:
@@ -564,7 +598,9 @@ def _get_runtime_cpu_time(self) -> Iterable[Observation]:
564
598
self ._runtime_cpu_time_labels ,
565
599
)
566
600
567
- def _get_runtime_gc_count (self ) -> Iterable [Observation ]:
601
+ def _get_runtime_gc_count (
602
+ self , options : CallbackOptions
603
+ ) -> Iterable [Observation ]:
568
604
"""Observer callback for garbage collection"""
569
605
for index , count in enumerate (gc .get_count ()):
570
606
self ._runtime_gc_count_labels ["count" ] = str (index )
0 commit comments