Skip to content

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

Merged
dianashevchenko merged 11 commits into
mainfrom
shevchenko/tag-resource-sampling
Jan 8, 2024
Merged

ddtrace/tracer: adding sampling by resource and tags#2448
dianashevchenko merged 11 commits into
mainfrom
shevchenko/tag-resource-sampling

Conversation

@dianashevchenko

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

pr-commenter Bot commented Dec 19, 2023

Copy link
Copy Markdown

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%]

Comment thread ddtrace/tracer/rules_sampler.go Outdated
_, _, _, stop := startTestTracer(t)
defer stop()

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@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.

LGTM

@dianashevchenko
dianashevchenko merged commit a784a5f into main Jan 8, 2024
@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.

3 participants