Skip to content
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

fix: erlang elixir samples #4177

Merged
merged 6 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions content/en/docs/languages/erlang/sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ description(_) ->
<<"AttributeSampler">>.

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

{{% /tab %}} {{% tab Elixir %}}
Expand All @@ -184,12 +184,11 @@ defmodule AttributesSampler do
end

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
no_match =
Enum.into(attributes, %MapSet{})
|> MapSet.disjoint?(Enum.into(config_attributes, %MapSet{}))

if no_match, do: {:record_and_sample, [], []}, else: {:drop, [], []}
end
end
```
Expand Down