Skip to content

Commit

Permalink
Merge pull request #257 from wuunder/add_guard_register_tracer
Browse files Browse the repository at this point in the history
Add guard to register_tracer
  • Loading branch information
bryannaegele authored Jul 2, 2021
2 parents 795848b + a7b5607 commit 9110035
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions apps/opentelemetry_api/src/opentelemetry.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ set_default_tracer(Tracer) ->
set_tracer(Name, Tracer) ->
verify_and_set_term(Tracer, Name, otel_tracer).

-spec register_tracer(atom(), string()) -> boolean().
register_tracer(Name, Vsn) ->
otel_tracer_provider:register_tracer(Name, Vsn).
-spec register_tracer(atom(), string() | binary()) -> boolean().
register_tracer(Name, Vsn) when is_atom(Name) and is_binary(Vsn) ->
otel_tracer_provider:register_tracer(Name, Vsn);
register_tracer(Name, Vsn) when is_atom(Name) and is_list(Vsn) ->
otel_tracer_provider:register_tracer(Name, list_to_binary(Vsn)).

-spec register_application_tracer(atom()) -> boolean().
register_application_tracer(Name) ->
Expand Down
4 changes: 2 additions & 2 deletions apps/opentelemetry_api/src/otel_tracer_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
-type cb_state() :: term().

-callback init(term()) -> {ok, cb_state()}.
-callback register_tracer(atom(), string(), cb_state()) -> boolean().
-callback register_tracer(atom(), binary(), cb_state()) -> boolean().
-callback resource(cb_state()) -> term() | undefined.

-record(state, {callback :: module(),
Expand All @@ -50,7 +50,7 @@ resource() ->
undefined
end.

-spec register_tracer(atom(), string()) -> boolean().
-spec register_tracer(atom(), binary()) -> boolean().
register_tracer(Name, Vsn) ->
try
gen_server:call(?MODULE, {register_tracer, Name, Vsn})
Expand Down

0 comments on commit 9110035

Please sign in to comment.