opentelemetry-erlang-contrib
opentelemetry-erlang-contrib copied to clipboard
Enable event filtering in LiveView instrumentation
Is your feature request related to a problem? Please describe.
LiveView can be very noisy, and the current implementation of opentelemetry_phoenix
currently only supports enabled/disabled (I believe).
Describe the solution you'd like I'm not sure the best general solution, presumably an allow and/or deny list for filtering these events.
Describe alternatives you've considered My current solution, as suggested in the Elixir slack, is a custom sampler.
defmodule SpanNamesSampler do
def setup(attributes) when is_map(attributes) do
attributes
end
def setup(_), do: %{}
def description(_), do: "Allows you to drop spans based on their name."
def should_sample(_ctx, _trace_id, _links, span_name, _span_kind, _attributes, config_attributes) do
spans_to_drop = Map.get(config_attributes, :spans_to_drop, [])
if Enum.member?(spans_to_drop, span_name) do
{:drop, [], []}
else
{:record_and_sample, [], []}
end
end
end
config :opentelemetry, sampler: {SpanNamesSampler, %{spans_to_drop: ["super-annoying-event-handler"]}}