func (a *Agent) sample(ts *info.TagStats, pt ProcessedTrace) (events []*pb.Span, keep bool) {
	priority, hasPriority := sampler.GetSamplingPriority(pt.Root)

	// Depending on the sampling priority, count that trace differently.
	stat := &ts.TracesPriorityNone
	if hasPriority {
		if priority < 0 {
			stat = &ts.TracesPriorityNeg
		} else if priority == 0 {
			stat = &ts.TracesPriority0
		} else if priority == 1 {
			stat = &ts.TracesPriority1
		} else {
			stat = &ts.TracesPriority2
		}
	}
	atomic.AddInt64(stat, 1)

	if priority < 0 {
		return nil, false
	}

	sampled := a.runSamplers(pt, hasPriority)

	events, numExtracted := a.EventProcessor.Process(pt.Root, pt.Trace)

	atomic.AddInt64(&ts.EventsExtracted, int64(numExtracted))
	atomic.AddInt64(&ts.EventsSampled, int64(len(events)))

	return events, sampled
}
// sample decides whether the trace will be kept and extracts any APM events
// from it.
sample decides whether the trace will be kept and extracts any APM events
from it.
// sample decides whether the trace will be kept and extracts any APM events // from it .
func (a *Agent) sample(ts *info.TagStats, pt ProcessedTrace) (events []*pb.Span, keep bool) {
	priority, hasPriority := sampler.GetSamplingPriority(pt.Root)
	stat := &ts.TracesPriorityNone
	if hasPriority {
		if priority < 0 {
			stat = &ts.TracesPriorityNeg
		} else if priority == 0 {
			stat = &ts.TracesPriority0
		} else if priority == 1 {
			stat = &ts.TracesPriority1
		} else {
			stat = &ts.TracesPriority2
		}
	}
	atomic.AddInt64(stat, 1)
	if priority < 0 {
		return nil, false
	}
	sampled := a.runSamplers(pt, hasPriority)
	events, numExtracted := a.EventProcessor.Process(pt.Root, pt.Trace)
	atomic.AddInt64(&ts.EventsExtracted, int64(numExtracted))
	atomic.AddInt64(&ts.EventsSampled, int64(len(events)))
	return events, sampled
}
func ( a * Agent ) sample ( ts * info . TagStats , pt ProcessedTrace ) ( events [ ] * pb . Span , keep bool ) { priority , hasPriority := sampler . GetSamplingPriority ( pt . Root ) stat := & ts . TracesPriorityNone if hasPriority { if priority < 0 { stat = & ts . TracesPriorityNeg } else if priority == 0 { stat = & ts . TracesPriority0 } else if priority == 1 { stat = & ts . TracesPriority1 } else { stat = & ts . TracesPriority2 } } atomic . AddInt64 ( stat , 1 ) if priority < 0 { return nil , false } sampled := a . runSamplers ( pt , hasPriority ) events , numExtracted := a . EventProcessor . Process ( pt . Root , pt . Trace ) atomic . AddInt64 ( & ts . EventsExtracted , int64 ( numExtracted ) ) atomic . AddInt64 ( & ts . EventsSampled , int64 ( len ( events ) ) ) return events , sampled }
sample decides whether the trace will be kept and extracts any APM events
from it.
sample decides whether the trace will be kept and extracts any APM events from it .
// Depending on the sampling priority, count that trace differently.