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

Sampling Rule and Rate Limiter Standardization #598

Merged
merged 3 commits into from
Dec 31, 2019

Conversation

colin-higgins
Copy link
Member

Changes proposed in this pull request:
Standardize configuration of trace sampling rules and rate limiting for tracing without limits.

@DataDog/apm-dotnet

bobuva
bobuva previously approved these changes Dec 30, 2019
Copy link
Contributor

@bobuva bobuva left a comment

Choose a reason for hiding this comment

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

This looks good, I don't see anything to comment on. Nice work!

Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

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

Just a small comment to double check that traces per second is correctly used in all cases.

maxTracesPerSecond = 100; // default
}

MaxTracesSubmittedPerSecond = maxTracesPerSecond.Value;
Copy link
Member

Choose a reason for hiding this comment

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

If I am looking at it right I think this is perfect, but just wanted to drop a message here to double check.
We are doing RuleBasedSampler.OptInTracingWithoutLimits(); here (if the parameter that controls traces per second is set) and when a new a new rule is registered (if the user register at least one rule).

Some languages let users opt-in also using of a global configuration env variable, DD_TRACE_SAMPLE_RATE=0.7 which means, not surprisingly...sample 70% of the traces, no matter what. In this case, we need to enforce the traces per second limit as well.

I could not find evidence of this in the possibility in this tracer - I looked here - , but just wanted to double check. If you haven't this configuration option then no action is required, otherwise I'd ask you to make sure the if that env is set we comply with max traces per second.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have such a configuration option no, currently that would be accomplished with a single rule with no filter on service or operation.

Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

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

The name of this env variable should be changed from DD_CUSTOM_SAMPLING_RULES to DD_TRACE_SAMPLING_RULES.


public CustomSamplingRule(
float rate,
string ruleName,
Copy link
Member

Choose a reason for hiding this comment

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

what is ruleName used for?

Copy link
Member

Choose a reason for hiding this comment

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

feels unnecessary?

Copy link
Member Author

@colin-higgins colin-higgins Dec 31, 2019

Choose a reason for hiding this comment

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

Was for testing and more easily identifying rules.
When logging, the name is logged with the rule.
If it is not specified, it is given a name based on it's index in configuration.
return new CustomSamplingRule(r.SampleRate, r.RuleName ?? $"config-rule-{index}", r.Service, r.OperationName)

First rule is "config-rule-1", second rule is "config-rule-2", etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Then it makes it easier to look at config and know which rule a trace is matched on.

@colin-higgins colin-higgins merged commit fe69dea into master Dec 31, 2019
@colin-higgins colin-higgins deleted the colin/tracing-without-limits-standards branch December 31, 2019 21:54
}

public void SetDefaultSampleRates(IEnumerable<KeyValuePair<string, float>> sampleRates)
public static void OptInTracingWithoutLimits()
Copy link
Member

@lucaspimentel lucaspimentel Jan 6, 2020

Choose a reason for hiding this comment

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

(Too late since this is already merged)

Note that this enables TwL for all RuleBasedSampler instances, even through each Tracer instance can have different settings (some with custom rules and some without).


Scope root;

using (root = Tracer.Instance.StartActive(operationName: operationName, serviceName: serviceName))
Copy link
Member

Choose a reason for hiding this comment

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

Tests that only use manual instrumentation don't need an additional project, since we don't need to attach the profiler.


Scope root;

using (root = Tracer.Instance.StartActive(operationName: operationName, serviceName: serviceName))
Copy link
Member

Choose a reason for hiding this comment

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

Tests that only use manual instrumentation don't need an additional project, since we don't need to attach the profiler.

@lucaspimentel lucaspimentel added this to the 1.11.1 milestone Jan 13, 2020
@lucaspimentel lucaspimentel added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Jan 23, 2020
MikeGoldsmith pushed a commit to lightstep/ls-trace-dotnet that referenced this pull request Mar 20, 2020
* Standardize tracing without limits features
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants