open-telemetry / open-telemetry/opentelemetry-python-contrib

Flaky aiohttp-server test

Open
#4,811 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

___________________ test_non_global_tracer_provider[tracer0] ___________________

tracer = (<opentelemetry.sdk.trace.TracerProvider object at 0x7fcd595da2f0>, <opentelemetry.sdk.trace.export.in_memory_span_exporter.InMemorySpanExporter object at 0x7fcd595d8640>)
server_fixture = (<aiohttp.test_utils.TestServer object at 0x7fcd5905cf10>, <Application 0x7fcd5905fa60>)
aiohttp_client = <function aiohttp_client.<locals>.go at 0x7fcd58e052d0>

    @pytest.mark.asyncio
    @pytest.mark.parametrize(
        "tracer",
        [
            TestBase().create_tracer_provider(
                sampler=ParentBased(TraceIdRatioBased(0.05))
            )
        ],
    )
    async def test_non_global_tracer_provider(
        tracer,
        server_fixture,
        aiohttp_client,
    ):
        n_requests = 1000
        collection_ratio = 0.05
        n_expected_trace_ids = n_requests * collection_ratio
    
        _, memory_exporter = tracer
        server, _ = server_fixture
    
        assert len(memory_exporter.get_finished_spans()) == 0
    
        client = await aiohttp_client(server)
        for _ in range(n_requests):
            await client.get("/test-path")
    
        trace_ids = {
            span.context.trace_id
            for span in memory_exporter.get_finished_spans()
            if span.context is not None
        }
>       assert (
            0.5 * n_expected_trace_ids
            <= len(trace_ids)
            <= 1.5 * n_expected_trace_ids
        )
E       assert 76 <= (1.5 * 50.0)
E        +  where 76 = len({2870422772196705649903001175704674312, 5236962977604931392781393493980307814, 9166974748134247912278532743094285373, 11186596335564230688763845256640643026, 17107527909052643297455219803861083764, 19284384784456314131277395680413534400, ...})

instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/test_aiohttp_server_integration.py:451: AssertionError

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/test_aiohttp_server_integration.py, especially test_non_global_tracer_provider around line 451, and run the test repeatedly to reproduce the failure. Inspect how the 1,000 requests and sampling assertion are exercised; done means the test reliably validates the expected sampling behavior without intermittent failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.