-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v2: remove sampling priority #2906
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -530,10 +530,10 @@ func (s *Span) setMetric(key string, v float64) { | |
if v == float64(samplernames.AppSec) { | ||
s.setSamplingPriorityLocked(ext.PriorityUserKeep, samplernames.AppSec) | ||
} | ||
case ext.SamplingPriority: | ||
// ext.SamplingPriority is deprecated in favor of ext.ManualKeep and ext.ManualDrop. | ||
// We have it here for backward compatibility. | ||
s.setSamplingPriorityLocked(int(v), samplernames.Manual) | ||
case ext.ManualDrop: | ||
if v == float64(samplernames.AppSec) { | ||
s.setSamplingPriorityLocked(ext.PriorityUserReject, samplernames.AppSec) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hannahkm Shouldn't we support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean as a case? In which case (no pun intended) it's on line 529 (it had existed already before) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I missed it. Ok, good to go! 😁 |
||
} | ||
default: | ||
s.metrics[key] = v | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,7 @@ func TestAddSpanLink(t *testing.T) { | |
|
||
// Test adding a link with a sampling decision | ||
linkedSpanSampled := newSpan("linked_sampled", "service", "res", 3, 4, 0) | ||
linkedSpanSampled.Context().setSamplingPriority(2, samplernames.Manual) | ||
linkedSpanSampled.Context().setSamplingPriority(ext.PriorityUserKeep, samplernames.Manual) | ||
rootSpan.AddLink(linkedSpanSampled.Context(), map[string]string{}) | ||
assert.Equal(len(rootSpan.spanLinks), 2) | ||
spanLinkSampled := rootSpan.spanLinks[1] | ||
|
@@ -214,7 +214,7 @@ func TestShouldDrop(t *testing.T) { | |
} { | ||
t.Run("", func(t *testing.T) { | ||
s := newSpan("", "", "", 1, 1, 0) | ||
s.SetTag(ext.SamplingPriority, tt.prio) | ||
s.setSamplingPriority(tt.prio, samplernames.Default) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quick question, why default here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaik, the value we pass into
|
||
s.SetTag(ext.EventSampleRate, tt.rate) | ||
atomic.StoreInt32(&s.context.errors, tt.errors) | ||
assert.Equal(t, shouldKeep(s), tt.want) | ||
|
@@ -836,7 +836,7 @@ func TestSpanSamplingPriority(t *testing.T) { | |
ext.PriorityUserKeep, | ||
999, // not used, but we should allow it | ||
} { | ||
span.SetTag(ext.SamplingPriority, priority) | ||
span.setSamplingPriority(priority, samplernames.Default) | ||
v, ok := span.metrics[keySamplingPriority] | ||
assert.True(ok) | ||
assert.EqualValues(priority, v) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we need to add this here to be honest. There is a weird use case for ManualKeep, defined by appsec rules. But they don't use the same convention for manualDrop 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Julio-Guerra Any idea why this there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you git-blame the file? It wasn't me who wrote those lines but @Barbayar a few years ago when he worked on distributed tracing on all tracers. IIRC, it was just about the decision maker tag
_dd.p.dm
.ASM doesn't rely on those details, we're good as long as we can force-keep the traces when we have security events.
The only ASM RFC where we went into such details is the standalone ASM billing RFC and they are system-tested so regressions would be found if any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the PR description, I believe it would be great to keep a lower-level API for internal usage that provides more options. But likely bonus as far as I am aware of our product needs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I spoke with @Barbayar and it seems that AppSec has a few cases where we want to keep specific traces, which is why I decided to keep the case. I'll keep the
ManualKeep
case, but seems like we don't need theManualDrop
, so I've removed it. Thanks!