Add SpanSamplingRule for Single Span Ingestion#3283
Conversation
This comment has been minimized.
This comment has been minimized.
andrewlock
left a comment
There was a problem hiding this comment.
Just minor code style comments/questions, mostly because I don't have all the sampling stuff in my head yet - better for Lucas or Zach to review that side of it I think :D
| /// <para><c>0.0</c> is drop all.</para> | ||
| /// <para><c>1.0</c> is accept all.</para> | ||
| /// </value> | ||
| float SamplingRate { get; } |
There was a problem hiding this comment.
Any reason for float over double?
There was a problem hiding this comment.
Good question
I chose a float because the RFC called it a float
| { | ||
| // TODO default glob (maybe null/empty/whitespace) should be * | ||
| var regexPattern = "^" + Regex.Escape(glob).Replace("\\?", ".").Replace("\\*", ".*") + "$"; | ||
| var regex = new Regex(regexPattern, RegexOptions.Compiled, RegexTimeout); |
There was a problem hiding this comment.
Maybe worth using the non-backtracking regex if available?
There was a problem hiding this comment.
👍
I had to add a #if NETCOREAPP3_1_OR_GREATER to it to get that option 2b186e9
Is there a way to do non-backtracking regex in previous frameworks?
There was a problem hiding this comment.
Unfortunately not, but probably still worth it 🙂
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // TODO should we log here? | ||
| if (!IsMatch(span)) | ||
| { | ||
| return false; |
There was a problem hiding this comment.
I'm not quite sure how ShouldKeep will be used, but I'm a little concerned that the decision for "didn't match" and "chose not to sample" both result in a false return value. What do you think about making the return type bool?? Or perhaps we require the caller to call IsMatch first so we always know that the rule applies?
There was a problem hiding this comment.
I like the idea of breaking it up to try and call the IsMatch first and then go and making the sampling decision with some separate function
I'll try that out and see how that works with the SpanSampler implementation
There was a problem hiding this comment.
Split these up in 300ce78
To be a IsMatch that returns a bool for whether the glob patterns match and ShouldSample that returns bool for whether the sampling rate/limit are good
zacharycmontoya
left a comment
There was a problem hiding this comment.
Looks good with some really small feedback 👍🏼
SpanSamplingRule for Single Span Ingestion
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7ba0b8e to
e17b72b
Compare
…/dd-trace-dotnet into steven/single-span/limiter
21ce657 to
fd809c4
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Benchmarks Report 🐌Benchmarks for #3283 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️Raw results
|
Code Coverage Report 📊✔️ Merging #3283 into master will not change line coverage
View the full report for further details: Datadog.Trace Breakdown ✔️
The following classes have significant coverage changes.
The following classes were added in #3283:
View the full reports for further details: |
Summary of changes
Adds a
SpanSamplingRulethat is used for configuring Single Span Ingestion rules.Reason for change
Single Span Ingestion needs its own set of rules.
Implementation details
From the RFC:
For the glob pattern, I opted to just convert it to
Regexfor the time being.Test coverage
CustomSamplingRuleTestswhich may point out that there is some refactoring that should be done.Other details
SpanRateLimiterfor Single Span Ingestion #3282