From 6a7e1b12df0d23d0fe5d246bcbf1831c1c7c63de Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Sat, 11 Jun 2022 22:31:20 +0530 Subject: [PATCH 01/14] Add metric instrumentation for WSGI --- .../instrumentation/wsgi/__init__.py | 82 +++++++++++++++++-- .../tests/test_wsgi_middleware.py | 21 +++++ 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py index 4f64217893..cf99ec236a 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py @@ -158,6 +158,7 @@ def response_hook(span: Span, environ: WSGIEnvironment, status: str, response_he import functools import typing import wsgiref.util as wsgiref_util +from timeit import default_timer from opentelemetry import context, trace from opentelemetry.instrumentation.utils import ( @@ -165,6 +166,7 @@ def response_hook(span: Span, environ: WSGIEnvironment, status: str, response_he http_status_to_status_code, ) from opentelemetry.instrumentation.wsgi.version import __version__ +from opentelemetry.metrics import get_meter from opentelemetry.propagators.textmap import Getter from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace.status import Status, StatusCode @@ -181,6 +183,26 @@ def response_hook(span: Span, environ: WSGIEnvironment, status: str, response_he _CARRIER_KEY_PREFIX = "HTTP_" _CARRIER_KEY_PREFIX_LEN = len(_CARRIER_KEY_PREFIX) +# List of recommended attributes +_duration_attrs = [ + SpanAttributes.HTTP_METHOD, + SpanAttributes.HTTP_HOST, + SpanAttributes.HTTP_SCHEME, + SpanAttributes.HTTP_STATUS_CODE, + SpanAttributes.HTTP_FLAVOR, + SpanAttributes.HTTP_SERVER_NAME, + SpanAttributes.NET_HOST_NAME, + SpanAttributes.NET_HOST_PORT, +] + +_active_requests_count_attrs = [ + SpanAttributes.HTTP_METHOD, + SpanAttributes.HTTP_HOST, + SpanAttributes.HTTP_SCHEME, + SpanAttributes.HTTP_FLAVOR, + SpanAttributes.HTTP_SERVER_NAME, +] + class WSGIGetter(Getter[dict]): def get( @@ -304,6 +326,14 @@ def collect_custom_response_headers_attributes(response_headers): return attributes +def _parse_status_code(resp_status): + status_code, _ = resp_status.split(" ", 1) + try: + return int(status_code) + except ValueError: + return None + + def add_response_attributes( span, start_response_status, response_headers ): # pylint: disable=unused-argument @@ -352,18 +382,39 @@ class OpenTelemetryMiddleware: """ def __init__( - self, wsgi, request_hook=None, response_hook=None, tracer_provider=None + self, + wsgi, + request_hook=None, + response_hook=None, + tracer_provider=None, + meter_provider=None, ): self.wsgi = wsgi self.tracer = trace.get_tracer(__name__, __version__, tracer_provider) + self.meter = get_meter(__name__, __version__, meter_provider) + self.duration_recorder = self.meter.create_histogram( + "http.server.duration", + "ms", + "measures the duration of the inbound HTTP request", + ) + self.active_requests_counter = self.meter.create_up_down_counter( + "http.server.active_requests", + "1", + "measures the number of concurrent HTTP requests that are currently in-flight", + ) self.request_hook = request_hook self.response_hook = response_hook @staticmethod - def _create_start_response(span, start_response, response_hook): + def _create_start_response( + span, start_response, response_hook, duration_attrs + ): @functools.wraps(start_response) def _start_response(status, response_headers, *args, **kwargs): add_response_attributes(span, status, response_headers) + status_code = _parse_status_code(status) + if status_code is not None: + duration_attrs[SpanAttributes.HTTP_STATUS_CODE] = status_code if span.is_recording() and span.kind == trace.SpanKind.SERVER: custom_attributes = collect_custom_response_headers_attributes( response_headers @@ -383,13 +434,24 @@ def __call__(self, environ, start_response): environ: A WSGI environment. start_response: The WSGI start_response callable. """ + req_attrs = collect_request_attributes(environ) + active_requests_count_attrs = {} + for attr_key in _active_requests_count_attrs: + if req_attrs.get(attr_key) is not None: + active_requests_count_attrs[attr_key] = req_attrs[attr_key] + + duration_attrs = {} + for attr_key in _duration_attrs: + if req_attrs.get(attr_key) is not None: + duration_attrs[attr_key] = req_attrs[attr_key] + span, token = _start_internal_or_server_span( tracer=self.tracer, span_name=get_default_span_name(environ), start_time=None, context_carrier=environ, context_getter=wsgi_getter, - attributes=collect_request_attributes(environ), + attributes=req_attrs, ) if span.is_recording() and span.kind == trace.SpanKind.SERVER: custom_attributes = collect_custom_request_headers_attributes( @@ -405,15 +467,15 @@ def __call__(self, environ, start_response): if response_hook: response_hook = functools.partial(response_hook, span, environ) + start = default_timer() + self.active_requests_counter.add(1, active_requests_count_attrs) try: with trace.use_span(span): start_response = self._create_start_response( - span, start_response, response_hook + span, start_response, response_hook, duration_attrs ) iterable = self.wsgi(environ, start_response) - return _end_span_after_iterating( - iterable, span, self.tracer, token - ) + return _end_span_after_iterating(iterable, span, token) except Exception as ex: if span.is_recording(): span.set_status(Status(StatusCode.ERROR, str(ex))) @@ -421,12 +483,16 @@ def __call__(self, environ, start_response): if token is not None: context.detach(token) raise + finally: + duration = max(default_timer() - start, 0) + self.duration_recorder.record(duration, duration_attrs) + self.active_requests_counter.add(-1, active_requests_count_attrs) # Put this in a subfunction to not delay the call to the wrapped # WSGI application (instrumentation should change the application # behavior as little as possible). -def _end_span_after_iterating(iterable, span, tracer, token): +def _end_span_after_iterating(iterable, span, token): try: with trace.use_span(span): yield from iterable diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index 3238930792..dfa28fac66 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -147,6 +147,27 @@ def validate_response( expected_attributes[SpanAttributes.HTTP_METHOD] = http_method self.assertEqual(span_list[0].attributes, expected_attributes) + expected_names = [ + "http.server.active_requests", + "http.server.duration", + ] + recommended_attrs = { + "http.server.active_requests": otel_wsgi._active_requests_count_attrs, + "http.server.duration": otel_wsgi._duration_attrs, + } + + metrics_list = self.memory_metrics_reader.get_metrics_data() + self.assertTrue(len(metrics_list.resource_metrics) != 0) + for resource_metric in metrics_list.resource_metrics: + self.assertTrue(len(resource_metric.scope_metrics) != 0) + for scope_metric in resource_metric.scope_metrics: + self.assertTrue(len(scope_metric.metrics) != 0) + for metric in scope_metric.metrics: + self.assertIn(metric.name, expected_names) + for point in metric.data.data_points: + for attr in point.attributes: + self.assertIn(attr, recommended_attrs[metric.name]) + def test_basic_wsgi_call(self): app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi) response = app(self.environ, self.start_response) From 90c8e9d426e92c59ccc9aa89e91a3dc246bb728a Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Sun, 12 Jun 2022 22:18:30 +0530 Subject: [PATCH 02/14] Update core repo SHA --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 562b47bc52..17e94468a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: - 'release/*' pull_request: env: - CORE_REPO_SHA: cad776a2031c84fb3c3a1af90ee2a939f3394b9a + CORE_REPO_SHA: ee167c468c4c8f8d28223ba2ded560147c50e5ba jobs: build: @@ -42,7 +42,7 @@ jobs: path: | .tox ~/.cache/pip - key: v5-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }} + key: v6-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }} - name: run tox run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json # - name: Find and merge ${{ matrix.package }} benchmarks @@ -118,7 +118,7 @@ jobs: path: | .tox ~/.cache/pip - key: v5-misc-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt', 'gen-requirements.txt', 'docs-requirements.txt') }} + key: v6-misc-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt', 'gen-requirements.txt', 'docs-requirements.txt') }} - name: run tox run: tox -e ${{ matrix.tox-environment }} - name: Ensure generated code is up to date From 43e3f2bee8c8e46dc5f65cdb27c9c7e92481b9cc Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Sun, 12 Jun 2022 22:19:56 +0530 Subject: [PATCH 03/14] Add CHANGELOG entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ea55c217b..fb43d0e20d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1111](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1111)) - Set otlp-proto-grpc as the default metrics exporter for auto-instrumentation ([#1127](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1127)) +- Add metric instrumentation for WSGI + ([#1128](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1128)) ## [1.12.0rc1-0.31b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc1-0.31b0) - 2022-05-17 From 78ad9eb6bc12eeffbed2c89fafa5fe9484cc5270 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Sun, 12 Jun 2022 22:41:45 +0530 Subject: [PATCH 04/14] update tests --- .../tests/test_wsgi_middleware.py | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index dfa28fac66..014bc96c5c 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -20,6 +20,7 @@ import opentelemetry.instrumentation.wsgi as otel_wsgi from opentelemetry import trace as trace_api +from opentelemetry.sdk.metrics.export import HistogramDataPoint from opentelemetry.sdk.resources import Resource from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.test.test_base import TestBase @@ -99,6 +100,16 @@ def wsgi_with_custom_response_headers(environ, start_response): return [b"*"] +_expected_metric_names = [ + "http.server.active_requests", + "http.server.duration", +] +_recommended_attrs = { + "http.server.active_requests": otel_wsgi._active_requests_count_attrs, + "http.server.duration": otel_wsgi._duration_attrs, +} + + class TestWsgiApplication(WsgiTestBase): def validate_response( self, @@ -147,27 +158,6 @@ def validate_response( expected_attributes[SpanAttributes.HTTP_METHOD] = http_method self.assertEqual(span_list[0].attributes, expected_attributes) - expected_names = [ - "http.server.active_requests", - "http.server.duration", - ] - recommended_attrs = { - "http.server.active_requests": otel_wsgi._active_requests_count_attrs, - "http.server.duration": otel_wsgi._duration_attrs, - } - - metrics_list = self.memory_metrics_reader.get_metrics_data() - self.assertTrue(len(metrics_list.resource_metrics) != 0) - for resource_metric in metrics_list.resource_metrics: - self.assertTrue(len(resource_metric.scope_metrics) != 0) - for scope_metric in resource_metric.scope_metrics: - self.assertTrue(len(scope_metric.metrics) != 0) - for metric in scope_metric.metrics: - self.assertIn(metric.name, expected_names) - for point in metric.data.data_points: - for attr in point.attributes: - self.assertIn(attr, recommended_attrs[metric.name]) - def test_basic_wsgi_call(self): app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi) response = app(self.environ, self.start_response) @@ -251,6 +241,30 @@ def test_wsgi_internal_error(self): StatusCode.ERROR, ) + def test_wsgi_metrics(self): + app = otel_wsgi.OpenTelemetryMiddleware(error_wsgi_unhandled) + self.assertRaises(ValueError, app, self.environ, self.start_response) + self.assertRaises(ValueError, app, self.environ, self.start_response) + self.assertRaises(ValueError, app, self.environ, self.start_response) + metrics_list = self.memory_metrics_reader.get_metrics_data() + + self.assertTrue(len(metrics_list.resource_metrics) != 0) + for resource_metric in metrics_list.resource_metrics: + self.assertTrue(len(resource_metric.scope_metrics) != 0) + for scope_metric in resource_metric.scope_metrics: + self.assertTrue(len(scope_metric.metrics) != 0) + for metric in scope_metric.metrics: + self.assertIn(metric.name, _expected_metric_names) + data_points = list(metric.data.data_points) + self.assertEqual(len(data_points), 1) + for point in data_points: + if isinstance(point, HistogramDataPoint): + self.assertEqual(point.count, 3) + for attr in point.attributes: + self.assertIn( + attr, _recommended_attrs[metric.name] + ) + def test_default_span_name_missing_request_method(self): """Test that default span_names with missing request method.""" self.environ.pop("REQUEST_METHOD") From 3d70431807055a872bf4a6222ce7de663ba263af Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Tue, 14 Jun 2022 07:35:59 +0530 Subject: [PATCH 05/14] Update Core repo SHA --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17e94468a2..41206fe3eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: - 'release/*' pull_request: env: - CORE_REPO_SHA: ee167c468c4c8f8d28223ba2ded560147c50e5ba + CORE_REPO_SHA: a598338c4c95c5a6b96609695e8f86a515a9970c jobs: build: From 1ad67c0b92200693c885bf884fedd0664395d096 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Sat, 18 Jun 2022 00:53:33 +0530 Subject: [PATCH 06/14] Address review comments --- .../instrumentation/wsgi/__init__.py | 18 +++++++++--------- .../tests/test_wsgi_middleware.py | 11 ++++++++++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py index cf99ec236a..17ca131a5f 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py @@ -392,15 +392,15 @@ def __init__( self.wsgi = wsgi self.tracer = trace.get_tracer(__name__, __version__, tracer_provider) self.meter = get_meter(__name__, __version__, meter_provider) - self.duration_recorder = self.meter.create_histogram( - "http.server.duration", - "ms", - "measures the duration of the inbound HTTP request", + self.duration_histogram = self.meter.create_histogram( + name="http.server.duration", + unit="ms", + description="measures the duration of the inbound HTTP request", ) self.active_requests_counter = self.meter.create_up_down_counter( - "http.server.active_requests", - "1", - "measures the number of concurrent HTTP requests that are currently in-flight", + name="http.server.active_requests", + unit="requests", + description="measures the number of concurrent HTTP requests that are currently in-flight", ) self.request_hook = request_hook self.response_hook = response_hook @@ -484,8 +484,8 @@ def __call__(self, environ, start_response): context.detach(token) raise finally: - duration = max(default_timer() - start, 0) - self.duration_recorder.record(duration, duration_attrs) + duration = max(round((default_timer() - start) * 1000), 0) + self.duration_histogram.record(duration, duration_attrs) self.active_requests_counter.add(-1, active_requests_count_attrs) diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index 014bc96c5c..1cf4a2f2ee 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -20,7 +20,10 @@ import opentelemetry.instrumentation.wsgi as otel_wsgi from opentelemetry import trace as trace_api -from opentelemetry.sdk.metrics.export import HistogramDataPoint +from opentelemetry.sdk.metrics.export import ( + HistogramDataPoint, + NumberDataPoint, +) from opentelemetry.sdk.resources import Resource from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.test.test_base import TestBase @@ -247,6 +250,8 @@ def test_wsgi_metrics(self): self.assertRaises(ValueError, app, self.environ, self.start_response) self.assertRaises(ValueError, app, self.environ, self.start_response) metrics_list = self.memory_metrics_reader.get_metrics_data() + number_data_point_seen = False + histogram_data_point_seen = False self.assertTrue(len(metrics_list.resource_metrics) != 0) for resource_metric in metrics_list.resource_metrics: @@ -260,10 +265,14 @@ def test_wsgi_metrics(self): for point in data_points: if isinstance(point, HistogramDataPoint): self.assertEqual(point.count, 3) + histogram_data_point_seen = True + if isinstance(point, NumberDataPoint): + number_data_point_seen = True for attr in point.attributes: self.assertIn( attr, _recommended_attrs[metric.name] ) + self.assertTrue(number_data_point_seen and histogram_data_point_seen) def test_default_span_name_missing_request_method(self): """Test that default span_names with missing request method.""" From 1e2b697211990d2a26776a13988c47838b7bd568 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Sat, 18 Jun 2022 01:15:57 +0530 Subject: [PATCH 07/14] Update core repo SHA --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41206fe3eb..e1ee67d9eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: - 'release/*' pull_request: env: - CORE_REPO_SHA: a598338c4c95c5a6b96609695e8f86a515a9970c + CORE_REPO_SHA: d4d7c67663cc22615748d632e1c8c5799e8eacae jobs: build: From 6c4a9c9be4c7c6e5e0ef8abbb364e3bd01aecc54 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Tue, 21 Jun 2022 22:40:19 +0530 Subject: [PATCH 08/14] Fix tests --- .../tests/test_middleware.py | 7 +++---- .../tests/test_automatic.py | 3 +-- .../tests/test_programmatic.py | 21 +++++++------------ .../tests/test_automatic.py | 15 ++++--------- .../tests/test_programmatic.py | 3 +-- .../tests/test_wsgi_middleware.py | 2 +- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py index 855cf3e389..a0d4e793c6 100644 --- a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py @@ -35,7 +35,6 @@ from opentelemetry.sdk.trace import Span from opentelemetry.sdk.trace.id_generator import RandomIdGenerator from opentelemetry.semconv.trace import SpanAttributes -from opentelemetry.test.test_base import TestBase from opentelemetry.test.wsgitestutil import WsgiTestBase from opentelemetry.trace import ( SpanKind, @@ -84,7 +83,7 @@ _django_instrumentor = DjangoInstrumentor() -class TestMiddleware(TestBase, WsgiTestBase): +class TestMiddleware(WsgiTestBase): @classmethod def setUpClass(cls): conf.settings.configure(ROOT_URLCONF=modules[__name__]) @@ -402,7 +401,7 @@ def test_trace_response_headers(self): self.memory_exporter.clear() -class TestMiddlewareWithTracerProvider(TestBase, WsgiTestBase): +class TestMiddlewareWithTracerProvider(WsgiTestBase): @classmethod def setUpClass(cls): conf.settings.configure(ROOT_URLCONF=modules[__name__]) @@ -460,7 +459,7 @@ def test_django_with_wsgi_instrumented(self): ) -class TestMiddlewareWsgiWithCustomHeaders(TestBase, WsgiTestBase): +class TestMiddlewareWsgiWithCustomHeaders(WsgiTestBase): @classmethod def setUpClass(cls): conf.settings.configure(ROOT_URLCONF=modules[__name__]) diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py index 4a64c0a9e0..b4ed9eb0bc 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py @@ -17,14 +17,13 @@ from werkzeug.wrappers import Response from opentelemetry.instrumentation.flask import FlaskInstrumentor -from opentelemetry.test.test_base import TestBase from opentelemetry.test.wsgitestutil import WsgiTestBase # pylint: disable=import-error from .base_test import InstrumentationTest -class TestAutomatic(InstrumentationTest, TestBase, WsgiTestBase): +class TestAutomatic(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py index 6329bf1d30..2bcb097c7b 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py @@ -26,7 +26,6 @@ from opentelemetry.instrumentation.wsgi import OpenTelemetryMiddleware from opentelemetry.sdk.resources import Resource from opentelemetry.semconv.trace import SpanAttributes -from opentelemetry.test.test_base import TestBase from opentelemetry.test.wsgitestutil import WsgiTestBase from opentelemetry.util.http import get_excluded_urls @@ -50,7 +49,7 @@ def expected_attributes(override_attributes): return default_attributes -class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase): +class TestProgrammatic(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() @@ -252,7 +251,7 @@ def test_exclude_lists_from_explicit(self): self.assertEqual(len(span_list), 1) -class TestProgrammaticHooks(InstrumentationTest, TestBase, WsgiTestBase): +class TestProgrammaticHooks(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() @@ -300,9 +299,7 @@ def test_hooks(self): self.assertEqual(resp.headers["hook_attr"], "hello otel") -class TestProgrammaticHooksWithoutApp( - InstrumentationTest, TestBase, WsgiTestBase -): +class TestProgrammaticHooksWithoutApp(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() @@ -350,9 +347,7 @@ def test_no_app_hooks(self): self.assertEqual(resp.headers["hook_attr"], "hello otel without app") -class TestProgrammaticCustomTracerProvider( - InstrumentationTest, TestBase, WsgiTestBase -): +class TestProgrammaticCustomTracerProvider(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() resource = Resource.create({"service.name": "flask-api"}) @@ -383,7 +378,7 @@ def test_custom_span_name(self): class TestProgrammaticCustomTracerProviderWithoutApp( - InstrumentationTest, TestBase, WsgiTestBase + InstrumentationTest, WsgiTestBase ): def setUp(self): super().setUp() @@ -417,7 +412,7 @@ def test_custom_span_name(self): class TestProgrammaticWrappedWithOtherFramework( - InstrumentationTest, TestBase, WsgiTestBase + InstrumentationTest, WsgiTestBase ): def setUp(self): super().setUp() @@ -444,9 +439,7 @@ def test_mark_span_internal_in_presence_of_span_from_other_framework(self): ) -class TestCustomRequestResponseHeaders( - InstrumentationTest, TestBase, WsgiTestBase -): +class TestCustomRequestResponseHeaders(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py index b9edd44d72..89df49e49e 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py @@ -19,7 +19,6 @@ from opentelemetry import trace from opentelemetry.instrumentation.pyramid import PyramidInstrumentor from opentelemetry.test.globals_test import reset_trace_globals -from opentelemetry.test.test_base import TestBase from opentelemetry.test.wsgitestutil import WsgiTestBase from opentelemetry.trace import SpanKind from opentelemetry.trace.status import StatusCode @@ -32,7 +31,7 @@ from .pyramid_base_test import InstrumentationTest -class TestAutomatic(InstrumentationTest, TestBase, WsgiTestBase): +class TestAutomatic(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() @@ -158,9 +157,7 @@ def test_400s_response_is_not_an_error(self): self.assertEqual(len(span_list), 1) -class TestWrappedWithOtherFramework( - InstrumentationTest, TestBase, WsgiTestBase -): +class TestWrappedWithOtherFramework(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() PyramidInstrumentor().instrument() @@ -189,9 +186,7 @@ def test_with_existing_span(self): ) -class TestCustomRequestResponseHeaders( - InstrumentationTest, TestBase, WsgiTestBase -): +class TestCustomRequestResponseHeaders(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() PyramidInstrumentor().instrument() @@ -296,9 +291,7 @@ def test_custom_response_header_not_added_in_internal_span(self): self.assertNotIn(key, span.attributes) -class TestCustomHeadersNonRecordingSpan( - InstrumentationTest, TestBase, WsgiTestBase -): +class TestCustomHeadersNonRecordingSpan(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() # This is done because set_tracer_provider cannot override the diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py index 414e6ff28e..d3a4fa91db 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py @@ -24,7 +24,6 @@ ) from opentelemetry.instrumentation.pyramid import PyramidInstrumentor from opentelemetry.semconv.trace import SpanAttributes -from opentelemetry.test.test_base import TestBase from opentelemetry.test.wsgitestutil import WsgiTestBase from opentelemetry.util.http import get_excluded_urls @@ -48,7 +47,7 @@ def expected_attributes(override_attributes): return default_attributes -class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase): +class TestProgrammatic(InstrumentationTest, WsgiTestBase): def setUp(self): super().setUp() config = Configurator() diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index 1cf4a2f2ee..7bdfabc37f 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -505,7 +505,7 @@ def test_mark_span_internal_in_presence_of_span_from_other_framework(self): ) -class TestAdditionOfCustomRequestResponseHeaders(WsgiTestBase, TestBase): +class TestAdditionOfCustomRequestResponseHeaders(WsgiTestBase): def setUp(self): super().setUp() tracer_provider, _ = TestBase.create_tracer_provider() From 43e77532047d604aec7f22340d482a341c3efd0f Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Tue, 21 Jun 2022 22:47:55 +0530 Subject: [PATCH 09/14] Add metrics status --- instrumentation/README.md | 84 +++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/instrumentation/README.md b/instrumentation/README.md index ffb2c8bad7..17af15a41c 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -1,43 +1,43 @@ -| Instrumentation | Supported Packages | -| --------------- | ------------------ | -| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | -| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | -| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | -| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | -| [opentelemetry-instrumentation-aws-lambda](./opentelemetry-instrumentation-aws-lambda) | aws_lambda | -| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 | -| [opentelemetry-instrumentation-boto3sqs](./opentelemetry-instrumentation-boto3sqs) | boto3 ~= 1.0 | -| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 | -| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | -| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka ~= 1.8.2 | -| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | -| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | -| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | -| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | -| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | -| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | -| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | -| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | -| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | -| [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 | -| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | -| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | -| [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | -| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | -| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 4 | -| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 | -| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 | -| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | -| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 | -| [opentelemetry-instrumentation-remoulade](./opentelemetry-instrumentation-remoulade) | remoulade >= 0.50 | -| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 | -| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 | -| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy | -| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 | -| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 | -| [opentelemetry-instrumentation-system-metrics](./opentelemetry-instrumentation-system-metrics) | psutil >= 5 | -| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | -| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | -| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | -| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | \ No newline at end of file +| Instrumentation | Supported Packages | Metrics support | +| --------------- | ------------------ | --------------- | +| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | [ ] +| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | [ ] +| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | [ ] +| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | [ ] +| [opentelemetry-instrumentation-aws-lambda](./opentelemetry-instrumentation-aws-lambda) | aws_lambda | [ ] +| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 | [ ] +| [opentelemetry-instrumentation-boto3sqs](./opentelemetry-instrumentation-boto3sqs) | boto3 ~= 1.0 | [ ] +| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 | [ ] +| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | [ ] +| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka ~= 1.8.2 | [ ] +| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | [ ] +| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | [ ] +| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | [ ] +| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | [ ] +| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | [ ] +| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | [ ] +| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | [ ] +| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | [ ] +| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | [ ] +| [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 | [ ] +| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | [ ] +| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | [ ] +| [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | [ ] +| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | [ ] +| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 4 | [ ] +| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 | [ ] +| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 | [ ] +| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | [ ] +| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 | [ ] +| [opentelemetry-instrumentation-remoulade](./opentelemetry-instrumentation-remoulade) | remoulade >= 0.50 | [ ] +| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 | [ ] +| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 | [ ] +| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy | [ ] +| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 | [ ] +| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 | [ ] +| [opentelemetry-instrumentation-system-metrics](./opentelemetry-instrumentation-system-metrics) | psutil >= 5 | [ ] +| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | [ ] +| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | [ ] +| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | [ ] +| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | [x] \ No newline at end of file From 8b4dbdd3cbb640459e1768bb633cba4e700963fc Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Tue, 21 Jun 2022 22:58:10 +0530 Subject: [PATCH 10/14] Auto generate --- instrumentation/README.md | 1 + .../src/opentelemetry/instrumentation/wsgi/package.py | 2 ++ scripts/generate_instrumentation_readme.py | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/instrumentation/README.md b/instrumentation/README.md index 17af15a41c..4052815eab 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -1,6 +1,7 @@ | Instrumentation | Supported Packages | Metrics support | | --------------- | ------------------ | --------------- | + | [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | [ ] | [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | [ ] | [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | [ ] diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py index 7a66a17a93..942f175da1 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py @@ -14,3 +14,5 @@ _instruments = tuple() + +_supports_metrics = True diff --git a/scripts/generate_instrumentation_readme.py b/scripts/generate_instrumentation_readme.py index dbaa42367c..ff4772a49a 100755 --- a/scripts/generate_instrumentation_readme.py +++ b/scripts/generate_instrumentation_readme.py @@ -23,8 +23,9 @@ _prefix = "opentelemetry-instrumentation-" header = """ -| Instrumentation | Supported Packages | -| --------------- | ------------------ |""" +| Instrumentation | Supported Packages | Metrics support | +| --------------- | ------------------ | --------------- | +""" def main(): @@ -62,11 +63,14 @@ def main(): exec(fh.read(), pkg_info) instruments = pkg_info["_instruments"] + supports_metrics = pkg_info.get("_supports_metrics") if not instruments: instruments = (name,) + metric_colum = "[x]" if supports_metrics else "[ ]" + table.append( - f"| [{instrumentation}](./{instrumentation}) | {','.join(instruments)} |" + f"| [{instrumentation}](./{instrumentation}) | {','.join(instruments)} | {metric_colum}" ) with open( From 7c2d08592c493b4e54d4377246c2913a0b2647a1 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Tue, 21 Jun 2022 23:13:21 +0530 Subject: [PATCH 11/14] fix lint --- .../src/opentelemetry/instrumentation/wsgi/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py index 17ca131a5f..11c5acf643 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py @@ -427,6 +427,7 @@ def _start_response(status, response_headers, *args, **kwargs): return _start_response + # pylint: disable=too-many-branches def __call__(self, environ, start_response): """The WSGI application From bb75d362624b0fd0387422e2ee0ed65d00fd146d Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Wed, 22 Jun 2022 02:56:16 +0530 Subject: [PATCH 12/14] Fix readme --- instrumentation/README.md | 80 +++++++++++----------- scripts/generate_instrumentation_readme.py | 4 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/instrumentation/README.md b/instrumentation/README.md index 4052815eab..2e13ffa425 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -2,43 +2,43 @@ | Instrumentation | Supported Packages | Metrics support | | --------------- | ------------------ | --------------- | -| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | [ ] -| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | [ ] -| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | [ ] -| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | [ ] -| [opentelemetry-instrumentation-aws-lambda](./opentelemetry-instrumentation-aws-lambda) | aws_lambda | [ ] -| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 | [ ] -| [opentelemetry-instrumentation-boto3sqs](./opentelemetry-instrumentation-boto3sqs) | boto3 ~= 1.0 | [ ] -| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 | [ ] -| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | [ ] -| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka ~= 1.8.2 | [ ] -| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | [ ] -| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | [ ] -| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | [ ] -| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | [ ] -| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | [ ] -| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | [ ] -| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | [ ] -| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | [ ] -| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | [ ] -| [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 | [ ] -| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | [ ] -| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | [ ] -| [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | [ ] -| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | [ ] -| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 4 | [ ] -| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 | [ ] -| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 | [ ] -| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | [ ] -| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 | [ ] -| [opentelemetry-instrumentation-remoulade](./opentelemetry-instrumentation-remoulade) | remoulade >= 0.50 | [ ] -| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 | [ ] -| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 | [ ] -| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy | [ ] -| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 | [ ] -| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 | [ ] -| [opentelemetry-instrumentation-system-metrics](./opentelemetry-instrumentation-system-metrics) | psutil >= 5 | [ ] -| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | [ ] -| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | [ ] -| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | [ ] -| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | [x] \ No newline at end of file +| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | No | +| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | No | +| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | No | +| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | No | +| [opentelemetry-instrumentation-aws-lambda](./opentelemetry-instrumentation-aws-lambda) | aws_lambda | No | +| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 | No | +| [opentelemetry-instrumentation-boto3sqs](./opentelemetry-instrumentation-boto3sqs) | boto3 ~= 1.0 | No | +| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 | No | +| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | No | +| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka ~= 1.8.2 | No | +| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | No | +| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | No | +| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | No | +| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | No | +| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | No | +| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | No | +| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | No | +| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | No | +| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | No | +| [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 | No | +| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | No | +| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | No | +| [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | No | +| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | No | +| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 4 | No | +| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 | No | +| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 | No | +| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | No | +| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 | No | +| [opentelemetry-instrumentation-remoulade](./opentelemetry-instrumentation-remoulade) | remoulade >= 0.50 | No | +| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 | No | +| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 | No | +| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy | No | +| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 | No | +| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 | No | +| [opentelemetry-instrumentation-system-metrics](./opentelemetry-instrumentation-system-metrics) | psutil >= 5 | No | +| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | No | +| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | No | +| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | No | +| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | Yes | \ No newline at end of file diff --git a/scripts/generate_instrumentation_readme.py b/scripts/generate_instrumentation_readme.py index ff4772a49a..625e4d0c7e 100755 --- a/scripts/generate_instrumentation_readme.py +++ b/scripts/generate_instrumentation_readme.py @@ -67,10 +67,10 @@ def main(): if not instruments: instruments = (name,) - metric_colum = "[x]" if supports_metrics else "[ ]" + metric_column = "Yes" if supports_metrics else "No" table.append( - f"| [{instrumentation}](./{instrumentation}) | {','.join(instruments)} | {metric_colum}" + f"| [{instrumentation}](./{instrumentation}) | {','.join(instruments)} | {metric_column} |" ) with open( From 2250b7b8505e6217cd9c21d95362897665e52c12 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Wed, 22 Jun 2022 03:08:06 +0530 Subject: [PATCH 13/14] fix readme again --- instrumentation/README.md | 80 +++++++++++----------- scripts/generate_instrumentation_readme.py | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/instrumentation/README.md b/instrumentation/README.md index 2e13ffa425..a86e60d847 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -2,43 +2,43 @@ | Instrumentation | Supported Packages | Metrics support | | --------------- | ------------------ | --------------- | -| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | No | -| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | No | -| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | No | -| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | No | -| [opentelemetry-instrumentation-aws-lambda](./opentelemetry-instrumentation-aws-lambda) | aws_lambda | No | -| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 | No | -| [opentelemetry-instrumentation-boto3sqs](./opentelemetry-instrumentation-boto3sqs) | boto3 ~= 1.0 | No | -| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 | No | -| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | No | -| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka ~= 1.8.2 | No | -| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | No | -| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | No | -| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | No | -| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | No | -| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | No | -| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | No | -| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | No | -| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | No | -| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | No | -| [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 | No | -| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | No | -| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | No | -| [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | No | -| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | No | -| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 4 | No | -| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 | No | -| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 | No | -| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | No | -| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 | No | -| [opentelemetry-instrumentation-remoulade](./opentelemetry-instrumentation-remoulade) | remoulade >= 0.50 | No | -| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 | No | -| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 | No | -| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy | No | -| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 | No | -| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 | No | -| [opentelemetry-instrumentation-system-metrics](./opentelemetry-instrumentation-system-metrics) | psutil >= 5 | No | -| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | No | -| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | No | -| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | No | -| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | Yes | \ No newline at end of file +| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | No +| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | No +| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | No +| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | No +| [opentelemetry-instrumentation-aws-lambda](./opentelemetry-instrumentation-aws-lambda) | aws_lambda | No +| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 | No +| [opentelemetry-instrumentation-boto3sqs](./opentelemetry-instrumentation-boto3sqs) | boto3 ~= 1.0 | No +| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 | No +| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | No +| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka ~= 1.8.2 | No +| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | No +| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | No +| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | No +| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | No +| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | No +| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | No +| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | No +| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | No +| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | No +| [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 | No +| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | No +| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | No +| [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | No +| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | No +| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 4 | No +| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 | No +| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 | No +| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | No +| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 | No +| [opentelemetry-instrumentation-remoulade](./opentelemetry-instrumentation-remoulade) | remoulade >= 0.50 | No +| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 | No +| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 | No +| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy | No +| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 | No +| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 | No +| [opentelemetry-instrumentation-system-metrics](./opentelemetry-instrumentation-system-metrics) | psutil >= 5 | No +| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | No +| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | No +| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | No +| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | Yes \ No newline at end of file diff --git a/scripts/generate_instrumentation_readme.py b/scripts/generate_instrumentation_readme.py index 625e4d0c7e..b954ff11db 100755 --- a/scripts/generate_instrumentation_readme.py +++ b/scripts/generate_instrumentation_readme.py @@ -70,7 +70,7 @@ def main(): metric_column = "Yes" if supports_metrics else "No" table.append( - f"| [{instrumentation}](./{instrumentation}) | {','.join(instruments)} | {metric_column} |" + f"| [{instrumentation}](./{instrumentation}) | {','.join(instruments)} | {metric_column}" ) with open( From f7919f094a7a090d97de6c56a5aec76340374f39 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Wed, 22 Jun 2022 03:22:38 +0530 Subject: [PATCH 14/14] actually fix readme --- instrumentation/README.md | 1 - scripts/generate_instrumentation_readme.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/instrumentation/README.md b/instrumentation/README.md index a86e60d847..030dca937d 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -1,7 +1,6 @@ | Instrumentation | Supported Packages | Metrics support | | --------------- | ------------------ | --------------- | - | [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | No | [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | No | [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | No diff --git a/scripts/generate_instrumentation_readme.py b/scripts/generate_instrumentation_readme.py index b954ff11db..00045cd73c 100755 --- a/scripts/generate_instrumentation_readme.py +++ b/scripts/generate_instrumentation_readme.py @@ -24,8 +24,7 @@ header = """ | Instrumentation | Supported Packages | Metrics support | -| --------------- | ------------------ | --------------- | -""" +| --------------- | ------------------ | --------------- |""" def main():