From 21a9be8ecf561c5e5a7782ae591ad075563b92c1 Mon Sep 17 00:00:00 2001 From: Dylan Russell Date: Mon, 3 Nov 2025 21:00:03 +0000 Subject: [PATCH 1/3] Initial commit --- .../proto/common/_internal/utils}/__init__.py | 4 +--- .../exporter/otlp/proto/common/utils.py | 20 +++++++++++++++++++ .../tests/test_otlp_exporter_mixin.py | 12 +++-------- .../metrics/test_otlp_metrics_exporter.py | 5 +++-- .../tests/test_proto_log_exporter.py | 5 +++-- .../tests/test_proto_span_exporter.py | 5 +++-- 6 files changed, 33 insertions(+), 18 deletions(-) rename exporter/{opentelemetry-exporter-otlp-proto-http/tests/_common => opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils}/__init__.py (91%) create mode 100644 exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/tests/_common/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py similarity index 91% rename from exporter/opentelemetry-exporter-otlp-proto-http/tests/_common/__init__.py rename to exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py index 08801b68af..a01c40ed09 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/tests/_common/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=protected-access - class IterEntryPoint: def __init__(self, name, class_type): @@ -21,4 +19,4 @@ def __init__(self, name, class_type): self.class_type = class_type def load(self): - return self.class_type + return self.class_type \ No newline at end of file diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py new file mode 100644 index 0000000000..6c88e273e0 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py @@ -0,0 +1,20 @@ +# 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. + + +from opentelemetry.exporter.otlp.proto.common._internal.utils import ( + IterEntryPoint, +) + +__all__ = ["IterEntryPoint"] diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py index dd27a5b43c..bd995671b0 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py @@ -33,6 +33,9 @@ from opentelemetry.exporter.otlp.proto.common.trace_encoder import ( encode_spans, ) +from opentelemetry.exporter.otlp.proto.common.utils import ( + IterEntryPoint, +) from opentelemetry.exporter.otlp.proto.grpc.exporter import ( # noqa: F401 InvalidCompressionValueException, OTLPExporterMixin, @@ -61,15 +64,6 @@ logger = getLogger(__name__) -class IterEntryPoint: - def __init__(self, name, class_type): - self.name = name - self.class_type = class_type - - def load(self): - return self.class_type - - # The below tests use this test SpanExporter and Spans, but are testing the # underlying behavior in the mixin. A MetricExporter or LogExporter could # just as easily be used. diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py index d7a5bed2d4..4fe5f24378 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py @@ -25,6 +25,9 @@ from opentelemetry.exporter.otlp.proto.common.metrics_encoder import ( encode_metrics, ) +from opentelemetry.exporter.otlp.proto.common.utils import ( + IterEntryPoint, +) from opentelemetry.exporter.otlp.proto.http import Compression from opentelemetry.exporter.otlp.proto.http.metric_exporter import ( DEFAULT_COMPRESSION, @@ -78,8 +81,6 @@ ) from opentelemetry.test.metrictestutil import _generate_sum -from .._common import IterEntryPoint - OS_ENV_ENDPOINT = "os.env.base" OS_ENV_CERTIFICATE = "os/env/base.crt" OS_ENV_CLIENT_CERTIFICATE = "os/env/client-cert.pem" 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 d136e09ffd..feb072f0da 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 @@ -27,6 +27,9 @@ from requests.models import Response from opentelemetry._logs import SeverityNumber +from opentelemetry.exporter.otlp.proto.common.utils import ( + IterEntryPoint, +) from opentelemetry.exporter.otlp.proto.http import Compression from opentelemetry.exporter.otlp.proto.http._log_exporter import ( DEFAULT_COMPRESSION, @@ -68,8 +71,6 @@ set_span_in_context, ) -from ._common import IterEntryPoint - ENV_ENDPOINT = "http://localhost.env:8080/" ENV_CERTIFICATE = "/etc/base.crt" ENV_CLIENT_CERTIFICATE = "/etc/client-cert.pem" diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py index 2d6dea71de..ae264b9f52 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py @@ -22,6 +22,9 @@ from requests import Session from requests.models import Response +from opentelemetry.exporter.otlp.proto.common.utils import ( + IterEntryPoint, +) from opentelemetry.exporter.otlp.proto.http import Compression from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( DEFAULT_COMPRESSION, @@ -51,8 +54,6 @@ from opentelemetry.sdk.trace import _Span from opentelemetry.sdk.trace.export import SpanExportResult -from ._common import IterEntryPoint - OS_ENV_ENDPOINT = "os.env.base" OS_ENV_CERTIFICATE = "os/env/base.crt" OS_ENV_CLIENT_CERTIFICATE = "os/env/client-cert.pem" From e838f98787a4bf0c59a92862e6a19e0529d72767 Mon Sep 17 00:00:00 2001 From: Dylan Russell Date: Mon, 3 Nov 2025 21:04:37 +0000 Subject: [PATCH 2/3] Fix precommit --- .../exporter/otlp/proto/common/_internal/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py index a01c40ed09..5e7fc521d2 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py @@ -19,4 +19,4 @@ def __init__(self, name, class_type): self.class_type = class_type def load(self): - return self.class_type \ No newline at end of file + return self.class_type From d67406a2483c2ca9ba697e662a1e8fd11e31095a Mon Sep 17 00:00:00 2001 From: Dylan Russell Date: Tue, 4 Nov 2025 17:09:42 +0000 Subject: [PATCH 3/3] Move IterEntryPoint to test util package --- .../exporter/otlp/proto/common/utils.py | 20 ------------------- .../tests/test_otlp_exporter_mixin.py | 4 +--- .../metrics/test_otlp_metrics_exporter.py | 4 +--- .../tests/test_proto_log_exporter.py | 4 +--- .../tests/test_proto_span_exporter.py | 4 +--- opentelemetry-sdk/tests/test_configurator.py | 10 +--------- .../opentelemetry/test/mock_test_classes.py | 0 7 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py rename exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py => tests/opentelemetry-test-utils/src/opentelemetry/test/mock_test_classes.py (100%) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py deleted file mode 100644 index 6c88e273e0..0000000000 --- a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/utils.py +++ /dev/null @@ -1,20 +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. - - -from opentelemetry.exporter.otlp.proto.common._internal.utils import ( - IterEntryPoint, -) - -__all__ = ["IterEntryPoint"] diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py index bd995671b0..d64a601bbb 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py @@ -33,9 +33,6 @@ from opentelemetry.exporter.otlp.proto.common.trace_encoder import ( encode_spans, ) -from opentelemetry.exporter.otlp.proto.common.utils import ( - IterEntryPoint, -) from opentelemetry.exporter.otlp.proto.grpc.exporter import ( # noqa: F401 InvalidCompressionValueException, OTLPExporterMixin, @@ -60,6 +57,7 @@ SpanExporter, SpanExportResult, ) +from opentelemetry.test.mock_test_classes import IterEntryPoint logger = getLogger(__name__) diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py index 4fe5f24378..eca1aed5d9 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py @@ -25,9 +25,6 @@ from opentelemetry.exporter.otlp.proto.common.metrics_encoder import ( encode_metrics, ) -from opentelemetry.exporter.otlp.proto.common.utils import ( - IterEntryPoint, -) from opentelemetry.exporter.otlp.proto.http import Compression from opentelemetry.exporter.otlp.proto.http.metric_exporter import ( DEFAULT_COMPRESSION, @@ -80,6 +77,7 @@ InstrumentationScope as SDKInstrumentationScope, ) from opentelemetry.test.metrictestutil import _generate_sum +from opentelemetry.test.mock_test_classes import IterEntryPoint OS_ENV_ENDPOINT = "os.env.base" OS_ENV_CERTIFICATE = "os/env/base.crt" 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 feb072f0da..001927b3b7 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 @@ -27,9 +27,6 @@ from requests.models import Response from opentelemetry._logs import SeverityNumber -from opentelemetry.exporter.otlp.proto.common.utils import ( - IterEntryPoint, -) from opentelemetry.exporter.otlp.proto.http import Compression from opentelemetry.exporter.otlp.proto.http._log_exporter import ( DEFAULT_COMPRESSION, @@ -64,6 +61,7 @@ ) from opentelemetry.sdk.resources import Resource as SDKResource from opentelemetry.sdk.util.instrumentation import InstrumentationScope +from opentelemetry.test.mock_test_classes import IterEntryPoint from opentelemetry.trace import ( NonRecordingSpan, SpanContext, diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py index ae264b9f52..10dcb1a9e0 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py @@ -22,9 +22,6 @@ from requests import Session from requests.models import Response -from opentelemetry.exporter.otlp.proto.common.utils import ( - IterEntryPoint, -) from opentelemetry.exporter.otlp.proto.http import Compression from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( DEFAULT_COMPRESSION, @@ -53,6 +50,7 @@ ) from opentelemetry.sdk.trace import _Span from opentelemetry.sdk.trace.export import SpanExportResult +from opentelemetry.test.mock_test_classes import IterEntryPoint OS_ENV_ENDPOINT = "os.env.base" OS_ENV_CERTIFICATE = "os/env/base.crt" diff --git a/opentelemetry-sdk/tests/test_configurator.py b/opentelemetry-sdk/tests/test_configurator.py index cdb5008261..7f6c8190fe 100644 --- a/opentelemetry-sdk/tests/test_configurator.py +++ b/opentelemetry-sdk/tests/test_configurator.py @@ -72,6 +72,7 @@ SamplingResult, TraceIdRatioBased, ) +from opentelemetry.test.mock_test_classes import IterEntryPoint from opentelemetry.trace import Link, SpanKind from opentelemetry.trace.span import TraceState from opentelemetry.util.types import Attributes @@ -307,15 +308,6 @@ def generate_trace_id(self): pass -class IterEntryPoint: - def __init__(self, name, class_type): - self.name = name - self.class_type = class_type - - def load(self): - return self.class_type - - class TestTraceInit(TestCase): def setUp(self): super() diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py b/tests/opentelemetry-test-utils/src/opentelemetry/test/mock_test_classes.py similarity index 100% rename from exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/utils/__init__.py rename to tests/opentelemetry-test-utils/src/opentelemetry/test/mock_test_classes.py