sentry-elixir icon indicating copy to clipboard operation
sentry-elixir copied to clipboard

Support client reports

Open stephanie-anderson opened this issue 1 year ago • 1 comments

Support https://develop.sentry.dev/sdk/client-reports/

If tracing is supported by the time this issue is handled, we would also want to report dropped spans: https://github.com/getsentry/projects/issues/70

stephanie-anderson avatar Sep 04 '24 14:09 stephanie-anderson

Just talked strategy with @savhappy, notes:

  • Send client reports every 30 seconds (if enabled)
  • Support an option to have client reports on/off (:send_client_reports)
  • (Probably) add Sentry.Envelope.from_client_report/1
  • Support type: :client_report in Sentry.Envelope, propagates to Sentry.Envelope.item_to_binary/2 helper function

A client report should be a struct typed as:

@type client_report() :: %Sentry.ClientReport{
  timestamp: timestamp(),
  discarded_events: %{
    optional({type :: atom(), reason :: atom()}) => pos_integer()
  } 
}

# Example:
%ClientReport{
  timestamp: ...,
  discarded_events: %{    
    {"error", "rate_limiting"} => 3,
    {"transaction", "queue_overflow"} => 324,
    {"error", "queue_overflow"} => 1
  }
}

We don't have {type, reason} tuples in there if the count is 0, which is why it's pos_integer(). We can just add them on the fly:

def add_discarded_event(client_report, type, reason) do
  Map.update(client_report.discarded_events, {type, reason}, 1, &(&1 + 1))
end

whatyouhide avatar Sep 24 '24 09:09 whatyouhide

Closed in #801, thanks @savhappy 💟

whatyouhide avatar Oct 21 '24 08:10 whatyouhide