Skip to content

Commit

Permalink
run mix format at top level for mix.exs
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed Apr 1, 2023
1 parent 8786a13 commit f4aebe3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 32 deletions.
64 changes: 33 additions & 31 deletions test/otel_tests.exs
Original file line number Diff line number Diff line change
Expand Up @@ -268,42 +268,44 @@ defmodule OtelTests do

test "Custom Sampler that checks attributes" do
name = "span-prob-sampled"
trace_id = 120647249294066572380176333851662846319
trace_id = 120_647_249_294_066_572_380_176_333_851_662_846_319

ctx = :otel_tracer.set_current_span(:otel_ctx.new(), :undefined)

{sampler, _description, opts} =
:otel_sampler.new({AttributesSampler, %{"http.target": "/healthcheck"}})

assert {:drop, [], []} = sampler.should_sample(
ctx,
trace_id,
[],
name,
:undefined,
%{"http.target": "/healthcheck",
other_attr: :other_attr_value},
opts
)

assert {:record_and_sample, [], []} = sampler.should_sample(
ctx,
trace_id,
[],
name,
:undefined,
%{other_attr: :other_attr_value},
opts
)

assert {:record_and_sample, [], []} = sampler.should_sample(
ctx,
trace_id,
[],
name,
:undefined,
%{},
opts
)
assert {:drop, [], []} =
sampler.should_sample(
ctx,
trace_id,
[],
name,
:undefined,
%{"http.target": "/healthcheck", other_attr: :other_attr_value},
opts
)

assert {:record_and_sample, [], []} =
sampler.should_sample(
ctx,
trace_id,
[],
name,
:undefined,
%{other_attr: :other_attr_value},
opts
)

assert {:record_and_sample, [], []} =
sampler.should_sample(
ctx,
trace_id,
[],
name,
:undefined,
%{},
opts
)
end
end
11 changes: 10 additions & 1 deletion test/support/attributes_sampler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ defmodule AttributesSampler do
"AttributesSampler"
end

def should_sample(_ctx, _trace_id, _links, _span_name, _span_kind, attributes, config_attributes) do
def should_sample(
_ctx,
_trace_id,
_links,
_span_name,
_span_kind,
attributes,
config_attributes
) do
case :maps.intersect(attributes, config_attributes) do
map when map_size(map) > 0 ->
{:drop, [], []}

_ ->
{:record_and_sample, [], []}
end
Expand Down

0 comments on commit f4aebe3

Please sign in to comment.