Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

separate context propagation otep #4

Merged
merged 9 commits into from
Nov 20, 2019

Conversation

tsloughter
Copy link
Member

Based on OTEP-66 open-telemetry/oteps#66

Still to do and will be added to this PR before merging: propagators.

@tsloughter
Copy link
Member Author

Corresponding commit to the SDK open-telemetry/opentelemetry-erlang@21d75b9

@@ -106,12 +112,42 @@
set_default_tracer(Tracer) ->
persistent_term:put({?MODULE, default_tracer}, Tracer).

set_default_context_manager(ContextModule) ->
persistent_term:put({?MODULE, context_manager}, ContextModule).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to guard that this is actually a module (or an atom if we don't check for loading)? Like there's a risk of setting a bad value and insta-killing all the things, no?

In fact looking at the call below, the expected form is {Module, Args} and asserting there could prevent huge mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agh yea, very good catch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is actually used as just a module atom. Clearly need some typespecs so dialyzer will catch this shit where get_* is used.

I'm now unsure if there should be a tuple or not. Depends on if some state (that can't be updated because it is in a persistent term) is needed. I think I have an idea, will update this in a bit.

end, ok, List),
ok
end,
persistent_term:put({?MODULE, http_extractor}, Fun).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is no longer safe for hot-code loading, since after two editions of this module being loaded, the Fun will need to be reaped, ending up killing all processes that hold a reference to it?

Though from a quick test, it seems like it just eventually turns into a badfun, so it's not that bad?

I guess the only workaround would be to extract the function to have a kind of "state" argument and use a fully qualified fun to make it work. Probably not worth the effort at this point in time?

src/ot_baggage.erl Outdated Show resolved Hide resolved
Fun()
after
set_current(CtxModule, Namespace, PrevCtx)
end.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this usage implies that the current values for the context can't be global, and only process-global at best? Otherwise running two of these at the same time may break things, right? Might be worth pointing out in a comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, context is tied to a process. I can note that.

String = "", %% Headers
New = FromText(String, CtxModule:get_current(Namespace)),
CtxModule:set_current(Namespace, New)
end.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a stub?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yea, I'll finish this.

@tsloughter tsloughter merged commit cf03475 into open-telemetry:master Nov 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants