[WIP] Add client error reports
@savhappy can you lmk when this will be ready for review?
@whatyouhide yep yep I'll tag you here when ready
@whatyouhide ready for an initial review. I've only added a single instance of recording an event but will add in more after discussion
Thanks @whatyouhide for this! Updated with these comments except the blocking tests. Will add those shortly. Hold off on more feedback till I get the next round out. I need to add data_category to this somewhere too and maybe a capture_event function to direct how this report is classified.
Question @whatyouhide : I need to add in the appropriate data_category to the payload. We add the type only in the headers but other SDK's have a type field. The mappings for types would look like this
defmodule Sentry.DataCategory do
@spec data_category_mappings(String.t()) :: String.t()
def data_category_mappings(type) do
case type do
"session" -> "session"
"sessions" -> "session"
"attachment" -> "attachment"
"transaction" -> "transaction"
"profile" -> "profile"
"span" -> "span"
"check_in" -> "monitor"
"statsd" -> "metric_bucket"
"metric_meta" -> "metric_bucket"
"event" -> "error"
"client_report" -> "internal"
_ -> "default"
end
end
end
But we only have the types Event, Attachment, CheckIn, ClientReport (and soon Transaction). So whats the best way to go about deriving the type that will age well as we add more in the future? Or should I just get it based on the struct that's passed and if its not one of the structs see if it fits a string that's passed as the arg for data_category instead? I hope this makes sense. If not we can go into detail on Tuesday.
@savhappy can you elaborate on the issue here? Where do we need to add data_category? And what is the data category?
Yep! @whatyouhide The data categories are used to classify the type of data being ingested (ingest side types for collecting statistics).
It's defined in the Client Report docs as -> category: The data category for which the discard reason applies. These are the same data categories used for [rate limits](https://develop.sentry.dev/sdk/rate-limiting/#definitions).
We need to add the data_category to the payload ->
"discarded_events": [
{
"reason": "queue_overflow",
"category": "transaction",
"quantity": 1
}
So When I send {reason, category} over to the genserver. I need to ensure that I'm sending over the correct data category to Sentry.
In Transport module ->
def record_discarded_event(reason, category) do
# add logic for data category here
# call to client report genserver
ClientReport.add_discarded_event({reason, category})
# end
:ok
end
@whatyouhide should we create a ticket that reminds us to add in spans to the client report when supported?