-
Notifications
You must be signed in to change notification settings - Fork 105
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
inital api impl #4
Conversation
Related docs: |
0ce5016
to
4f109e3
Compare
src/opentelemetry.erl
Outdated
%% Before OTP-20 rand:uniform could not give precision higher than 2^56. | ||
%% Here we do a compile time check for support of this feature and will | ||
%% combine multiple calls to rand if on an OTP version older than 20.0 | ||
-ifdef(OTP_RELEASE). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which versions of OTP will we support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTP20 will cover Elixir programmers going back to 1.5 as long as the reason they're using an old Elixir isn't because they need an even older OTP.
Use of the :seq_trace
label to track spans will be tricky in OTP20 without hoping that the birthday paradox won't give us collisions: it's limited to 28 bits, giving us a 17% chance of a collision per 10K spans. Might not hurt as long as they expire fast, but it'll be a lot easier in OTP21.
|
||
-include("opentelemetry.hrl"). | ||
|
||
-define(tracer, (persistent_term:get({opentelemetry, tracer}, ot_tracer_sdk))). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is usage of persistent_term
then we support only OTP 21+, which mean that earlier part with fallback for old OTPs.
|
||
-include("opentelemetry.hrl"). | ||
|
||
-define(tracer, (persistent_term:get({opentelemetry, tracer}, ot_tracer_sdk))). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will there always be only one tracer? I haven't checked Java implementation yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the default tracer. There will only be one default tracer.
There is heavy use of |
I use persistent term because it needs to have as low overhead as possible. I'm even uneasy using persistent term for this as it also still entails a slow function call because of not being a static module name in the code. We can have it compile to an application config if on earlier OTPs and just document this fact. |
I think that it will be a pretty low overhead when comparing to other languages anyway. |
Quite. We're wrapping spans around calls with 10²–10⁵ms latency at work. No need to worry about per-span overheads in the 10⁻²ms range, e.g. Not having lerned me some Erlang, can I assume from Elixir we can |
Re-reading your comment in the intro, and the code: is the idea that the default tracer won't be pluggable, so it can go extra fast, but users will be able to plug in the |
src/ot_ctx.erl
Outdated
%%%------------------------------------------------------------------------- | ||
-module(ot_ctx). | ||
|
||
-callback get(any()) -> any(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: if the key will always be ?SPAN_CTX
, do we need the Key
arguments?
A: it'll provide more or less backward-compatible rummaging through the process dictionary (ot_span_ctx_key
vs oc_span_ctx_key
) with ot_ctx_pdict
, and give people a plausible way of sharing the seq_trace
label with ot_ctx_seqtrace
.
That said, I bet we could type it as an atom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried writing against this API. Straight away, needed to special-case :oc_span_ctx_key
so I knew to try other means than just Process.get/1
. Strikes me it'd be simpler for API consumers if ot_ctx
didn't take keys, and if the seq_trace
implementation relied on a lower level API to accomplish plausible sharing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tripped over this trying to wrap up the work above:
Special-casing the span context key to try unreliable but useful ways of recovering it, e.g. wading through $callers
, could also cause problems for the context restoration feature of the get_current_ctx
… start_span
… with_span_ctx
… finish_span
… with_span_ctx
pattern, which would end up putting back a context that wasn't really there.
If our goal is to let users track the current span context however they need to, strikes me the behaviour should have put_span_ctx/1
, get_span_ctx/0
, and recover_span_ctx/0
. I'll try it out and report back.
Nearly forgot Logger.metadata
sync et al, which'd need a separate behaviour sync_current_span_ctx/2
called every time we change the current span context or its attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the ot_tracer_sdk_dyn
will become ot_tracer_sdk
. Then ctx will be dynamic like tracer. This should resolve your issues, right?
src/ot_ctx.erl
Outdated
|
||
-callback get(any()) -> any(). | ||
-callback with_value(any(), any()) -> ok. | ||
-callback with_value(any(), any(), fun()) -> ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> any().
, surely, as it'll return the result of fun/0
?
That was the original idea but I think you are right that it is too convoluted. |
d505e73
to
d2d6f7f
Compare
Pushed updates. I moved the It also now tracks the current tracer used in the pdict: https://github.com/open-telemetry/opentelemetry-erlang/pull/4/files#diff-98920f865a632de900785a223c5e42ccR53 This way if you create a span with a different tracer from the default it will use that tracer instead of the default when the span is finished (or is updated or a child is created). |
d2d6f7f
to
857a300
Compare
I've marked this is ready for review so we can get it merged in before even more gets added in and it gets more of a pain to follow. |
src/opentelemetry_sup.erl
Outdated
intensity => 0, | ||
period => 1}, | ||
ChildSpecs = [], | ||
ChildSpecs = [#{id => ot_span_ets, | ||
start => {ot_span_ets, start_link, [Opts]}}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for sure we will expand this I would create ot_span_sup
that would handle just spans and would manage everything related to them. This would simplify opentelemetry_sup
in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean having opentelemetry_sup
start ot_span_sup
which starts ot_span_ets
? Do you expect there to be other span related children?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsloughter I do not know how we want to implement dispatching spans to the handler(s). Will there be another process like in OC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I guess I was considering reporters and such as separate from span management.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the sweeper too. Yea, I'll make this change. One sec.
857a300
to
0fe4f0f
Compare
0fe4f0f
to
d2a1e34
Compare
separate context propagation otep
http1.1 support
…er-add-timeout refactor opentelemetry_exporter
Opening as a draft PR to get the conversation started (also related to the convo @garthk started in opencensus-beam/opencensus_elixir#23)
There are currently two tracers here:
oc_tracer_sdk
and oc_tracer_sdk_dyn`. The former uses the pdict context and ets storage spans directly while the latter can have the context and storage set with configuration.I'm not married to any of this.