-
Notifications
You must be signed in to change notification settings - Fork 40
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
make the rules sample limiter and default sampling rate configurable #215
Changes from all commits
e3f5331
7b1b424
822710c
bec255b
d06674c
95c4917
8e5cbd9
7b4f539
a3a6c70
bc76da9
89c521c
871cee5
bec4983
ff4d9e2
a77dbe1
8fa61da
94bac9e
3b2bdcb
9683118
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ namespace opentracing { | |
|
||
ot::expected<TracerOptions> optionsFromConfig(const char *configuration, | ||
std::string &error_message) { | ||
TracerOptions options{"localhost", 8126, "", "web", "", 1.0}; | ||
TracerOptions options; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line almost destroyed me. Hours lost... |
||
json config; | ||
try { | ||
config = json::parse(configuration); | ||
|
@@ -85,6 +85,9 @@ ot::expected<TracerOptions> optionsFromConfig(const char *configuration, | |
if (config.find("dd.trace.analytics-sample-rate") != config.end()) { | ||
config.at("dd.trace.analytics-sample-rate").get_to(options.analytics_rate); | ||
} | ||
if (config.find("sampling_limit_per_second") != config.end()) { | ||
config.at("sampling_limit_per_second").get_to(options.sampling_limit_per_second); | ||
} | ||
} catch (const nlohmann::detail::type_error &) { | ||
error_message = "configuration has an argument with an incorrect type"; | ||
return ot::make_unexpected(std::make_error_code(std::errc::invalid_argument)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,28 +19,9 @@ ot::expected<TracerOptions> optionsFromConfig(const char *configuration, | |
template <class TracerImpl> | ||
class TracerFactory : public ot::TracerFactory { | ||
public: | ||
// Accepts configuration in JSON format, with the following keys: | ||
// "service": Required. A string, the name of the service. | ||
// "agent_host": A string, defaults to localhost. Can also be set by the environment variable | ||
// DD_AGENT_HOST | ||
// "agent_port": A number, defaults to 8126. "type": A string, defaults to web. Can also be set | ||
// by the environment variable DD_TRACE_AGENT_PORT | ||
// "type": A string, defaults to web. | ||
// "environment": A string, defaults to "". The environment this trace belongs to. | ||
// eg. "" (env:none), "staging", "prod". Can also be set by the environment variable | ||
// DD_ENV | ||
// "sample_rate": A double, defaults to 1.0. | ||
// "operation_name_override": A string, if not empty it overrides the operation name (and the | ||
// overridden operation name is recorded in the tag "operation"). | ||
// "propagation_style_extract": A list of strings, each string is one of "Datadog", "B3". | ||
// Defaults to ["Datadog"]. The type of headers to use to propagate | ||
// distributed traces. Can also be set by the environment variable | ||
// DD_PROPAGATION_STYLE_EXTRACT. | ||
// "propagation_style_inject": A list of strings, each string is one of "Datadog", "B3". Defaults | ||
// to ["Datadog"]. The type of headers to use to receive distributed traces. Can also be set | ||
// by the environment variable DD_PROPAGATION_STYLE_INJECT. | ||
// | ||
// Extra keys will be ignored. | ||
// Accepts configuration as a JSON object. See `optionsFromConfig` in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense - this comment wasn't being maintained when changes in the actual implementation occurred. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose the latter because I didn't feel like writing the documentation myself, and saw that it might fall out of sync anyway :) I couldn't find a place in the public documentation, either, that describes everything supported here. One thing to consider is making this a public contract, maintenance and all, and then linking to it from the public docs. Not today, though. |
||
// tracer_factory.cpp for a list of supported attributes. Unsupported | ||
// attributes are ignored. | ||
ot::expected<std::shared_ptr<ot::Tracer>> MakeTracer(const char *configuration, | ||
std::string &error_message) const | ||
noexcept override; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an integer instead? It's a quantity, and I'm not certain values of 0.2 or 1.5 make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it's a use case anyone would want, but I did verify that values less than one have the expected behavior: 0.5 means at most one every two seconds. Might have even added a unit test.
It does no harm and allows for that kind of thing, so I'll keep it.