Fix ctx return types for process_propagator functions (#114)

This commit is contained in:
Aaron Renner 2022-10-19 17:52:52 -06:00 committed by GitHub
parent da912fd08b
commit 8e5d373477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -84,7 +84,7 @@ defmodule OpentelemetryProcessPropagator do
@doc """
Attempt to fetch an otel context from a give pid.
"""
@spec fetch_ctx(pid) :: OpenTelemetry.span_ctx() | :undefined
@spec fetch_ctx(pid) :: OpenTelemetry.Ctx.t() | :undefined
defdelegate fetch_ctx(pid), to: :opentelemetry_process_propagator
@doc """
@ -92,14 +92,14 @@ defmodule OpentelemetryProcessPropagator do
This is equivalent to calling `fetch_parent_ctx(1, :"$ancestors")`
"""
@spec fetch_parent_ctx() :: OpenTelemetry.span_ctx() | :undefined
@spec fetch_parent_ctx() :: OpenTelemetry.Ctx.t() | :undefined
defdelegate fetch_parent_ctx(), to: :opentelemetry_process_propagator
@doc """
Attempt to find an otel context in a spawning process within `n` number of parent
processes
"""
@spec fetch_parent_ctx(non_neg_integer()) :: OpenTelemetry.span_ctx() | :undefined
@spec fetch_parent_ctx(non_neg_integer()) :: OpenTelemetry.Ctx.t() | :undefined
defdelegate fetch_parent_ctx(depth), to: :opentelemetry_process_propagator
@doc """
@ -110,6 +110,6 @@ defmodule OpentelemetryProcessPropagator do
Processes spawned by `proc_lib` are stored under `:"$ancestors`. The
Elixir `Task` module uses the `:"$callers` key.
"""
@spec fetch_parent_ctx(non_neg_integer(), atom()) :: OpenTelemetry.span_ctx() | :undefined
@spec fetch_parent_ctx(non_neg_integer(), atom()) :: OpenTelemetry.Ctx.t() | :undefined
defdelegate fetch_parent_ctx(max_depth, key), to: :opentelemetry_process_propagator
end

View File

@ -5,15 +5,15 @@
fetch_parent_ctx/1,
fetch_parent_ctx/2]).
-spec fetch_parent_ctx() -> opentelemetry:span_ctx() | undefined.
-spec fetch_parent_ctx() -> otel_ctx:t() | undefined.
fetch_parent_ctx() ->
fetch_parent_ctx(1, '$ancestors').
-spec fetch_parent_ctx(non_neg_integer()) -> opentelemetry:span_ctx() | undefined.
-spec fetch_parent_ctx(non_neg_integer()) -> otel_ctx:t() | undefined.
fetch_parent_ctx(MaxDepth) ->
fetch_parent_ctx(MaxDepth, '$ancestors').
-spec fetch_parent_ctx(non_neg_integer(), atom()) -> opentelemetry:span_ctx() | undefined.
-spec fetch_parent_ctx(non_neg_integer(), atom()) -> otel_ctx:t() | undefined.
fetch_parent_ctx(MaxDepth, Key) ->
Pids = pids(Key, pdict(self())),
inspect_parent(undefined, lists:sublist(Pids, MaxDepth)).
@ -30,7 +30,7 @@ inspect_parent(_Ctx, [Pid | Rest]) ->
inspect_parent(OtelCtx, [])
end.
-spec fetch_ctx(pid()) -> opentelemetry:span_ctx() | undefined.
-spec fetch_ctx(pid()) -> otel_ctx:t() | undefined.
fetch_ctx(Pid) ->
case pdict(Pid) of
undefined ->
@ -48,7 +48,7 @@ pdict(Pid) ->
undefined
end.
-spec otel_ctx([{term(), term()}]) -> opentelemetry:span_ctx() | undefined.
-spec otel_ctx([{term(), term()}]) -> otel_ctx:t() | undefined.
otel_ctx(Dictionary) ->
case lists:keyfind('$__current_otel_ctx', 1, Dictionary) of
false ->