-
Notifications
You must be signed in to change notification settings - Fork 72
Description
I'm interested in seeing telemetry extended with an API to enable an additional type of instrumentation - the mutation of an outbound request / query with Distributed Trace context information.
The general API could be implemented as an instrumentation hook that a library could build into their code that enables telemetry handlers to mutate specific data structures.
Taking HTTP requests as an example, we could imagine an HTTP client library adding telemetry hooks:
defmodule HttpClient do
def request(url, body, headers) do
extra_headers =
:telemetry.decorate(
[:httpoison, :request, :headers],
%{url: url, body: body, headers: headers}
)
validate(extra_headers)
do_request(url, body, headers ++ extra_headers)
end
endThen a handler could attach to [:httpoison, :request, :headers], and do some work in the handler...
defmodule MyTelemetryHandler do
def handle([:httpoison, :request, :headers], request) do
context = get_trace_context(request)
generate_distributed_tracing_headers(context)
end
endThis would provide a general mechanism for outbound instrumentation, without hard-wiring to any vendor-specific instrumentation details.
Very open to discussions about strategy and naming!
Issues to sort out:
- Clarify naming for the various parts of the puzzle
- Account for collecting annotations from multiple handlers
- Have a mechanism or pattern for validating the data returned from handlers
For context, this issue has been discussed before in #24 and beam-telemetry/telemetry_metrics#46