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 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions content/en/docs/languages/erlang/sampling.md
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.
ConfAttrPairs = maps:intersect_with(fun (_key, Attr, Conf) -> {Attr, Conf} end, Attributes, ConfigAttributes),
case lists:any(fun({_, {A, B}}) -> A == B end, maps:to_list(ConfAttrPairs)) of
true -> {?DROP, [], []};
_ -> {?RECORD_AND_SAMPLE, [], []}
end
end.
```

{{% /tab %}} {{% tab Elixir %}}
Expand All @@ -184,12 +184,12 @@ 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
attr_match =
Map.intersect(attributes, config_attributes, fn _key, attr, conf -> {attr, conf} end)
|> Map.to_list()
|> Enum.any?(fn {_, {attr, conf}} -> attr == conf end)

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