Skip to content

Commit 800f4a7

Browse files
Graborgcartermp
andauthored
fix: erlang elixir samples (#4177)
Co-authored-by: Phillip Carter <[email protected]>
1 parent e9d298e commit 800f4a7

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

content/en/docs/languages/erlang/sampling.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ description(_) ->
159159
<<"AttributeSampler">>.
160160

161161
should_sample(_Ctx, _TraceId, _Links, _SpanName, _SpanKind, Attributes, ConfigAttributes) ->
162-
case maps:intersect(Attributes, ConfigAttributes) of
163-
Map when map_size(Map) > 0 ->
164-
{?DROP, [], []};
165-
_ ->
166-
{?RECORD_AND_SAMPLE, [], []}
167-
end.
162+
AttributesSet = sets:from_list(maps:to_list(Attributes)),
163+
ConfigSet = sets:from_list(maps:to_list(ConfigAttributes)),
164+
case sets:is_disjoint(AttributesSet, ConfigSet) of
165+
true -> {?RECORD_AND_SAMPLE, [], []};
166+
_ -> {?DROP, [], []}
167+
end.
168168
```
169169

170170
{{% /tab %}} {{% tab Elixir %}}
@@ -184,12 +184,11 @@ defmodule AttributesSampler do
184184
end
185185

186186
def should_sample(_ctx, _trace_id, _links, _span_name, _span_kind, attributes, config_attributes) do
187-
case :maps.intersect(attributes, config_attributes) do
188-
map when map_size(map) > 0 ->
189-
{:drop, [], []}
190-
_ ->
191-
{:record_and_sample, [], []}
192-
end
187+
no_match =
188+
Enum.into(attributes, %MapSet{})
189+
|> MapSet.disjoint?(Enum.into(config_attributes, %MapSet{}))
190+
191+
if no_match, do: {:record_and_sample, [], []}, else: {:drop, [], []}
193192
end
194193
end
195194
```

0 commit comments

Comments
 (0)