Skip to content

Clear capture_message_content env var in programmatic override test - #109

Closed
xrmx with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-3774433771
Closed

Clear capture_message_content env var in programmatic override test#109
xrmx with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-3774433771

Conversation

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown

test_can_override_capture_message_content_programmatically was non-deterministic: if OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT was set in the environment, it would override the programmatic capture_message_content=True argument, causing the assertion to fail or pass for the wrong reason.

Changes

  • tests/test_instrumentor.py: Pop OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT from the environment before calling instrumentor.instrument(capture_message_content=True), ensuring the test actually validates the programmatic override path regardless of CI/local environment state.
def test_can_override_capture_message_content_programmatically(instrument):
    instrument.uninstrument()
    instrumentor = OpenAIInstrumentor()
    env_var = "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"
    os.environ.pop(env_var, None)  # prevent env from overriding programmatic setting
    instrumentor.instrument(capture_message_content=True)
    assert instrumentor.capture_message_content
    instrumentor.uninstrument()

Co-authored-by: xrmx <12932+xrmx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code as per review comment 3774433771 Clear capture_message_content env var in programmatic override test Aug 13, 2026
Copilot AI requested a review from xrmx August 13, 2026 10:24
@xrmx xrmx closed this Aug 13, 2026
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.

2 participants