OpentelemetryProcessPropagator.Task
provides a set of extensions to the Task
module to reduce some boilerplate in propagating OpenTelemetry contexts across process boundaries. Since these are extensions rather than a replacement of Elixir's module, this library can be aliased into a file without concern for creating spans where you do not want them.
Each Task
function is replicated with two variants: *_with_span
and *_with_linked_span
. Each of these variations has a specific use case. The original implementation for each function automatically propagates the current context.
*
- propagates the current context*_with_span
- propagates the current context and starts a new child span.*_with_linked_span
- propagates the current context and starts a new linked span.Module RedefinementUsageThis module does not redefine the
Task
module, instead providing a wrapper of the module, so this functionality will not globally modify the default behavior of theTask
module.
defmodule MyApp do
require OpenTelemetry.Tracer
alias OpentelemetryProcessPropagator.Task
def traced_task_with_existing_span do
Task.async(fn ->
:ok
end)
|> Task.await()
end
def traced_task_with_new_span do
Task.async_with_span(:span_name, %{attributes: %{a: "b"}}, fn ->
Tracer.set_attribute(:c, "d")
:ok
end)
|> Task.await()
end
def traced_task_with_new_linked_span do
Task.async_with_linked_span(:span_name, %{attributes: %{a: "b"}}, fn ->
Tracer.set_attribute(:c, "d")
:ok
end)
|> Task.await()
end
end
Summary Functions
Returns a stream that runs the given function fun
concurrently on each element in enumerable
with the current OpenTelemetry.Ctx.t/0
attached.
Returns a stream where the given function (module
and function
) is mapped concurrently on each element in enumerable
with the current OpenTelemetry.Ctx.t/0
attached.
Returns a stream that runs the given function fun
concurrently on each element in enumerable
with a new linked span.
Returns a stream where the given function (module
and function
) is mapped concurrently on each element in enumerable
with a new linked span.
Returns a stream that runs the given function fun
concurrently on each element in enumerable
with a new child span.
Returns a stream where the given function (module
and function
) is mapped concurrently on each element in enumerable
with a new child span.
Starts a task with a new linked span that can be awaited on.
Starts a task with a new linked span that can be awaited on.
Starts a task with a new child span that can be awaited on.
Starts a task with a new child span that can be awaited on.
Starts a task as part of a supervision tree with the given fun
with the current OpenTelemetry.Ctx.t/0
attached.
Starts a task as part of a supervision tree with the given module
, function
, and args
with the current OpenTelemetry.Ctx.t/0
attached.
Starts a task as part of a supervision tree with the given fun
in a new linked span.
Starts a task as part of a supervision tree with the given module
, function
, and args
in a new linked span.
Starts a task as part of a supervision tree with the given fun
in a new child span.
Starts a task as part of a supervision tree with the given module
, function
, and args
in a new child span.
Starts a task with a new linked span.
Starts a task with a new linked span.
Starts a task with a new child span.
Starts a task with a new child span.
FunctionsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4