Skip to content

openai: make instrument fixture explicit - #108

Merged
xrmx merged 5 commits into
elastic:mainfrom
nehachinnasani23:fix/openai-explicit-instrument-fixture
Aug 13, 2026
Merged

openai: make instrument fixture explicit#108
xrmx merged 5 commits into
elastic:mainfrom
nehachinnasani23:fix/openai-explicit-instrument-fixture

Conversation

@nehachinnasani23

Copy link
Copy Markdown
Contributor

Summary

  • Remove autouse from the OpenAI instrument test fixture and require tests to opt in explicitly.
  • Add a capture-message-content instrumentation fixture for tests that need OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true.
  • Remove repeated uninstrument/reinstrument blocks from capture-message-content tests.

Closes #55

Testing

  • . .venv/bin/activate && cd instrumentation/elastic-opentelemetry-instrumentation-openai && pytest tests/test_instrumentor.py tests/test_embeddings.py tests/test_chat_completions.py
  • . .venv/bin/activate && cd instrumentation/elastic-opentelemetry-instrumentation-openai && pytest
  • . .venv/bin/activate && python -m compileall -q instrumentation/elastic-opentelemetry-instrumentation-openai/tests/conftest.py instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_instrumentor.py instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_embeddings.py instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_chat_completions.py instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_beta_chat_completions.py
  • git diff --check

Note

  • python -m ruff check ... was attempted, but ruff is not installed in the dev requirements environment.

@nehachinnasani23
nehachinnasani23 requested a review from a team as a code owner August 13, 2026 04:59
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the OpenAI instrumentation test suite to make instrumentation opt-in per test, and introduces a dedicated fixture for tests that must run with OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true.

Changes:

  • Remove autouse=True from the instrument fixture and require tests to request instrumentation explicitly.
  • Add a capture_message_content_instrument fixture that sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true and instruments accordingly.
  • Simplify capture-message-content tests by removing repeated manual uninstrument/reinstrument blocks.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
instrumentation/elastic-opentelemetry-instrumentation-openai/tests/conftest.py Makes instrumentation fixtures explicit and adds a capture-message-content variant.
instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_instrumentor.py Adjusts instrumentor tests to no longer rely on autouse instrumentation.
instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_embeddings.py Updates tests to opt in to instrumentation via the instrument fixture.
instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_chat_completions.py Updates tests to opt in to instrumentation; uses capture-message-content fixture where required.
instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_beta_chat_completions.py Same as above for beta chat completions tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread instrumentation/elastic-opentelemetry-instrumentation-openai/tests/conftest.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@xrmx
xrmx merged commit 557f689 into elastic:main Aug 13, 2026
14 checks passed
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.

openai: make the instrument fixture explicit

3 participants