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

Add sampling configuration by DD_TRACE_SAMPLING_RULES #2968

Merged
merged 5 commits into from
Jul 14, 2023

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jul 14, 2023

Adds support for configuring the RuleSampler using the environment variable DD_TRACE_SAMPLING_RULES.

This is already supported by most tracers of other languages.

This environment variable is a JSON array of objects, with each object being of the format:

{ "sample_rate": 0.123, "name": "span.name", "service": "service-name" }

The supporting feature, RuleSampler, already exists; this PR only adds an additional configuration avenue.

@marcotc marcotc self-assigned this Jul 14, 2023
@marcotc marcotc requested a review from a team July 14, 2023 02:27
# @return [String,nil]
# @public_api
option :rules do |o|
o.default { ENV.fetch(Configuration::Ext::Sampling::ENV_RULES, nil) }
Copy link
Member

Choose a reason for hiding this comment

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

Isn't ENV.fetch(Configuration::Ext::Sampling::ENV_RULES, nil) the same as ENV[Configuration::Ext::Sampling::ENV_RULES]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we just write ENV.fetch(blah, nil) more than ENV#[] in this file.

I feel like this will mostly go away when we refactor configuration 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave this one like this, because it will be simple to refactor when this code gets simplified in the configuration refactoring.

@github-actions github-actions bot added the core Involves Datadog core libraries label Jul 14, 2023
sample_rate: sample_rate,
}

Core::BackportFrom24.hash_compact!(kwargs)
Copy link
Member Author

@marcotc marcotc Jul 14, 2023

Choose a reason for hiding this comment

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

I don't like how this BackportFrom comes in right in the middle of the method, can we start using refinements again? 🙏

@marcotc marcotc merged commit 8d3ef4f into master Jul 14, 2023
@marcotc marcotc deleted the sampling-rules-config branch July 14, 2023 21:55
@github-actions github-actions bot added this to the 1.13.0 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants