requests
instrumentation should not modify the custom headers dictionary
#1729
Labels
bug
Something isn't working
Describe your environment
Using python 3.10 and
Steps to reproduce
When you pass a custom header dictionary to requests, e.g.
requests.get("http://example.com", headers=myheaders)
, opentelemetry instrumentation code injects tracing headers into it. However it should create a copy of the dict instead of modifying it directly. It leads to subtle bugs when the header dictionary is a variable that is long lived and used elsewhere in the user code.Running the code below illustrates the problem.
What is the expected behavior?
Instrumentation should not modify the dictionary. The code above should print
What is the actual behavior?
Instead, the dictionary is modified and the code above prints something like
The text was updated successfully, but these errors were encountered: