Skip to content

Commit

Permalink
update name to SystemMetricsInstrumentor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten committed Apr 4, 2022
1 parent 0b59ab8 commit f105899
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ test =

[options.packages.find]
where = src

[options.entry_points]
opentelemetry_instrumentor =
system_metrics = opentelemetry.instrumentation.system_metrics:SystemMetricsInstrumentor
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
.. code:: python
from opentelemetry._metrics import set_meter_provider
from opentelemetry.instrumentation.system_metrics import SystemMetrics
from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
from opentelemetry.sdk._metrics import MeterProvider
from opentelemetry.sdk._metrics.export import ConsoleMetricExporter, PeriodicExportingMetricReader
exporter = ConsoleMetricExporter()
set_meter_provider(MeterProvider(PeriodicExportingMetricReader(exporter)))
SystemMetrics()
SystemMetricsInstrumentor().instrument()
# metrics are collected asynchronously
input("...")
Expand All @@ -63,7 +63,7 @@
"runtime.memory": ["rss", "vms"],
"runtime.cpu.time": ["user", "system"],
}
SystemMetrics(config=configuration)
SystemMetricsInstrumentor(config=configuration).instrument()
API
---
Expand All @@ -86,7 +86,7 @@
from opentelemetry.sdk.util import get_dict_as_key


class SystemMetrics(BaseInstrumentor):
class SystemMetricsInstrumentor(BaseInstrumentor):
# pylint: disable=too-many-statements
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from opentelemetry._metrics import get_meter_provider
from opentelemetry._metrics.measurement import Measurement
from opentelemetry.instrumentation.system_metrics import SystemMetrics
from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
from opentelemetry.sdk._metrics import MeterProvider
from opentelemetry.sdk._metrics.export import InMemoryMetricReader
from opentelemetry.test.test_base import TestBase
Expand Down Expand Up @@ -59,12 +59,12 @@ def setUp(self):
def tearDown(self):
super().tearDown()
self._patch_net_connections.stop()
SystemMetrics().uninstrument()
SystemMetricsInstrumentor().uninstrument()

def test_system_metrics_instrument(self):
reader = InMemoryMetricReader()
meter_provider = MeterProvider(metric_readers=[reader])
system_metrics = SystemMetrics()
system_metrics = SystemMetricsInstrumentor()
system_metrics.instrument(meter_provider=meter_provider)
metrics = reader.get_metrics()
metric_names = list({x.name for x in metrics })
Expand Down Expand Up @@ -117,7 +117,7 @@ def _test_metrics(self, observer_name, expected):
reader = InMemoryMetricReader()
meter_provider = MeterProvider(metric_readers=[reader])

system_metrics = SystemMetrics()
system_metrics = SystemMetricsInstrumentor()
system_metrics.instrument(meter_provider=meter_provider)
self._assert_metrics(observer_name, reader, expected)
system_metrics.uninstrument()
Expand Down

0 comments on commit f105899

Please sign in to comment.