From 78c19dcd764983be83d07faeca21abf3d2061a52 Mon Sep 17 00:00:00 2001 From: Vivek Khatri Date: Tue, 9 Jul 2024 22:23:29 +0530 Subject: [PATCH 01/15] Fix #3695: add attributes to get_meter fn and InstrumentationScope (#4015) --- CHANGELOG.md | 2 + .../metrics/_internal/__init__.py | 5 ++ .../sdk/metrics/_internal/__init__.py | 4 +- .../opentelemetry/sdk/util/instrumentation.py | 32 ++++++++-- .../tests/metrics/test_metrics.py | 64 +++++++++++++++++++ opentelemetry-sdk/tests/metrics/test_point.py | 4 +- 6 files changed, 104 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2bc58afe6..34f49c95b44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3965](https://github.com/open-telemetry/opentelemetry-python/pull/3965)) - Validate links at span creation ([#3991](https://github.com/open-telemetry/opentelemetry-python/pull/3991)) +- Add attributes field in `MeterProvider.get_meter` and `InstrumentationScope` + ([#4015](https://github.com/open-telemetry/opentelemetry-python/pull/4015)) ## Version 1.25.0/0.46b0 (2024-05-30) diff --git a/opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py b/opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py index 9cbf14d2edc..972ff2707c6 100644 --- a/opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py +++ b/opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py @@ -75,6 +75,7 @@ ) from opentelemetry.util._once import Once from opentelemetry.util._providers import _load_provider +from opentelemetry.util.types import Attributes _logger = getLogger(__name__) @@ -102,6 +103,7 @@ def get_meter( name: str, version: Optional[str] = None, schema_url: Optional[str] = None, + attributes: Optional[Attributes] = None, ) -> "Meter": """Returns a `Meter` for use by the given instrumentation library. @@ -128,6 +130,7 @@ def get_meter( ``importlib.metadata.version(instrumenting_library_name)``. schema_url: Optional. Specifies the Schema URL of the emitted telemetry. + attributes: Optional. Attributes that are associated with the emitted telemetry. """ @@ -139,6 +142,7 @@ def get_meter( name: str, version: Optional[str] = None, schema_url: Optional[str] = None, + attributes: Optional[Attributes] = None, ) -> "Meter": """Returns a NoOpMeter.""" return NoOpMeter(name, version=version, schema_url=schema_url) @@ -155,6 +159,7 @@ def get_meter( name: str, version: Optional[str] = None, schema_url: Optional[str] = None, + attributes: Optional[Attributes] = None, ) -> "Meter": with self._lock: if self._real_meter_provider is not None: diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py index 1e3a4528e37..9dc95c0edb8 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py @@ -54,6 +54,7 @@ from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.util.instrumentation import InstrumentationScope from opentelemetry.util._once import Once +from opentelemetry.util.types import Attributes _logger = getLogger(__name__) @@ -518,6 +519,7 @@ def get_meter( name: str, version: Optional[str] = None, schema_url: Optional[str] = None, + attributes: Optional[Attributes] = None, ) -> Meter: if self._disabled: @@ -534,7 +536,7 @@ def get_meter( _logger.warning("Meter name cannot be None or empty.") return NoOpMeter(name, version=version, schema_url=schema_url) - info = InstrumentationScope(name, version, schema_url) + info = InstrumentationScope(name, version, schema_url, attributes) with self._meter_lock: if not self._meters.get(info): # FIXME #2558 pass SDKConfig object to meter so that the meter diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py b/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py index 085d3fd874f..a6fd7d7f66b 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py @@ -16,6 +16,9 @@ from deprecated import deprecated +from opentelemetry.attributes import BoundedAttributes +from opentelemetry.util.types import Attributes + class InstrumentationInfo: """Immutable information about an instrumentation library module. @@ -82,22 +85,24 @@ class InstrumentationScope: properties. """ - __slots__ = ("_name", "_version", "_schema_url") + __slots__ = ("_name", "_version", "_schema_url", "_attributes") def __init__( self, name: str, version: Optional[str] = None, schema_url: Optional[str] = None, + attributes: Optional[Attributes] = None, ) -> None: self._name = name self._version = version if schema_url is None: schema_url = "" self._schema_url = schema_url + self._attributes = BoundedAttributes(attributes=attributes) def __repr__(self) -> str: - return f"{type(self).__name__}({self._name}, {self._version}, {self._schema_url})" + return f"{type(self).__name__}({self._name}, {self._version}, {self._schema_url}, {self._attributes})" def __hash__(self) -> int: return hash((self._name, self._version, self._schema_url)) @@ -105,19 +110,31 @@ def __hash__(self) -> int: def __eq__(self, value: object) -> bool: if not isinstance(value, InstrumentationScope): return NotImplemented - return (self._name, self._version, self._schema_url) == ( + return ( + self._name, + self._version, + self._schema_url, + self._attributes, + ) == ( value._name, value._version, value._schema_url, + value._attributes, ) def __lt__(self, value: object) -> bool: if not isinstance(value, InstrumentationScope): return NotImplemented - return (self._name, self._version, self._schema_url) < ( + return ( + self._name, + self._version, + self._schema_url, + self._attributes, + ) < ( value._name, value._version, value._schema_url, + value._attributes, ) @property @@ -132,12 +149,19 @@ def version(self) -> Optional[str]: def name(self) -> str: return self._name + @property + def attributes(self) -> Attributes: + return self._attributes + def to_json(self, indent=4) -> str: return dumps( { "name": self._name, "version": self._version, "schema_url": self._schema_url, + "attributes": ( + dict(self._attributes) if bool(self._attributes) else None + ), }, indent=indent, ) diff --git a/opentelemetry-sdk/tests/metrics/test_metrics.py b/opentelemetry-sdk/tests/metrics/test_metrics.py index 199305005b3..d55262274b6 100644 --- a/opentelemetry-sdk/tests/metrics/test_metrics.py +++ b/opentelemetry-sdk/tests/metrics/test_metrics.py @@ -18,6 +18,7 @@ from typing import Iterable, Sequence from unittest.mock import MagicMock, Mock, patch +from opentelemetry.attributes import BoundedAttributes from opentelemetry.metrics import NoOpMeter from opentelemetry.sdk.environment_variables import OTEL_SDK_DISABLED from opentelemetry.sdk.metrics import ( @@ -126,11 +127,36 @@ def test_get_meter(self): "name", version="version", schema_url="schema_url", + attributes={"key": "value"}, ) self.assertEqual(meter._instrumentation_scope.name, "name") self.assertEqual(meter._instrumentation_scope.version, "version") self.assertEqual(meter._instrumentation_scope.schema_url, "schema_url") + self.assertEqual( + meter._instrumentation_scope.attributes, {"key": "value"} + ) + + def test_get_meter_attributes(self): + """ + `MeterProvider.get_meter` arguments are used to create an + `InstrumentationScope` object on the created `Meter`. + """ + + meter = MeterProvider().get_meter( + "name", + version="version", + schema_url="schema_url", + attributes={"key": "value", "key2": 5, "key3": "value3"}, + ) + + self.assertEqual(meter._instrumentation_scope.name, "name") + self.assertEqual(meter._instrumentation_scope.version, "version") + self.assertEqual(meter._instrumentation_scope.schema_url, "schema_url") + self.assertEqual( + meter._instrumentation_scope.attributes, + {"key": "value", "key2": 5, "key3": "value3"}, + ) def test_get_meter_empty(self): """ @@ -180,6 +206,44 @@ def test_get_meter_duplicate(self): self.assertIs(meter1, meter2) self.assertIsNot(meter1, meter3) + def test_get_meter_comparison_with_attributes(self): + """ + Subsequent calls to `MeterProvider.get_meter` with the same arguments + should return the same `Meter` instance. + """ + mp = MeterProvider() + meter1 = mp.get_meter( + "name", + version="version", + schema_url="schema_url", + attributes={"key": "value", "key2": 5, "key3": "value3"}, + ) + meter2 = mp.get_meter( + "name", + version="version", + schema_url="schema_url", + attributes={"key": "value", "key2": 5, "key3": "value3"}, + ) + meter3 = mp.get_meter( + "name2", + version="version", + schema_url="schema_url", + ) + meter4 = mp.get_meter( + "name", + version="version", + schema_url="schema_url", + attributes={"key": "value", "key2": 5, "key3": "value4"}, + ) + self.assertIs(meter1, meter2) + self.assertIsNot(meter1, meter3) + self.assertTrue( + meter3._instrumentation_scope > meter4._instrumentation_scope + ) + self.assertIsInstance( + meter4._instrumentation_scope.attributes, BoundedAttributes + ) + def test_shutdown(self): mock_metric_reader_0 = MagicMock( diff --git a/opentelemetry-sdk/tests/metrics/test_point.py b/opentelemetry-sdk/tests/metrics/test_point.py index 20dd0e72384..cff07ff6aea 100644 --- a/opentelemetry-sdk/tests/metrics/test_point.py +++ b/opentelemetry-sdk/tests/metrics/test_point.py @@ -178,7 +178,7 @@ def setUpClass(cls): metrics=[cls.metric_0, cls.metric_1, cls.metric_2], schema_url="schema_url_0", ) - cls.scope_metrics_0_str = f'{{"scope": {{"name": "name_0", "version": "version_0", "schema_url": "schema_url_0"}}, "metrics": [{cls.metric_0_str}, {cls.metric_1_str}, {cls.metric_2_str}], "schema_url": "schema_url_0"}}' + cls.scope_metrics_0_str = f'{{"scope": {{"name": "name_0", "version": "version_0", "schema_url": "schema_url_0", "attributes": null}}, "metrics": [{cls.metric_0_str}, {cls.metric_1_str}, {cls.metric_2_str}], "schema_url": "schema_url_0"}}' cls.scope_metrics_1 = ScopeMetrics( scope=InstrumentationScope( @@ -189,7 +189,7 @@ def setUpClass(cls): metrics=[cls.metric_0, cls.metric_1, cls.metric_2], schema_url="schema_url_1", ) - cls.scope_metrics_1_str = f'{{"scope": {{"name": "name_1", "version": "version_1", "schema_url": "schema_url_1"}}, "metrics": [{cls.metric_0_str}, {cls.metric_1_str}, {cls.metric_2_str}], "schema_url": "schema_url_1"}}' + cls.scope_metrics_1_str = f'{{"scope": {{"name": "name_1", "version": "version_1", "schema_url": "schema_url_1", "attributes": null}}, "metrics": [{cls.metric_0_str}, {cls.metric_1_str}, {cls.metric_2_str}], "schema_url": "schema_url_1"}}' cls.resource_metrics_0 = ResourceMetrics( resource=Resource( From b596734d15c267984f8f302306dffc1cf7683e6c Mon Sep 17 00:00:00 2001 From: arunk1988 <84958541+arunk1988@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:11:06 +0530 Subject: [PATCH 02/15] Update opentracing and opencesus docs examples to not use JaegerExporter (#4023) --- docs/examples/opencensus-shim/README.rst | 8 ++++---- docs/examples/opencensus-shim/app.py | 9 +++++---- .../examples/opencensus-shim/requirements.txt | 2 +- docs/examples/opentracing/README.rst | 8 ++++---- docs/examples/opentracing/main.py | 19 ++++++++++++------- docs/examples/opentracing/requirements.txt | 2 +- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/examples/opencensus-shim/README.rst b/docs/examples/opencensus-shim/README.rst index 9c24440172b..f620fdc0864 100644 --- a/docs/examples/opencensus-shim/README.rst +++ b/docs/examples/opencensus-shim/README.rst @@ -20,10 +20,10 @@ Start Jaeger .. code-block:: sh docker run --rm \ - -p 6831:6831/udp \ - -p 6832:6832/udp \ + -p 4317:4317 \ + -p 4318:4318 \ -p 16686:16686 \ - jaegertracing/all-in-one:1.13 \ + jaegertracing/all-in-one:latest \ --log-level=debug Python Dependencies @@ -43,7 +43,7 @@ Alternatively, you can install the Python dependencies separately: pip install \ opentelemetry-api \ opentelemetry-sdk \ - opentelemetry-exporter-jaeger \ + opentelemetry-exporter-otlp \ opentelemetry-opencensus-shim \ opentelemetry-instrumentation-sqlite3 \ opencensus \ diff --git a/docs/examples/opencensus-shim/app.py b/docs/examples/opencensus-shim/app.py index 5c8b7f744b6..9103ba53337 100644 --- a/docs/examples/opencensus-shim/app.py +++ b/docs/examples/opencensus-shim/app.py @@ -18,7 +18,9 @@ from opencensus.ext.flask.flask_middleware import FlaskMiddleware from opentelemetry import trace -from opentelemetry.exporter.jaeger.thrift import JaegerExporter +from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( + OTLPSpanExporter, +) from opentelemetry.instrumentation.sqlite3 import SQLite3Instrumentor from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider @@ -40,9 +42,8 @@ # Configure OTel to export traces to Jaeger tracer_provider.add_span_processor( BatchSpanProcessor( - JaegerExporter( - agent_host_name="localhost", - agent_port=6831, + OTLPSpanExporter( + endpoint="localhost:4317", ) ) ) diff --git a/docs/examples/opencensus-shim/requirements.txt b/docs/examples/opencensus-shim/requirements.txt index da9f0f3f969..9e619db7c97 100644 --- a/docs/examples/opencensus-shim/requirements.txt +++ b/docs/examples/opencensus-shim/requirements.txt @@ -1,6 +1,6 @@ opentelemetry-api opentelemetry-sdk -opentelemetry-exporter-jaeger +opentelemetry-exporter-otlp opentelemetry-opencensus-shim opentelemetry-instrumentation-sqlite3 opencensus diff --git a/docs/examples/opentracing/README.rst b/docs/examples/opentracing/README.rst index 0bf5f8dca3d..d811c36fd46 100644 --- a/docs/examples/opentracing/README.rst +++ b/docs/examples/opentracing/README.rst @@ -26,10 +26,10 @@ Start Jaeger .. code-block:: sh docker run --rm \ - -p 6831:6831/udp \ - -p 6832:6832/udp \ + -p 4317:4317 \ + -p 4318:4318 \ -p 16686:16686 \ - jaegertracing/all-in-one:1.13 \ + jaegertracing/all-in-one:latest \ --log-level=debug Redis @@ -61,7 +61,7 @@ Alternatively, you can install the Python dependencies separately: pip install \ opentelemetry-api \ opentelemetry-sdk \ - opentelemetry-exporter-jaeger \ + opentelemetry-exporter-otlp \ opentelemetry-opentracing-shim \ redis \ redis_opentracing diff --git a/docs/examples/opentracing/main.py b/docs/examples/opentracing/main.py index 3975c4a45d7..f8a9c55cc51 100755 --- a/docs/examples/opentracing/main.py +++ b/docs/examples/opentracing/main.py @@ -3,7 +3,9 @@ from rediscache import RedisCache from opentelemetry import trace -from opentelemetry.exporter.jaeger.thrift import JaegerExporter +from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( + OTLPSpanExporter, +) from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor from opentelemetry.shim import opentracing_shim @@ -12,13 +14,16 @@ trace.set_tracer_provider(TracerProvider()) tracer_provider = trace.get_tracer_provider() -# Configure the tracer to export traces to Jaeger -jaeger_exporter = JaegerExporter( - agent_host_name="localhost", - agent_port=6831, +# Create an OTLP gRPC span exporter +otlp_exporter = OTLPSpanExporter( + endpoint="http://localhost:4317", + # For insecure connection, useful for testing + insecure=True, +) +# Add the exporter to the tracer provider +trace.get_tracer_provider().add_span_processor( + BatchSpanProcessor(otlp_exporter) ) -span_processor = BatchSpanProcessor(jaeger_exporter) -tracer_provider.add_span_processor(span_processor) # Create an OpenTracing shim. This implements the OpenTracing tracer API, but # forwards calls to the underlying OpenTelemetry tracer. diff --git a/docs/examples/opentracing/requirements.txt b/docs/examples/opentracing/requirements.txt index fa4b520936d..db390be5fdd 100644 --- a/docs/examples/opentracing/requirements.txt +++ b/docs/examples/opentracing/requirements.txt @@ -1,6 +1,6 @@ opentelemetry-api opentelemetry-sdk -opentelemetry-exporter-jaeger +opentelemetry-exporter-otlp opentelemetry-opentracing-shim redis redis_opentracing From 49bfc29f75fdc8833a35e51fa7f1d74cbc047464 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Wed, 10 Jul 2024 19:17:03 +0200 Subject: [PATCH 03/15] Bump certifi and zipp (#4038) --- docs/getting_started/tests/requirements.txt | 4 ++-- .../opentelemetry-exporter-opencensus/test-requirements.txt | 2 +- .../test-requirements-0.txt | 2 +- .../test-requirements-1.txt | 2 +- .../test-requirements-0.txt | 2 +- .../test-requirements-1.txt | 2 +- .../test-requirements-0.txt | 4 ++-- .../test-requirements-1.txt | 4 ++-- exporter/opentelemetry-exporter-otlp/test-requirements.txt | 2 +- .../opentelemetry-exporter-prometheus/test-requirements.txt | 2 +- .../opentelemetry-exporter-zipkin-json/test-requirements.txt | 4 ++-- .../test-requirements.txt | 4 ++-- exporter/opentelemetry-exporter-zipkin/test-requirements.txt | 2 +- opentelemetry-api/test-requirements.txt | 2 +- opentelemetry-proto/test-requirements-0.txt | 2 +- opentelemetry-proto/test-requirements-1.txt | 2 +- opentelemetry-sdk/test-requirements.txt | 2 +- opentelemetry-semantic-conventions/test-requirements.txt | 2 +- propagator/opentelemetry-propagator-b3/test-requirements.txt | 2 +- .../opentelemetry-propagator-jaeger/test-requirements.txt | 2 +- shim/opentelemetry-opencensus-shim/test-requirements.txt | 4 ++-- shim/opentelemetry-opentracing-shim/test-requirements.txt | 2 +- tests/opentelemetry-test-utils/test-requirements.txt | 2 +- 23 files changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/getting_started/tests/requirements.txt b/docs/getting_started/tests/requirements.txt index 02276ce3ba9..b22401771a4 100644 --- a/docs/getting_started/tests/requirements.txt +++ b/docs/getting_started/tests/requirements.txt @@ -1,6 +1,6 @@ asgiref==3.7.2 attrs==23.1.0 -certifi==2023.7.22 +certifi==2024.7.4 charset-normalizer==2.0.12 click==8.1.7 Deprecated==1.2.14 @@ -21,7 +21,7 @@ typing_extensions==4.8.0 urllib3==1.26.19 Werkzeug==3.0.3 wrapt==1.15.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-semantic-conventions -e opentelemetry-api -e opentelemetry-sdk diff --git a/exporter/opentelemetry-exporter-opencensus/test-requirements.txt b/exporter/opentelemetry-exporter-opencensus/test-requirements.txt index 46e751a8092..aad1363f39d 100644 --- a/exporter/opentelemetry-exporter-opencensus/test-requirements.txt +++ b/exporter/opentelemetry-exporter-opencensus/test-requirements.txt @@ -12,7 +12,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e tests/opentelemetry-test-utils diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-0.txt b/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-0.txt index 9a6dce5bd97..093b69f3fe2 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-0.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-0.txt @@ -10,7 +10,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e opentelemetry-semantic-conventions diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-1.txt b/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-1.txt index 297b85e9f46..27e61810db3 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-1.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-1.txt @@ -10,7 +10,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e opentelemetry-semantic-conventions diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt index f5bd68b42bd..5c9bd04d4db 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt @@ -13,7 +13,7 @@ pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e tests/opentelemetry-test-utils -e exporter/opentelemetry-exporter-otlp-proto-common diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt index 3ab26295cb1..50cbb0c2fe4 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt @@ -13,7 +13,7 @@ pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e tests/opentelemetry-test-utils -e exporter/opentelemetry-exporter-otlp-proto-common diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-0.txt b/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-0.txt index 5a9304405b6..6d83270f10f 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-0.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-0.txt @@ -1,5 +1,5 @@ asgiref==3.7.2 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 Deprecated==1.2.14 googleapis-common-protos==1.62.0 @@ -18,7 +18,7 @@ tomli==2.0.1 typing_extensions==4.10.0 urllib3==2.2.2 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e tests/opentelemetry-test-utils -e exporter/opentelemetry-exporter-otlp-proto-common diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-1.txt b/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-1.txt index ad207ddc53d..28e23c5edf2 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-1.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-1.txt @@ -1,5 +1,5 @@ asgiref==3.7.2 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 Deprecated==1.2.14 googleapis-common-protos==1.62.0 @@ -18,7 +18,7 @@ tomli==2.0.1 typing_extensions==4.10.0 urllib3==2.2.2 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e tests/opentelemetry-test-utils -e exporter/opentelemetry-exporter-otlp-proto-common diff --git a/exporter/opentelemetry-exporter-otlp/test-requirements.txt b/exporter/opentelemetry-exporter-otlp/test-requirements.txt index 2cc6208c01e..bdb237ab620 100644 --- a/exporter/opentelemetry-exporter-otlp/test-requirements.txt +++ b/exporter/opentelemetry-exporter-otlp/test-requirements.txt @@ -9,7 +9,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e tests/opentelemetry-test-utils -e exporter/opentelemetry-exporter-otlp-proto-common diff --git a/exporter/opentelemetry-exporter-prometheus/test-requirements.txt b/exporter/opentelemetry-exporter-prometheus/test-requirements.txt index c7f558e670a..71167534060 100644 --- a/exporter/opentelemetry-exporter-prometheus/test-requirements.txt +++ b/exporter/opentelemetry-exporter-prometheus/test-requirements.txt @@ -10,7 +10,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e tests/opentelemetry-test-utils diff --git a/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt b/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt index b9ba9dd3b74..6b304a56ddf 100644 --- a/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt +++ b/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt @@ -1,5 +1,5 @@ asgiref==3.7.2 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 Deprecated==1.2.14 idna==3.7 @@ -14,7 +14,7 @@ tomli==2.0.1 typing_extensions==4.10.0 urllib3==2.2.2 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e opentelemetry-semantic-conventions diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt b/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt index 9ca8fc39a5d..a3b296b4805 100644 --- a/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt +++ b/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt @@ -1,5 +1,5 @@ asgiref==3.7.2 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 Deprecated==1.2.14 idna==3.7 @@ -15,7 +15,7 @@ tomli==2.0.1 typing_extensions==4.10.0 urllib3==2.2.2 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e exporter/opentelemetry-exporter-zipkin-json -e opentelemetry-sdk diff --git a/exporter/opentelemetry-exporter-zipkin/test-requirements.txt b/exporter/opentelemetry-exporter-zipkin/test-requirements.txt index bfffbb10e9c..6174e79ba3d 100644 --- a/exporter/opentelemetry-exporter-zipkin/test-requirements.txt +++ b/exporter/opentelemetry-exporter-zipkin/test-requirements.txt @@ -9,7 +9,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e exporter/opentelemetry-exporter-zipkin-json -e exporter/opentelemetry-exporter-zipkin-proto-http diff --git a/opentelemetry-api/test-requirements.txt b/opentelemetry-api/test-requirements.txt index 7f58c82a604..9dbb8596c71 100644 --- a/opentelemetry-api/test-requirements.txt +++ b/opentelemetry-api/test-requirements.txt @@ -9,7 +9,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-sdk -e opentelemetry-semantic-conventions -e tests/opentelemetry-test-utils diff --git a/opentelemetry-proto/test-requirements-0.txt b/opentelemetry-proto/test-requirements-0.txt index d99d2658828..671756980ce 100644 --- a/opentelemetry-proto/test-requirements-0.txt +++ b/opentelemetry-proto/test-requirements-0.txt @@ -10,5 +10,5 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-proto diff --git a/opentelemetry-proto/test-requirements-1.txt b/opentelemetry-proto/test-requirements-1.txt index 449ec2febd4..b598b4f172a 100644 --- a/opentelemetry-proto/test-requirements-1.txt +++ b/opentelemetry-proto/test-requirements-1.txt @@ -10,5 +10,5 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-proto diff --git a/opentelemetry-sdk/test-requirements.txt b/opentelemetry-sdk/test-requirements.txt index 04498c470ee..1edbe859610 100644 --- a/opentelemetry-sdk/test-requirements.txt +++ b/opentelemetry-sdk/test-requirements.txt @@ -11,7 +11,7 @@ pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e tests/opentelemetry-test-utils -e opentelemetry-api -e opentelemetry-semantic-conventions diff --git a/opentelemetry-semantic-conventions/test-requirements.txt b/opentelemetry-semantic-conventions/test-requirements.txt index 39e75f7de2b..cada74f6991 100644 --- a/opentelemetry-semantic-conventions/test-requirements.txt +++ b/opentelemetry-semantic-conventions/test-requirements.txt @@ -9,6 +9,6 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-semantic-conventions diff --git a/propagator/opentelemetry-propagator-b3/test-requirements.txt b/propagator/opentelemetry-propagator-b3/test-requirements.txt index 8ffc454a196..a86ca788eda 100644 --- a/propagator/opentelemetry-propagator-b3/test-requirements.txt +++ b/propagator/opentelemetry-propagator-b3/test-requirements.txt @@ -10,7 +10,7 @@ pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e opentelemetry-semantic-conventions diff --git a/propagator/opentelemetry-propagator-jaeger/test-requirements.txt b/propagator/opentelemetry-propagator-jaeger/test-requirements.txt index 8ff3b0a6521..f1200ed9eed 100644 --- a/propagator/opentelemetry-propagator-jaeger/test-requirements.txt +++ b/propagator/opentelemetry-propagator-jaeger/test-requirements.txt @@ -9,7 +9,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e opentelemetry-semantic-conventions diff --git a/shim/opentelemetry-opencensus-shim/test-requirements.txt b/shim/opentelemetry-opencensus-shim/test-requirements.txt index c4d399c4a1a..22810bf4d6c 100644 --- a/shim/opentelemetry-opencensus-shim/test-requirements.txt +++ b/shim/opentelemetry-opencensus-shim/test-requirements.txt @@ -1,6 +1,6 @@ asgiref==3.7.2 cachetools==5.3.3 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 Deprecated==1.2.14 google-api-core==2.17.1 @@ -27,7 +27,7 @@ tomli==2.0.1 typing_extensions==4.10.0 urllib3==2.2.2 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e tests/opentelemetry-test-utils diff --git a/shim/opentelemetry-opentracing-shim/test-requirements.txt b/shim/opentelemetry-opentracing-shim/test-requirements.txt index f8bc4095cca..af2b495543e 100644 --- a/shim/opentelemetry-opentracing-shim/test-requirements.txt +++ b/shim/opentelemetry-opentracing-shim/test-requirements.txt @@ -10,7 +10,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e tests/opentelemetry-test-utils diff --git a/tests/opentelemetry-test-utils/test-requirements.txt b/tests/opentelemetry-test-utils/test-requirements.txt index ec1e418f78f..8e9c26e9255 100644 --- a/tests/opentelemetry-test-utils/test-requirements.txt +++ b/tests/opentelemetry-test-utils/test-requirements.txt @@ -9,7 +9,7 @@ pytest==7.4.4 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 -zipp==3.17.0 +zipp==3.19.2 -e opentelemetry-api -e opentelemetry-sdk -e opentelemetry-semantic-conventions From b3ab961b375298791274296099cb45136df0132f Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 10 Jul 2024 12:54:42 -0600 Subject: [PATCH 04/15] Move benchmarks outside of tests directory (#4033) Fixes #4029 --- .github/workflows/benchmarks.yml | 27 ++-------- .github/workflows/test.yml | 8 +-- .gitignore | 3 ++ CONTRIBUTING.md | 6 +-- opentelemetry-sdk/benchmark-requirements.txt | 1 + .../metrics/test_benchmark_metrics.py | 0 .../test_benchmark_metrics_histogram,.py | 0 .../benchmarks/trace/test_benchmark_trace.py | 0 .../profile_resource_usage_batch_export.py | 49 ------------------- .../profile_resource_usage_simple_export.py | 49 ------------------- tox.ini | 3 ++ 11 files changed, 17 insertions(+), 129 deletions(-) create mode 100644 opentelemetry-sdk/benchmark-requirements.txt rename opentelemetry-sdk/{tests/performance => }/benchmarks/metrics/test_benchmark_metrics.py (100%) rename opentelemetry-sdk/{tests/performance => }/benchmarks/metrics/test_benchmark_metrics_histogram,.py (100%) rename opentelemetry-sdk/{tests/performance => }/benchmarks/trace/test_benchmark_trace.py (100%) delete mode 100644 opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_batch_export.py delete mode 100644 opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_simple_export.py diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 0c06f8b741f..965b701f312 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -7,42 +7,25 @@ on: jobs: sdk-benchmarks: env: - py312: "3.12" - RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-sdk-${{ matrix.os }} runs-on: self-hosted - strategy: - # Ensures the entire test matrix is run, even if one permutation fails - fail-fast: false - matrix: - python-version: [py312] - os: [ubuntu-20.04, windows-2019] steps: - name: Checkout Core Repo @ SHA - ${{ github.sha }} uses: actions/checkout@v4 - - name: Set up Python ${{ env[matrix.python-version] }} + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ env[matrix.python-version] }} + python-version: "3.12" architecture: 'x64' - name: Install tox run: pip install tox - - name: Cache tox environment - # Preserves .tox directory between runs for faster installs - uses: actions/cache@v4 - with: - path: | - .tox - ~/.cache/pip - key: v3-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', - 'dev-requirements.txt') }}-core - name: Run tox - run: tox -f ${{ matrix.python-version }}-sdk -- -k opentelemetry-sdk/tests/performance/benchmarks --benchmark-json=opentelemetry-sdk/tests/output.json + run: tox -e benchmark-opentelemetry-sdk -- -k opentelemetry-sdk/benchmarks --benchmark-json=opentelemetry-sdk/output.json - name: Report on SDK benchmark results uses: benchmark-action/github-action-benchmark@v1 with: - name: OpenTelemetry Python SDK Benchmarks - Python ${{ env[matrix.python-version ]}} - SDK + name: OpenTelemetry Python SDK Benchmarks tool: pytest - output-file-path: opentelemetry-sdk/tests/output.json + output-file-path: opentelemetry-sdk/output.json gh-pages-branch: gh-pages github-token: ${{ secrets.GITHUB_TOKEN }} # Make a commit on `gh-pages` with benchmarks from previous step diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc19428329f..f70b22765a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,11 +92,7 @@ jobs: - name: Windows does not let git check out files with long names if: ${{ matrix.os == 'windows-2019'}} run: git config --system core.longpaths true - - name: run pytest with --benchmark-skip - if: ${{ matrix.package == 'sdk' || matrix.package == 'exporter-otlp-proto-grpc' }} - run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-skip - - name: run pytest without --benchmark-skip - if: ${{ !(matrix.package == 'sdk' || matrix.package == 'exporter-otlp-proto-grpc') }} + - name: run tox run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra misc: strategy: @@ -217,4 +213,4 @@ jobs: key: v3-tox-cache-${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib - name: run tox - run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-skip + run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra diff --git a/.gitignore b/.gitignore index f2324c7bfca..07c7b9aa6e4 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,6 @@ docs/examples/django/db.sqlite3 # Semantic conventions scripts/semconv/semantic-conventions + +# Benchmark result files +*-benchmark.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e4b13bf3dd7..31eedfef8c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -126,7 +126,7 @@ The continuation integration overrides that environment variable with as per the ### Benchmarks -Running the `tox` tests also runs the performance tests if any are available. Benchmarking tests are done with `pytest-benchmark` and they output a table with results to the console. +Some packages have benchmark tests. To run them, run `tox -f benchmark`. Benchmark tests use `pytest-benchmark` and they output a table with results to the console. To write benchmarks, simply use the [pytest benchmark fixture](https://pytest-benchmark.readthedocs.io/en/latest/usage.html#usage) like the following: @@ -142,10 +142,10 @@ def test_simple_start_span(benchmark): benchmark(benchmark_start_as_current_span, "benchmarkedSpan", 42) ``` -Make sure the test file is under the `tests/performance/benchmarks/` folder of +Make sure the test file is under the `benchmarks/` folder of the package it is benchmarking and further has a path that corresponds to the file in the package it is testing. Make sure that the file name begins with -`test_benchmark_`. (e.g. `opentelemetry-sdk/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py`) +`test_benchmark_`. (e.g. `opentelemetry-sdk/benchmarks/trace/propagation/test_benchmark_b3_format.py`) ## Pull Requests diff --git a/opentelemetry-sdk/benchmark-requirements.txt b/opentelemetry-sdk/benchmark-requirements.txt new file mode 100644 index 00000000000..44564857ef4 --- /dev/null +++ b/opentelemetry-sdk/benchmark-requirements.txt @@ -0,0 +1 @@ +pytest-benchmark==4.0.0 diff --git a/opentelemetry-sdk/tests/performance/benchmarks/metrics/test_benchmark_metrics.py b/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics.py similarity index 100% rename from opentelemetry-sdk/tests/performance/benchmarks/metrics/test_benchmark_metrics.py rename to opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics.py diff --git a/opentelemetry-sdk/tests/performance/benchmarks/metrics/test_benchmark_metrics_histogram,.py b/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram,.py similarity index 100% rename from opentelemetry-sdk/tests/performance/benchmarks/metrics/test_benchmark_metrics_histogram,.py rename to opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram,.py diff --git a/opentelemetry-sdk/tests/performance/benchmarks/trace/test_benchmark_trace.py b/opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py similarity index 100% rename from opentelemetry-sdk/tests/performance/benchmarks/trace/test_benchmark_trace.py rename to opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py diff --git a/opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_batch_export.py b/opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_batch_export.py deleted file mode 100644 index 3e9a201c967..00000000000 --- a/opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_batch_export.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import time - -from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( - OTLPSpanExporter, -) -from opentelemetry.sdk.trace import TracerProvider, sampling -from opentelemetry.sdk.trace.export import BatchSpanProcessor - -TEST_DURATION_SECONDS = 15 -SPANS_PER_SECOND = 10_000 - - -class MockTraceServiceStub: - def __init__(self, channel): - self.Export = lambda *args, **kwargs: None - - -old_stub = OTLPSpanExporter._stub -OTLPSpanExporter._stub = MockTraceServiceStub - -simple_span_processor = BatchSpanProcessor(OTLPSpanExporter()) -tracer = TracerProvider( - active_span_processor=simple_span_processor, - sampler=sampling.DEFAULT_ON, -).get_tracer("resource_usage_tracer") - -starttime = time.time() -for _ in range(TEST_DURATION_SECONDS): - for _ in range(SPANS_PER_SECOND): - span = tracer.start_span("benchmarkedSpan") - span.end() - time_to_finish_spans = time.time() - starttime - time.sleep(1.0 - time_to_finish_spans if time_to_finish_spans < 1.0 else 0) - -OTLPSpanExporter._stub = old_stub diff --git a/opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_simple_export.py b/opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_simple_export.py deleted file mode 100644 index bc27fb519da..00000000000 --- a/opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_simple_export.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import time - -from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( - OTLPSpanExporter, -) -from opentelemetry.sdk.trace import TracerProvider, sampling -from opentelemetry.sdk.trace.export import SimpleSpanProcessor - -TEST_DURATION_SECONDS = 15 -SPANS_PER_SECOND = 10_000 - - -class MockTraceServiceStub: - def __init__(self, channel): - self.Export = lambda *args, **kwargs: None - - -old_stub = OTLPSpanExporter._stub -OTLPSpanExporter._stub = MockTraceServiceStub - -simple_span_processor = SimpleSpanProcessor(OTLPSpanExporter()) -tracer = TracerProvider( - active_span_processor=simple_span_processor, - sampler=sampling.DEFAULT_ON, -).get_tracer("resource_usage_tracer") - -starttime = time.time() -for _ in range(TEST_DURATION_SECONDS): - for _ in range(SPANS_PER_SECOND): - span = tracer.start_span("benchmarkedSpan") - span.end() - time_to_finish_spans = time.time() - starttime - time.sleep(1.0 - time_to_finish_spans if time_to_finish_spans < 1.0 else 0) - -OTLPSpanExporter._stub = old_stub diff --git a/tox.ini b/tox.ini index c766a20ff54..48ca1f10df8 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ envlist = py3{8,9,10,11,12}-opentelemetry-sdk pypy3-opentelemetry-sdk + benchmark-opentelemetry-sdk py3{8,9,10,11,12}-opentelemetry-semantic-conventions pypy3-opentelemetry-semantic-conventions @@ -113,6 +114,7 @@ commands_pre = api: pip install -r {toxinidir}/opentelemetry-api/test-requirements.txt sdk: pip install -r {toxinidir}/opentelemetry-sdk/test-requirements.txt + benchmark-opentelemetry-sdk: pip install -r {toxinidir}/opentelemetry-sdk/benchmark-requirements.txt semantic-conventions: pip install -r {toxinidir}/opentelemetry-semantic-conventions/test-requirements.txt @@ -168,6 +170,7 @@ commands_pre = commands = api: pytest {toxinidir}/opentelemetry-api/tests {posargs} sdk: pytest {toxinidir}/opentelemetry-sdk/tests {posargs} + benchmark-opentelemetry-sdk: pytest {toxinidir}/opentelemetry-sdk/benchmarks {posargs} --benchmark-json=sdk-benchmark.json protobuf: pytest {toxinidir}/opentelemetry-proto/tests {posargs} semantic-conventions: pytest {toxinidir}/opentelemetry-semantic-conventions/tests {posargs} getting-started: pytest {toxinidir}/docs/getting_started/tests {posargs} From 732ea8a492556ca22df02f0e853ee0a445f89682 Mon Sep 17 00:00:00 2001 From: Rajat Jain Date: Thu, 11 Jul 2024 00:43:12 +0530 Subject: [PATCH 05/15] Added py.typed in sub-modules confirming to PEP 420 (#3385) * Added py.typed in sub-modules confirming to PEP 420 * Moved py.typed inside the sub-modules.. * Making environment_variables as well as verison a module. * Put verion.py and environment_variables.py in their own modules and respective changes in pyproject.toml * Update opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py * Update opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py * Update opentelemetry-api/src/opentelemetry/propagate/__init__.py --------- Co-authored-by: Diego Hurtado --- .../opentelemetry-exporter-jaeger-proto-grpc}/py.typed | 0 exporter/opentelemetry-exporter-jaeger-thrift/py.typed | 0 exporter/opentelemetry-exporter-jaeger/py.typed | 0 exporter/opentelemetry-exporter-opencensus/py.typed | 0 exporter/opentelemetry-exporter-otlp-proto-common/py.typed | 0 exporter/opentelemetry-exporter-otlp-proto-grpc/py.typed | 0 exporter/opentelemetry-exporter-otlp-proto-http/py.typed | 0 exporter/opentelemetry-exporter-otlp/py.typed | 0 exporter/opentelemetry-exporter-prometheus/py.typed | 0 exporter/opentelemetry-exporter-zipkin-json/py.typed | 0 exporter/opentelemetry-exporter-zipkin-proto-http/py.typed | 0 exporter/opentelemetry-exporter-zipkin/py.typed | 0 opentelemetry-api/py.typed | 0 opentelemetry-api/pyproject.toml | 2 +- opentelemetry-api/src/opentelemetry/_logs/py.typed | 0 opentelemetry-api/src/opentelemetry/attributes/py.typed | 0 opentelemetry-api/src/opentelemetry/baggage/py.typed | 0 opentelemetry-api/src/opentelemetry/context/py.typed | 0 .../__init__.py} | 0 .../src/opentelemetry/environment_variables/py.typed | 0 opentelemetry-api/src/opentelemetry/metrics/py.typed | 0 opentelemetry-api/src/opentelemetry/propagate/py.typed | 0 opentelemetry-api/src/opentelemetry/propagators/py.typed | 0 opentelemetry-api/src/opentelemetry/trace/py.typed | 0 opentelemetry-api/src/opentelemetry/util/py.typed | 0 .../src/opentelemetry/{version.py => version/__init__.py} | 0 opentelemetry-api/src/opentelemetry/version/py.typed | 0 opentelemetry-proto/py.typed | 0 opentelemetry-proto/pyproject.toml | 2 +- .../src/opentelemetry/proto/{version.py => version/__init__.py} | 0 opentelemetry-sdk/py.typed | 0 opentelemetry-sdk/pyproject.toml | 2 +- opentelemetry-sdk/src/opentelemetry/sdk/_configuration/py.typed | 0 opentelemetry-sdk/src/opentelemetry/sdk/_logs/py.typed | 0 .../__init__.py} | 0 .../src/opentelemetry/sdk/environment_variables/py.typed | 0 opentelemetry-sdk/src/opentelemetry/sdk/error_handler/py.typed | 0 opentelemetry-sdk/src/opentelemetry/sdk/metrics/py.typed | 0 opentelemetry-sdk/src/opentelemetry/sdk/resources/py.typed | 0 opentelemetry-sdk/src/opentelemetry/sdk/trace/py.typed | 0 opentelemetry-sdk/src/opentelemetry/sdk/util/py.typed | 0 .../src/opentelemetry/sdk/{version.py => version/__init__.py} | 0 opentelemetry-sdk/src/opentelemetry/sdk/version/py.typed | 0 opentelemetry-semantic-conventions/py.typed | 0 opentelemetry-semantic-conventions/pyproject.toml | 2 +- .../src/opentelemetry/semconv/metrics/py.typed | 0 .../src/opentelemetry/semconv/resource/py.typed | 0 .../src/opentelemetry/semconv/trace/py.typed | 0 .../opentelemetry/semconv/{version.py => version/__init__.py} | 0 propagator/opentelemetry-propagator-b3/py.typed | 0 propagator/opentelemetry-propagator-jaeger/py.typed | 0 51 files changed, 4 insertions(+), 4 deletions(-) rename {opentelemetry-api/src/opentelemetry => exporter/opentelemetry-exporter-jaeger-proto-grpc}/py.typed (100%) create mode 100644 exporter/opentelemetry-exporter-jaeger-thrift/py.typed create mode 100644 exporter/opentelemetry-exporter-jaeger/py.typed create mode 100644 exporter/opentelemetry-exporter-opencensus/py.typed create mode 100644 exporter/opentelemetry-exporter-otlp-proto-common/py.typed create mode 100644 exporter/opentelemetry-exporter-otlp-proto-grpc/py.typed create mode 100644 exporter/opentelemetry-exporter-otlp-proto-http/py.typed create mode 100644 exporter/opentelemetry-exporter-otlp/py.typed create mode 100644 exporter/opentelemetry-exporter-prometheus/py.typed create mode 100644 exporter/opentelemetry-exporter-zipkin-json/py.typed create mode 100644 exporter/opentelemetry-exporter-zipkin-proto-http/py.typed create mode 100644 exporter/opentelemetry-exporter-zipkin/py.typed create mode 100644 opentelemetry-api/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/_logs/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/attributes/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/baggage/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/context/py.typed rename opentelemetry-api/src/opentelemetry/{environment_variables.py => environment_variables/__init__.py} (100%) create mode 100644 opentelemetry-api/src/opentelemetry/environment_variables/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/metrics/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/propagate/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/propagators/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/trace/py.typed create mode 100644 opentelemetry-api/src/opentelemetry/util/py.typed rename opentelemetry-api/src/opentelemetry/{version.py => version/__init__.py} (100%) create mode 100644 opentelemetry-api/src/opentelemetry/version/py.typed create mode 100644 opentelemetry-proto/py.typed rename opentelemetry-proto/src/opentelemetry/proto/{version.py => version/__init__.py} (100%) create mode 100644 opentelemetry-sdk/py.typed create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/_configuration/py.typed create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/_logs/py.typed rename opentelemetry-sdk/src/opentelemetry/sdk/{environment_variables.py => environment_variables/__init__.py} (100%) create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/py.typed create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/error_handler/py.typed create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/metrics/py.typed create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/resources/py.typed create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/trace/py.typed create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/util/py.typed rename opentelemetry-sdk/src/opentelemetry/sdk/{version.py => version/__init__.py} (100%) create mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/version/py.typed create mode 100644 opentelemetry-semantic-conventions/py.typed create mode 100644 opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/py.typed create mode 100644 opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/py.typed create mode 100644 opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/py.typed rename opentelemetry-semantic-conventions/src/opentelemetry/semconv/{version.py => version/__init__.py} (100%) create mode 100644 propagator/opentelemetry-propagator-b3/py.typed create mode 100644 propagator/opentelemetry-propagator-jaeger/py.typed diff --git a/opentelemetry-api/src/opentelemetry/py.typed b/exporter/opentelemetry-exporter-jaeger-proto-grpc/py.typed similarity index 100% rename from opentelemetry-api/src/opentelemetry/py.typed rename to exporter/opentelemetry-exporter-jaeger-proto-grpc/py.typed diff --git a/exporter/opentelemetry-exporter-jaeger-thrift/py.typed b/exporter/opentelemetry-exporter-jaeger-thrift/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-jaeger/py.typed b/exporter/opentelemetry-exporter-jaeger/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-opencensus/py.typed b/exporter/opentelemetry-exporter-opencensus/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/py.typed b/exporter/opentelemetry-exporter-otlp-proto-common/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/py.typed b/exporter/opentelemetry-exporter-otlp-proto-grpc/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/py.typed b/exporter/opentelemetry-exporter-otlp-proto-http/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-otlp/py.typed b/exporter/opentelemetry-exporter-otlp/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-prometheus/py.typed b/exporter/opentelemetry-exporter-prometheus/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-zipkin-json/py.typed b/exporter/opentelemetry-exporter-zipkin-json/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/py.typed b/exporter/opentelemetry-exporter-zipkin-proto-http/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-zipkin/py.typed b/exporter/opentelemetry-exporter-zipkin/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/py.typed b/opentelemetry-api/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/pyproject.toml b/opentelemetry-api/pyproject.toml index 0cc10d33d88..7278412f258 100644 --- a/opentelemetry-api/pyproject.toml +++ b/opentelemetry-api/pyproject.toml @@ -55,7 +55,7 @@ default_tracer_provider = "opentelemetry.trace:NoOpTracerProvider" Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/opentelemetry-api" [tool.hatch.version] -path = "src/opentelemetry/version.py" +path = "src/opentelemetry/version/__init__.py" [tool.hatch.build.targets.sdist] include = [ diff --git a/opentelemetry-api/src/opentelemetry/_logs/py.typed b/opentelemetry-api/src/opentelemetry/_logs/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/attributes/py.typed b/opentelemetry-api/src/opentelemetry/attributes/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/baggage/py.typed b/opentelemetry-api/src/opentelemetry/baggage/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/context/py.typed b/opentelemetry-api/src/opentelemetry/context/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/environment_variables.py b/opentelemetry-api/src/opentelemetry/environment_variables/__init__.py similarity index 100% rename from opentelemetry-api/src/opentelemetry/environment_variables.py rename to opentelemetry-api/src/opentelemetry/environment_variables/__init__.py diff --git a/opentelemetry-api/src/opentelemetry/environment_variables/py.typed b/opentelemetry-api/src/opentelemetry/environment_variables/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/metrics/py.typed b/opentelemetry-api/src/opentelemetry/metrics/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/propagate/py.typed b/opentelemetry-api/src/opentelemetry/propagate/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/propagators/py.typed b/opentelemetry-api/src/opentelemetry/propagators/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/trace/py.typed b/opentelemetry-api/src/opentelemetry/trace/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/util/py.typed b/opentelemetry-api/src/opentelemetry/util/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-api/src/opentelemetry/version.py b/opentelemetry-api/src/opentelemetry/version/__init__.py similarity index 100% rename from opentelemetry-api/src/opentelemetry/version.py rename to opentelemetry-api/src/opentelemetry/version/__init__.py diff --git a/opentelemetry-api/src/opentelemetry/version/py.typed b/opentelemetry-api/src/opentelemetry/version/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-proto/py.typed b/opentelemetry-proto/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-proto/pyproject.toml b/opentelemetry-proto/pyproject.toml index c8af4c5797d..505a88f4d5c 100644 --- a/opentelemetry-proto/pyproject.toml +++ b/opentelemetry-proto/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/opentelemetry-proto" [tool.hatch.version] -path = "src/opentelemetry/proto/version.py" +path = "src/opentelemetry/proto/version/__init__.py" [tool.hatch.build.targets.sdist] include = [ diff --git a/opentelemetry-proto/src/opentelemetry/proto/version.py b/opentelemetry-proto/src/opentelemetry/proto/version/__init__.py similarity index 100% rename from opentelemetry-proto/src/opentelemetry/proto/version.py rename to opentelemetry-proto/src/opentelemetry/proto/version/__init__.py diff --git a/opentelemetry-sdk/py.typed b/opentelemetry-sdk/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/pyproject.toml b/opentelemetry-sdk/pyproject.toml index 30b1c00de06..a606f47f1d6 100644 --- a/opentelemetry-sdk/pyproject.toml +++ b/opentelemetry-sdk/pyproject.toml @@ -72,7 +72,7 @@ process = "opentelemetry.sdk.resources:ProcessResourceDetector" Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/opentelemetry-sdk" [tool.hatch.version] -path = "src/opentelemetry/sdk/version.py" +path = "src/opentelemetry/sdk/version/__init__.py" [tool.hatch.build.targets.sdist] include = [ diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py similarity index 100% rename from opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py rename to opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/error_handler/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/error_handler/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/resources/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/trace/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/util/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/util/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/version.py b/opentelemetry-sdk/src/opentelemetry/sdk/version/__init__.py similarity index 100% rename from opentelemetry-sdk/src/opentelemetry/sdk/version.py rename to opentelemetry-sdk/src/opentelemetry/sdk/version/__init__.py diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/version/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/version/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-semantic-conventions/py.typed b/opentelemetry-semantic-conventions/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-semantic-conventions/pyproject.toml b/opentelemetry-semantic-conventions/pyproject.toml index ef6c56597b9..a370e905334 100644 --- a/opentelemetry-semantic-conventions/pyproject.toml +++ b/opentelemetry-semantic-conventions/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/opentelemetry-semantic-conventions" [tool.hatch.version] -path = "src/opentelemetry/semconv/version.py" +path = "src/opentelemetry/semconv/version/__init__.py" [tool.hatch.build.targets.sdist] include = [ diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/version.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/version/__init__.py similarity index 100% rename from opentelemetry-semantic-conventions/src/opentelemetry/semconv/version.py rename to opentelemetry-semantic-conventions/src/opentelemetry/semconv/version/__init__.py diff --git a/propagator/opentelemetry-propagator-b3/py.typed b/propagator/opentelemetry-propagator-b3/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/propagator/opentelemetry-propagator-jaeger/py.typed b/propagator/opentelemetry-propagator-jaeger/py.typed new file mode 100644 index 00000000000..e69de29bb2d From eb287111ed1bfc968210b29657f8b22a3502bef8 Mon Sep 17 00:00:00 2001 From: Tamir David <53215879+tamirdavid@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:04:38 +0300 Subject: [PATCH 06/15] fix: align process command arguments to spec defenition (#4032) --- CHANGELOG.md | 2 ++ opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py | 2 +- opentelemetry-sdk/tests/resources/test_resources.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f49c95b44..f716f96c941 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Update sdk process resource detector `process.command_args` attribute to also include the executable itself + ([#4032](https://github.com/open-telemetry/opentelemetry-python/pull/4032)) - Fix `start_time_unix_nano` for delta collection for explicit bucket histogram aggregation ([#4009](https://github.com/open-telemetry/opentelemetry-python/pull/4009)) - Fix `start_time_unix_nano` for delta collection for sum aggregation diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py index 77a0ca9618b..1fed32c0be5 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py @@ -348,7 +348,7 @@ def detect(self) -> "Resource": _process_executable_path = os.path.dirname(_process_executable_name) _process_command = sys.argv[0] _process_command_line = " ".join(sys.argv) - _process_command_args = sys.argv[1:] + _process_command_args = sys.argv resource_info = { PROCESS_RUNTIME_DESCRIPTION: sys.version, PROCESS_RUNTIME_NAME: sys.implementation.name, diff --git a/opentelemetry-sdk/tests/resources/test_resources.py b/opentelemetry-sdk/tests/resources/test_resources.py index a0c6159010d..8a42d0c6d0f 100644 --- a/opentelemetry-sdk/tests/resources/test_resources.py +++ b/opentelemetry-sdk/tests/resources/test_resources.py @@ -608,7 +608,7 @@ def test_process_detector(self): ) self.assertEqual( aggregated_resource.attributes[PROCESS_COMMAND_ARGS], - tuple(sys.argv[1:]), + tuple(sys.argv), ) def test_resource_detector_entry_points_default(self): From 61ea97d5376adb32e561889644263da7ae2ec0ae Mon Sep 17 00:00:00 2001 From: Georg Pirklbauer Date: Thu, 11 Jul 2024 18:15:13 +0200 Subject: [PATCH 07/15] Add missing example requirements (#4000) --- docs/examples/metrics/instruments/requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/examples/metrics/instruments/requirements.txt diff --git a/docs/examples/metrics/instruments/requirements.txt b/docs/examples/metrics/instruments/requirements.txt new file mode 100644 index 00000000000..5c5cb8b1e11 --- /dev/null +++ b/docs/examples/metrics/instruments/requirements.txt @@ -0,0 +1,3 @@ +opentelemetry-api~=1.25 +opentelemetry-sdk~=1.25 +opentelemetry-exporter-otlp~=1.25 From ee1b008bfe0317f911553906b880e92a40ffa6f4 Mon Sep 17 00:00:00 2001 From: soumyadeepm04 <84105194+soumyadeepm04@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:34:44 -0400 Subject: [PATCH 08/15] OTLP exporter is encoding invalid span/trace IDs in the logs fix (#4006) --- CHANGELOG.md | 2 + .../common/_internal/_log_encoder/__init__.py | 14 +++- .../tests/test_log_encoder.py | 4 +- .../tests/logs/test_otlp_logs_exporter.py | 68 +++++++++++++++++ .../tests/test_proto_log_exporter.py | 74 +++++++++++++++++++ 5 files changed, 158 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f716f96c941..44938228ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- OTLP exporter is encoding invalid span/trace IDs in the logs fix + ([#4006](https://github.com/open-telemetry/opentelemetry-python/pull/4006)) - Update sdk process resource detector `process.command_args` attribute to also include the executable itself ([#4032](https://github.com/open-telemetry/opentelemetry-python/pull/4032)) - Fix `start_time_unix_nano` for delta collection for explicit bucket histogram aggregation diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py index 4252ab7f139..47ff0cf3e0f 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py @@ -39,11 +39,21 @@ def encode_logs(batch: Sequence[LogData]) -> ExportLogsServiceRequest: def _encode_log(log_data: LogData) -> PB2LogRecord: + span_id = ( + None + if log_data.log_record.span_id == 0 + else _encode_span_id(log_data.log_record.span_id) + ) + trace_id = ( + None + if log_data.log_record.trace_id == 0 + else _encode_trace_id(log_data.log_record.trace_id) + ) return PB2LogRecord( time_unix_nano=log_data.log_record.timestamp, observed_time_unix_nano=log_data.log_record.observed_timestamp, - span_id=_encode_span_id(log_data.log_record.span_id), - trace_id=_encode_trace_id(log_data.log_record.trace_id), + span_id=span_id, + trace_id=trace_id, flags=int(log_data.log_record.trace_flags), body=_encode_value(log_data.log_record.body), severity_text=log_data.log_record.severity_text, diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 58620b963ea..158940585c1 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -239,8 +239,8 @@ def get_test_logs( PB2LogRecord( time_unix_nano=1644650249738562048, observed_time_unix_nano=1644650249738562049, - trace_id=_encode_trace_id(0), - span_id=_encode_span_id(0), + trace_id=None, + span_id=None, flags=int(TraceFlags.DEFAULT), severity_text="WARN", severity_number=SeverityNumber.WARN.value, diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/logs/test_otlp_logs_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/logs/test_otlp_logs_exporter.py index c281cbebce1..b81fa4e7bbc 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/logs/test_otlp_logs_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/logs/test_otlp_logs_exporter.py @@ -21,6 +21,7 @@ from google.protobuf.duration_pb2 import ( # pylint: disable=no-name-in-module Duration, ) +from google.protobuf.json_format import MessageToDict from google.rpc.error_details_pb2 import RetryInfo from grpc import ChannelCredentials, Compression, StatusCode, server @@ -167,6 +168,36 @@ def setUp(self): "third_name", "third_version" ), ) + self.log_data_4 = LogData( + log_record=LogRecord( + timestamp=int(time.time() * 1e9), + trace_id=0, + span_id=5213367945872657629, + trace_flags=TraceFlags(0x01), + severity_text="ERROR", + severity_number=SeverityNumber.WARN, + body="Invalid trace id check", + resource=SDKResource({"service": "myapp"}), + ), + instrumentation_scope=InstrumentationScope( + "fourth_name", "fourth_version" + ), + ) + self.log_data_5 = LogData( + log_record=LogRecord( + timestamp=int(time.time() * 1e9), + trace_id=2604504634922341076776623263868986801, + span_id=0, + trace_flags=TraceFlags(0x01), + severity_text="ERROR", + severity_number=SeverityNumber.WARN, + body="Invalid span id check", + resource=SDKResource({"service": "myapp"}), + ), + instrumentation_scope=InstrumentationScope( + "fifth_name", "fifth_version" + ), + ) def tearDown(self): self.server.stop(None) @@ -342,6 +373,43 @@ def test_failure(self): self.exporter.export([self.log_data_1]), LogExportResult.FAILURE ) + def export_log_and_deserialize(self, log_data): + # pylint: disable=protected-access + translated_data = self.exporter._translate_data([log_data]) + request_dict = MessageToDict(translated_data) + log_records = ( + request_dict.get("resourceLogs")[0] + .get("scopeLogs")[0] + .get("logRecords") + ) + return log_records + + def test_exported_log_without_trace_id(self): + log_records = self.export_log_and_deserialize(self.log_data_4) + if log_records: + log_record = log_records[0] + self.assertIn("spanId", log_record) + self.assertNotIn( + "traceId", + log_record, + "traceId should not be present in the log record", + ) + else: + self.fail("No log records found") + + def test_exported_log_without_span_id(self): + log_records = self.export_log_and_deserialize(self.log_data_5) + if log_records: + log_record = log_records[0] + self.assertIn("traceId", log_record) + self.assertNotIn( + "spanId", + log_record, + "spanId should not be present in the log record", + ) + else: + self.fail("No log records found") + def test_translate_log_data(self): expected = ExportLogsServiceRequest( diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_log_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_log_exporter.py index 6b6aafd465f..e92ea389afb 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_log_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_log_exporter.py @@ -20,6 +20,7 @@ import requests import responses +from google.protobuf.json_format import MessageToDict from opentelemetry._logs import SeverityNumber from opentelemetry.exporter.otlp.proto.http import Compression @@ -31,6 +32,9 @@ OTLPLogExporter, ) from opentelemetry.exporter.otlp.proto.http.version import __version__ +from opentelemetry.proto.collector.logs.v1.logs_service_pb2 import ( + ExportLogsServiceRequest, +) from opentelemetry.sdk._logs import LogData from opentelemetry.sdk._logs import LogRecord as SDKLogRecord from opentelemetry.sdk._logs.export import LogExportResult @@ -167,6 +171,76 @@ def test_exporter_env(self): ) self.assertIsInstance(exporter._session, requests.Session) + @staticmethod + def export_log_and_deserialize(log): + with patch("requests.Session.post") as mock_post: + exporter = OTLPLogExporter() + exporter.export([log]) + request_body = mock_post.call_args[1]["data"] + request = ExportLogsServiceRequest() + request.ParseFromString(request_body) + request_dict = MessageToDict(request) + log_records = ( + request_dict.get("resourceLogs")[0] + .get("scopeLogs")[0] + .get("logRecords") + ) + return log_records + + def test_exported_log_without_trace_id(self): + log = LogData( + log_record=SDKLogRecord( + timestamp=1644650195189786182, + trace_id=0, + span_id=1312458408527513292, + trace_flags=TraceFlags(0x01), + severity_text="WARN", + severity_number=SeverityNumber.WARN, + body="Invalid trace id check", + resource=SDKResource({"first_resource": "value"}), + attributes={"a": 1, "b": "c"}, + ), + instrumentation_scope=InstrumentationScope("name", "version"), + ) + log_records = TestOTLPHTTPLogExporter.export_log_and_deserialize(log) + if log_records: + log_record = log_records[0] + self.assertIn("spanId", log_record) + self.assertNotIn( + "traceId", + log_record, + "trace_id should not be present in the log record", + ) + else: + self.fail("No log records found") + + def test_exported_log_without_span_id(self): + log = LogData( + log_record=SDKLogRecord( + timestamp=1644650195189786360, + trace_id=89564621134313219400156819398935297696, + span_id=0, + trace_flags=TraceFlags(0x01), + severity_text="WARN", + severity_number=SeverityNumber.WARN, + body="Invalid span id check", + resource=SDKResource({"first_resource": "value"}), + attributes={"a": 1, "b": "c"}, + ), + instrumentation_scope=InstrumentationScope("name", "version"), + ) + log_records = TestOTLPHTTPLogExporter.export_log_and_deserialize(log) + if log_records: + log_record = log_records[0] + self.assertIn("traceId", log_record) + self.assertNotIn( + "spanId", + log_record, + "spanId should not be present in the log record", + ) + else: + self.fail("No log records found") + @responses.activate @patch("opentelemetry.exporter.otlp.proto.http._log_exporter.sleep") def test_exponential_backoff(self, mock_sleep): From 5dc48c522d279e57e1a3b505e3411a581eb013fd Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Thu, 11 Jul 2024 12:19:08 -0600 Subject: [PATCH 09/15] Separate lint into several jobs (#3902) * Separate lint into several jobs Fixes #3893 * Remove proto-related packages from getting-started * Add global lint * Fix lint workflow * Revert "Remove proto-related packages from getting-started" This reverts commit 34d61391f9d992fad6d4c5f28d982e0825f838aa. * Do not run getting started tests with pypy * Add missing requirements for lint --- .codespellrc | 2 +- .github/workflows/lint.yml | 54 ++++ .github/workflows/test.yml | 6 +- CONTRIBUTING.md | 2 +- docs/getting_started/__init__.py | 0 docs/getting_started/flask_example.py | 2 +- docs/getting_started/tests/requirements.txt | 3 + docs/getting_started/tests/test_flask.py | 6 +- .../test-requirements.txt | 1 + lint-requirements.txt | 15 + tox.ini | 280 ++++++++++++------ 11 files changed, 281 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 docs/getting_started/__init__.py create mode 100644 lint-requirements.txt diff --git a/.codespellrc b/.codespellrc index b81e62f640c..b82bff46711 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,4 +1,4 @@ [codespell] # skipping auto generated folders -skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions +skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions,*-requirements*.txt ignore-words-list = ans,ue,ot,hist,ro diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000..3ef461853cf --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,54 @@ +name: Lint tests + +on: + push: + branches-ignore: + - 'release/*' + pull_request: + +jobs: + lint-3_12: + strategy: + fail-fast: false # ensures the entire test matrix is run, even if one permutation fails + matrix: + package: + - "opentelemetry-api" + - "opentelemetry-proto" + - "opentelemetry-sdk" + - "opentelemetry-semantic-conventions" + - "opentelemetry-getting-started" + - "opentelemetry-opentracing-shim" + - "opentelemetry-opencensus-shim" + - "opentelemetry-exporter-opencensus" + - "opentelemetry-exporter-otlp-proto-common" + - "opentelemetry-exporter-otlp-combined" + - "opentelemetry-exporter-otlp-proto-grpc" + - "opentelemetry-exporter-otlp-proto-http" + - "opentelemetry-exporter-otlp-proto-prometheus" + - "opentelemetry-exporter-otlp-proto-zipkin-combined" + - "opentelemetry-exporter-otlp-proto-zipkin-proto-http" + - "opentelemetry-exporter-otlp-proto-zipkin-json" + - "opentelemetry-propagator-b3" + - "opentelemetry-propagator-jaeger" + - "opentelemetry-test-utils" + os: [ubuntu-20.04] + runs-on: ubuntu-20.04 + steps: + - name: Checkout Core Repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install tox + run: pip install tox + - name: Cache tox environment + # Preserves .tox directory between runs for faster installs + uses: actions/cache@v4 + with: + path: | + .tox + ~/.cache/pip + key: v7-build-tox-cache-${{ matrix.package }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }} + - name: run tox + run: tox -e lint-${{ matrix.package }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f70b22765a4..179233c9254 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,7 +56,7 @@ jobs: - "exporter-zipkin-combined" - "exporter-zipkin-proto-http" - "exporter-zipkin-json" - - "protobuf" + - "proto" - "propagator-b3" - "propagator-jaeger" os: [ubuntu-20.04, windows-2019] @@ -69,6 +69,8 @@ jobs: package: "exporter-otlp-combined" - python-version: pypy3 package: "exporter-otlp-proto-grpc" + - python-version: pypy3 + package: "getting-started" steps: - name: Checkout Core Repo @ SHA - ${{ github.sha }} @@ -98,7 +100,7 @@ jobs: strategy: fail-fast: false matrix: - tox-environment: ["docker-tests-proto3", "docker-tests-proto4", "lint", "spellcheck", + tox-environment: ["docker-tests-proto3", "docker-tests-proto4", "spellcheck", "docs", "mypy", "mypyinstalled", "tracecontext"] name: ${{ matrix.tox-environment }} runs-on: ubuntu-20.04 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 31eedfef8c6..048a9daa6c8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,7 +57,7 @@ You can run `tox` with the following arguments: - `tox -e py312-opentelemetry-api` to e.g. run the API unit tests under a specific Python version - `tox -e spellcheck` to run a spellcheck on all the code -- `tox -e lint` to run lint checks on all code +- `tox -e lint-some-package` to run lint checks on `some-package` `black` and `isort` are executed when `tox -e lint` is run. The reported errors can be tedious to fix manually. An easier way to do so is: diff --git a/docs/getting_started/__init__.py b/docs/getting_started/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/docs/getting_started/flask_example.py b/docs/getting_started/flask_example.py index 64ed606c7f6..3ddf61d15f5 100644 --- a/docs/getting_started/flask_example.py +++ b/docs/getting_started/flask_example.py @@ -40,7 +40,7 @@ @app.route("/") def hello(): with tracer.start_as_current_span("example-request"): - requests.get("http://www.example.com") + requests.get("http://www.example.com", timeout=10) return "hello" diff --git a/docs/getting_started/tests/requirements.txt b/docs/getting_started/tests/requirements.txt index b22401771a4..41880ca863f 100644 --- a/docs/getting_started/tests/requirements.txt +++ b/docs/getting_started/tests/requirements.txt @@ -23,5 +23,8 @@ Werkzeug==3.0.3 wrapt==1.15.0 zipp==3.19.2 -e opentelemetry-semantic-conventions +-e opentelemetry-proto +-e exporter/opentelemetry-exporter-otlp-proto-common +-e exporter/opentelemetry-exporter-otlp-proto-grpc -e opentelemetry-api -e opentelemetry-sdk diff --git a/docs/getting_started/tests/test_flask.py b/docs/getting_started/tests/test_flask.py index 4d6127f792b..ffaa7deb213 100644 --- a/docs/getting_started/tests/test_flask.py +++ b/docs/getting_started/tests/test_flask.py @@ -19,14 +19,16 @@ import requests from requests.adapters import HTTPAdapter -from requests.packages.urllib3.util.retry import Retry +from requests.packages.urllib3.util.retry import ( # pylint: disable=import-error + Retry, +) class TestFlask(unittest.TestCase): def test_flask(self): dirpath = os.path.dirname(os.path.realpath(__file__)) server_script = f"{dirpath}/../flask_example.py" - server = subprocess.Popen( + server = subprocess.Popen( # pylint: disable=consider-using-with [sys.executable, server_script], stdout=subprocess.PIPE, ) diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt b/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt index a3b296b4805..c1913e6928d 100644 --- a/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt +++ b/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt @@ -17,6 +17,7 @@ urllib3==2.2.2 wrapt==1.16.0 zipp==3.19.2 -e opentelemetry-api +-e opentelemetry-proto -e exporter/opentelemetry-exporter-zipkin-json -e opentelemetry-sdk -e tests/opentelemetry-test-utils diff --git a/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 00000000000..006edb46e8c --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1,15 @@ +astroid==3.0.3 +black==24.3.0 +click==8.1.7 +dill==0.3.8 +flake8==6.1.0 +isort==5.12.0 +mccabe==0.7.0 +mypy-extensions==1.0.0 +packaging==24.0 +pathspec==0.12.1 +platformdirs==4.2.1 +pycodestyle==2.11.1 +pyflakes==3.1.0 +pylint==3.0.2 +tomlkit==0.12.4 diff --git a/tox.ini b/tox.ini index 48ca1f10df8..9d768888c96 100644 --- a/tox.ini +++ b/tox.ini @@ -5,84 +5,101 @@ skip_missing_interpreters = True envlist = ; Environments are organized by individual package, allowing ; for specifying supported Python versions per package. - py3{8,9,10,11,12}-opentelemetry-api - pypy3-opentelemetry-api + + py3{8,9,10,11,12}-test-opentelemetry-api + pypy3-test-opentelemetry-api + lint-opentelemetry-api ; The numbers at the end of the environment names ; below mean these dependencies are being used: ; 0: protobuf==3.20.3 ; 1: protobuf==4.25.3 - py3{8,9,10,11,12}-opentelemetry-protobuf-{0,1} - pypy3-opentelemetry-protobuf-{0,1} + py3{8,9,10,11,12}-test-opentelemetry-proto-{0,1} + pypy3-test-opentelemetry-proto-{0,1} + lint-opentelemetry-proto py3{8,9,10,11,12}-opentelemetry-sdk pypy3-opentelemetry-sdk + lint-opentelemetry-sdk benchmark-opentelemetry-sdk - py3{8,9,10,11,12}-opentelemetry-semantic-conventions - pypy3-opentelemetry-semantic-conventions + py3{8,9,10,11,12}-test-opentelemetry-semantic-conventions + pypy3-test-opentelemetry-semantic-conventions + lint-opentelemetry-semantic-conventions - ; docs/getting-started - py3{8,9,10,11,12}-opentelemetry-getting-started - pypy3-opentelemetry-getting-started + py3{8,9,10,11,12}-test-opentelemetry-getting-started + lint-opentelemetry-getting-started - py3{8,9,10,11,12}-opentelemetry-opentracing-shim - pypy3-opentelemetry-opentracing-shim + py3{8,9,10,11,12}-test-opentelemetry-opentracing-shim + pypy3-test-opentelemetry-opentracing-shim + lint-opentelemetry-opentracing-shim - py3{8,9,10,11,12}-opentelemetry-opencensus-shim + py3{8,9,10,11,12}-test-opentelemetry-opencensus-shim ; opencensus-shim intentionally excluded from pypy3 (grpcio install fails) + lint-opentelemetry-opencensus-shim - py3{8,9,10,11,12}-opentelemetry-exporter-opencensus + py3{8,9,10,11,12}-test-opentelemetry-exporter-opencensus ; exporter-opencensus intentionally excluded from pypy3 + lint-opentelemetry-exporter-opencensus ; The numbers at the end of the environment names ; below mean these dependencies are being used: ; 0: protobuf==3.20.3 ; 1: protobuf==4.25.3 - py3{8,9,10,11,12}-opentelemetry-exporter-otlp-proto-common-{0,1} - pypy3-opentelemetry-exporter-otlp-proto-common-{0,1} + py3{8,9,10,11,12}-test-opentelemetry-exporter-otlp-proto-common-{0,1} + pypy3-test-opentelemetry-exporter-otlp-proto-common-{0,1} + lint-opentelemetry-exporter-otlp-proto-common ; opentelemetry-exporter-otlp - py3{8,9,10,11,12}-opentelemetry-exporter-otlp-combined + py3{8,9,10,11,12}-test-opentelemetry-exporter-otlp-combined ; intentionally excluded from pypy3 + lint-opentelemetry-exporter-otlp-combined ; The numbers at the end of the environment names ; below mean these dependencies are being used: ; 0: protobuf==3.20.3 ; 1: protobuf==4.25.3 - py3{8,9,10,11,12}-opentelemetry-exporter-otlp-proto-grpc-{0,1} + py3{8,9,10,11,12}-test-opentelemetry-exporter-otlp-proto-grpc-{0,1} ; intentionally excluded from pypy3 + lint-opentelemetry-exporter-otlp-proto-grpc ; The numbers at the end of the environment names ; below mean these dependencies are being used: ; 0: protobuf==3.20.3 ; 1: protobuf==4.25.3 - py3{8,9,10,11,12}-opentelemetry-exporter-otlp-proto-http-{0,1} - pypy3-opentelemetry-exporter-otlp-proto-http-{0,1} + py3{8,9,10,11,12}-test-opentelemetry-exporter-otlp-proto-http-{0,1} + pypy3-test-opentelemetry-exporter-otlp-proto-http-{0,1} + lint-opentelemetry-exporter-otlp-proto-http - py3{8,9,10,11,12}-opentelemetry-exporter-prometheus - pypy3-opentelemetry-exporter-prometheus + py3{8,9,10,11,12}-test-opentelemetry-exporter-prometheus + pypy3-test-opentelemetry-exporter-prometheus + lint-opentelemetry-exporter-prometheus ; opentelemetry-exporter-zipkin - py3{8,9,10,11,12}-opentelemetry-exporter-zipkin-combined - pypy3-opentelemetry-exporter-zipkin-combined + py3{8,9,10,11,12}-test-opentelemetry-exporter-zipkin-combined + pypy3-test-opentelemetry-exporter-zipkin-combined + lint-opentelemetry-exporter-zipkin-combined - py3{8,9,10,11,12}-opentelemetry-exporter-zipkin-proto-http - pypy3-opentelemetry-exporter-zipkin-proto-http + py3{8,9,10,11,12}-test-opentelemetry-exporter-zipkin-proto-http + pypy3-test-opentelemetry-exporter-zipkin-proto-http + lint-opentelemetry-exporter-zipkin-proto-http - py3{8,9,10,11,12}-opentelemetry-exporter-zipkin-json - pypy3-opentelemetry-exporter-zipkin-json + py3{8,9,10,11,12}-test-opentelemetry-exporter-zipkin-json + pypy3-test-opentelemetry-exporter-zipkin-json + lint-opentelemetry-exporter-zipkin-json - py3{8,9,10,11,12}-opentelemetry-propagator-b3 - pypy3-opentelemetry-propagator-b3 + py3{8,9,10,11,12}-test-opentelemetry-propagator-b3 + pypy3-test-opentelemetry-propagator-b3 + lint-opentelemetry-propagator-b3 - py3{8,9,10,11,12}-opentelemetry-propagator-jaeger - pypy3-opentelemetry-propagator-jaeger + py3{8,9,10,11,12}-test-opentelemetry-propagator-jaeger + pypy3-test-opentelemetry-propagator-jaeger + lint-opentelemetry-propagator-jaeger - py3{8,9,10,11,12}-opentelemetry-test-utils - pypy3-opentelemetry-test-utils + py3{8,9,10,11,12}-test-opentelemetry-test-utils + pypy3-test-opentelemetry-test-utils + lint-opentelemetry-test-utils - lint spellcheck tracecontext mypy,mypyinstalled @@ -92,6 +109,7 @@ envlist = [testenv] deps = + lint: -r dev-requirements.txt coverage: pytest coverage: pytest-cov @@ -120,8 +138,9 @@ commands_pre = test-utils: pip install -r {toxinidir}/tests/opentelemetry-test-utils/test-requirements.txt - protobuf-0: pip install -r {toxinidir}/opentelemetry-proto/test-requirements-0.txt - protobuf-1: pip install -r {toxinidir}/opentelemetry-proto/test-requirements-1.txt + opentelemetry-proto-0: pip install -r {toxinidir}/opentelemetry-proto/test-requirements-0.txt + opentelemetry-proto-1: pip install -r {toxinidir}/opentelemetry-proto/test-requirements-1.txt + lint-opentelemetry-proto: pip install -r {toxinidir}/opentelemetry-proto/test-requirements-1.txt getting-started: pip install -r {toxinidir}/docs/getting_started/tests/requirements.txt getting-started: pip install -e {env:CONTRIB_REPO}\#egg=opentelemetry-util-http&subdirectory=util/opentelemetry-util-http @@ -134,14 +153,17 @@ commands_pre = exporter-otlp-proto-common-0: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-0.txt exporter-otlp-proto-common-1: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-1.txt + lint-opentelemetry-exporter-otlp-proto-common: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-1.txt exporter-otlp-combined: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp/test-requirements.txt opentelemetry-exporter-otlp-proto-grpc-0: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt opentelemetry-exporter-otlp-proto-grpc-1: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt + lint-opentelemetry-exporter-otlp-proto-grpc: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt opentelemetry-exporter-otlp-proto-http-0: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-0.txt opentelemetry-exporter-otlp-proto-http-1: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-1.txt + lint-opentelemetry-exporter-otlp-proto-http: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-1.txt opentracing-shim: pip install -r {toxinidir}/shim/opentelemetry-opentracing-shim/test-requirements.txt @@ -168,28 +190,138 @@ commands_pre = mypyinstalled: pip install file://{toxinidir}/opentelemetry-api/ commands = - api: pytest {toxinidir}/opentelemetry-api/tests {posargs} - sdk: pytest {toxinidir}/opentelemetry-sdk/tests {posargs} + test-opentelemetry-api: pytest {toxinidir}/opentelemetry-api/tests {posargs} + lint-opentelemetry-api: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-api + lint-opentelemetry-api: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-api + lint-opentelemetry-api: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-api + lint-opentelemetry-api: pylint {toxinidir}/opentelemetry-api/src/opentelemetry + lint-opentelemetry-api: pylint {toxinidir}/opentelemetry-api/tests + + test-opentelemetry-sdk: pytest {toxinidir}/opentelemetry-sdk/tests {posargs} + lint-opentelemetry-sdk: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-sdk + lint-opentelemetry-sdk: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-sdk + lint-opentelemetry-sdk: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-sdk + lint-opentelemetry-sdk: pylint {toxinidir}/opentelemetry-sdk/src/opentelemetry + lint-opentelemetry-sdk: pylint {toxinidir}/opentelemetry-sdk/tests benchmark-opentelemetry-sdk: pytest {toxinidir}/opentelemetry-sdk/benchmarks {posargs} --benchmark-json=sdk-benchmark.json - protobuf: pytest {toxinidir}/opentelemetry-proto/tests {posargs} - semantic-conventions: pytest {toxinidir}/opentelemetry-semantic-conventions/tests {posargs} - getting-started: pytest {toxinidir}/docs/getting_started/tests {posargs} - opentracing-shim: pytest {toxinidir}/shim/opentelemetry-opentracing-shim/tests {posargs} - opencensus-shim: pytest {toxinidir}/shim/opentelemetry-opencensus-shim/tests {posargs} - - exporter-opencensus: pytest {toxinidir}/exporter/opentelemetry-exporter-opencensus/tests {posargs} - exporter-otlp-proto-common: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/tests {posargs} - exporter-otlp-combined: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp/tests {posargs} - exporter-otlp-proto-grpc: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/tests {posargs} - exporter-otlp-proto-http: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/tests {posargs} - exporter-prometheus: pytest {toxinidir}/exporter/opentelemetry-exporter-prometheus/tests {posargs} - exporter-zipkin-combined: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin/tests {posargs} - exporter-zipkin-proto-http: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/tests {posargs} - exporter-zipkin-json: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/tests {posargs} - - propagator-b3: pytest {toxinidir}/propagator/opentelemetry-propagator-b3/tests {posargs} - propagator-jaeger: pytest {toxinidir}/propagator/opentelemetry-propagator-jaeger/tests {posargs} - test-utils: pytest {toxinidir}/tests/opentelemetry-test-utils/tests {posargs} + + test-opentelemetry-proto: pytest {toxinidir}/opentelemetry-proto/tests {posargs} + lint-opentelemetry-proto: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-proto + lint-opentelemetry-proto: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-proto + lint-opentelemetry-proto: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-proto + lint-opentelemetry-proto: pylint {toxinidir}/opentelemetry-proto/src/opentelemetry + lint-opentelemetry-proto: pylint {toxinidir}/opentelemetry-proto/tests + + test-opentelemetry-semantic-conventions: pytest {toxinidir}/opentelemetry-semantic-conventions/tests {posargs} + lint-opentelemetry-semantic-conventions: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-semantic-conventions + lint-opentelemetry-semantic-conventions: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-semantic-conventions + lint-opentelemetry-semantic-conventions: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-semantic-conventions + lint-opentelemetry-semantic-conventions: pylint {toxinidir}/opentelemetry-semantic-conventions/src/opentelemetry + lint-opentelemetry-semantic-conventions: pylint {toxinidir}/opentelemetry-semantic-conventions/tests + + test-opentelemetry-getting-started: pytest {toxinidir}/docs/getting_started/tests {posargs} + lint-opentelemetry-getting-started: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/docs/getting_started + lint-opentelemetry-getting-started: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/docs/getting_started + lint-opentelemetry-getting-started: flake8 --config {toxinidir}/.flake8 {toxinidir}/docs/getting_started + lint-opentelemetry-getting-started: pylint {toxinidir}/docs/getting_started + + test-opentelemetry-opentracing-shim: pytest {toxinidir}/shim/opentelemetry-opentracing-shim/tests {posargs} + lint-opentelemetry-opentracing-shim: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/shim/opentelemetry-opentracing-shim + lint-opentelemetry-opentracing-shim: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/shim/opentelemetry-opentracing-shim + lint-opentelemetry-opentracing-shim: flake8 --config {toxinidir}/.flake8 {toxinidir}/shim/opentelemetry-opentracing-shim + lint-opentelemetry-opentracing-shim: pylint {toxinidir}/shim/opentelemetry-opentracing-shim/src/opentelemetry + lint-opentelemetry-opentracing-shim: pylint {toxinidir}/shim/opentelemetry-opentracing-shim/tests + + test-opentelemetry-opencensus-shim: pytest {toxinidir}/shim/opentelemetry-opencensus-shim/tests {posargs} + lint-opentelemetry-opencensus-shim: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/shim/opentelemetry-opencensus-shim + lint-opentelemetry-opencensus-shim: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/shim/opentelemetry-opencensus-shim + lint-opentelemetry-opencensus-shim: flake8 --config {toxinidir}/.flake8 {toxinidir}/shim/opentelemetry-opencensus-shim + lint-opentelemetry-opencensus-shim: pylint {toxinidir}/shim/opentelemetry-opencensus-shim/src/opentelemetry + lint-opentelemetry-opencensus-shim: pylint {toxinidir}/shim/opentelemetry-opencensus-shim/tests + + test-opentelemetry-exporter-opencensus: pytest {toxinidir}/exporter/opentelemetry-exporter-opencensus/tests {posargs} + lint-opentelemetry-exporter-opencensus: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-opencensus + lint-opentelemetry-exporter-opencensus: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-opencensus + lint-opentelemetry-exporter-opencensus: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-opencensus + lint-opentelemetry-exporter-opencensus: pylint {toxinidir}/exporter/opentelemetry-exporter-opencensus/src/opentelemetry + lint-opentelemetry-exporter-opencensus: pylint {toxinidir}/exporter/opentelemetry-exporter-opencensus/tests + + test-opentelemetry-exporter-otlp-proto-common: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/tests {posargs} + lint-opentelemetry-exporter-otlp-proto-common: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common + lint-opentelemetry-exporter-otlp-proto-common: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common + lint-opentelemetry-exporter-otlp-proto-common: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common + lint-opentelemetry-exporter-otlp-proto-common: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry + lint-opentelemetry-exporter-otlp-proto-common: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/tests + + test-opentelemetry-exporter-otlp-combined: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp/tests {posargs} + lint-opentelemetry-exporter-otlp-combined: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp + lint-opentelemetry-exporter-otlp-combined: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp + lint-opentelemetry-exporter-otlp-combined: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp + lint-opentelemetry-exporter-otlp-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp/src/opentelemetry + lint-opentelemetry-exporter-otlp-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp/tests + + test-opentelemetry-exporter-otlp-proto-grpc: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/tests {posargs} + lint-opentelemetry-exporter-otlp-proto-grpc: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc + lint-opentelemetry-exporter-otlp-proto-grpc: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc + lint-opentelemetry-exporter-otlp-proto-grpc: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc + lint-opentelemetry-exporter-otlp-proto-grpc: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry + lint-opentelemetry-exporter-otlp-proto-grpc: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/tests + + test-opentelemetry-exporter-otlp-proto-http: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/tests {posargs} + lint-opentelemetry-exporter-otlp-proto-http: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http + lint-opentelemetry-exporter-otlp-proto-http: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http + lint-opentelemetry-exporter-otlp-proto-http: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http + lint-opentelemetry-exporter-otlp-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry + lint-opentelemetry-exporter-otlp-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/tests + + test-opentelemetry-exporter-prometheus: pytest {toxinidir}/exporter/opentelemetry-exporter-prometheus/tests {posargs} + lint-opentelemetry-exporter-prometheus: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-prometheus + lint-opentelemetry-exporter-prometheus: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-prometheus + lint-opentelemetry-exporter-prometheus: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-prometheus + lint-opentelemetry-exporter-prometheus: pylint {toxinidir}/exporter/opentelemetry-exporter-prometheus/src/opentelemetry + lint-opentelemetry-exporter-prometheus: pylint {toxinidir}/exporter/opentelemetry-exporter-prometheus/tests + + test-opentelemetry-exporter-zipkin-combined: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin/tests {posargs} + lint-opentelemetry-exporter-zipkin-combined: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-zipkin + lint-opentelemetry-exporter-zipkin-combined: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-zipkin + lint-opentelemetry-exporter-zipkin-combined: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-zipkin + lint-opentelemetry-exporter-zipkin-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin/src/opentelemetry + lint-opentelemetry-exporter-zipkin-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin/tests + + test-opentelemetry-exporter-zipkin-proto-http: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/tests {posargs} + lint-opentelemetry-exporter-zipkin-proto-http: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http + lint-opentelemetry-exporter-zipkin-proto-http: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http + lint-opentelemetry-exporter-zipkin-proto-http: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http + lint-opentelemetry-exporter-zipkin-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry + lint-opentelemetry-exporter-zipkin-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/tests + + test-opentelemetry-exporter-zipkin-json: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/tests {posargs} + lint-opentelemetry-exporter-zipkin-json: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-zipkin-json + lint-opentelemetry-exporter-zipkin-json: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-zipkin-json + lint-opentelemetry-exporter-zipkin-json: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-zipkin-json + lint-opentelemetry-exporter-zipkin-json: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry + lint-opentelemetry-exporter-zipkin-json: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/tests + + test-opentelemetry-propagator-b3: pytest {toxinidir}/propagator/opentelemetry-propagator-b3/tests {posargs} + lint-opentelemetry-propagator-b3: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/propagator/opentelemetry-propagator-b3 + lint-opentelemetry-propagator-b3: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/propagator/opentelemetry-propagator-b3 + lint-opentelemetry-propagator-b3: flake8 --config {toxinidir}/.flake8 {toxinidir}/propagator/opentelemetry-propagator-b3 + lint-opentelemetry-propagator-b3: pylint {toxinidir}/propagator/opentelemetry-propagator-b3/src/opentelemetry + lint-opentelemetry-propagator-b3: pylint {toxinidir}/propagator/opentelemetry-propagator-b3/tests + + test-opentelemetry-propagator-jaeger: pytest {toxinidir}/propagator/opentelemetry-propagator-jaeger/tests {posargs} + lint-opentelemetry-propagator-jaeger: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/propagator/opentelemetry-propagator-jaeger + lint-opentelemetry-propagator-jaeger: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/propagator/opentelemetry-propagator-jaeger + lint-opentelemetry-propagator-jaeger: flake8 --config {toxinidir}/.flake8 {toxinidir}/propagator/opentelemetry-propagator-jaeger + lint-opentelemetry-propagator-jaeger: pylint {toxinidir}/propagator/opentelemetry-propagator-jaeger/src/opentelemetry + lint-opentelemetry-propagator-jaeger: pylint {toxinidir}/propagator/opentelemetry-propagator-jaeger/tests + + test-opentelemetry-test-utils: pytest {toxinidir}/tests/opentelemetry-test-utils/tests {posargs} + lint-opentelemetry-test-utils: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/tests/opentelemetry-test-utils + lint-opentelemetry-test-utils: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/tests/opentelemetry-test-utils + lint-opentelemetry-test-utils: flake8 --config {toxinidir}/.flake8 {toxinidir}/tests/opentelemetry-test-utils + lint-opentelemetry-test-utils: pylint {toxinidir}/tests/opentelemetry-test-utils/src/opentelemetry + lint-opentelemetry-test-utils: pylint {toxinidir}/tests/opentelemetry-test-utils/tests coverage: {toxinidir}/scripts/coverage.sh @@ -203,43 +335,25 @@ commands = ; implicit Any due to unfollowed import would result). mypyinstalled: mypy --install-types --non-interactive --namespace-packages opentelemetry-api/tests/mypysmoke.py --strict -[testenv:spellcheck] +[testenv:lint] basepython: python3 recreate = True deps = - codespell==2.2.6 + -r dev-requirements.txt commands = - codespell + black --config {toxinidir}/pyproject.toml {toxinidir} --diff --check + isort --settings-path {toxinidir}/.isort.cfg {toxinidir} --diff --check-only + flake8 --config {toxinidir}/.flake8 {toxinidir} -[testenv:lint] +[testenv:spellcheck] basepython: python3 recreate = True deps = - -r dev-requirements.txt - -commands_pre = - pip install -r {toxinidir}/opentelemetry-api/test-requirements.txt \ - -r {toxinidir}/opentelemetry-sdk/test-requirements.txt \ - -r {toxinidir}/opentelemetry-semantic-conventions/test-requirements.txt \ - -r {toxinidir}/opentelemetry-proto/test-requirements-0.txt \ - -r {toxinidir}/shim/opentelemetry-opentracing-shim/test-requirements.txt \ - -r {toxinidir}/shim/opentelemetry-opencensus-shim/test-requirements.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-opencensus/test-requirements.txt \ - -r {toxinidir}/tests/opentelemetry-test-utils/test-requirements.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements-0.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-0.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-prometheus/test-requirements.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-otlp/test-requirements.txt \ - -r {toxinidir}/exporter/opentelemetry-exporter-zipkin/test-requirements.txt \ - -r {toxinidir}/propagator/opentelemetry-propagator-b3/test-requirements.txt \ - -r {toxinidir}/propagator/opentelemetry-propagator-jaeger/test-requirements.txt + codespell==2.2.6 commands = - python scripts/eachdist.py lint --check-only + codespell [testenv:docs] basepython: python3 From 7237f78edfcf011755697e3fcc3ca20561ce1417 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Thu, 11 Jul 2024 13:06:01 -0600 Subject: [PATCH 10/15] Skip test case in pypy or windows (#3986) * Skip test case when running in Windows or Pypy Fixes #3985 * Use pytest-retry on flaky test case * Remove flaky * Use flaky instead * Revert "Use flaky instead" This reverts commit 4d433d658eb9eab0b9684ed58d7c7ca1e0ad3127. * Revert "Remove flaky" This reverts commit cc26486d272d44240d55fbd442099e9f3187258b. * Revert "Use pytest-retry on flaky test case" This reverts commit e96ea890086bf818bc5435f1ea32b0386c8f8231. * One last attempt with a forced delay * Revert "One last attempt with a forced delay" This reverts commit 75717d9fa0bf6a34ec1cca9f2624fb398d197b3d. * Fix comment * Fix zipp requirements * Remove flaky --- opentelemetry-sdk/tests/trace/export/test_export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opentelemetry-sdk/tests/trace/export/test_export.py b/opentelemetry-sdk/tests/trace/export/test_export.py index 2ba76e9b41f..7a29ef3c42d 100644 --- a/opentelemetry-sdk/tests/trace/export/test_export.py +++ b/opentelemetry-sdk/tests/trace/export/test_export.py @@ -462,8 +462,8 @@ def _target(): span_processor.shutdown() @mark.skipif( - python_implementation() == "PyPy" and system() == "Windows", - reason="This test randomly fails with huge delta in Windows with PyPy", + python_implementation() == "PyPy" or system() == "Windows", + reason="This test randomly fails with huge delta in Windows or PyPy", ) def test_batch_span_processor_scheduled_delay(self): """Test that spans are exported each schedule_delay_millis""" From 0115d2f579ed1ea6161b1e44fbe64586200e4e66 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Thu, 11 Jul 2024 17:26:09 -0600 Subject: [PATCH 11/15] Set _LastValueAggregation start_time_unix_nano to None (#4004) * Sest _LastValueAggregation start_time_unix_nano to None Fixes #3678 * Use None in test utils too --------- Co-authored-by: Riccardo Magliocchetti --- .../tests/test_metrics_encoder.py | 1 + .../src/opentelemetry/sdk/metrics/_internal/aggregation.py | 2 +- opentelemetry-sdk/tests/metrics/test_aggregation.py | 4 ++++ .../src/opentelemetry/test/metrictestutil.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_metrics_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_metrics_encoder.py index 70863bb44a7..6d68b48f250 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_metrics_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_metrics_encoder.py @@ -296,6 +296,7 @@ def test_encode_gauge_int(self): ), ], time_unix_nano=1641946016139533244, + start_time_unix_nano=0, as_int=9000, ) ], diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py index b389cc6ba5c..3a09cdcfea1 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py @@ -370,7 +370,7 @@ def collect( return NumberDataPoint( attributes=self._attributes, - start_time_unix_nano=0, + start_time_unix_nano=None, time_unix_nano=collection_start_nano, value=value, ) diff --git a/opentelemetry-sdk/tests/metrics/test_aggregation.py b/opentelemetry-sdk/tests/metrics/test_aggregation.py index 37656b0a34c..fb87d177e8d 100644 --- a/opentelemetry-sdk/tests/metrics/test_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/test_aggregation.py @@ -236,6 +236,8 @@ def test_collect(self): self.assertEqual(first_number_data_point.value, 1) + self.assertIsNone(first_number_data_point.start_time_unix_nano) + last_value_aggregation.aggregate(measurement(1)) # CI fails the last assertion without this @@ -249,6 +251,8 @@ def test_collect(self): self.assertEqual(second_number_data_point.value, 1) + self.assertIsNone(second_number_data_point.start_time_unix_nano) + self.assertGreater( second_number_data_point.time_unix_nano, first_number_data_point.time_unix_nano, diff --git a/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py b/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py index 08354bf0de4..33f1039ef87 100644 --- a/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py +++ b/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py @@ -83,7 +83,7 @@ def _generate_gauge( data_points=[ NumberDataPoint( attributes=attributes, - start_time_unix_nano=1641946015139533244, + start_time_unix_nano=None, time_unix_nano=1641946016139533244, value=value, ) From c883f6cc1243ab7e0e5bc177169f25cdf0aac29f Mon Sep 17 00:00:00 2001 From: Lakshya Singh Date: Fri, 12 Jul 2024 06:37:17 +0530 Subject: [PATCH 12/15] add missing dependency - deprecated (#4046) Signed-off-by: Lakshya Singh --- opentelemetry-semantic-conventions/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/opentelemetry-semantic-conventions/pyproject.toml b/opentelemetry-semantic-conventions/pyproject.toml index a370e905334..17954a3485a 100644 --- a/opentelemetry-semantic-conventions/pyproject.toml +++ b/opentelemetry-semantic-conventions/pyproject.toml @@ -28,6 +28,7 @@ classifiers = [ dependencies = [ "opentelemetry-api == 1.26.0.dev", + "Deprecated >= 1.2.6", ] [project.urls] From 9304017cc0e75602e8b8e8ab933ffe2a253e3887 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Fri, 12 Jul 2024 11:03:01 -0600 Subject: [PATCH 13/15] Move benchmarks for b3 propagator and grpc exporter (#4050) Fixs #4049 Co-authored-by: Leighton Chen --- .../benchmark-requirements.txt | 1 + .../benchmarks/test_benchmark_trace_exporter.py | 0 .../test-requirements-0.txt | 1 - .../test-requirements-1.txt | 1 - opentelemetry-sdk/test-requirements.txt | 1 - .../opentelemetry-propagator-b3/benchmark-requirements.txt | 1 + .../trace/propagation/test_benchmark_b3_format.py | 0 .../opentelemetry-propagator-b3/test-requirements.txt | 1 - tox.ini | 6 ++++++ 9 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt rename exporter/opentelemetry-exporter-otlp-proto-grpc/{tests/performance => }/benchmarks/test_benchmark_trace_exporter.py (100%) create mode 100644 propagator/opentelemetry-propagator-b3/benchmark-requirements.txt rename propagator/opentelemetry-propagator-b3/{tests/performance => }/benchmarks/trace/propagation/test_benchmark_b3_format.py (100%) diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt b/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt new file mode 100644 index 00000000000..44564857ef4 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt @@ -0,0 +1 @@ +pytest-benchmark==4.0.0 diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/performance/benchmarks/test_benchmark_trace_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks/test_benchmark_trace_exporter.py similarity index 100% rename from exporter/opentelemetry-exporter-otlp-proto-grpc/tests/performance/benchmarks/test_benchmark_trace_exporter.py rename to exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks/test_benchmark_trace_exporter.py diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt index 5c9bd04d4db..abbd8927d0f 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt @@ -9,7 +9,6 @@ pluggy==1.5.0 protobuf==3.20.3 py-cpuinfo==9.0.0 pytest==7.4.4 -pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt index 50cbb0c2fe4..250b55bed86 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt @@ -9,7 +9,6 @@ pluggy==1.5.0 protobuf==4.25.3 py-cpuinfo==9.0.0 pytest==7.4.4 -pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 diff --git a/opentelemetry-sdk/test-requirements.txt b/opentelemetry-sdk/test-requirements.txt index 1edbe859610..8a7ccc7bd78 100644 --- a/opentelemetry-sdk/test-requirements.txt +++ b/opentelemetry-sdk/test-requirements.txt @@ -7,7 +7,6 @@ packaging==24.0 pluggy==1.5.0 py-cpuinfo==9.0.0 pytest==7.4.4 -pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 diff --git a/propagator/opentelemetry-propagator-b3/benchmark-requirements.txt b/propagator/opentelemetry-propagator-b3/benchmark-requirements.txt new file mode 100644 index 00000000000..44564857ef4 --- /dev/null +++ b/propagator/opentelemetry-propagator-b3/benchmark-requirements.txt @@ -0,0 +1 @@ +pytest-benchmark==4.0.0 diff --git a/propagator/opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py b/propagator/opentelemetry-propagator-b3/benchmarks/trace/propagation/test_benchmark_b3_format.py similarity index 100% rename from propagator/opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py rename to propagator/opentelemetry-propagator-b3/benchmarks/trace/propagation/test_benchmark_b3_format.py diff --git a/propagator/opentelemetry-propagator-b3/test-requirements.txt b/propagator/opentelemetry-propagator-b3/test-requirements.txt index a86ca788eda..9fea63eff92 100644 --- a/propagator/opentelemetry-propagator-b3/test-requirements.txt +++ b/propagator/opentelemetry-propagator-b3/test-requirements.txt @@ -6,7 +6,6 @@ packaging==24.0 pluggy==1.5.0 py-cpuinfo==9.0.0 pytest==7.4.4 -pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 diff --git a/tox.ini b/tox.ini index 9d768888c96..dfa3edd0289 100644 --- a/tox.ini +++ b/tox.ini @@ -62,6 +62,7 @@ envlist = py3{8,9,10,11,12}-test-opentelemetry-exporter-otlp-proto-grpc-{0,1} ; intentionally excluded from pypy3 lint-opentelemetry-exporter-otlp-proto-grpc + benchmark-opentelemetry-exporter-otlp-proto-grpc ; The numbers at the end of the environment names ; below mean these dependencies are being used: @@ -91,6 +92,7 @@ envlist = py3{8,9,10,11,12}-test-opentelemetry-propagator-b3 pypy3-test-opentelemetry-propagator-b3 lint-opentelemetry-propagator-b3 + benchmark-opentelemetry-propagator-b3 py3{8,9,10,11,12}-test-opentelemetry-propagator-jaeger pypy3-test-opentelemetry-propagator-jaeger @@ -160,6 +162,7 @@ commands_pre = opentelemetry-exporter-otlp-proto-grpc-0: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-0.txt opentelemetry-exporter-otlp-proto-grpc-1: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt lint-opentelemetry-exporter-otlp-proto-grpc: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements-1.txt + benchmark-exporter-otlp-proto-grpc: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt opentelemetry-exporter-otlp-proto-http-0: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-0.txt opentelemetry-exporter-otlp-proto-http-1: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements-1.txt @@ -178,6 +181,7 @@ commands_pre = exporter-zipkin-json: pip install -r {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt propagator-b3: pip install -r {toxinidir}/propagator/opentelemetry-propagator-b3/test-requirements.txt + benchmark-opentelemetry-propagator-b3: pip install -r {toxinidir}/propagator/opentelemetry-propagator-b3/benchmark-requirements.txt propagator-jaeger: pip install -r {toxinidir}/propagator/opentelemetry-propagator-jaeger/test-requirements.txt @@ -266,6 +270,7 @@ commands = lint-opentelemetry-exporter-otlp-proto-grpc: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc lint-opentelemetry-exporter-otlp-proto-grpc: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry lint-opentelemetry-exporter-otlp-proto-grpc: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/tests + benchmark-opentelemetry-exporter-otlp-proto-grpc: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks {posargs} --benchmark-json=exporter-otlp-proto-grpc-benchmark.json test-opentelemetry-exporter-otlp-proto-http: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/tests {posargs} lint-opentelemetry-exporter-otlp-proto-http: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http @@ -308,6 +313,7 @@ commands = lint-opentelemetry-propagator-b3: flake8 --config {toxinidir}/.flake8 {toxinidir}/propagator/opentelemetry-propagator-b3 lint-opentelemetry-propagator-b3: pylint {toxinidir}/propagator/opentelemetry-propagator-b3/src/opentelemetry lint-opentelemetry-propagator-b3: pylint {toxinidir}/propagator/opentelemetry-propagator-b3/tests + benchmark-opentelemetry-propagator-b3: pytest {toxinidir}/propagator/opentelemetry-propagator-b3/benchmarks {posargs} --benchmark-json=propagator-b3-benchmark.json test-opentelemetry-propagator-jaeger: pytest {toxinidir}/propagator/opentelemetry-propagator-jaeger/tests {posargs} lint-opentelemetry-propagator-jaeger: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/propagator/opentelemetry-propagator-jaeger From a67f5f8f225647c726cda43033bc5077ced724e3 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 12 Jul 2024 11:30:09 -0700 Subject: [PATCH 14/15] =?UTF-8?q?Add=20Em=C3=ADdio=20Neto=20as=20an=20appr?= =?UTF-8?q?over=20(#4052)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 588b7ccb399..3bf66016dea 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Meeting notes are available as a public [Google doc](https://docs.google.com/doc Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)): - [Aaron Abbott](https://github.com/aabmass), Google +- [Emídio Neto](https://github.com/emdneto), Zenvia - [Jeremy Voss](https://github.com/jeremydvoss), Microsoft - [Owais Lone](https://github.com/owais), Splunk - [Pablo Collins](https://github.com/pmcollins), Splunk From b79a9650fb92a28989e7b1986373c43c2290fad5 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Mon, 15 Jul 2024 06:56:44 -0600 Subject: [PATCH 15/15] Point pylint to the root directory of every package (#4048) * Point pylint to the root directory of every package Fixes #3814 * Fix lint for api * Fix sdk lint * Fix sdk lint * Fix lint for b3 * Fix tox ini and lint * Fix zipkin --- .../test_benchmark_trace_exporter.py | 2 + .../tests/attributes/test_attributes.py | 4 +- .../tests/logs/test_logger_provider.py | 14 +++-- .../tests/metrics/test_instruments.py | 2 + opentelemetry-api/tests/metrics/test_meter.py | 18 +++--- .../tests/metrics/test_meter_provider.py | 7 ++- .../metrics/test_subclass_instantiation.py | 2 + .../propagators/test_global_httptextformat.py | 6 +- .../propagators/test_w3cbaggagepropagator.py | 4 +- .../test_tracecontexthttptextformat.py | 6 +- .../tests/util/test__providers.py | 4 +- .../metrics/test_benchmark_metrics.py | 2 + ...py => test_benchmark_metrics_histogram.py} | 12 ++-- .../benchmarks/trace/test_benchmark_trace.py | 5 +- .../test_exponent_mapping.py | 5 +- ...xponential_bucket_histogram_aggregation.py | 7 ++- .../test_logarithm_mapping.py | 5 +- ...t_explicit_bucket_histogram_aggregation.py | 2 + .../tests/metrics/test_aggregation.py | 2 + .../tests/metrics/test_backward_compat.py | 4 +- .../tests/metrics/test_import.py | 2 +- .../metrics/test_in_memory_metric_reader.py | 2 + .../tests/metrics/test_instrument.py | 3 +- .../metrics/test_measurement_consumer.py | 2 + .../tests/metrics/test_metric_reader.py | 5 +- .../metrics/test_metric_reader_storage.py | 2 + .../tests/metrics/test_metrics.py | 23 ++++---- .../test_periodic_exporting_metric_reader.py | 9 ++- opentelemetry-sdk/tests/metrics/test_point.py | 6 -- opentelemetry-sdk/tests/metrics/test_view.py | 2 + .../metrics/test_view_instrument_match.py | 4 +- .../propagation/test_benchmark_b3_format.py | 4 +- tox.ini | 59 +++++++------------ 33 files changed, 135 insertions(+), 101 deletions(-) rename opentelemetry-sdk/benchmarks/metrics/{test_benchmark_metrics_histogram,.py => test_benchmark_metrics_histogram.py} (92%) diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks/test_benchmark_trace_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks/test_benchmark_trace_exporter.py index 2b39a8feb33..9051dbeed0c 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks/test_benchmark_trace_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks/test_benchmark_trace_exporter.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=invalid-name + from unittest.mock import patch from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( diff --git a/opentelemetry-api/tests/attributes/test_attributes.py b/opentelemetry-api/tests/attributes/test_attributes.py index 61388de722b..cf6aecb41fa 100644 --- a/opentelemetry-api/tests/attributes/test_attributes.py +++ b/opentelemetry-api/tests/attributes/test_attributes.py @@ -21,6 +21,7 @@ class TestAttributes(unittest.TestCase): + # pylint: disable=invalid-name def assertValid(self, value, key="k"): expected = value if isinstance(value, MutableSequence): @@ -89,6 +90,7 @@ def test_sequence_attr_decode(self): class TestBoundedAttributes(unittest.TestCase): + # pylint: disable=consider-using-dict-items base = { "name": "Firulais", "age": 7, @@ -188,7 +190,7 @@ def test_locking(self): """ bdict = BoundedAttributes(immutable=False) - with bdict._lock: + with bdict._lock: # pylint: disable=protected-access for num in range(100): bdict[str(num)] = num diff --git a/opentelemetry-api/tests/logs/test_logger_provider.py b/opentelemetry-api/tests/logs/test_logger_provider.py index 84f3f13e9c3..71f403c695f 100644 --- a/opentelemetry-api/tests/logs/test_logger_provider.py +++ b/opentelemetry-api/tests/logs/test_logger_provider.py @@ -34,16 +34,16 @@ def tearDown(self): def test_set_logger_provider(self): lp_mock = Mock() # pylint: disable=protected-access - assert logs_internal._LOGGER_PROVIDER is None + self.assertIsNone(logs_internal._LOGGER_PROVIDER) set_logger_provider(lp_mock) - assert logs_internal._LOGGER_PROVIDER is lp_mock - assert get_logger_provider() is lp_mock + self.assertIs(logs_internal._LOGGER_PROVIDER, lp_mock) + self.assertIs(get_logger_provider(), lp_mock) def test_get_logger_provider(self): # pylint: disable=protected-access - assert logs_internal._LOGGER_PROVIDER is None + self.assertIsNone(logs_internal._LOGGER_PROVIDER) - assert isinstance( + self.assertIsInstance( get_logger_provider(), logs_internal.ProxyLoggerProvider ) @@ -59,4 +59,6 @@ def test_get_logger_provider(self): "opentelemetry._logs._internal.cast", Mock(**{"return_value": "test_logger_provider"}), ): - assert get_logger_provider() == "test_logger_provider" + self.assertEqual( + get_logger_provider(), "test_logger_provider" + ) diff --git a/opentelemetry-api/tests/metrics/test_instruments.py b/opentelemetry-api/tests/metrics/test_instruments.py index 12267433af0..840fbf6e132 100644 --- a/opentelemetry-api/tests/metrics/test_instruments.py +++ b/opentelemetry-api/tests/metrics/test_instruments.py @@ -36,6 +36,7 @@ class ChildInstrument(Instrument): + # pylint: disable=useless-parent-delegation def __init__(self, name, *args, unit="", description="", **kwargs): super().__init__( name, *args, unit=unit, description=description, **kwargs @@ -500,6 +501,7 @@ def test_up_down_counter_add_method(self): class TestObservableUpDownCounter(TestCase): + # pylint: disable=protected-access def test_create_observable_up_down_counter(self): """ Test that the ObservableUpDownCounter can be created with create_observable_up_down_counter. diff --git a/opentelemetry-api/tests/metrics/test_meter.py b/opentelemetry-api/tests/metrics/test_meter.py index 2226965521e..984690bdbbf 100644 --- a/opentelemetry-api/tests/metrics/test_meter.py +++ b/opentelemetry-api/tests/metrics/test_meter.py @@ -23,6 +23,7 @@ class ChildMeter(Meter): + # pylint: disable=signature-differs def create_counter(self, name, unit="", description=""): super().create_counter(name, unit=unit, description=description) @@ -32,10 +33,10 @@ def create_up_down_counter(self, name, unit="", description=""): ) def create_observable_counter( - self, name, callback, unit="", description="" + self, name, callbacks, unit="", description="" ): super().create_observable_counter( - name, callback, unit=unit, description=description + name, callbacks, unit=unit, description=description ) def create_histogram(self, name, unit="", description=""): @@ -44,20 +45,23 @@ def create_histogram(self, name, unit="", description=""): def create_gauge(self, name, unit="", description=""): super().create_gauge(name, unit=unit, description=description) - def create_observable_gauge(self, name, callback, unit="", description=""): + def create_observable_gauge( + self, name, callbacks, unit="", description="" + ): super().create_observable_gauge( - name, callback, unit=unit, description=description + name, callbacks, unit=unit, description=description ) def create_observable_up_down_counter( - self, name, callback, unit="", description="" + self, name, callbacks, unit="", description="" ): super().create_observable_up_down_counter( - name, callback, unit=unit, description=description + name, callbacks, unit=unit, description=description ) class TestMeter(TestCase): + # pylint: disable=no-member def test_repeated_instrument_names(self): try: @@ -72,7 +76,7 @@ def test_repeated_instrument_names(self): test_meter.create_observable_up_down_counter( "observable_up_down_counter", Mock() ) - except Exception as error: + except Exception as error: # pylint: disable=broad-exception-caught self.fail(f"Unexpected exception raised {error}") for instrument_name in [ diff --git a/opentelemetry-api/tests/metrics/test_meter_provider.py b/opentelemetry-api/tests/metrics/test_meter_provider.py index 559b56205ec..bce530d6caf 100644 --- a/opentelemetry-api/tests/metrics/test_meter_provider.py +++ b/opentelemetry-api/tests/metrics/test_meter_provider.py @@ -13,6 +13,8 @@ # limitations under the License. # type: ignore +# pylint: disable=protected-access + from unittest import TestCase from unittest.mock import Mock, patch @@ -54,6 +56,7 @@ def reset_meter_provider(): reset_metrics_globals() +# pylint: disable=redefined-outer-name def test_set_meter_provider(reset_meter_provider): """ Test that the API provides a way to set a global default MeterProvider @@ -113,7 +116,7 @@ def test_get_meter_parameters(self): NoOpMeterProvider().get_meter( "name", version="version", schema_url="schema_url" ) - except Exception as error: + except Exception as error: # pylint: disable=broad-exception-caught self.fail(f"Unexpected exception raised: {error}") def test_invalid_name(self): @@ -176,7 +179,7 @@ def test_proxy_provider(self): self.assertIsInstance(meter2, Mock) mock_real_mp.get_meter.assert_called_with(another_name, None, None) - # pylint: disable=too-many-locals + # pylint: disable=too-many-locals,too-many-statements def test_proxy_meter(self): meter_name = "foo" proxy_meter: _ProxyMeter = _ProxyMeterProvider().get_meter(meter_name) diff --git a/opentelemetry-api/tests/metrics/test_subclass_instantiation.py b/opentelemetry-api/tests/metrics/test_subclass_instantiation.py index a5b68d1c063..67001e8206b 100644 --- a/opentelemetry-api/tests/metrics/test_subclass_instantiation.py +++ b/opentelemetry-api/tests/metrics/test_subclass_instantiation.py @@ -17,6 +17,8 @@ # Any tests that fail here indicate that the public API has changed in a way that is not backwards compatible. # Either bump the major version of the API, or make the necessary changes to the API to remain semver compatible. +# pylint: disable=useless-parent-delegation,arguments-differ + from typing import Optional from opentelemetry.metrics import ( diff --git a/opentelemetry-api/tests/propagators/test_global_httptextformat.py b/opentelemetry-api/tests/propagators/test_global_httptextformat.py index 466ce6895f8..c383ec6030b 100644 --- a/opentelemetry-api/tests/propagators/test_global_httptextformat.py +++ b/opentelemetry-api/tests/propagators/test_global_httptextformat.py @@ -29,9 +29,9 @@ class TestDefaultGlobalPropagator(unittest.TestCase): SPAN_ID = int("1234567890123456", 16) # type:int def test_propagation(self): - traceparent_value = "00-{trace_id}-{span_id}-00".format( - trace_id=format_trace_id(self.TRACE_ID), - span_id=format_span_id(self.SPAN_ID), + traceparent_value = ( + f"00-{format_trace_id(self.TRACE_ID)}-" + f"{format_span_id(self.SPAN_ID)}-00" ) tracestate_value = "foo=1,bar=2,baz=3" headers = { diff --git a/opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py b/opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py index 99e37652ab0..2200fc6f384 100644 --- a/opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py +++ b/opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py @@ -27,6 +27,8 @@ class TestW3CBaggagePropagator(TestCase): + # pylint: disable=protected-access + # pylint: disable=too-many-public-methods def setUp(self): self.propagator = W3CBaggagePropagator() @@ -38,7 +40,7 @@ def _extract(self, header_value): def _inject(self, values): """Test helper""" ctx = get_current() - for k, v in values.items(): + for k, v in values.items(): # pylint: disable=invalid-name ctx = set_baggage(k, v, context=ctx) output = {} self.propagator.inject(output, context=ctx) diff --git a/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py b/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py index 7fefd8dea67..9db07add257 100644 --- a/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py +++ b/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py @@ -47,9 +47,9 @@ def test_headers_with_tracestate(self): """When there is a traceparent and tracestate header, data from both should be added to the SpanContext. """ - traceparent_value = "00-{trace_id}-{span_id}-00".format( - trace_id=format(self.TRACE_ID, "032x"), - span_id=format(self.SPAN_ID, "016x"), + traceparent_value = ( + f"00-{format(self.TRACE_ID, '032x')}-" + f"{format(self.SPAN_ID, '016x')}-00" ) tracestate_value = "foo=1,bar=2,baz=3" span_context = trace.get_current_span( diff --git a/opentelemetry-api/tests/util/test__providers.py b/opentelemetry-api/tests/util/test__providers.py index f7b21ebacf1..940303f1375 100644 --- a/opentelemetry-api/tests/util/test__providers.py +++ b/opentelemetry-api/tests/util/test__providers.py @@ -20,7 +20,7 @@ from opentelemetry.util import _providers -class Test_Providers(TestCase): +class Test_Providers(TestCase): # pylint: disable=invalid-name @patch.dict( environ, { # type: ignore @@ -49,7 +49,7 @@ def test__providers(self, mock_entry_points): ) self.assertEqual( - _providers._load_provider( + _providers._load_provider( # pylint: disable=protected-access "provider_environment_variable", "provider" ), "a", diff --git a/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics.py b/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics.py index 81fb0b6e1d8..7b062ce2c26 100644 --- a/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics.py +++ b/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics.py @@ -53,6 +53,7 @@ ) def test_counter_add(benchmark, num_labels, temporality): labels = {} + # pylint: disable=invalid-name for i in range(num_labels): labels = {f"Key{i}": f"Value{i}" for i in range(num_labels)} @@ -68,6 +69,7 @@ def benchmark_counter_add(): @pytest.mark.parametrize("num_labels", [0, 1, 3, 5, 10]) def test_up_down_counter_add(benchmark, num_labels): labels = {} + # pylint: disable=invalid-name for i in range(num_labels): labels = {f"Key{i}": f"Value{i}" for i in range(num_labels)} diff --git a/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram,.py b/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram.py similarity index 92% rename from opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram,.py rename to opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram.py index 2f9c4405418..1c7cdf2cb5a 100644 --- a/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram,.py +++ b/opentelemetry-sdk/benchmarks/metrics/test_benchmark_metrics_histogram.py @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# pylint: disable=invalid-name import random import pytest @@ -70,7 +72,7 @@ def _generate_bounds(bound_count): def test_histogram_record(benchmark, num_labels): labels = {} for i in range(num_labels): - labels["Key{}".format(i)] = "Value{}".format(i) + labels[f"Key{i}"] = "Value{i}" def benchmark_histogram_record(): hist.record(random.random() * MAX_BOUND_VALUE) @@ -82,7 +84,7 @@ def benchmark_histogram_record(): def test_histogram_record_10(benchmark, num_labels): labels = {} for i in range(num_labels): - labels["Key{}".format(i)] = "Value{}".format(i) + labels[f"Key{i}"] = "Value{i}" def benchmark_histogram_record_10(): hist10.record(random.random() * MAX_BOUND_VALUE) @@ -94,7 +96,7 @@ def benchmark_histogram_record_10(): def test_histogram_record_49(benchmark, num_labels): labels = {} for i in range(num_labels): - labels["Key{}".format(i)] = "Value{}".format(i) + labels[f"Key{i}"] = "Value{i}" def benchmark_histogram_record_49(): hist49.record(random.random() * MAX_BOUND_VALUE) @@ -106,7 +108,7 @@ def benchmark_histogram_record_49(): def test_histogram_record_50(benchmark, num_labels): labels = {} for i in range(num_labels): - labels["Key{}".format(i)] = "Value{}".format(i) + labels[f"Key{i}"] = "Value{i}" def benchmark_histogram_record_50(): hist50.record(random.random() * MAX_BOUND_VALUE) @@ -118,7 +120,7 @@ def benchmark_histogram_record_50(): def test_histogram_record_1000(benchmark, num_labels): labels = {} for i in range(num_labels): - labels["Key{}".format(i)] = "Value{}".format(i) + labels[f"Key{i}"] = "Value{i}" def benchmark_histogram_record_1000(): hist1000.record(random.random() * MAX_BOUND_VALUE) diff --git a/opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py b/opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py index a407a341f45..20a9b909427 100644 --- a/opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py +++ b/opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py @@ -12,11 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import opentelemetry.sdk.trace as trace from opentelemetry.sdk.resources import Resource -from opentelemetry.sdk.trace import sampling +from opentelemetry.sdk.trace import TracerProvider, sampling -tracer = trace.TracerProvider( +tracer = TracerProvider( sampler=sampling.DEFAULT_ON, resource=Resource( { diff --git a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponent_mapping.py b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponent_mapping.py index 96ba3991819..cfd33ef4a15 100644 --- a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponent_mapping.py +++ b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponent_mapping.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access + from math import inf from sys import float_info, version_info from unittest.mock import patch @@ -60,7 +62,7 @@ def test_singleton(self): "opentelemetry.sdk.metrics._internal.exponential_histogram.mapping." "exponent_mapping.ExponentMapping._init" ) - def test_init_called_once(self, mock_init): + def test_init_called_once(self, mock_init): # pylint: disable=no-self-use ExponentMapping(-3) ExponentMapping(-3) @@ -171,6 +173,7 @@ def test_exponent_mapping_neg_one(self): self.assertEqual(exponent_mapping.map_to_index(0.06), -3) def test_exponent_mapping_neg_four(self): + # pylint: disable=too-many-statements exponent_mapping = ExponentMapping(-4) self.assertEqual(exponent_mapping.map_to_index(float(0x1)), -1) self.assertEqual(exponent_mapping.map_to_index(float(0x10)), 0) diff --git a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py index bae0aca20bf..e243e09643d 100644 --- a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access,too-many-lines,invalid-name +# pylint: disable=consider-using-enumerate,no-self-use,too-many-public-methods + import random as insecure_random from itertools import permutations from logging import WARNING @@ -386,7 +389,7 @@ def mock_increment(self, bucket_index: int) -> None: """ Increments a bucket """ - + # pylint: disable=cell-var-from-loop self._counts[bucket_index] += increment exponential_histogram_aggregation = ( @@ -658,6 +661,7 @@ def test_aggregator_copy_swap(self): exponential_histogram_aggregation_1, ) + # pylint: disable=unnecessary-dunder-call exponential_histogram_aggregation_2._positive.__init__() exponential_histogram_aggregation_2._negative.__init__() exponential_histogram_aggregation_2._sum = 0 @@ -962,6 +966,7 @@ def collect_and_validate() -> None: upper_bound = 2 ** ((index + 1) / (2**scale)) matches = 0 for value in values: + # pylint: disable=chained-comparison if value > lower_bound and value <= upper_bound: matches += 1 assert ( diff --git a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_logarithm_mapping.py b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_logarithm_mapping.py index 1fd18845bb6..43820d677b0 100644 --- a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_logarithm_mapping.py +++ b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_logarithm_mapping.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access + from math import sqrt from unittest import TestCase from unittest.mock import patch @@ -53,6 +55,7 @@ def left_boundary(scale: int, index: int) -> float: class TestLogarithmMapping(TestCase): + # pylint: disable=invalid-name def assertInEpsilon(self, first, second, epsilon): self.assertLessEqual(first, (second * (1 + epsilon))) self.assertGreaterEqual(first, (second * (1 - epsilon))) @@ -66,7 +69,7 @@ def assertInEpsilon(self, first, second, epsilon): "opentelemetry.sdk.metrics._internal.exponential_histogram.mapping." "logarithm_mapping.LogarithmMapping._init" ) - def test_init_called_once(self, mock_init): + def test_init_called_once(self, mock_init): # pylint: disable=no-self-use LogarithmMapping(3) LogarithmMapping(3) diff --git a/opentelemetry-sdk/tests/metrics/integration_test/test_explicit_bucket_histogram_aggregation.py b/opentelemetry-sdk/tests/metrics/integration_test/test_explicit_bucket_histogram_aggregation.py index b705be33569..fee13525a32 100644 --- a/opentelemetry-sdk/tests/metrics/integration_test/test_explicit_bucket_histogram_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/integration_test/test_explicit_bucket_histogram_aggregation.py @@ -104,6 +104,7 @@ def test_synchronous_delta_temporality(self): previous_time_unix_nano = metric_data.time_unix_nano self.assertEqual( metric_data.bucket_counts, + # pylint: disable=consider-using-generator tuple( [ 1 if internal_index == index + 2 else 0 @@ -224,6 +225,7 @@ def test_synchronous_cumulative_temporality(self): ) self.assertEqual( metric_data.bucket_counts, + # pylint: disable=consider-using-generator tuple( [ ( diff --git a/opentelemetry-sdk/tests/metrics/test_aggregation.py b/opentelemetry-sdk/tests/metrics/test_aggregation.py index fb87d177e8d..9d61da72a04 100644 --- a/opentelemetry-sdk/tests/metrics/test_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/test_aggregation.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access + from math import inf from time import sleep from typing import Union diff --git a/opentelemetry-sdk/tests/metrics/test_backward_compat.py b/opentelemetry-sdk/tests/metrics/test_backward_compat.py index 46008554fe6..e29ca71469f 100644 --- a/opentelemetry-sdk/tests/metrics/test_backward_compat.py +++ b/opentelemetry-sdk/tests/metrics/test_backward_compat.py @@ -44,7 +44,7 @@ class OrigMetricExporter(MetricExporter): def export( self, - metrics: Sequence[Metric], + metrics_data: Sequence[Metric], timeout_millis: float = 10_000, **kwargs, ) -> MetricExportResult: @@ -60,7 +60,7 @@ def force_flush(self, timeout_millis: float = 10_000) -> bool: class OrigMetricReader(MetricReader): def _receive_metrics( self, - metrics: Iterable[Metric], + metrics_data: Iterable[Metric], timeout_millis: float = 10_000, **kwargs, ) -> None: diff --git a/opentelemetry-sdk/tests/metrics/test_import.py b/opentelemetry-sdk/tests/metrics/test_import.py index 73b9e1ece9c..5d656acce69 100644 --- a/opentelemetry-sdk/tests/metrics/test_import.py +++ b/opentelemetry-sdk/tests/metrics/test_import.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=unused-import +# pylint: disable=unused-import,import-outside-toplevel,too-many-locals from opentelemetry.test import TestCase diff --git a/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py index 68c81e8b7ef..40a0f3a3042 100644 --- a/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access + from time import sleep from unittest import TestCase from unittest.mock import Mock diff --git a/opentelemetry-sdk/tests/metrics/test_instrument.py b/opentelemetry-sdk/tests/metrics/test_instrument.py index d103050994e..d4a2ddf5094 100644 --- a/opentelemetry-sdk/tests/metrics/test_instrument.py +++ b/opentelemetry-sdk/tests/metrics/test_instrument.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=no-self-use + from logging import WARNING from unittest import TestCase from unittest.mock import Mock @@ -198,7 +200,6 @@ def test_generator_callback_0(self): ) def test_generator_multiple_generator_callback(self): - self.maxDiff = None observable_gauge = _ObservableGauge( "name", Mock(), diff --git a/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py b/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py index 9d3b9691d61..19c514c13e8 100644 --- a/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py +++ b/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=invalid-name,no-self-use + from time import sleep from unittest import TestCase from unittest.mock import MagicMock, Mock, patch diff --git a/opentelemetry-sdk/tests/metrics/test_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_metric_reader.py index fff645e36d9..5a09112bd0e 100644 --- a/opentelemetry-sdk/tests/metrics/test_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_metric_reader.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access + from typing import Dict, Iterable from unittest import TestCase from unittest.mock import patch @@ -62,7 +64,7 @@ def __init__( def _receive_metrics( self, - metrics: Iterable[Metric], + metrics_data: Iterable[Metric], timeout_millis: float = 10_000, **kwargs, ) -> None: @@ -146,6 +148,7 @@ def test_configure_aggregation(self): LastValueAggregation, ) + # pylint: disable=no-self-use def test_force_flush(self): with patch.object(DummyMetricReader, "collect") as mock_collect: diff --git a/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py b/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py index 5bcf07f6b68..2aac9874659 100644 --- a/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py +++ b/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access,invalid-name + from logging import WARNING from unittest.mock import MagicMock, Mock, patch diff --git a/opentelemetry-sdk/tests/metrics/test_metrics.py b/opentelemetry-sdk/tests/metrics/test_metrics.py index d55262274b6..f899b30808a 100644 --- a/opentelemetry-sdk/tests/metrics/test_metrics.py +++ b/opentelemetry-sdk/tests/metrics/test_metrics.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access,no-self-use + from logging import WARNING from time import sleep @@ -52,7 +54,7 @@ def __init__(self): def _receive_metrics( self, - metrics: Iterable[Metric], + metrics_data: Iterable[Metric], timeout_millis: float = 10_000, **kwargs, ) -> None: @@ -316,7 +318,7 @@ def test_shutdown_race(self, mock_logger): self.assertEqual(mock_logger.warning.call_count, num_threads - 1) @patch( - "opentelemetry.sdk.metrics._internal." "SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal.SynchronousMeasurementConsumer" ) def test_measurement_collect_callback( self, mock_sync_measurement_consumer @@ -339,7 +341,7 @@ def test_measurement_collect_callback( ) @patch( - "opentelemetry.sdk.metrics." "_internal.SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal.SynchronousMeasurementConsumer" ) def test_creates_sync_measurement_consumer( self, mock_sync_measurement_consumer @@ -348,7 +350,7 @@ def test_creates_sync_measurement_consumer( mock_sync_measurement_consumer.assert_called() @patch( - "opentelemetry.sdk.metrics." "_internal.SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal.SynchronousMeasurementConsumer" ) def test_register_asynchronous_instrument( self, mock_sync_measurement_consumer @@ -356,6 +358,7 @@ def test_register_asynchronous_instrument( meter_provider = MeterProvider() + # pylint: disable=no-member meter_provider._measurement_consumer.register_asynchronous_instrument.assert_called_with( meter_provider.get_meter("name").create_observable_counter( "name0", callbacks=[Mock()] @@ -373,7 +376,7 @@ def test_register_asynchronous_instrument( ) @patch( - "opentelemetry.sdk.metrics._internal." "SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal.SynchronousMeasurementConsumer" ) def test_consume_measurement_counter(self, mock_sync_measurement_consumer): sync_consumer_instance = mock_sync_measurement_consumer() @@ -385,7 +388,7 @@ def test_consume_measurement_counter(self, mock_sync_measurement_consumer): sync_consumer_instance.consume_measurement.assert_called() @patch( - "opentelemetry.sdk.metrics." "_internal.SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal.SynchronousMeasurementConsumer" ) def test_consume_measurement_up_down_counter( self, mock_sync_measurement_consumer @@ -401,7 +404,7 @@ def test_consume_measurement_up_down_counter( sync_consumer_instance.consume_measurement.assert_called() @patch( - "opentelemetry.sdk.metrics._internal." "SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal.SynchronousMeasurementConsumer" ) def test_consume_measurement_histogram( self, mock_sync_measurement_consumer @@ -415,7 +418,7 @@ def test_consume_measurement_histogram( sync_consumer_instance.consume_measurement.assert_called() @patch( - "opentelemetry.sdk.metrics._internal." "SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal.SynchronousMeasurementConsumer" ) def test_consume_measurement_gauge(self, mock_sync_measurement_consumer): sync_consumer_instance = mock_sync_measurement_consumer() @@ -544,11 +547,11 @@ def __init__(self): def export( self, - metrics: Sequence[Metric], + metrics_data: Sequence[Metric], timeout_millis: float = 10_000, **kwargs, ) -> MetricExportResult: - self.metrics[self._counter] = metrics + self.metrics[self._counter] = metrics_data self._counter += 1 return MetricExportResult.SUCCESS diff --git a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py index 98f59526ef6..962b4fdd643 100644 --- a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access,invalid-name,no-self-use + import math from logging import WARNING from time import sleep, time_ns @@ -53,12 +55,12 @@ def __init__( def export( self, - metrics: Sequence[Metric], + metrics_data: Sequence[Metric], timeout_millis: float = 10_000, **kwargs, ) -> MetricExportResult: sleep(self.wait) - self.metrics.extend(metrics) + self.metrics.extend(metrics_data) return True def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None: @@ -83,6 +85,7 @@ def __init__( ) self._collect_exception = exception + # pylint: disable=overridden-final-method def collect(self, timeout_millis: float = 10_000) -> None: raise self._collect_exception @@ -214,7 +217,7 @@ def test_shutdown_multiple_times(self): pmr = self._create_periodic_reader([], FakeMetricsExporter()) with self.assertLogs(level="WARNING") as w: self.run_with_many_threads(pmr.shutdown) - self.assertTrue("Can't shutdown multiple times", w.output[0]) + self.assertTrue("Can't shutdown multiple times" in w.output[0]) with self.assertLogs(level="WARNING") as w: pmr.shutdown() diff --git a/opentelemetry-sdk/tests/metrics/test_point.py b/opentelemetry-sdk/tests/metrics/test_point.py index cff07ff6aea..846f2c2fc9f 100644 --- a/opentelemetry-sdk/tests/metrics/test_point.py +++ b/opentelemetry-sdk/tests/metrics/test_point.py @@ -238,8 +238,6 @@ def test_histogram_data_point(self): def test_exp_histogram_data_point(self): - self.maxDiff = None - self.assertEqual( self.exp_histogram_data_point_0.to_json(indent=None), self.exp_histogram_data_point_0_str, @@ -251,8 +249,6 @@ def test_sum(self): def test_gauge(self): - self.maxDiff = None - self.assertEqual(self.gauge_0.to_json(indent=None), self.gauge_0_str) def test_histogram(self): @@ -263,8 +259,6 @@ def test_histogram(self): def test_exp_histogram(self): - self.maxDiff = None - self.assertEqual( self.exp_histogram_0.to_json(indent=None), self.exp_histogram_0_str ) diff --git a/opentelemetry-sdk/tests/metrics/test_view.py b/opentelemetry-sdk/tests/metrics/test_view.py index 00376a0068b..96d433677cf 100644 --- a/opentelemetry-sdk/tests/metrics/test_view.py +++ b/opentelemetry-sdk/tests/metrics/test_view.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access + from unittest import TestCase from unittest.mock import Mock diff --git a/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py b/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py index c22c2d7a96b..f4d2d02351a 100644 --- a/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py +++ b/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=protected-access + from unittest import TestCase from unittest.mock import MagicMock, Mock @@ -36,7 +38,7 @@ ) -class Test_ViewInstrumentMatch(TestCase): +class Test_ViewInstrumentMatch(TestCase): # pylint: disable=invalid-name @classmethod def setUpClass(cls): diff --git a/propagator/opentelemetry-propagator-b3/benchmarks/trace/propagation/test_benchmark_b3_format.py b/propagator/opentelemetry-propagator-b3/benchmarks/trace/propagation/test_benchmark_b3_format.py index 23cbf773eda..26fdb650f27 100644 --- a/propagator/opentelemetry-propagator-b3/benchmarks/trace/propagation/test_benchmark_b3_format.py +++ b/propagator/opentelemetry-propagator-b3/benchmarks/trace/propagation/test_benchmark_b3_format.py @@ -13,7 +13,7 @@ # limitations under the License. import opentelemetry.propagators.b3 as b3_format -import opentelemetry.sdk.trace as trace +from opentelemetry.sdk.trace import TracerProvider FORMAT = b3_format.B3Format() @@ -28,7 +28,7 @@ def test_extract_single_header(benchmark): def test_inject_empty_context(benchmark): - tracer = trace.TracerProvider().get_tracer("sdk_tracer_provider") + tracer = TracerProvider().get_tracer("sdk_tracer_provider") with tracer.start_as_current_span("Root Span"): with tracer.start_as_current_span("Child Span"): benchmark( diff --git a/tox.ini b/tox.ini index dfa3edd0289..fe9906e15ad 100644 --- a/tox.ini +++ b/tox.ini @@ -18,8 +18,8 @@ envlist = pypy3-test-opentelemetry-proto-{0,1} lint-opentelemetry-proto - py3{8,9,10,11,12}-opentelemetry-sdk - pypy3-opentelemetry-sdk + py3{8,9,10,11,12}-test-opentelemetry-sdk + pypy3-test-opentelemetry-sdk lint-opentelemetry-sdk benchmark-opentelemetry-sdk @@ -119,6 +119,7 @@ deps = proto3: protobuf~=3.19.0 proto4: protobuf~=4.0 +allowlist_externals = sh setenv = ; override CONTRIB_REPO_SHA via env variable when testing other branches/commits than main @@ -198,30 +199,26 @@ commands = lint-opentelemetry-api: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-api lint-opentelemetry-api: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-api lint-opentelemetry-api: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-api - lint-opentelemetry-api: pylint {toxinidir}/opentelemetry-api/src/opentelemetry - lint-opentelemetry-api: pylint {toxinidir}/opentelemetry-api/tests + lint-opentelemetry-api: pylint {toxinidir}/opentelemetry-api test-opentelemetry-sdk: pytest {toxinidir}/opentelemetry-sdk/tests {posargs} lint-opentelemetry-sdk: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-sdk lint-opentelemetry-sdk: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-sdk lint-opentelemetry-sdk: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-sdk - lint-opentelemetry-sdk: pylint {toxinidir}/opentelemetry-sdk/src/opentelemetry - lint-opentelemetry-sdk: pylint {toxinidir}/opentelemetry-sdk/tests + lint-opentelemetry-sdk: pylint {toxinidir}/opentelemetry-sdk benchmark-opentelemetry-sdk: pytest {toxinidir}/opentelemetry-sdk/benchmarks {posargs} --benchmark-json=sdk-benchmark.json test-opentelemetry-proto: pytest {toxinidir}/opentelemetry-proto/tests {posargs} lint-opentelemetry-proto: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-proto lint-opentelemetry-proto: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-proto lint-opentelemetry-proto: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-proto - lint-opentelemetry-proto: pylint {toxinidir}/opentelemetry-proto/src/opentelemetry - lint-opentelemetry-proto: pylint {toxinidir}/opentelemetry-proto/tests + lint-opentelemetry-proto: pylint {toxinidir}/opentelemetry-proto test-opentelemetry-semantic-conventions: pytest {toxinidir}/opentelemetry-semantic-conventions/tests {posargs} lint-opentelemetry-semantic-conventions: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-semantic-conventions lint-opentelemetry-semantic-conventions: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/opentelemetry-semantic-conventions lint-opentelemetry-semantic-conventions: flake8 --config {toxinidir}/.flake8 {toxinidir}/opentelemetry-semantic-conventions - lint-opentelemetry-semantic-conventions: pylint {toxinidir}/opentelemetry-semantic-conventions/src/opentelemetry - lint-opentelemetry-semantic-conventions: pylint {toxinidir}/opentelemetry-semantic-conventions/tests + lint-opentelemetry-semantic-conventions: pylint {toxinidir}/opentelemetry-semantic-conventions test-opentelemetry-getting-started: pytest {toxinidir}/docs/getting_started/tests {posargs} lint-opentelemetry-getting-started: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/docs/getting_started @@ -233,101 +230,87 @@ commands = lint-opentelemetry-opentracing-shim: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/shim/opentelemetry-opentracing-shim lint-opentelemetry-opentracing-shim: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/shim/opentelemetry-opentracing-shim lint-opentelemetry-opentracing-shim: flake8 --config {toxinidir}/.flake8 {toxinidir}/shim/opentelemetry-opentracing-shim - lint-opentelemetry-opentracing-shim: pylint {toxinidir}/shim/opentelemetry-opentracing-shim/src/opentelemetry - lint-opentelemetry-opentracing-shim: pylint {toxinidir}/shim/opentelemetry-opentracing-shim/tests + lint-opentelemetry-opentracing-shim: sh -c "cd shim && pylint --rcfile ../.pylintrc {toxinidir}/shim/opentelemetry-opentracing-shim" test-opentelemetry-opencensus-shim: pytest {toxinidir}/shim/opentelemetry-opencensus-shim/tests {posargs} lint-opentelemetry-opencensus-shim: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/shim/opentelemetry-opencensus-shim lint-opentelemetry-opencensus-shim: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/shim/opentelemetry-opencensus-shim lint-opentelemetry-opencensus-shim: flake8 --config {toxinidir}/.flake8 {toxinidir}/shim/opentelemetry-opencensus-shim - lint-opentelemetry-opencensus-shim: pylint {toxinidir}/shim/opentelemetry-opencensus-shim/src/opentelemetry - lint-opentelemetry-opencensus-shim: pylint {toxinidir}/shim/opentelemetry-opencensus-shim/tests + lint-opentelemetry-opencensus-shim: sh -c "cd shim && pylint --rcfile ../.pylintrc {toxinidir}/shim/opentelemetry-opencensus-shim" test-opentelemetry-exporter-opencensus: pytest {toxinidir}/exporter/opentelemetry-exporter-opencensus/tests {posargs} lint-opentelemetry-exporter-opencensus: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-opencensus lint-opentelemetry-exporter-opencensus: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-opencensus lint-opentelemetry-exporter-opencensus: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-opencensus - lint-opentelemetry-exporter-opencensus: pylint {toxinidir}/exporter/opentelemetry-exporter-opencensus/src/opentelemetry - lint-opentelemetry-exporter-opencensus: pylint {toxinidir}/exporter/opentelemetry-exporter-opencensus/tests + lint-opentelemetry-exporter-opencensus: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-opencensus" test-opentelemetry-exporter-otlp-proto-common: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/tests {posargs} lint-opentelemetry-exporter-otlp-proto-common: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common lint-opentelemetry-exporter-otlp-proto-common: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common lint-opentelemetry-exporter-otlp-proto-common: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common - lint-opentelemetry-exporter-otlp-proto-common: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry - lint-opentelemetry-exporter-otlp-proto-common: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/tests + lint-opentelemetry-exporter-otlp-proto-common: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common" test-opentelemetry-exporter-otlp-combined: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp/tests {posargs} lint-opentelemetry-exporter-otlp-combined: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp lint-opentelemetry-exporter-otlp-combined: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp lint-opentelemetry-exporter-otlp-combined: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp - lint-opentelemetry-exporter-otlp-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp/src/opentelemetry - lint-opentelemetry-exporter-otlp-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp/tests + lint-opentelemetry-exporter-otlp-combined: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-otlp" test-opentelemetry-exporter-otlp-proto-grpc: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/tests {posargs} lint-opentelemetry-exporter-otlp-proto-grpc: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc lint-opentelemetry-exporter-otlp-proto-grpc: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc lint-opentelemetry-exporter-otlp-proto-grpc: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc - lint-opentelemetry-exporter-otlp-proto-grpc: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry - lint-opentelemetry-exporter-otlp-proto-grpc: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/tests + lint-opentelemetry-exporter-otlp-proto-grpc: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc" benchmark-opentelemetry-exporter-otlp-proto-grpc: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmarks {posargs} --benchmark-json=exporter-otlp-proto-grpc-benchmark.json test-opentelemetry-exporter-otlp-proto-http: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/tests {posargs} lint-opentelemetry-exporter-otlp-proto-http: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http lint-opentelemetry-exporter-otlp-proto-http: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http lint-opentelemetry-exporter-otlp-proto-http: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http - lint-opentelemetry-exporter-otlp-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry - lint-opentelemetry-exporter-otlp-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/tests + lint-opentelemetry-exporter-otlp-proto-http: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http" test-opentelemetry-exporter-prometheus: pytest {toxinidir}/exporter/opentelemetry-exporter-prometheus/tests {posargs} lint-opentelemetry-exporter-prometheus: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-prometheus lint-opentelemetry-exporter-prometheus: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-prometheus lint-opentelemetry-exporter-prometheus: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-prometheus - lint-opentelemetry-exporter-prometheus: pylint {toxinidir}/exporter/opentelemetry-exporter-prometheus/src/opentelemetry - lint-opentelemetry-exporter-prometheus: pylint {toxinidir}/exporter/opentelemetry-exporter-prometheus/tests + lint-opentelemetry-exporter-prometheus: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-prometheus" test-opentelemetry-exporter-zipkin-combined: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin/tests {posargs} lint-opentelemetry-exporter-zipkin-combined: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-zipkin lint-opentelemetry-exporter-zipkin-combined: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-zipkin lint-opentelemetry-exporter-zipkin-combined: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-zipkin - lint-opentelemetry-exporter-zipkin-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin/src/opentelemetry - lint-opentelemetry-exporter-zipkin-combined: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin/tests + lint-opentelemetry-exporter-zipkin-combined: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-zipkin" test-opentelemetry-exporter-zipkin-proto-http: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/tests {posargs} lint-opentelemetry-exporter-zipkin-proto-http: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http lint-opentelemetry-exporter-zipkin-proto-http: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http lint-opentelemetry-exporter-zipkin-proto-http: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http - lint-opentelemetry-exporter-zipkin-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry - lint-opentelemetry-exporter-zipkin-proto-http: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/tests + lint-opentelemetry-exporter-zipkin-proto-http: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http" test-opentelemetry-exporter-zipkin-json: pytest {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/tests {posargs} lint-opentelemetry-exporter-zipkin-json: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/exporter/opentelemetry-exporter-zipkin-json lint-opentelemetry-exporter-zipkin-json: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/exporter/opentelemetry-exporter-zipkin-json lint-opentelemetry-exporter-zipkin-json: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-zipkin-json - lint-opentelemetry-exporter-zipkin-json: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry - lint-opentelemetry-exporter-zipkin-json: pylint {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/tests + lint-opentelemetry-exporter-zipkin-json: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-zipkin-json" test-opentelemetry-propagator-b3: pytest {toxinidir}/propagator/opentelemetry-propagator-b3/tests {posargs} lint-opentelemetry-propagator-b3: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/propagator/opentelemetry-propagator-b3 lint-opentelemetry-propagator-b3: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/propagator/opentelemetry-propagator-b3 lint-opentelemetry-propagator-b3: flake8 --config {toxinidir}/.flake8 {toxinidir}/propagator/opentelemetry-propagator-b3 - lint-opentelemetry-propagator-b3: pylint {toxinidir}/propagator/opentelemetry-propagator-b3/src/opentelemetry - lint-opentelemetry-propagator-b3: pylint {toxinidir}/propagator/opentelemetry-propagator-b3/tests + lint-opentelemetry-propagator-b3: sh -c "cd propagator && pylint --rcfile ../.pylintrc {toxinidir}/propagator/opentelemetry-propagator-b3" benchmark-opentelemetry-propagator-b3: pytest {toxinidir}/propagator/opentelemetry-propagator-b3/benchmarks {posargs} --benchmark-json=propagator-b3-benchmark.json test-opentelemetry-propagator-jaeger: pytest {toxinidir}/propagator/opentelemetry-propagator-jaeger/tests {posargs} lint-opentelemetry-propagator-jaeger: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/propagator/opentelemetry-propagator-jaeger lint-opentelemetry-propagator-jaeger: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/propagator/opentelemetry-propagator-jaeger lint-opentelemetry-propagator-jaeger: flake8 --config {toxinidir}/.flake8 {toxinidir}/propagator/opentelemetry-propagator-jaeger - lint-opentelemetry-propagator-jaeger: pylint {toxinidir}/propagator/opentelemetry-propagator-jaeger/src/opentelemetry - lint-opentelemetry-propagator-jaeger: pylint {toxinidir}/propagator/opentelemetry-propagator-jaeger/tests + lint-opentelemetry-propagator-jaeger: sh -c "cd propagator && pylint --rcfile ../.pylintrc {toxinidir}/propagator/opentelemetry-propagator-jaeger" test-opentelemetry-test-utils: pytest {toxinidir}/tests/opentelemetry-test-utils/tests {posargs} lint-opentelemetry-test-utils: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/tests/opentelemetry-test-utils lint-opentelemetry-test-utils: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/tests/opentelemetry-test-utils lint-opentelemetry-test-utils: flake8 --config {toxinidir}/.flake8 {toxinidir}/tests/opentelemetry-test-utils - lint-opentelemetry-test-utils: pylint {toxinidir}/tests/opentelemetry-test-utils/src/opentelemetry - lint-opentelemetry-test-utils: pylint {toxinidir}/tests/opentelemetry-test-utils/tests + lint-opentelemetry-test-utils: sh -c "cd tests && pylint --rcfile ../.pylintrc {toxinidir}/tests/opentelemetry-test-utils" coverage: {toxinidir}/scripts/coverage.sh