diff --git a/src/observability/tests/test_file_exporter.py b/src/observability/tests/test_file_exporter.py index d79b76195..a90c5acae 100644 --- a/src/observability/tests/test_file_exporter.py +++ b/src/observability/tests/test_file_exporter.py @@ -5,6 +5,7 @@ import json from pathlib import Path +import pytest from opentelemetry import trace from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider @@ -14,6 +15,9 @@ from observability import runspan as _runspan from observability.file_exporter import OTLPJsonFileExporter +# Encoding needs protobuf and the OTLP encoder, both from the "otel" group. +_OTLP_ENCODER = "opentelemetry.exporter.otlp.proto.common._internal.trace_encoder" + def _reset_provider(): """Swap in a fresh global TracerProvider for the next test.""" @@ -32,6 +36,7 @@ def _install_file_exporter(path: Path) -> TracerProvider: def test_file_exporter_writes_jsonl(tmp_path: Path): + pytest.importorskip(_OTLP_ENCODER) out = tmp_path / "traces.jsonl" _install_file_exporter(out) @@ -64,6 +69,7 @@ def test_file_exporter_creates_parent_dir(tmp_path: Path): def test_file_exporter_appends(tmp_path: Path): + pytest.importorskip(_OTLP_ENCODER) out = tmp_path / "traces.jsonl" _install_file_exporter(out)