-
Notifications
You must be signed in to change notification settings - Fork 808
Description
Latest release 0.32b0 introduced a bug where an additional span is created every time a new aiohttp ClientSession is created. This leads to 1 span per request when the first session is created, 2 spans when the second session gets created, ... and so on.
When AioHttpClientInstrumentor.instrument() the instrumentor intercepts the ClientSession.__init__ call and injects a TraceConfig instance into the parameters that are passed to the ClientSession. With the latest release an additional parameter trace_configs was added to the AioHttpClientInstrumentor.instrument() method.
The problem is that the trace_configs argument is now injected into every newly created ClientSession but it is also shared between all ClientSessions.
Every time a new ClientSession is created the instrumented __init__ call now adds one additional trace_config to the shared trace_configs argument (associated code can be found here). Since one trace_config defines the hooks to create and end one span, every added trace_config will produce an additional span per request.
Steps to reproduce
Instrument the aiohttp-client with AioHttpClientInstrumentor.instrument(). Create at least two ClientSessions and make one HTTP request to some arbitrary URL. The produced spans increase with every new ClientSession that is created.
Describe exactly how to reproduce the error. Include a code sample if applicable.
What is the expected behavior?
One span per HTTP request independent of the number of ClientSessions that are created.
What is the actual behavior?
Number of created spans increase with each newly created ClientSession.