Skip to content

Enable event filtering in LiveView instrumentation #208

Open
@marcdel

Description

@marcdel

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"]}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions