From f105899027924f42c1fe6989caa4f8e490090fce Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Mon, 4 Apr 2022 11:07:13 -0700 Subject: [PATCH] update name to SystemMetricsInstrumentor --- .../setup.cfg | 4 ++++ .../instrumentation/system_metrics/__init__.py | 8 ++++---- .../tests/test_system_metrics.py | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/setup.cfg b/instrumentation/opentelemetry-instrumentation-system-metrics/setup.cfg index 918a62c293..e54d7338a0 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/setup.cfg @@ -50,3 +50,7 @@ test = [options.packages.find] where = src + +[options.entry_points] +opentelemetry_instrumentor = + system_metrics = opentelemetry.instrumentation.system_metrics:SystemMetricsInstrumentor diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py index d41ed6dcce..dd30e6227c 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py @@ -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("...") @@ -63,7 +63,7 @@ "runtime.memory": ["rss", "vms"], "runtime.cpu.time": ["user", "system"], } - SystemMetrics(config=configuration) + SystemMetricsInstrumentor(config=configuration).instrument() API --- @@ -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, diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py index 9b37bfeddb..60a96045bc 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py @@ -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 @@ -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 }) @@ -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()