Skip to content

fix(roadmap): alternatives ADR cap test reads logs of other loggers #4062

Description

@dan-petty

What happens

tests/roadmap/test_roadmap_alternatives.py::test_the_decisions_are_cut_by_whole_entries_the_oldest_go_first_and_a_warning_says_so failed in one full local devops ci run on a loaded host. The test passes alone (166 passed in the file) and passes in the four GitHub shards.

Cause

The test compares the list of ALL warning records with the one expected warning. In the failing run, eight extra records came from the logger opentelemetry.sdk.trace.export with the text "Processor is already shutdown, ignoring call". A test that ran before it in the same xdist worker shut a span processor down and left the tracer state behind.

Expected

The test reads only the records of the logger devops_cli.roadmap.adr. The test that leaves the shut processor behind is found and its tracer state is reset.

Steps

  1. Run uv run devops ci on a loaded host, or run the telemetry tests and then the file in one worker.
  2. Read the assertion at index 4 of the tuple.

Proposed design

Problem statement

The alternatives ADR cap test failed on a loaded host because it read warnings from other loggers. PR #4077 filters its records by logger name. A telemetry test still shuts down a span processor and leaves tracer state behind, so later tests can emit spurious warnings.

Acceptance criteria

Requirement: ADR cap test reads one logger

The alternatives ADR cap test SHALL assert only on log records whose logger name is devops_cli.roadmap.adr.

Scenario: An unrelated logger warns

  • WHEN A logger other than devops_cli.roadmap.adr emits a warning during the ADR cap test.
  • THEN The test ignores that warning and asserts only the ADR cap warning.

Requirement: Telemetry test restores tracer state

The telemetry test that shuts down a span processor SHALL restore the OpenTelemetry tracer state after it runs.

Scenario: A later test exports a span

  • WHEN The telemetry test that shuts down a span processor finishes and a later test exports a span.
  • THEN No Processor is already shutdown, ignoring call warning is logged by opentelemetry.sdk.trace.export.

Requirement: Combined worker run passes

The telemetry tests and the alternatives ADR cap test SHALL pass when they run in one pytest worker.

Scenario: Telemetry tests run first

  • WHEN The telemetry tests and the alternatives ADR cap test run in one pytest worker with the telemetry tests first.
  • THEN pytest exits with status 0 and the ADR cap test reports no Processor is already shutdown, ignoring call warning.

Existing Tool Considered

No alternatives check has run. pytest's caplog fixture covers logger-scoped log capture. The OpenTelemetry TracerProvider lifecycle covers tracer-state restore. No new tool or library is necessary.

Key questions

  • Should the ADR cap test filter captured records by logger name?: Yes. The test reads only records whose logger name is devops_cli.roadmap.adr. Keep that filter and add a regression case for an unrelated warning. (best practice) [sources: tests/roadmap/test_roadmap_alternatives.py]
    • Chosen: Filter by logger name. It isolates the test from warnings of other loggers, including OpenTelemetry.
    • Rejected: Assert every captured warning. It fails when an unrelated logger warns, as the loaded-host run showed.
  • How should the test that shuts down a span processor restore tracer state?: Use a pytest fixture that saves the global tracer provider before the test and restores it after the test. Do not leave a shut provider in place. (best practice) [sources: tests/support/fakes/otlp.py, tests/roadmap/test_roadmap_alternatives.py]
    • Chosen: Save and restore the provider in a fixture. It restores global state after the test and keeps later tests isolated.
    • Rejected: Reset the provider in each telemetry test. It repeats setup and a new test can miss it.
    • Rejected: Filter later tests only. It hides the leak and keeps cross-test coupling.
  • Should the fix change production code or only tests?: Change only tests. The failure comes from cross-test state leakage, not from production logging or tracing. (best practice) [sources: tests/roadmap/test_roadmap_alternatives.py]
    • Chosen: Test-only change. It fixes isolation without changing runtime behavior.
    • Rejected: Change production logging or tracing. It adds risk and does not fix the leaked test state.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-10: partly.
Tool: pytest-dev/pytest (https://github.com/pytest-dev/pytest), MIT, last activity 2026-11-09, maintained.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. A flaky test under load causes CI noise but does not block a user-facing feature.
    • Value: Medium. It removes a recurring CI failure that blocks merge confidence.
    • Effort: Low. The fix is to add a logger-name filter in one test and reset tracer state in another.
    • Related: fix(tests): a logfire console span leaks into stdout of a later test #3532, which asks for a different change. Both fix test pollution from telemetry state in xdist workers, but the candidate filters log records by logger name while #3532 stops a logfire span from writing to stdout.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    The test fails on PR #4077 (shard 2 of 4, run 42416842507): the log records hold 'Processor is already shutdown, ignoring call' lines next to the expected warning. #4077 does not touch this test or alternatives code. I re-ran the failed job.

  5. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    PR #4077 filters the log records of three alternatives tests by logger name (the first half of Expected). The second half stays open: find the test that leaves the shut span processor and reset its tracer state. The shard of #4077 failed twice on this test, so the order of tests in the worker made it fail every time there.

  6. added
    status/ready
    and removed
    status/new
    on Nov 8, 2026
  7. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at b9c88de (see proposed design in issue body).

  8. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: pytest's caplog fixture, which the test already uses, captures records per logger, so filtering by logger name needs no new tool. The pytest repository read confirms it is maintained. My one web search found no ready-made tool that resets OpenTelemetry's global tracer state between tests, so the fixture that saves and restores the provider has to be written in the repository.

    Tool: pytest-dev/pytest (https://github.com/pytest-dev/pytest)

    • License: MIT
    • Last activity: 2026-11-09
    • Maintained: yes

    Covers:

    • Logger-scoped log capture and filtering via caplog
    • Fixture mechanism to save and restore global state after each test

    Lacks:

    • Finding the telemetry test that leaves a shut span processor behind
    • A ready-made reset of the OpenTelemetry global tracer provider

    Tools considered:

    Searches run:

    • pytest reset OpenTelemetry global tracer provider between tests fixture, results: 5

    Sources:

    Checked on 2026-11-10. A person decides what this means for the item. The check changes no label and closes no issue.

  9. removed
    status/ready
    on Nov 14, 2026
  10. added a commit that references this issue on Nov 14, 2026
  11. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor
  12. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions