Skip to content
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

Merged
merged 3 commits into from
Oct 9, 2024
Merged

Conversation

hannahkm
Copy link
Contributor

@hannahkm hannahkm commented Oct 2, 2024

What does this PR do?

Removes support for ext.SamplingPriority. Users should opt to use span.SetTag(ext.ManualKeep, true) for keeping spans/traces, and span.SetTag(ext.ManualDrop, true) for dropping spans/traces.

Motivation

Re: PR #1082 , ext.SamplingPriority has been deprecated.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@hannahkm hannahkm added the apm:ecosystem contrib/* related feature requests or bugs label Oct 3, 2024
@pr-commenter
Copy link

pr-commenter bot commented Oct 3, 2024

Benchmarks

Benchmark execution time: 2024-10-04 13:45:17

Comparing candidate commit 9b50388 in PR branch hannah/remove-samplingpriority with baseline commit 7d4b68c in branch v2-dev.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 52 metrics, 0 unstable metrics.

scenario:BenchmarkInjectW3C-24

  • 🟩 execution_time [-145.919ns; -120.281ns] or [-3.454%; -2.847%]

@hannahkm hannahkm marked this pull request as ready for review October 3, 2024 15:09
@hannahkm hannahkm requested review from a team as code owners October 3, 2024 15:09
Comment on lines 533 to 535
case ext.ManualDrop:
if v == float64(samplernames.AppSec) {
s.setSamplingPriorityLocked(ext.PriorityUserReject, samplernames.AppSec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hannahkm Shouldn't we support ext.ManualKeep too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed it. Ok, good to go! 😁

@hannahkm hannahkm mentioned this pull request Oct 3, 2024
6 tasks
eliottness
eliottness previously approved these changes Oct 4, 2024
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick question, why default here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik, the value we pass into samplernames doesn't make an impact for this test case, so I opted to keep the code clean (i.e. not adding if statements or extraneous parameters to the tt structs), since we would otherwise have to check for priorities 2 or -1 to set it to Manual.

Default says that the priority was set without a sampler, which I believe still holds true in this case. Maybe I'm missing some logic here?

// We have it here for backward compatibility.
s.setSamplingPriorityLocked(int(v), samplernames.Manual)
case ext.ManualDrop:
if v == float64(samplernames.AppSec) {
Copy link
Contributor

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 🤔

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 the ManualDrop, so I've removed it. Thanks!

Copy link
Contributor

@eliottness eliottness left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure either about what is on about the manual drop appsec :/

@eliottness eliottness self-requested a review October 4, 2024 17:24
@eliottness eliottness dismissed their stale review October 4, 2024 17:25

Would like to hear back from @Julio-Guerra on the appsec manual drop comment before merging if you don't mind

@hannahkm hannahkm merged commit 4bdbe4c into v2-dev Oct 9, 2024
153 checks passed
@hannahkm hannahkm deleted the hannah/remove-samplingpriority branch October 9, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants