Skip to content

ddtrace/tracer: locking sampling decision after context propagation#2483

Merged
dianashevchenko merged 3 commits into
shevchenko/tag-resource-samplingfrom
shevchenko/sampling-decision-locked
Jan 8, 2024
Merged

ddtrace/tracer: locking sampling decision after context propagation#2483
dianashevchenko merged 3 commits into
shevchenko/tag-resource-samplingfrom
shevchenko/sampling-decision-locked

Conversation

@dianashevchenko

Copy link
Copy Markdown
Contributor

What does this PR do?

Previously, the sampling decision of the span could be updated if new tags were set or a resource name updated. Now, this is onlyu possible up to a moment where a context is injected / propagated to preserve the connections between spans and avoid broken traces with different sampling priorities.

Motivation

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.

For Datadog employees:

  • If this PR touches code that handles credentials of any kind, such as Datadog API keys, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

@pr-commenter

pr-commenter Bot commented Jan 5, 2024

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2024-01-08 14:02:16

Comparing candidate commit 5336d81 in PR branch shevchenko/sampling-decision-locked with baseline commit 83faea4 in branch shevchenko/tag-resource-sampling.

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

Comment thread ddtrace/tracer/span.go Outdated
Comment thread ddtrace/tracer/tracer.go Outdated
Comment thread ddtrace/tracer/span.go Outdated
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment on lines +348 to +354
func (t *trace) isTraceLocked() bool {
t.mu.RLock()
defer t.mu.RUnlock()
return t.locked
}

func (t *trace) setTraceLocked(locked bool) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit (optional, you can ignore this): I would suggest removing the "trace" part in the functions as it introduces repetition.

Suggested change
func (t *trace) isTraceLocked() bool {
t.mu.RLock()
defer t.mu.RUnlock()
return t.locked
}
func (t *trace) setTraceLocked(locked bool) {
func (t *trace) isLocked() bool {
t.mu.RLock()
defer t.mu.RUnlock()
return t.locked
}
func (t *trace) setLock(locked bool) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

applied

@darccio darccio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dianashevchenko
dianashevchenko merged commit 55761ee into shevchenko/tag-resource-sampling Jan 8, 2024
@dianashevchenko
dianashevchenko deleted the shevchenko/sampling-decision-locked branch January 8, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants