From 3dd1a3fe2853880e957b4cdb32b2961c85c239da Mon Sep 17 00:00:00 2001 From: abhati27 Date: Thu, 15 Oct 2026 00:48:20 -0400 Subject: [PATCH] fix(observability): skip OTLP-JSON exporter tests without the otel extra The two encoding tests exercise _encode_otlp_json, which imports protobuf and opentelemetry-exporter-otlp-proto-common. Both ship in the optional otel dependency group, so a default `uv sync` leaves them failing on a fresh clone. Gate them with importorskip so they skip when the extra is absent and still run when it is present, matching how the server suites skip on a missing service. Before: 8 failed, 696 passed, 3 skipped After: 6 failed, 696 passed, 5 skipped (remaining 6 are unrelated, in test_static_json_scorer.py) Signed-off-by: abhati27 --- src/observability/tests/test_file_exporter.py | 6 ++++++ 1 file changed, 6 insertions(+) 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)