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

Enable event filtering in LiveView instrumentation #208

Open
marcdel opened this issue Sep 18, 2023 · 0 comments
Open

Enable event filtering in LiveView instrumentation #208

marcdel opened this issue Sep 18, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@marcdel
Copy link
Contributor

marcdel commented Sep 18, 2023

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"]}}
@marcdel marcdel added the enhancement New feature or request label Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant