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

ddtrace/tracer: adding sampling by resource and tags #2448

Merged
merged 11 commits into from Jan 8, 2024

Conversation

dianashevchenko
Copy link
Contributor

What does this PR do?

This PR changes the sampling rule matching logic. Tests are updated accordingly.
Additionally, updated the MarshalJSON method of the SamplingRule.

What to remember when reviewing

  • 2 fields are added to the sampling rule - tags, resource
  • exactName and exactService are removed,, in favour of just Service and Name fields in the SamplingRule
  • changes in regexes in log_test.go relate to the removed exactName or exactService fields, thus regexes changed

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
Copy link

pr-commenter bot commented Dec 19, 2023

Benchmarks

Benchmark execution time: 2024-01-08 14:59:07

Comparing candidate commit 5305d5f in PR branch shevchenko/tag-resource-sampling with baseline commit d28a899 in branch main.

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

scenario:BenchmarkTracerAddSpans-24

  • 🟩 execution_time [-153.329ns; -92.671ns] or [-3.680%; -2.224%]

_, _, _, stop := startTestTracer(t)
defer stop()

s, _ := StartSpanFromContext(context.Background(), "web.request",
Copy link

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undefined: context

tr, _, _, stop := startTestTracer(t)
defer stop()

originSpan, _ := StartSpanFromContext(context.Background(), "web.request",
Copy link

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undefined: context

w3cCtx, err := tr.Extract(headers)
assert.Nil(t, err)

w3cSpan, _ := StartSpanFromContext(context.Background(), "web.request", ChildOf(w3cCtx))
Copy link

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undefined: context (typecheck)

_, _, _, stop := startTestTracer(t)
defer stop()

s, _ := StartSpanFromContext(context.Background(), "web.request",
Copy link

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undefined: context

tr, _, _, stop := startTestTracer(t)
defer stop()

originSpan, _ := StartSpanFromContext(context.Background(), "web.request",
Copy link

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undefined: context

w3cCtx, err := tr.Extract(headers)
assert.Nil(t, err)

w3cSpan, _ := StartSpanFromContext(context.Background(), "web.request", ChildOf(w3cCtx))
Copy link

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undefined: context) (typecheck)

@dianashevchenko dianashevchenko marked this pull request as ready for review January 8, 2024 15:00
@dianashevchenko dianashevchenko requested a review from a team as a code owner January 8, 2024 15:00
Copy link
Contributor

@darccio darccio left a comment

Choose a reason for hiding this comment

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

LGTM

@dianashevchenko dianashevchenko merged commit a784a5f into main Jan 8, 2024
153 checks passed
@dianashevchenko dianashevchenko deleted the shevchenko/tag-resource-sampling branch January 8, 2024 15:37
knusbaum pushed a commit that referenced this pull request Jan 9, 2024
…to new sampling rules implementation in v2 (#2492)

Updates TestStartupLog/errors to handle the way that sampling rules work
in #2448, as in v2 it causes to return an error when creating the tracer.
The error is logged as before, but we don't need to run the tracer to
create it.
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.

None yet

3 participants