From 9c46c71cb103ac8248fb76229c3519cacb6963b1 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Mon, 13 Jul 2026 23:39:39 -0400 Subject: [PATCH 1/5] add OTLP Json file tests --- .../tests/.gitignore | 3 +++ .../tests/collector-config.yaml | 18 ++++++++++++--- .../tests/docker-compose.yml | 3 ++- .../tests/otlp-file-data/logs/.gitkeep | 0 .../tests/otlp-file-data/metrics/.gitkeep | 0 .../tests/otlp-file-data/traces/.gitkeep | 0 .../tests/otlpexporter/__init__.py | 22 ++++++++++++++++++- .../tests/otlpexporter/conftest.py | 12 ++++++++++ .../otlpexporter/test_otlp_logs_functional.py | 10 ++++++++- .../test_otlp_metrics_functional.py | 10 ++++++++- .../test_otlp_traces_functional.py | 10 ++++++++- tox.ini | 3 +++ 12 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 tests/opentelemetry-docker-tests/tests/.gitignore create mode 100644 tests/opentelemetry-docker-tests/tests/otlp-file-data/logs/.gitkeep create mode 100644 tests/opentelemetry-docker-tests/tests/otlp-file-data/metrics/.gitkeep create mode 100644 tests/opentelemetry-docker-tests/tests/otlp-file-data/traces/.gitkeep diff --git a/tests/opentelemetry-docker-tests/tests/.gitignore b/tests/opentelemetry-docker-tests/tests/.gitignore new file mode 100644 index 00000000000..0242039b261 --- /dev/null +++ b/tests/opentelemetry-docker-tests/tests/.gitignore @@ -0,0 +1,3 @@ +# JSON output written by the OTLP JSON File exporter during docker tests and +# tailed by the collector's otlp_json_file receiver (see docker-compose.yml). +otlp-file-data/**/*.jsonl diff --git a/tests/opentelemetry-docker-tests/tests/collector-config.yaml b/tests/opentelemetry-docker-tests/tests/collector-config.yaml index dbd52364e17..1be73178a92 100644 --- a/tests/opentelemetry-docker-tests/tests/collector-config.yaml +++ b/tests/opentelemetry-docker-tests/tests/collector-config.yaml @@ -5,6 +5,18 @@ receivers: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318 + otlp_json_file/traces: + include: [/otlp-file-data/traces/*.jsonl] + start_at: beginning + include_file_name: false + otlp_json_file/metrics: + include: [/otlp-file-data/metrics/*.jsonl] + start_at: beginning + include_file_name: false + otlp_json_file/logs: + include: [/otlp-file-data/logs/*.jsonl] + start_at: beginning + include_file_name: false exporters: otlphttp: @@ -13,11 +25,11 @@ exporters: service: pipelines: traces: - receivers: [otlp] + receivers: [otlp, otlp_json_file/traces] exporters: [otlphttp] metrics: - receivers: [otlp] + receivers: [otlp, otlp_json_file/metrics] exporters: [otlphttp] logs: - receivers: [otlp] + receivers: [otlp, otlp_json_file/logs] exporters: [otlphttp] diff --git a/tests/opentelemetry-docker-tests/tests/docker-compose.yml b/tests/opentelemetry-docker-tests/tests/docker-compose.yml index 52cc7074d4a..0d42cb3069c 100644 --- a/tests/opentelemetry-docker-tests/tests/docker-compose.yml +++ b/tests/opentelemetry-docker-tests/tests/docker-compose.yml @@ -6,10 +6,11 @@ services: - "8888:8888" - "55678:55678" otcollector: - image: otel/opentelemetry-collector:0.149.0 + image: otel/opentelemetry-collector-contrib:0.156.0 command: ["--config=/etc/otelcol/collector-config.yaml"] volumes: - ./collector-config.yaml:/etc/otelcol/collector-config.yaml + - ./otlp-file-data:/otlp-file-data ports: - "4317:4317" - "4318:4318" diff --git a/tests/opentelemetry-docker-tests/tests/otlp-file-data/logs/.gitkeep b/tests/opentelemetry-docker-tests/tests/otlp-file-data/logs/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/opentelemetry-docker-tests/tests/otlp-file-data/metrics/.gitkeep b/tests/opentelemetry-docker-tests/tests/otlp-file-data/metrics/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/opentelemetry-docker-tests/tests/otlp-file-data/traces/.gitkeep b/tests/opentelemetry-docker-tests/tests/otlp-file-data/traces/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py index 0976ac5b690..df852a716f0 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py @@ -3,8 +3,11 @@ from __future__ import annotations +from collections.abc import Callable from dataclasses import dataclass, field +from pathlib import Path from typing import Any, Generic, TypeVar +from uuid import uuid4 ExporterT = TypeVar("ExporterT") @@ -13,15 +16,32 @@ "x-another-header": "another-value", } +# Directory bind-mounted into the collector container (see docker-compose.yml). +# Resolved relative to the compose file, which sits one level above this package. +OTLP_FILE_DATA_DIR = Path(__file__).parent.parent / "otlp-file-data" + @dataclass class ExporterConfig(Generic[ExporterT]): id: str exporter_class: type[ExporterT] kwargs: dict[str, Any] = field(default_factory=dict) + lazy_kwargs: Callable[[], dict[str, Any]] | None = None def build(self) -> ExporterT: - return self.exporter_class(**self.kwargs) + extra = self.lazy_kwargs() if self.lazy_kwargs is not None else {} + return self.exporter_class(**self.kwargs, **extra) + + +def new_otlp_file(signal: str) -> str: + """Return a unique .jsonl path under the collector-mounted directory. + + ``signal`` is one of ``"traces"``, ``"metrics"``, ``"logs"`` and selects the + subdirectory the collector's ``otlp_json_file/`` receiver tails. + """ + directory = OTLP_FILE_DATA_DIR / signal + directory.mkdir(parents=True, exist_ok=True) + return str(directory / f"{uuid4().hex}.jsonl") def _attrs_to_dict(attributes) -> dict: diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py index d777a33fa6a..671cb57d443 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py @@ -9,6 +9,18 @@ from opentelemetry.test._otlp_test_server import OtlpProtoTestServer +from . import OTLP_FILE_DATA_DIR + + +@pytest.fixture(scope="session", autouse=True) +def clean_otlp_file_data() -> None: + """Remove stale .jsonl files so the collector doesn't replay old runs.""" + for signal in ("traces", "metrics", "logs"): + directory = OTLP_FILE_DATA_DIR / signal + directory.mkdir(parents=True, exist_ok=True) + for stale in directory.glob("*.jsonl"): + stale.unlink() + @pytest.fixture(scope="class") def server() -> Iterator[OtlpProtoTestServer]: diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py index 02fc8f555b5..420b45d690e 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py @@ -11,6 +11,9 @@ from inline_snapshot import snapshot from opentelemetry._logs import Logger, SeverityNumber +from opentelemetry.exporter.otlp.json.file._log_exporter import ( + FileLogExporter, +) from opentelemetry.exporter.otlp.proto.grpc._log_exporter import ( OTLPLogExporter as GRPCLogExporter, ) @@ -28,7 +31,7 @@ from opentelemetry.sdk.resources import Resource from opentelemetry.test._otlp_test_server import OtlpProtoTestServer -from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict +from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, new_otlp_file LOG_EXPORTER_CONFIGS: list[ExporterConfig[LogRecordExporter]] = [ ExporterConfig( @@ -75,6 +78,11 @@ exporter_class=GRPCLogExporter, kwargs={"insecure": True, "headers": CUSTOM_HEADERS}, ), + ExporterConfig( + id="file", + exporter_class=FileLogExporter, + lazy_kwargs=lambda: {"path": new_otlp_file("logs")}, + ), ] diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py index 2691dd4f7af..5428986075a 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py @@ -10,6 +10,9 @@ from grpc import Compression as GRPCCompression from inline_snapshot import snapshot +from opentelemetry.exporter.otlp.json.file.metric_exporter import ( + FileMetricExporter, +) from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import ( OTLPMetricExporter as GRPCMetricExporter, ) @@ -32,7 +35,7 @@ from opentelemetry.sdk.resources import Resource from opentelemetry.test._otlp_test_server import OtlpProtoTestServer -from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict +from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, new_otlp_file METRIC_EXPORTER_CONFIGS: list[ExporterConfig[MetricExporter]] = [ ExporterConfig( @@ -79,6 +82,11 @@ exporter_class=GRPCMetricExporter, kwargs={"insecure": True, "headers": CUSTOM_HEADERS}, ), + ExporterConfig( + id="file", + exporter_class=FileMetricExporter, + lazy_kwargs=lambda: {"path": new_otlp_file("metrics")}, + ), ] diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py index 9eb8a2a5ec5..c11f4e51f99 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py @@ -16,6 +16,9 @@ from opentelemetry.exporter.otlp.proto.http import ( Compression as HTTPCompression, ) +from opentelemetry.exporter.otlp.json.file.trace_exporter import ( + FileSpanExporter, +) from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( OTLPSpanExporter as HTTPSpanExporter, ) @@ -24,7 +27,7 @@ from opentelemetry.test._otlp_test_server import OtlpProtoTestServer from opentelemetry.trace import Link, SpanContext, StatusCode, TraceFlags -from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict +from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, new_otlp_file TRACE_EXPORTER_CONFIGS: list[ExporterConfig[SpanExporter]] = [ ExporterConfig( @@ -71,6 +74,11 @@ exporter_class=GRPCSpanExporter, kwargs={"insecure": True, "headers": CUSTOM_HEADERS}, ), + ExporterConfig( + id="file", + exporter_class=FileSpanExporter, + lazy_kwargs=lambda: {"path": new_otlp_file("traces")}, + ), ] diff --git a/tox.ini b/tox.ini index 577866b743d..6f6dd628536 100644 --- a/tox.ini +++ b/tox.ini @@ -371,6 +371,9 @@ deps = otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp + otlpexporter: -e {toxinidir}/opentelemetry-proto-json + otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp-json-common + otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp-json-file opencensus: -e {toxinidir}/exporter/opentelemetry-exporter-opencensus From 1cf758a69252a7ddd666bb26391a899bcde58db6 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Tue, 14 Jul 2026 22:58:40 -0400 Subject: [PATCH 2/5] updates --- tests/opentelemetry-docker-tests/tests/.gitignore | 7 ++++--- .../tests/docker-compose.yml | 2 +- .../tests/otlp-file-data/logs/.gitkeep | 0 .../tests/otlp-file-data/metrics/.gitkeep | 0 .../tests/otlp-file-data/traces/.gitkeep | 0 .../tests/otlpexporter/__init__.py | 10 +++++----- .../tests/otlpexporter/test_otlp_logs_functional.py | 4 ++-- .../tests/otlpexporter/test_otlp_metrics_functional.py | 4 ++-- .../tests/otlpexporter/test_otlp_traces_functional.py | 4 ++-- tox.ini | 2 ++ 10 files changed, 18 insertions(+), 15 deletions(-) delete mode 100644 tests/opentelemetry-docker-tests/tests/otlp-file-data/logs/.gitkeep delete mode 100644 tests/opentelemetry-docker-tests/tests/otlp-file-data/metrics/.gitkeep delete mode 100644 tests/opentelemetry-docker-tests/tests/otlp-file-data/traces/.gitkeep diff --git a/tests/opentelemetry-docker-tests/tests/.gitignore b/tests/opentelemetry-docker-tests/tests/.gitignore index 0242039b261..00f8578309a 100644 --- a/tests/opentelemetry-docker-tests/tests/.gitignore +++ b/tests/opentelemetry-docker-tests/tests/.gitignore @@ -1,3 +1,4 @@ -# JSON output written by the OTLP JSON File exporter during docker tests and -# tailed by the collector's otlp_json_file receiver (see docker-compose.yml). -otlp-file-data/**/*.jsonl +# Directory the OTLP JSON File exporter writes to during docker tests, created at +# runtime and tailed by the collector's otlp_json_file receiver (see +# docker-compose.yml). +otlpexporter/otlp-file-data/ diff --git a/tests/opentelemetry-docker-tests/tests/docker-compose.yml b/tests/opentelemetry-docker-tests/tests/docker-compose.yml index 0d42cb3069c..b686d2848a8 100644 --- a/tests/opentelemetry-docker-tests/tests/docker-compose.yml +++ b/tests/opentelemetry-docker-tests/tests/docker-compose.yml @@ -10,7 +10,7 @@ services: command: ["--config=/etc/otelcol/collector-config.yaml"] volumes: - ./collector-config.yaml:/etc/otelcol/collector-config.yaml - - ./otlp-file-data:/otlp-file-data + - ./otlpexporter/otlp-file-data:/otlp-file-data ports: - "4317:4317" - "4318:4318" diff --git a/tests/opentelemetry-docker-tests/tests/otlp-file-data/logs/.gitkeep b/tests/opentelemetry-docker-tests/tests/otlp-file-data/logs/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/opentelemetry-docker-tests/tests/otlp-file-data/metrics/.gitkeep b/tests/opentelemetry-docker-tests/tests/otlp-file-data/metrics/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/opentelemetry-docker-tests/tests/otlp-file-data/traces/.gitkeep b/tests/opentelemetry-docker-tests/tests/otlp-file-data/traces/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py index df852a716f0..500bcd926b2 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py @@ -17,8 +17,8 @@ } # Directory bind-mounted into the collector container (see docker-compose.yml). -# Resolved relative to the compose file, which sits one level above this package. -OTLP_FILE_DATA_DIR = Path(__file__).parent.parent / "otlp-file-data" +# Created at runtime (gitignored) and resolved relative to this package. +OTLP_FILE_DATA_DIR = Path(__file__).parent / "otlp-file-data" @dataclass @@ -26,14 +26,14 @@ class ExporterConfig(Generic[ExporterT]): id: str exporter_class: type[ExporterT] kwargs: dict[str, Any] = field(default_factory=dict) - lazy_kwargs: Callable[[], dict[str, Any]] | None = None + lazy_kwargs: dict[str, Callable[[], Any]] = field(default_factory=dict) def build(self) -> ExporterT: - extra = self.lazy_kwargs() if self.lazy_kwargs is not None else {} + extra = {key: factory() for key, factory in self.lazy_kwargs.items()} return self.exporter_class(**self.kwargs, **extra) -def new_otlp_file(signal: str) -> str: +def make_otlp_file(signal: str) -> str: """Return a unique .jsonl path under the collector-mounted directory. ``signal`` is one of ``"traces"``, ``"metrics"``, ``"logs"`` and selects the diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py index 420b45d690e..4d7b42e27d5 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_logs_functional.py @@ -31,7 +31,7 @@ from opentelemetry.sdk.resources import Resource from opentelemetry.test._otlp_test_server import OtlpProtoTestServer -from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, new_otlp_file +from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, make_otlp_file LOG_EXPORTER_CONFIGS: list[ExporterConfig[LogRecordExporter]] = [ ExporterConfig( @@ -81,7 +81,7 @@ ExporterConfig( id="file", exporter_class=FileLogExporter, - lazy_kwargs=lambda: {"path": new_otlp_file("logs")}, + lazy_kwargs={"path": lambda: make_otlp_file("logs")}, ), ] diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py index 5428986075a..2b92b21c70f 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_metrics_functional.py @@ -35,7 +35,7 @@ from opentelemetry.sdk.resources import Resource from opentelemetry.test._otlp_test_server import OtlpProtoTestServer -from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, new_otlp_file +from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, make_otlp_file METRIC_EXPORTER_CONFIGS: list[ExporterConfig[MetricExporter]] = [ ExporterConfig( @@ -85,7 +85,7 @@ ExporterConfig( id="file", exporter_class=FileMetricExporter, - lazy_kwargs=lambda: {"path": new_otlp_file("metrics")}, + lazy_kwargs={"path": lambda: make_otlp_file("metrics")}, ), ] diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py index c11f4e51f99..adf9250042d 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py @@ -27,7 +27,7 @@ from opentelemetry.test._otlp_test_server import OtlpProtoTestServer from opentelemetry.trace import Link, SpanContext, StatusCode, TraceFlags -from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, new_otlp_file +from . import CUSTOM_HEADERS, ExporterConfig, _attrs_to_dict, make_otlp_file TRACE_EXPORTER_CONFIGS: list[ExporterConfig[SpanExporter]] = [ ExporterConfig( @@ -77,7 +77,7 @@ ExporterConfig( id="file", exporter_class=FileSpanExporter, - lazy_kwargs=lambda: {"path": new_otlp_file("traces")}, + lazy_kwargs={"path": lambda: make_otlp_file("traces")}, ), ] diff --git a/tox.ini b/tox.ini index 6f6dd628536..dc09b25193c 100644 --- a/tox.ini +++ b/tox.ini @@ -379,11 +379,13 @@ deps = allowlist_externals = docker + mkdir changedir = tests/opentelemetry-docker-tests/tests commands_pre = + mkdir -p otlpexporter/otlp-file-data/traces otlpexporter/otlp-file-data/metrics otlpexporter/otlp-file-data/logs docker compose version docker compose up -d commands = From 61233aee5c0df262164d0f1d1f20ad61acd8a83b Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Tue, 14 Jul 2026 23:01:34 -0400 Subject: [PATCH 3/5] small refactor --- .../tests/otlpexporter/__init__.py | 13 ++++--------- .../otlpexporter/test_otlp_traces_functional.py | 6 +++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py index 500bcd926b2..66c7864e970 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/__init__.py @@ -6,7 +6,7 @@ from collections.abc import Callable from dataclasses import dataclass, field from pathlib import Path -from typing import Any, Generic, TypeVar +from typing import Any, Generic, Literal, TypeVar from uuid import uuid4 ExporterT = TypeVar("ExporterT") @@ -16,8 +16,7 @@ "x-another-header": "another-value", } -# Directory bind-mounted into the collector container (see docker-compose.yml). -# Created at runtime (gitignored) and resolved relative to this package. +# Directory bind mounted into the collector container (see docker-compose.yml). OTLP_FILE_DATA_DIR = Path(__file__).parent / "otlp-file-data" @@ -33,12 +32,8 @@ def build(self) -> ExporterT: return self.exporter_class(**self.kwargs, **extra) -def make_otlp_file(signal: str) -> str: - """Return a unique .jsonl path under the collector-mounted directory. - - ``signal`` is one of ``"traces"``, ``"metrics"``, ``"logs"`` and selects the - subdirectory the collector's ``otlp_json_file/`` receiver tails. - """ +def make_otlp_file(signal: Literal["traces", "metrics", "logs"]) -> str: + """Return a unique .jsonl path under the collector mounted directory.""" directory = OTLP_FILE_DATA_DIR / signal directory.mkdir(parents=True, exist_ok=True) return str(directory / f"{uuid4().hex}.jsonl") diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py index adf9250042d..e917ad33e98 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/test_otlp_traces_functional.py @@ -10,15 +10,15 @@ from grpc import Compression as GRPCCompression from inline_snapshot import snapshot +from opentelemetry.exporter.otlp.json.file.trace_exporter import ( + FileSpanExporter, +) from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( OTLPSpanExporter as GRPCSpanExporter, ) from opentelemetry.exporter.otlp.proto.http import ( Compression as HTTPCompression, ) -from opentelemetry.exporter.otlp.json.file.trace_exporter import ( - FileSpanExporter, -) from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( OTLPSpanExporter as HTTPSpanExporter, ) From d510c9b1b474720a50ce75dc7a01457ae83f20e6 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Tue, 14 Jul 2026 23:02:16 -0400 Subject: [PATCH 4/5] add changelog fragment --- .changelog/5412.added | 1 + 1 file changed, 1 insertion(+) create mode 100644 .changelog/5412.added diff --git a/.changelog/5412.added b/.changelog/5412.added new file mode 100644 index 00000000000..62e35791f17 --- /dev/null +++ b/.changelog/5412.added @@ -0,0 +1 @@ +`opentelemetry-exporter-otlp-json-file`: add OTLP JSON file Docker tests From 820534a52dc8850bc327e689e87f8476811f0325 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Wed, 15 Jul 2026 21:50:28 -0400 Subject: [PATCH 5/5] remove stale .jsonl files --- .../tests/otlpexporter/conftest.py | 12 ------------ tox.ini | 4 ++++ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py b/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py index 671cb57d443..d777a33fa6a 100644 --- a/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py +++ b/tests/opentelemetry-docker-tests/tests/otlpexporter/conftest.py @@ -9,18 +9,6 @@ from opentelemetry.test._otlp_test_server import OtlpProtoTestServer -from . import OTLP_FILE_DATA_DIR - - -@pytest.fixture(scope="session", autouse=True) -def clean_otlp_file_data() -> None: - """Remove stale .jsonl files so the collector doesn't replay old runs.""" - for signal in ("traces", "metrics", "logs"): - directory = OTLP_FILE_DATA_DIR / signal - directory.mkdir(parents=True, exist_ok=True) - for stale in directory.glob("*.jsonl"): - stale.unlink() - @pytest.fixture(scope="class") def server() -> Iterator[OtlpProtoTestServer]: diff --git a/tox.ini b/tox.ini index dc09b25193c..0d5b7fbbff7 100644 --- a/tox.ini +++ b/tox.ini @@ -380,11 +380,15 @@ deps = allowlist_externals = docker mkdir + rm changedir = tests/opentelemetry-docker-tests/tests commands_pre = + ; Remove stale .jsonl files so the collector doesn't replay old runs, then + ; recreate the dirs (user-owned) before docker creates the bind-mount source. + rm -rf otlpexporter/otlp-file-data mkdir -p otlpexporter/otlp-file-data/traces otlpexporter/otlp-file-data/metrics otlpexporter/otlp-file-data/logs docker compose version docker compose up -d