From 83668b03d9c1c1aae783a4520f734a26455ab896 Mon Sep 17 00:00:00 2001 From: Alexandre Fonseca Date: Mon, 19 Nov 2018 12:17:26 +0100 Subject: [PATCH 1/2] Ensure event priorities are propagated to Datadog backend. --- event/processor.go | 4 ++++ event/processor_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/event/processor.go b/event/processor.go index 918e9ec6a..af82f966a 100644 --- a/event/processor.go +++ b/event/processor.go @@ -83,6 +83,10 @@ func (p *Processor) Process(t model.ProcessedTrace) (events []*model.Event, numE // As well as the rates of sampling done during this processing event.SetExtractionSampleRate(extractionRate) event.SetMaxEPSSampleRate(epsRate) + if hasPriority { + // Make sure to set the sampling priority on the event span so that this gets propagated to the backend. + event.Span.SetSamplingPriority(priority) + } } return diff --git a/event/processor_test.go b/event/processor_test.go index 07707db3a..6675205f5 100644 --- a/event/processor_test.go +++ b/event/processor_test.go @@ -89,6 +89,12 @@ func TestProcessor(t *testing.T) { assert.EqualValues(test.expectedSampledPct, event.GetMaxEPSSampleRate()) assert.EqualValues(testClientSampleRate, event.GetClientTraceSampleRate()) assert.EqualValues(testPreSampleRate, event.GetPreSampleRate()) + + eventSpanPriority, ok := event.Span.GetSamplingPriority() + if !ok { + eventSpanPriority = model.PriorityNone + } + assert.EqualValues(test.priority, eventSpanPriority) } }) } From 80c08b11ae1a1d7da7f1c7bbd80c5fe9b2ccc628 Mon Sep 17 00:00:00 2001 From: Alexandre Fonseca Date: Mon, 19 Nov 2018 12:26:03 +0100 Subject: [PATCH 2/2] Address comments. --- event/processor.go | 1 - event/processor_test.go | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/event/processor.go b/event/processor.go index af82f966a..a2bd44e91 100644 --- a/event/processor.go +++ b/event/processor.go @@ -84,7 +84,6 @@ func (p *Processor) Process(t model.ProcessedTrace) (events []*model.Event, numE event.SetExtractionSampleRate(extractionRate) event.SetMaxEPSSampleRate(epsRate) if hasPriority { - // Make sure to set the sampling priority on the event span so that this gets propagated to the backend. event.Span.SetSamplingPriority(priority) } } diff --git a/event/processor_test.go b/event/processor_test.go index 6675205f5..58a047906 100644 --- a/event/processor_test.go +++ b/event/processor_test.go @@ -90,11 +90,11 @@ func TestProcessor(t *testing.T) { assert.EqualValues(testClientSampleRate, event.GetClientTraceSampleRate()) assert.EqualValues(testPreSampleRate, event.GetPreSampleRate()) - eventSpanPriority, ok := event.Span.GetSamplingPriority() + priority, ok := event.Span.GetSamplingPriority() if !ok { - eventSpanPriority = model.PriorityNone + priority = model.PriorityNone } - assert.EqualValues(test.priority, eventSpanPriority) + assert.EqualValues(test.priority, priority) } }) }