Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/observability/tests/test_file_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."""
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down