Skip to content

fix(observability): skip OTLP-JSON exporter tests without the otel extra - #641

Open
abhati27 wants to merge 1 commit into
IBM:mainfrom
abhati27:bugfix/otlp-exporter-test-skip
Open

abhati27 wants to merge 1 commit into
IBM:mainfrom
abhati27:bugfix/otlp-exporter-test-skip

Conversation

@abhati27

Copy link
Copy Markdown

Description

uv run pytest src/ -k "not integration" fails on a fresh clone with two errors in
src/observability/tests/test_file_exporter.py, both
ModuleNotFoundError: No module named 'google.protobuf'.

Fix Details

The two encoding tests go through _encode_otlp_json, which imports protobuf and the
OTLP common trace encoder. Both come from the optional otel dependency group, so a
default uv sync doesn't install them. Gated those two tests with
pytest.importorskip so they skip when the extra is absent and still run when it's
present. test_file_exporter_creates_parent_dir is left alone since it doesn't encode
anything.

This follows what INSTRUCTIONS.md already describes for the server suites, where a
missing dependency skips rather than fails.

Impact on Benchmarking

  • No change to baselines: This fix only improves stability/performance.

Test-only change, no scorer or runtime code touched.

Related Issues

  • Fixes: no existing issue, found while setting the repo up locally.

Verification Steps

  1. uv run pytest src/ -k "not integration"

    install before after
    default uv sync 8 failed, 696 passed, 3 skipped 6 failed, 696 passed, 5 skipped

    The remaining 6 are unrelated, in test_static_json_scorer.py, which passes an
    evaluation_metadata= kwarg that evaluate_static_json doesn't accept.

  2. Checked both directions so the guard isn't a permanent mute:

    • uv sync --group otel, then pytest src/observability/tests/test_file_exporter.py → 3 passed
    • uv sync, then the same → 1 passed, 2 skipped
    • uvx ruff check and uvx ruff format --check clean on the changed file

Checklist

  • I have added tests that prove my fix is effective — this change is to the tests
    themselves, verified by running them with and without the otel extra, as above.
  • My code follows the project's Ruff formatting and linting rules.
  • I have signed off my commits (DCO).

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 <anmolvb11@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 15, 2026 04:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@DhavalRepo18

Copy link
Copy Markdown
Collaborator

@abhati27 Whould you like to create a git issue first.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants