Backport fixes to 1.x#2479
Conversation
…2458) * Add tests for case where an exception is set on a span and a non-200 status code is set Shows that the tests are failing for the "legacy" (feature-flag disabled) use case. * Fix missing HTTP status code tag when span is manually marked as an error
The HttpClient integration (and the ASP.NET/ASP.NET Core integration when the feature flag is disabled) all do "cleaning" of URLs to try and reduce the cardinality introduced by number/guid route parameters. This works by examining each "segment" in a URL, and using heuristics to see if we should replace it with `?`. This works as expected for the following paths: - `/some/value/123` => `/some/value/?` - `/some/value/123/123-456 => `/some/value/?/?` - `/some/value/123/example.png => `/some/value/?/example.png` However, it treats the whole final segment as a single unit, which means filenames with extensions will never be obfuscated, e.g. - `/some-filevalue/123.png` - `/some-filevalue/123.456` - `/some-filevalue/123.c` That can lead to high cardinality, which in turn can cause problems for customers with too many endpoints in their account. To work around it, we treat the filename as a separate segment from the file extension, and don't try and obfuscate the extension
| scope.Span.SetHttpStatusCode(httpContext.Response.StatusCode, isServer: true); | ||
| scope.Span.SetHeaderTags(new HeadersCollectionAdapter(httpContext.Response.Headers), tracer.Settings.HeaderTags, defaultTagPrefix: SpanContextPropagator.HttpResponseHeadersTagPrefix); | ||
| span.SetHttpStatusCode(httpContext.Response.StatusCode, isServer: true); | ||
| span.SetHeaderTags(new HeadersCollectionAdapter(httpContext.Response.Headers), tracer.Settings.HeaderTags, defaultTagPrefix: SpanContextPropagator.HttpResponseHeadersTagPrefix); |
There was a problem hiding this comment.
There is a slight change in behavior here. Before we would be adding the header tags whenever there was no error. Now you only add them if there is no status code. It means that if there is a status code and no error, we would previously set the header tags and not anymore.
There was a problem hiding this comment.
Hmmm, that's a good point. That behaviour is in master too 🤔 I wonder then if we should change it so that the headers are always added in the stop, regardless (which would supersede #2460 too)
This comment has been minimized.
This comment has been minimized.
8acf930 to
ed1d1e6
Compare
Thes changes were necessary because of the significant differences between master and release/1.x
This comment has been minimized.
This comment has been minimized.
Code Coverage Report 📊⛔ Merging #2479 into master will will decrease line coverage by
View the full report for further details: Datadog.Trace Breakdown ⛔
The following classes have significant coverage changes. The following classes were added in #2479:
180 classes were removed from Datadog.Trace in #2479 View the full reports for further details: |
Benchmarks Report 🐌Benchmarks for #2479 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.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Slower
|
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery‑netcoreapp3.1 | 1.260 | 1,514.63 | 1,908.45 |
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | ExecuteNonQuery |
net472 | 1.831 μs | 0.0222 μs | 0.0218 μs | 0.0927 | 0.0009 | 0.0000 | 586 B |
| master | ExecuteNonQuery |
netcoreapp3.1 | 1.533 μs | 0.0300 μs | 0.0485 μs | 0.0087 | 0.0000 | 0.0000 | 624 B |
| #2479 | ExecuteNonQuery |
net472 | 2.023 μs | 0.0402 μs | 0.0847 μs | 0.1083 | 0.0010 | 0.0000 | 682 B |
| #2479 | ExecuteNonQuery |
netcoreapp3.1 | 1.912 μs | 0.0197 μs | 0.0175 μs | 0.0095 | 0.0000 | 0.0000 | 712 B |
Benchmarks.Trace.ElasticsearchBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #2479
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch‑net472
1.218
2,555.59
3,113.86
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync‑net472
1.130
2,912.39
3,290.06
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch‑net472 | 1.218 | 2,555.59 | 3,113.86 | |
| Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync‑net472 | 1.130 | 2,912.39 | 3,290.06 |
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | CallElasticsearch |
net472 | 2.552 μs | 0.0340 μs | 0.0266 μs | 0.1250 | 0.0000 | 0.0000 | 794 B |
| master | CallElasticsearch |
netcoreapp3.1 | 1.723 μs | 0.0251 μs | 0.0223 μs | 0.0104 | 0.0000 | 0.0000 | 784 B |
| master | CallElasticsearchAsync |
net472 | 2.937 μs | 0.0584 μs | 0.1069 μs | 0.1452 | 0.0000 | 0.0000 | 931 B |
| master | CallElasticsearchAsync |
netcoreapp3.1 | 1.891 μs | 0.0359 μs | 0.0318 μs | 0.0125 | 0.0000 | 0.0000 | 904 B |
| #2479 | CallElasticsearch |
net472 | 3.116 μs | 0.0587 μs | 0.0577 μs | 0.1284 | 0.0000 | 0.0000 | 827 B |
| #2479 | CallElasticsearch |
netcoreapp3.1 | 1.651 μs | 0.0313 μs | 0.0292 μs | 0.0104 | 0.0000 | 0.0000 | 768 B |
| #2479 | CallElasticsearchAsync |
net472 | 3.300 μs | 0.0506 μs | 0.0474 μs | 0.1501 | 0.0000 | 0.0000 | 963 B |
| #2479 | CallElasticsearchAsync |
netcoreapp3.1 | 1.772 μs | 0.0351 μs | 0.0345 μs | 0.0125 | 0.0000 | 0.0000 | 888 B |
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | ExecuteAsync |
net472 | 3.032 μs | 0.0604 μs | 0.0741 μs | 0.1662 | 0.0000 | 0.0000 | 1.03 KB |
| master | ExecuteAsync |
netcoreapp3.1 | 2.028 μs | 0.0159 μs | 0.0124 μs | 0.0146 | 0.0000 | 0.0000 | 1 KB |
| #2479 | ExecuteAsync |
net472 | 3.368 μs | 0.0362 μs | 0.0303 μs | 0.1696 | 0.0000 | 0.0000 | 1083 B |
| #2479 | ExecuteAsync |
netcoreapp3.1 | 1.953 μs | 0.0389 μs | 0.0606 μs | 0.0140 | 0.0000 | 0.0000 | 1008 B |
Benchmarks.Trace.HttpClientBenchmark - Faster 🎉 Same allocations ✔️
Faster 🎉 in #2479
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.HttpClientBenchmark.SendAsync‑net472
1.182
7,020.33
5,940.22
Benchmarks.Trace.HttpClientBenchmark.SendAsync‑netcoreapp3.1
1.156
4,934.83
4,270.55
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.HttpClientBenchmark.SendAsync‑net472 | 1.182 | 7,020.33 | 5,940.22 | |
| Benchmarks.Trace.HttpClientBenchmark.SendAsync‑netcoreapp3.1 | 1.156 | 4,934.83 | 4,270.55 |
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendAsync |
net472 | 7.053 μs | 0.1405 μs | 0.1618 μs | 0.3638 | 0.0000 | 0.0000 | 2.25 KB |
| master | SendAsync |
netcoreapp3.1 | 4.941 μs | 0.0986 μs | 0.1415 μs | 0.0316 | 0.0000 | 0.0000 | 2.15 KB |
| #2479 | SendAsync |
net472 | 5.950 μs | 0.1147 μs | 0.1853 μs | 0.3505 | 0.0000 | 0.0000 | 2.19 KB |
| #2479 | SendAsync |
netcoreapp3.1 | 4.317 μs | 0.0841 μs | 0.1152 μs | 0.0291 | 0.0000 | 0.0000 | 2.09 KB |
Benchmarks.Trace.ILoggerBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #2479
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.ILoggerBenchmark.EnrichedLog‑netcoreapp3.1
1.185
3,109.61
3,684.70
Benchmarks.Trace.ILoggerBenchmark.EnrichedLog‑net472
1.156
3,288.92
3,803.59
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.ILoggerBenchmark.EnrichedLog‑netcoreapp3.1 | 1.185 | 3,109.61 | 3,684.70 | |
| Benchmarks.Trace.ILoggerBenchmark.EnrichedLog‑net472 | 1.156 | 3,288.92 | 3,803.59 |
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 3.274 μs | 0.0608 μs | 0.0508 μs | 0.2247 | 0.0000 | 0.0000 | 1.4 KB |
| master | EnrichedLog |
netcoreapp3.1 | 3.115 μs | 0.0600 μs | 0.0561 μs | 0.0201 | 0.0000 | 0.0000 | 1.48 KB |
| #2479 | EnrichedLog |
net472 | 3.814 μs | 0.0736 μs | 0.0956 μs | 0.2872 | 0.0000 | 0.0000 | 1.79 KB |
| #2479 | EnrichedLog |
netcoreapp3.1 | 3.690 μs | 0.0335 μs | 0.0297 μs | 0.0274 | 0.0000 | 0.0000 | 1.94 KB |
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 291.5 μs | 3.40 μs | 3.18 μs | 0.4376 | 0.1459 | 0.0000 | 4.21 KB |
| master | EnrichedLog |
netcoreapp3.1 | 237.2 μs | 3.42 μs | 5.11 μs | 0.0000 | 0.0000 | 0.0000 | 4.09 KB |
| #2479 | EnrichedLog |
net472 | 296.2 μs | 3.05 μs | 2.71 μs | 0.5938 | 0.1485 | 0.0000 | 5.23 KB |
| #2479 | EnrichedLog |
netcoreapp3.1 | 233.9 μs | 2.21 μs | 1.85 μs | 0.0000 | 0.0000 | 0.0000 | 5.05 KB |
Benchmarks.Trace.NLogBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #2479
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.NLogBenchmark.EnrichedLog‑netcoreapp3.1
1.824
6,526.85
11,903.07
Benchmarks.Trace.NLogBenchmark.EnrichedLog‑net472
1.516
7,631.82
11,571.45
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.NLogBenchmark.EnrichedLog‑netcoreapp3.1 | 1.824 | 6,526.85 | 11,903.07 | |
| Benchmarks.Trace.NLogBenchmark.EnrichedLog‑net472 | 1.516 | 7,631.82 | 11,571.45 |
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 7.663 μs | 0.1288 μs | 0.1142 μs | 0.5019 | 0.0000 | 0.0000 | 3.13 KB |
| master | EnrichedLog |
netcoreapp3.1 | 6.522 μs | 0.1064 μs | 0.1182 μs | 0.0505 | 0.0000 | 0.0000 | 3.5 KB |
| #2479 | EnrichedLog |
net472 | 11.57 μs | 0.149 μs | 0.139 μs | 0.8553 | 0.0000 | 0.0000 | 5.31 KB |
| #2479 | EnrichedLog |
netcoreapp3.1 | 11.92 μs | 0.213 μs | 0.199 μs | 0.0885 | 0.0000 | 0.0000 | 6.28 KB |
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendReceive |
net472 | 2.378 μs | 0.0473 μs | 0.0736 μs | 0.1567 | 0.0000 | 0.0000 | 1003 B |
| master | SendReceive |
netcoreapp3.1 | 2.022 μs | 0.0285 μs | 0.0267 μs | 0.0139 | 0.0000 | 0.0000 | 1000 B |
| #2479 | SendReceive |
net472 | 2.106 μs | 0.0224 μs | 0.0187 μs | 0.1543 | 0.0000 | 0.0000 | 987 B |
| #2479 | SendReceive |
netcoreapp3.1 | 2.078 μs | 0.0413 μs | 0.0825 μs | 0.0130 | 0.0000 | 0.0000 | 984 B |
Benchmarks.Trace.SerilogBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #2479
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.SerilogBenchmark.EnrichedLog‑netcoreapp3.1
1.424
5,285.28
7,524.55
Benchmarks.Trace.SerilogBenchmark.EnrichedLog‑net472
1.335
5,948.89
7,941.38
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.SerilogBenchmark.EnrichedLog‑netcoreapp3.1 | 1.424 | 5,285.28 | 7,524.55 | |
| Benchmarks.Trace.SerilogBenchmark.EnrichedLog‑net472 | 1.335 | 5,948.89 | 7,941.38 |
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 5.965 μs | 0.1033 μs | 0.0916 μs | 0.2899 | 0.0000 | 0.0000 | 1.81 KB |
| master | EnrichedLog |
netcoreapp3.1 | 5.280 μs | 0.0990 μs | 0.0926 μs | 0.0183 | 0.0000 | 0.0000 | 1.44 KB |
| #2479 | EnrichedLog |
net472 | 8.005 μs | 0.1590 μs | 0.1487 μs | 0.4464 | 0.0000 | 0.0000 | 2.8 KB |
| #2479 | EnrichedLog |
netcoreapp3.1 | 7.509 μs | 0.1484 μs | 0.2600 μs | 0.0352 | 0.0000 | 0.0000 | 2.61 KB |
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartFinishSpan |
net472 | 905.4 ns | 12.64 ns | 11.21 ns | 0.0706 | 0.0000 | 0.0000 | 449 B |
| master | StartFinishSpan |
netcoreapp3.1 | 897.1 ns | 12.61 ns | 10.53 ns | 0.0063 | 0.0000 | 0.0000 | 448 B |
| master | StartFinishScope |
net472 | 1,090.9 ns | 21.42 ns | 20.03 ns | 0.0832 | 0.0000 | 0.0000 | 530 B |
| master | StartFinishScope |
netcoreapp3.1 | 1,061.1 ns | 19.71 ns | 17.47 ns | 0.0078 | 0.0000 | 0.0000 | 568 B |
| #2479 | StartFinishSpan |
net472 | 903.7 ns | 17.64 ns | 17.33 ns | 0.0678 | 0.0000 | 0.0000 | 433 B |
| #2479 | StartFinishSpan |
netcoreapp3.1 | 868.6 ns | 13.85 ns | 12.96 ns | 0.0061 | 0.0000 | 0.0000 | 432 B |
| #2479 | StartFinishScope |
net472 | 1,059.2 ns | 21.02 ns | 27.33 ns | 0.0806 | 0.0000 | 0.0000 | 514 B |
| #2479 | StartFinishScope |
netcoreapp3.1 | 1,011.7 ns | 8.57 ns | 6.69 ns | 0.0077 | 0.0000 | 0.0000 | 552 B |
Summary of changes
http.status_codetag on ASP.NET Core spans with errors (Fix missinghttp.status_codetag on ASP.NET Core spans with errors #2458)Reason for change
#2458 is impacting customers that are currently using 1.x, and are unable to upgrade at this time.
Implementation details
Cherry-picking #2458 was slightly problematic, as there have been a number of other fixes and changes in that time (#2419). However, including those as well was causing even more difficulty.