@@ -159,12 +159,12 @@ description(_) ->
159
159
<<" AttributeSampler" >>.
160
160
161
161
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 .
168
168
```
169
169
170
170
{{% /tab %}} {{% tab Elixir %}}
@@ -184,12 +184,11 @@ defmodule AttributesSampler do
184
184
end
185
185
186
186
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 , [], []}
193
192
end
194
193
end
195
194
```
0 commit comments