Documentation
¶
Index ¶
- type Aggregator
- func (a *Aggregator) AttachToEnvelope(envelope *protocol.Envelope)
- func (a *Aggregator) Record(reason DiscardReason, category ratelimit.Category, quantity int64)
- func (a *Aggregator) RecordForEnvelope(reason DiscardReason, envelope *protocol.Envelope)
- func (a *Aggregator) RecordItem(reason DiscardReason, item protocol.TelemetryItem)
- func (a *Aggregator) RecordOne(reason DiscardReason, category ratelimit.Category)
- func (a *Aggregator) TakeReport() *ClientReport
- type ClientReport
- type ClientReportProvider
- type ClientReportRecorder
- type DiscardReason
- type DiscardedEvent
- type OutcomeKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator collects discarded event outcomes for client reports. Uses atomic operations to be safe for concurrent use.
func NewAggregator ¶
func NewAggregator() *Aggregator
NewAggregator creates a new client report Aggregator.
func (*Aggregator) AttachToEnvelope ¶
func (a *Aggregator) AttachToEnvelope(envelope *protocol.Envelope)
AttachToEnvelope adds a client report to the envelope if the Aggregator has outcomes available.
func (*Aggregator) Record ¶
func (a *Aggregator) Record(reason DiscardReason, category ratelimit.Category, quantity int64)
Record records a discarded event outcome.
func (*Aggregator) RecordForEnvelope ¶
func (a *Aggregator) RecordForEnvelope(reason DiscardReason, envelope *protocol.Envelope)
RecordForEnvelope records client report outcomes for all items in the envelope. It inspects envelope item headers to derive categories, span counts, and log byte sizes.
func (*Aggregator) RecordItem ¶
func (a *Aggregator) RecordItem(reason DiscardReason, item protocol.TelemetryItem)
RecordItem records outcomes for a telemetry item, including supplementary categories (span outcomes for transactions, byte size for logs).
func (*Aggregator) RecordOne ¶
func (a *Aggregator) RecordOne(reason DiscardReason, category ratelimit.Category)
RecordOne is a helper method to record one discarded event outcome.
func (*Aggregator) TakeReport ¶
func (a *Aggregator) TakeReport() *ClientReport
TakeReport atomically takes all accumulated outcomes and returns a ClientReport.
type ClientReport ¶
type ClientReport struct {
Timestamp time.Time `json:"timestamp"`
DiscardedEvents []DiscardedEvent `json:"discarded_events"`
}
ClientReport is the payload sent to Sentry for tracking discarded events.
func (*ClientReport) ToEnvelopeItem ¶
func (r *ClientReport) ToEnvelopeItem() (*protocol.EnvelopeItem, error)
ToEnvelopeItem converts the ClientReport to an envelope item.
type ClientReportProvider ¶
type ClientReportProvider interface {
TakeReport() *ClientReport
AttachToEnvelope(envelope *protocol.Envelope)
}
ClientReportProvider is used by the single component responsible for sending client reports.
func NoopProvider ¶
func NoopProvider() ClientReportProvider
NoopProvider returns a no-op ClientReportProvider that always returns nil reports.
type ClientReportRecorder ¶
type ClientReportRecorder interface {
Record(reason DiscardReason, category ratelimit.Category, quantity int64)
RecordOne(reason DiscardReason, category ratelimit.Category)
RecordForEnvelope(reason DiscardReason, envelope *protocol.Envelope)
RecordItem(reason DiscardReason, item protocol.TelemetryItem)
}
ClientReportRecorder is used by components that need to record lost/discarded events.
func NoopRecorder ¶
func NoopRecorder() ClientReportRecorder
NoopRecorder returns a no-op ClientReportRecorder that silently discards all records.
type DiscardReason ¶
type DiscardReason string
DiscardReason represents why an item was discarded.
const ( // ReasonQueueOverflow indicates the transport queue was full. ReasonQueueOverflow DiscardReason = "queue_overflow" // ReasonBufferOverflow indicates that an internal buffer was full. ReasonBufferOverflow DiscardReason = "buffer_overflow" // ReasonRateLimitBackoff indicates the item was dropped due to rate limiting. ReasonRateLimitBackoff DiscardReason = "ratelimit_backoff" // ReasonBeforeSend indicates the item was dropped due to a BeforeSend callback. ReasonBeforeSend DiscardReason = "before_send" // ReasonEventProcessor indicates the item was dropped due to an event processor callback. ReasonEventProcessor DiscardReason = "event_processor" // ReasonSampleRate indicates the item was dropped due to sampling. ReasonSampleRate DiscardReason = "sample_rate" // ReasonNetworkError indicates an HTTP request failed (connection error). ReasonNetworkError DiscardReason = "network_error" // ReasonSendError indicates HTTP returned an error status (4xx, 5xx). // // The party that drops an envelope is responsible for counting the event (we skip outcomes that the server records // `http.StatusTooManyRequests` 429). However, relay does not always record an outcome for oversized envelopes, so // we accept the trade-off of double counting `http.StatusRequestEntityTooLarge` (413) codes, to record all events. // For more details https://develop.sentry.dev/sdk/expected-features/#dealing-with-network-failures ReasonSendError DiscardReason = "send_error" // ReasonInternalError indicates an internal SDK error. ReasonInternalError DiscardReason = "internal_sdk_error" )
type DiscardedEvent ¶
type DiscardedEvent struct {
Reason DiscardReason `json:"reason"`
Category ratelimit.Category `json:"category"`
Quantity int64 `json:"quantity"`
}
DiscardedEvent represents a single discard event outcome for the OutcomeKey.
type OutcomeKey ¶
type OutcomeKey struct {
Reason DiscardReason
Category ratelimit.Category
}
OutcomeKey uniquely identifies an outcome bucket for aggregation.