Problem
We'd like to use opentelemetry to instrument requests for internal HTTP requests, but we also send requests to external parties. If we put user IDs in baggage, we'd prefer not to send those outside of our systems, but there is no way to do that with the current approach.
Desired solution
Provide configuration for which origins have propagation enabled. This could take the form of allow- and deny-lists, or a user-provided callback that returns a boolean based on the request.
Alternatives
Let the user instrument individual Session objects so that they can use an instrumented Session for internal calls, and an uninstrumented one for external calls. The API could be mirrored off of the flask instrumentation, which provides an instrument_app method.
So, perhaps an interface like:
class RequestsInstrumentor(BaseInstrumentor):
# ... existing contents
def instrument_session(session: requests.Session) -> None:
...
def uninstrument_session(session: requests.Session) -> None:
...
This has a downside of not creating spans for those calls, when all we actually want is to prevent context propagation. It also forces cookie saving and connection pooling on users, making it hard to get the same behaviour as the bare requests.{get, post, ...} methods.
Problem
We'd like to use opentelemetry to instrument requests for internal HTTP requests, but we also send requests to external parties. If we put user IDs in baggage, we'd prefer not to send those outside of our systems, but there is no way to do that with the current approach.
Desired solution
Provide configuration for which origins have propagation enabled. This could take the form of allow- and deny-lists, or a user-provided callback that returns a boolean based on the request.
Alternatives
Let the user instrument individual Session objects so that they can use an instrumented Session for internal calls, and an uninstrumented one for external calls. The API could be mirrored off of the flask instrumentation, which provides an
instrument_appmethod.So, perhaps an interface like:
This has a downside of not creating spans for those calls, when all we actually want is to prevent context propagation. It also forces cookie saving and connection pooling on users, making it hard to get the same behaviour as the bare
requests.{get, post, ...}methods.