View Source OpentelemetryAbsinthe.Helpers (opentelemetry_absinthe v2.2.1)
OpenTelemetry-friendly alternatives of Absinthe.Resolution.Helpers functions
Some of the standard absinthe resolution helpers, like batch
or async
,
are not "opentelemetry-friendly": the resolvers, when invoked, lose the active span
and break the trace propagation.
This module defines compatible alternatives that can be used in the same way, but don't lose the trace information.
Summary
Functions
Wrapper around the "real" batch function used by batch_keep_span
Works like Absinthe.Resolution.Helpers.batch, but preserves the active span.
Functions
Wrapper around the "real" batch function used by batch_keep_span
Takes the passed span and sets it as the active one, then calls the original batch function with the original parameter.
@spec batch_keep_span( Absinthe.Middleware.Batch.batch_fun(), any(), Absinthe.Middleware.Batch.post_batch_fun() ) :: {:middleware, Absinthe.Middleware.Batch, term()}
Works like Absinthe.Resolution.Helpers.batch, but preserves the active span.
The function supplied to the batch
helper is executed in a Task by Absinthe,
which means that the erlang opentelemetry SDK would lose track of the currently
active span, because they are kept in a pdict.
To work around this, you can just replace batch
with batch_keep_span
,
and the active span will be automatically passed and reset as the active one
inside the batch function.
@spec batch_keep_span( Absinthe.Middleware.Batch.batch_fun(), any(), Absinthe.Middleware.Batch.post_batch_fun(), opts :: [{:timeout, pos_integer()}] ) :: {:middleware, Absinthe.Middleware.Batch, term()}