Skip to content

Commit

Permalink
Merge branch 'main' into dvic-root-span-sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed Aug 19, 2021
2 parents 7862aa5 + ea75b2a commit 38b964c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 2 additions & 4 deletions apps/opentelemetry/src/otel_span_ets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ start_span(Ctx, Name, Opts, Processors, InstrumentationLibrary) ->
Span2 = Processors(Ctx, Span1),
_ = storage_insert(Span2),
SpanCtx;
{SpanCtx, Span=#span{}} ->
%% span isn't recorded so don't run processors
%% but we do insert to ets table?
_ = storage_insert(Span),
{SpanCtx, #span{}} ->
%% span isn't recorded so don't run processors or insert into ets table
SpanCtx
end.

Expand Down
20 changes: 17 additions & 3 deletions apps/opentelemetry/test/opentelemetry_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
-include("otel_span.hrl").
-include("otel_test_utils.hrl").
-include("otel_sampler.hrl").
-include("otel_span_ets.hrl").

all() ->
[all_testcases(),
Expand All @@ -20,9 +21,9 @@ all() ->
all_testcases() ->
[disable_auto_registration, registered_tracers, with_span, macros, child_spans,
update_span_data, tracer_instrumentation_library, tracer_previous_ctx, stop_temporary_app,
reset_after, attach_ctx, default_sampler, root_span_sampling_always_on,
root_span_sampling_always_off,record_but_not_sample, record_exception_works,
record_exception_with_message_works].
reset_after, attach_ctx, default_sampler, non_recording_ets_table,
root_span_sampling_always_on, root_span_sampling_always_off,
record_but_not_sample, record_exception_works, record_exception_with_message_works].

groups() ->
[{w3c, [], [propagation]},
Expand Down Expand Up @@ -455,7 +456,20 @@ default_sampler(_Config) ->
%% local not sampled but is recorded should default to sampled
SpanCtx6 = otel_tracer:start_span(Tracer, <<"span-6">>, #{}),
?assertMatch(false, SpanCtx6#span_ctx.is_recording),
ok.

non_recording_ets_table(_Config) ->
Tracer = opentelemetry:get_tracer(),

SpanCtx1 = otel_tracer:start_span(Tracer, <<"span-1">>, #{}),
?assertMatch(true, SpanCtx1#span_ctx.is_recording),

AlwaysOff = otel_sampler:new(always_off),
SpanCtx2 = otel_tracer:start_span(Tracer, <<"span-2">>, #{sampler => AlwaysOff}),
?assertMatch(false, SpanCtx2#span_ctx.is_recording),

%% verify that ETS table only contains the recording span <<"span-1">>
?assertMatch([#span{name = <<"span-1">>}], ets:tab2list(?SPAN_TAB)),
ok.

root_span_sampling_always_off(_Config) ->
Expand Down

0 comments on commit 38b964c

Please sign in to comment.