When we instrument requests + an exporter that uses http requests and grpc (ex. cloud trace exporter) we get an infinite loop. The flow is:
Span A (manually started by user)
When we export span A, the exporter makes a request, that request is wrapped and instrumented in Span B.
When we export span B, the exporter makes a request, that request is wrapped and instrumented in Span C.
When we export span C, the exporter makes a request, that request is wrapped and instrumented in Span D.
...
forever.
How this issue is usually resolved is by adding the flag "suppress_instrumentation" to contextvars before exporting, so that requests are NOT wrapped and instrumented anymore. Cloud Trace exporter uses grpc, which spins up a new thread, where contextvars are ignored, that makes a request which, since contextvars got ignored, continues to infinite loop.
The current solution is simply to blacklist and always suppress the url that grpc makes the request to. This is obviously not the best way to deal with the issue for a variety of reasons (e.g. what is the url changes in the future? What is grpc changes and makes more requests? What if the user wants to legitimately instrument a request to this url?).
I've talked with the grpc team and they have said there is currently no way of passing contextvars to grpc threads, but it is something they are working on. Another possible solution is changing the oauth threadpool to someone have this flag in its contextvars.