View Source OpentelemetryProcessPropagator.Task (Opentelemetry Process Propagator v0.2.2)
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 Redefinement
This 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.
usage
Usage
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
Link to this section Summary
Functions
Starts a task with the current OpenTelemetry.Ctx.t/0
that can be awaited on.
Starts a task with the current OpenTelemetry.Ctx.t/0
that can be awaited on.
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.
See Task.await/1
.
Starts a task with the current OpenTelemetry.Ctx.t/0
.
Starts a task with the current OpenTelemetry.Ctx.t/0
.
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.
See Task.yield/1
.
Link to this section Functions
Starts a task with the current OpenTelemetry.Ctx.t/0
that can be awaited on.
See Task.async/1
for more information.
Starts a task with the current OpenTelemetry.Ctx.t/0
that can be awaited on.
See Task.async/3
for more information.
@spec async_stream(Enumerable.t(), (term() -> term()), keyword()) :: Enumerable.t()
Returns a stream that runs the given function fun
concurrently
on each element in enumerable
with the current OpenTelemetry.Ctx.t/0
attached.
See Task.async_stream/3
for more information.
@spec async_stream( Enumerable.t(), module(), atom(), [term()], keyword() ) :: Enumerable.t()
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.
See Task.async_stream/5
for more information.
async_stream_with_linked_span(enumerable, name, start_opts, fun, opts \\ [])
View Source@spec async_stream_with_linked_span( Enumerable.t(), OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (term() -> term()), keyword() ) :: Enumerable.t()
Returns a stream that runs the given function fun
concurrently
on each element in enumerable
with a new linked span.
See Task.async_stream/3
for more information.
async_stream_with_linked_span(enumerable, name, start_opts, module, function_name, args, opts \\ [])
View Source@spec async_stream_with_linked_span( Enumerable.t(), OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()], keyword() ) :: Enumerable.t()
Returns a stream where the given function (module
and function
)
is mapped concurrently on each element in enumerable
with a new linked span.
See Task.async_stream/5
for more information.
async_stream_with_span(enumerable, name, start_opts, fun, opts \\ [])
View Source@spec async_stream_with_span( Enumerable.t(), OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (term() -> term()), keyword() ) :: Enumerable.t()
Returns a stream that runs the given function fun
concurrently
on each element in enumerable
with a new child span.
See Task.async_stream/3
for more information.
async_stream_with_span(enumerable, name, start_opts, module, function_name, args, opts \\ [])
View Source@spec async_stream_with_span( Enumerable.t(), OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()], keyword() ) :: Enumerable.t()
Returns a stream where the given function (module
and function
)
is mapped concurrently on each element in enumerable
with a new child span.
See Task.async_stream/5
for more information.
@spec async_with_linked_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (() -> any()) ) :: Task.t()
Starts a task with a new linked span that can be awaited on.
See Task.async/1
for more information.
async_with_linked_span(name, start_opts, module, function_name, args)
View Source@spec async_with_linked_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()] ) :: Task.t()
Starts a task with a new linked span that can be awaited on.
See Task.async/3
for more information.
@spec async_with_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (() -> any()) ) :: Task.t()
Starts a task with a new child span that can be awaited on.
See Task.async/1
for more information.
@spec async_with_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()] ) :: Task.t()
Starts a task with a new child span that can be awaited on.
See Task.async/3
for more information.
See Task.await/1
.
See Task.await/2
.
See Task.await_many/1
.
See Task.await_many/2
.
See Task.child_spec/1
.
See Task.completed/1
.
See Task.ignore/1
.
See Task.shutdown/1
.
See Task.shutdown/2
.
Starts a task with the current OpenTelemetry.Ctx.t/0
.
See Task.start/1
for more information.
Starts a task with the current OpenTelemetry.Ctx.t/0
.
See Task.start/3
for more information.
Starts a task as part of a supervision tree with the given fun
with the current OpenTelemetry.Ctx.t/0
attached.
See Task.start_link/1
for more information.
Starts a task as part of a supervision tree with the given
module
, function
, and args
with the current OpenTelemetry.Ctx.t/0
attached.
See Task.start_link/3
for more information.
@spec start_link_with_linked_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (() -> any()) ) :: {:ok, pid()}
Starts a task as part of a supervision tree with the given fun
in a new linked span.
See Task.start_link/1
for more information.
start_link_with_linked_span(name, start_opts, module, function_name, args)
View Source@spec start_link_with_linked_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()] ) :: {:ok, pid()}
Starts a task as part of a supervision tree with the given
module
, function
, and args
in a new linked span.
See Task.start_link/3
for more information.
@spec start_link_with_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (() -> any()) ) :: {:ok, pid()}
Starts a task as part of a supervision tree with the given fun
in a new child span.
See Task.start_link/1
for more information.
start_link_with_span(name, start_opts, module, function_name, args)
View Source@spec start_link_with_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()] ) :: {:ok, pid()}
Starts a task as part of a supervision tree with the given
module
, function
, and args
in a new child span.
See Task.start_link/3
for more information.
@spec start_with_linked_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (() -> any()) ) :: {:ok, pid()}
Starts a task with a new linked span.
See Task.start/1
for more information.
start_with_linked_span(name, start_opts, module, function_name, args)
View Source@spec start_with_linked_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()] ) :: {:ok, pid()}
Starts a task with a new linked span.
See Task.start/3
for more information.
@spec start_with_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), (() -> any()) ) :: {:ok, pid()}
Starts a task with a new child span.
See Task.start/1
for more information.
@spec start_with_span( OpenTelemetry.span_name(), OpenTelemetry.Span.start_opts(), module(), atom(), [term()] ) :: {:ok, pid()}
Starts a task with a new child span.
See Task.start/3
for more information.
See Task.yield/1
.
See Task.yield/2
.
See Task.yield_many/1
.
See Task.yield_many/2
.