-
Notifications
You must be signed in to change notification settings - Fork 61
/
span_events.go
32 lines (27 loc) · 1.13 KB
/
span_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
// SpanEvents is a wrapper over AnalyticsEvents created for additional type
// safety and proper FailedHarvest behavior.
type SpanEvents struct {
*analyticsEvents
}
// NewSpanEvents returns a new span event reservoir with capacity max.
func NewSpanEvents(max int) *SpanEvents {
return &SpanEvents{newAnalyticsEvents(max)}
}
// AddEventFromData observes the occurrence of a span event. If the
// reservoir is full, sampling occurs. Note: when sampling occurs, it
// is possible the new event may be discarded.
func (events *SpanEvents) 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 *SpanEvents) FailedHarvest(newHarvest *Harvest) {
newHarvest.SpanEvents.MergeFailed(events.analyticsEvents)
}