You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add basic Open Telemetry instrumentation for all requests.
This commit wraps all requests in an Open Telemetry span that abides by
the semantic conventions for HTTP clients [0] (insofar as I understand
them). We also propagate the trace context [1] when there is one.
The main subtlety is that I had to tweak some of httr2's internals so
that request signing can take into account new headers. Luckily there is
fairly comprehensive test coverage so I'm fairly sure at this point that
I haven't broken anything.
Right now this instrumentation is opt in: `otel` is in `Suggests`, and
tracing must be enabled (e.g. via the `OTEL_TRACES_EXPORTER` environment
variable). Otherwise this is costless at runtime.
For example:
library(otelsdk)
Sys.setenv(OTEL_TRACES_EXPORTER = "stderr")
request("https://google.com") |>
req_perform()
I'm not sure that `otel` needs to move to `Imports`, because by design
users actually need the `otelsdk` package to enable tracing anyway.
Unit tests are included.
[0]: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-client-span
[1]: https://www.w3.org/TR/trace-context/
Signed-off-by: Aaron Jacobs <[email protected]>
0 commit comments