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

[Crashtracking] Fix crashtracking in single-file apps #6677

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kevingosse
Copy link
Collaborator

Summary of changes

Register the crashtracking WER handler even if we fail to unregister the .NET one.

Reason for change

For crashtracking to work, we need to unregister the WER handler registered by .NET, because it claims the crash and we won't be called. To unregister it, we need two information: the path to coreclr.dll, and its address in memory. It fails in single-file apps because there is no coreclr.dll. However, it also means that the .NET registration is invalid, so we will still be called if we register our own handler.

Regardless, even if the .NET WER handler registration is correct, it doesn't hurt to still register our own.

Test coverage

Tested on my machine. I don't think it's worth the hassle of publishing Samples.Console as single file.

@andrewlock
Copy link
Member

andrewlock commented Feb 18, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6677) - mean (69ms)  : 65, 72
     .   : milestone, 69,
    master - mean (73ms)  : 70, 77
     .   : milestone, 73,

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (994ms)  : 966, 1022
     .   : milestone, 994,
    master - mean (1,034ms)  : 1004, 1063
     .   : milestone, 1034,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6677) - mean (102ms)  : 99, 104
     .   : milestone, 102,
    master - mean (108ms)  : 105, 111
     .   : milestone, 108,

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (669ms)  : 653, 685
     .   : milestone, 669,
    master - mean (698ms)  : 680, 717
     .   : milestone, 698,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6677) - mean (88ms)  : 86, 91
     .   : milestone, 88,
    master - mean (95ms)  : 92, 97
     .   : milestone, 95,

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (628ms)  : 609, 647
     .   : milestone, 628,
    master - mean (656ms)  : 639, 672
     .   : milestone, 656,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6677) - mean (191ms)  : 187, 195
     .   : milestone, 191,
    master - mean (191ms)  : 186, 197
     .   : milestone, 191,

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (1,112ms)  : 1080, 1144
     .   : milestone, 1112,
    master - mean (1,109ms)  : 1073, 1146
     .   : milestone, 1109,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6677) - mean (271ms)  : 266, 277
     .   : milestone, 271,
    master - mean (273ms)  : 266, 280
     .   : milestone, 273,

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (868ms)  : 832, 904
     .   : milestone, 868,
    master - mean (867ms)  : 834, 900
     .   : milestone, 867,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6677) - mean (263ms)  : 257, 268
     .   : milestone, 263,
    master - mean (262ms)  : 258, 267
     .   : milestone, 262,

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (843ms)  : 810, 876
     .   : milestone, 843,
    master - mean (849ms)  : 822, 877
     .   : milestone, 849,

Loading

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

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

LGTM, hopefully it fixes the failures in #6678

@andrewlock
Copy link
Member

andrewlock commented Feb 18, 2025

Benchmarks Report for tracer 🐌

Benchmarks for #6677 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.168
  • All benchmarks have the same allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 8.17μs 50.4ns 501ns 0.0127 0.00422 0 5.6 KB
master StartStopWithChild netcoreapp3.1 10.4μs 61.1ns 573ns 0.0204 0.00509 0 5.81 KB
master StartStopWithChild net472 15.9μs 57.7ns 223ns 1.04 0.304 0.096 6.21 KB
#6677 StartStopWithChild net6.0 8.4μs 45.7ns 303ns 0.0115 0.00384 0 5.62 KB
#6677 StartStopWithChild netcoreapp3.1 10.6μs 60.8ns 467ns 0.02 0.00499 0 5.8 KB
#6677 StartStopWithChild net472 16.2μs 50.5ns 189ns 1.05 0.312 0.0987 6.21 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 465μs 396ns 1.48μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 661μs 493ns 1.84μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 848μs 420ns 1.52μs 0.422 0 0 3.3 KB
#6677 WriteAndFlushEnrichedTraces net6.0 483μs 420ns 1.57μs 0 0 0 2.7 KB
#6677 WriteAndFlushEnrichedTraces netcoreapp3.1 651μs 648ns 2.42μs 0 0 0 2.7 KB
#6677 WriteAndFlushEnrichedTraces net472 833μs 825ns 3.2μs 0.419 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 129μs 519ns 2.01μs 0.19 0 0 14.47 KB
master SendRequest netcoreapp3.1 144μs 564ns 2.18μs 0.215 0 0 17.27 KB
master SendRequest net472 0.0138ns 0.00198ns 0.00769ns 0 0 0 0 b
#6677 SendRequest net6.0 133μs 470ns 1.82μs 0.197 0 0 14.47 KB
#6677 SendRequest netcoreapp3.1 144μs 456ns 1.77μs 0.217 0 0 17.27 KB
#6677 SendRequest net472 0.00444ns 0.00118ns 0.00457ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 568μs 3.03μs 16.3μs 0.566 0 0 41.58 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 661μs 2.35μs 8.49μs 0.327 0 0 41.74 KB
master WriteAndFlushEnrichedTraces net472 863μs 4.1μs 16.4μs 8.68 2.6 0.434 53.31 KB
#6677 WriteAndFlushEnrichedTraces net6.0 563μs 3.07μs 20.1μs 0.558 0 0 41.54 KB
#6677 WriteAndFlushEnrichedTraces netcoreapp3.1 682μs 3.9μs 32.1μs 0.345 0 0 41.7 KB
#6677 WriteAndFlushEnrichedTraces net472 837μs 3.54μs 13.2μs 8.39 2.52 0.419 53.3 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.31μs 1.04ns 4.02ns 0.0138 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.83μs 1.54ns 5.98ns 0.0137 0 0 1.02 KB
master ExecuteNonQuery net472 2.09μs 4.61ns 17.9ns 0.156 0.00105 0 987 B
#6677 ExecuteNonQuery net6.0 1.29μs 0.874ns 3.15ns 0.0141 0 0 1.02 KB
#6677 ExecuteNonQuery netcoreapp3.1 1.78μs 1.97ns 7.61ns 0.0131 0 0 1.02 KB
#6677 ExecuteNonQuery net472 2.07μs 5ns 19.4ns 0.157 0.00104 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.19μs 0.665ns 2.58ns 0.0137 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.55μs 1.19ns 4.61ns 0.0132 0 0 976 B
master CallElasticsearch net472 2.52μs 1.47ns 5.69ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.27μs 0.432ns 1.67ns 0.0133 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 0.629ns 2.44ns 0.0139 0 0 1.02 KB
master CallElasticsearchAsync net472 2.67μs 2.35ns 9.1ns 0.166 0 0 1.05 KB
#6677 CallElasticsearch net6.0 1.31μs 1.14ns 4.43ns 0.0132 0 0 976 B
#6677 CallElasticsearch netcoreapp3.1 1.64μs 1.2ns 4.65ns 0.0131 0 0 976 B
#6677 CallElasticsearch net472 2.59μs 1.86ns 7.22ns 0.158 0 0 995 B
#6677 CallElasticsearchAsync net6.0 1.39μs 2.6ns 9.74ns 0.0132 0 0 952 B
#6677 CallElasticsearchAsync netcoreapp3.1 1.65μs 1.14ns 4.28ns 0.0139 0 0 1.02 KB
#6677 CallElasticsearchAsync net472 2.54μs 1.64ns 6.34ns 0.167 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.33μs 0.789ns 3.05ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.59μs 2.63ns 10.2ns 0.0128 0 0 952 B
master ExecuteAsync net472 1.9μs 0.837ns 3.24ns 0.145 0 0 915 B
#6677 ExecuteAsync net6.0 1.44μs 0.607ns 2.27ns 0.013 0 0 952 B
#6677 ExecuteAsync netcoreapp3.1 1.65μs 0.855ns 3.08ns 0.0124 0 0 952 B
#6677 ExecuteAsync net472 1.91μs 1.02ns 3.93ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.31μs 3.35ns 13ns 0.0323 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.28μs 2.02ns 7.81ns 0.037 0 0 2.85 KB
master SendAsync net472 7.4μs 2.09ns 8.1ns 0.496 0 0 3.12 KB
#6677 SendAsync net6.0 4.31μs 2.2ns 8.5ns 0.0321 0 0 2.31 KB
#6677 SendAsync netcoreapp3.1 5.4μs 2.03ns 7.31ns 0.0377 0 0 2.85 KB
#6677 SendAsync net472 7.43μs 2.13ns 7.96ns 0.493 0 0 3.12 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.47μs 0.573ns 2.22ns 0.0228 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.16μs 1.28ns 4.95ns 0.0228 0 0 1.64 KB
master EnrichedLog net472 2.66μs 1.78ns 6.65ns 0.25 0 0 1.57 KB
#6677 EnrichedLog net6.0 1.6μs 0.559ns 2.01ns 0.0225 0 0 1.64 KB
#6677 EnrichedLog netcoreapp3.1 2.21μs 3.31ns 12.8ns 0.0221 0 0 1.64 KB
#6677 EnrichedLog net472 2.42μs 0.884ns 3.31ns 0.249 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 113μs 329ns 1.27μs 0.0573 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 116μs 209ns 809ns 0 0 0 4.28 KB
master EnrichedLog net472 152μs 210ns 814ns 0.679 0.226 0 4.46 KB
#6677 EnrichedLog net6.0 112μs 164ns 614ns 0.0561 0 0 4.28 KB
#6677 EnrichedLog netcoreapp3.1 117μs 195ns 730ns 0 0 0 4.28 KB
#6677 EnrichedLog net472 149μs 191ns 738ns 0.669 0.223 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 3.06μs 0.809ns 2.8ns 0.0306 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.3μs 1.88ns 7.27ns 0.0281 0 0 2.2 KB
master EnrichedLog net472 4.98μs 2.19ns 8.19ns 0.319 0 0 2.02 KB
#6677 EnrichedLog net6.0 3.01μs 0.99ns 3.83ns 0.0305 0 0 2.2 KB
#6677 EnrichedLog netcoreapp3.1 4.13μs 1.96ns 6.78ns 0.0288 0 0 2.2 KB
#6677 EnrichedLog net472 4.78μs 1.08ns 3.9ns 0.32 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.45μs 0.764ns 2.86ns 0.016 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.85μs 0.793ns 2.97ns 0.0158 0 0 1.14 KB
master SendReceive net472 2.09μs 1.52ns 5.69ns 0.183 0 0 1.16 KB
#6677 SendReceive net6.0 1.43μs 1.53ns 5.91ns 0.0164 0 0 1.14 KB
#6677 SendReceive netcoreapp3.1 1.78μs 2.41ns 8.7ns 0.0151 0 0 1.14 KB
#6677 SendReceive net472 2.12μs 2.28ns 8.83ns 0.184 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.79μs 0.751ns 2.91ns 0.0223 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.89μs 1.32ns 5.11ns 0.0214 0 0 1.65 KB
master EnrichedLog net472 4.24μs 3.32ns 12.9ns 0.322 0 0 2.04 KB
#6677 EnrichedLog net6.0 2.81μs 0.852ns 3.3ns 0.0224 0 0 1.6 KB
#6677 EnrichedLog netcoreapp3.1 3.87μs 2.64ns 9.51ns 0.0213 0 0 1.65 KB
#6677 EnrichedLog net472 4.12μs 1.7ns 6.37ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6677

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.168 395.66 462.29

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 395ns 0.763ns 2.96ns 0.00817 0 0 576 B
master StartFinishSpan netcoreapp3.1 563ns 1.13ns 4.37ns 0.00781 0 0 576 B
master StartFinishSpan net472 584ns 0.913ns 3.42ns 0.0916 0 0 578 B
master StartFinishScope net6.0 470ns 0.94ns 3.64ns 0.00988 0 0 696 B
master StartFinishScope netcoreapp3.1 683ns 0.979ns 3.66ns 0.00936 0 0 696 B
master StartFinishScope net472 804ns 1.68ns 6.49ns 0.104 0 0 658 B
#6677 StartFinishSpan net6.0 462ns 1.05ns 3.94ns 0.00817 0 0 576 B
#6677 StartFinishSpan netcoreapp3.1 597ns 0.991ns 3.84ns 0.00785 0 0 576 B
#6677 StartFinishSpan net472 613ns 1.22ns 4.71ns 0.0917 0 0 578 B
#6677 StartFinishScope net6.0 482ns 0.8ns 3.1ns 0.00972 0 0 696 B
#6677 StartFinishScope netcoreapp3.1 719ns 1.36ns 5.28ns 0.00912 0 0 696 B
#6677 StartFinishScope net472 859ns 1.75ns 6.79ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 717ns 0.979ns 3.79ns 0.00978 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 928ns 1.45ns 5.44ns 0.00949 0 0 696 B
master RunOnMethodBegin net472 1.03μs 3.58ns 13.9ns 0.104 0 0 658 B
#6677 RunOnMethodBegin net6.0 673ns 0.172ns 0.668ns 0.00981 0 0 696 B
#6677 RunOnMethodBegin netcoreapp3.1 936ns 0.447ns 1.55ns 0.00937 0 0 696 B
#6677 RunOnMethodBegin net472 1.08μs 0.658ns 2.55ns 0.104 0 0 658 B

andrewlock added a commit that referenced this pull request Feb 18, 2025
…ts for the NuGet packages (#6678)

## Summary of changes

- Pack the trimming file into the _Datadog.Trace_ NuGet package
- Add smoke tests for the _Datadog.Trace_ and _Datadog.Trace.Trimming_
NuGet packages
- Remove the unnecessary sdk.props file from _Datadog.Trace.Trimming_

## Reason for change

When users are building trimmed (non-aot) apps, they need to reference
our trimming file, which is currently exposed via the
_Datadog.Trace.Trimming_ NuGet package. We created this as a separate
package, because we didn't want people to have to reference the
_Datadog.Trace_ NuGet if they didn't need it.

However, there's not really a good reason to force people to _have_ to
reference another NuGet package if they are _already_ referencing
_Datadog.Trace_. And there's no harm in including the trimming file for
non-trimmed apps, it has no impact.

## Implementation details

- Pack the same trimming.XML file into the _Datadog.Trace_ NuGet package
- Include a _Datadog.Trace.props_ file to automatically reference the
trimmer file when the NuGet is referenced
- Added smoke tests that confirm the _NuGet_ packaging is correct for
both the new package, and the existing package
- We already had "integration" tests that confirm the trimmer file
works, but we didn't have any tests that were using the NuGet package,
to confirm the `props` are correctly added etc.
- Removed the `sdk/sdk.props` file from _Datadog.Trace.Trimming_ as it's
unused. This file is only useful if you're creating a "[custom .NET
SDK](https://learn.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2022#use-the-sdk-attribute-on-the-project-element)"
to reference in the `<Project SDK="Some.SDK">` element (which we're
not).

## Test coverage

Added smoke tests to confirm both the _Datadog.Trace_ and
_Datadog.Trace.Trimming_ packages work as expected. For now, these are:

- `linux-x64`/`linux-musl-x64` only
- `net8.0`/`net9.0` only

We could expand that further if we want, but I'm not massively inclined
to do so - we primarily want to ensure the _packages_ are valid, and we
don't really need to run that across all the different platforms IMO.
Plus it will just increase the chance of flake.

## Other details

As part of this, noticed that crash tracking didn't work. 
- Disabled crash tracking in these tests for now
- #6677 was raised in
response
- Ideally we should merge this, and then re-enable the crash tracking
tests in that PR

I've kept these in the "standard, every PR" set of smoke tests for now,
but maybe we should move them to the master-only set? 🤷‍♂️

---------

Co-authored-by: Kevin Gosse <[email protected]>
@andrewlock andrewlock force-pushed the kevin/wer_single_file branch from 096456b to 6b51050 Compare February 21, 2025 11:31
@andrewlock andrewlock force-pushed the kevin/wer_single_file branch from 6b51050 to f488df3 Compare February 21, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants