Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for correct Behaviour in module_info/0 in API #135

Closed
ioolkos opened this issue Nov 1, 2020 · 6 comments
Closed

Checking for correct Behaviour in module_info/0 in API #135

ioolkos opened this issue Nov 1, 2020 · 6 comments

Comments

@ioolkos
Copy link

ioolkos commented Nov 1, 2020

Exploring things a little bit, I noticed that I can't set tracers when the .beam files are stripped in a prod release, I think.
There reason is the check for the correct Behaviour here:

case lists:keyfind(behaviour, 1, Attributes) of

The module_info/0 call might look like this, giving an empty attributes list:

1> otel_tracer_default:module_info().
[{module,otel_tracer_default},
 {exports,[{start_span,3},
           {start_span,4},
           {with_span,3},
           {with_span,4},
           {b3_propagators,0},
           {w3c_propagators,0},
           {module_info,0},
           {module_info,1}]},
 {attributes,[]},
 {compile,[]},
 {native,false},
 {md5,<<229,142,94,192,207,250,193,205,25,119,87,154,29,
        226,111,166>>}]
2> 

Do you think this is a correct assessment, and is it a case that matters?

@tsloughter
Copy link
Member

Argh, yes, we should remove this check.

@ioolkos
Copy link
Author

ioolkos commented Nov 1, 2020

Ok, something like this then:

-spec set_default_tracer(tracer()) -> boolean().
set_default_tracer(Tracer) ->
    persistent_term:put({?MODULE, default_tracer}, Tracer).

-spec set_tracer(atom(), tracer()) -> boolean().
set_tracer(Name, Tracer) ->
    persistent_term:put({?MODULE, Name}, Tracer).

-spec set_default_meter(meter()) -> boolean().
set_default_meter(Meter) ->
    persistent_term:put({?MODULE, default_meter}, Meter).

-spec set_meter(atom(), meter()) -> boolean().
set_meter(Name, Meter) ->
    persistent_term:put({?MODULE, Name}, Meter).

@tsloughter
Copy link
Member

It can still check if the module exists, even if it doesn't depend on the tracer behaviour being there.

@tsloughter
Copy link
Member

I added a fix here #137

@ioolkos
Copy link
Author

ioolkos commented Nov 2, 2020

Thanks! I'll test it.

@ioolkos
Copy link
Author

ioolkos commented Nov 5, 2020

Behaves as expected now. Thanks.

@ioolkos ioolkos closed this as completed Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants