-
Notifications
You must be signed in to change notification settings - Fork 61
/
error_events.go
32 lines (27 loc) · 1.15 KB
/
error_events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// Copyright 2020 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
package newrelic
// ErrorEvents is a wrapper over AnalyticsEvents created for additional type
// safety and proper FailedHarvest behavior.
type ErrorEvents struct {
*analyticsEvents
}
// NewErrorEvents returns a new error event reservoir with capacity max.
func NewErrorEvents(max int) *ErrorEvents {
return &ErrorEvents{newAnalyticsEvents(max)}
}
// AddEventFromData observes the occurrence of an error event. If the
// reservoir is full, sampling occurs. Note: when sampling occurs, it
// is possible the new event may be discarded.
func (events *ErrorEvents) AddEventFromData(data []byte, priority SamplingPriority) {
events.AddEvent(AnalyticsEvent{data: data, priority: priority})
}
// FailedHarvest is a callback invoked by the processor when an
// attempt to deliver the contents of events to the collector
// fails. After a failed delivery attempt, events is merged into
// the upcoming harvest. This may result in sampling.
func (events *ErrorEvents) FailedHarvest(newHarvest *Harvest) {
newHarvest.ErrorEvents.MergeFailed(events.analyticsEvents)
}