Skip to content

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

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

Merged
merged 3 commits into from
Mar 5, 2025

Conversation

kevingosse
Copy link
Contributor

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)  : 67, 72
     .   : milestone, 69,
    master - mean (70ms)  : 65, 74
     .   : milestone, 70,

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (1,003ms)  : 984, 1022
     .   : milestone, 1003,
    master - mean (1,003ms)  : 977, 1029
     .   : milestone, 1003,

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

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (688ms)  : 670, 705
     .   : milestone, 688,
    master - mean (688ms)  : 664, 711
     .   : milestone, 688,

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

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (638ms)  : 622, 653
     .   : milestone, 638,
    master - mean (640ms)  : 626, 654
     .   : milestone, 640,

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

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (1,109ms)  : 1083, 1135
     .   : milestone, 1109,
    master - mean (1,107ms)  : 1081, 1133
     .   : milestone, 1107,

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

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (879ms)  : 851, 907
     .   : milestone, 879,
    master - mean (877ms)  : 842, 913
     .   : milestone, 877,

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

    section CallTarget+Inlining+NGEN
    This PR (6677) - mean (854ms)  : 818, 890
     .   : milestone, 854,
    master - mean (855ms)  : 817, 892
     .   : milestone, 855,

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:

  • All benchmarks have the same speed
  • 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.19μs 46.8ns 338ns 0.0119 0.00398 0 5.6 KB
master StartStopWithChild netcoreapp3.1 10.7μs 60.3ns 435ns 0.015 0.00499 0 5.81 KB
master StartStopWithChild net472 16.2μs 47.8ns 185ns 1.04 0.299 0.0969 6.2 KB
#6677 StartStopWithChild net6.0 8.54μs 47.3ns 295ns 0.0161 0.00807 0 5.61 KB
#6677 StartStopWithChild netcoreapp3.1 10.5μs 58.7ns 394ns 0.0254 0.0102 0 5.8 KB
#6677 StartStopWithChild net472 16.3μs 60.2ns 233ns 1.05 0.317 0.0975 6.2 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 483μs 358ns 1.39μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 644μs 635ns 2.46μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 849μs 397ns 1.54μs 0.422 0 0 3.3 KB
#6677 WriteAndFlushEnrichedTraces net6.0 505μs 195ns 674ns 0 0 0 2.7 KB
#6677 WriteAndFlushEnrichedTraces netcoreapp3.1 658μs 299ns 1.08μs 0 0 0 2.7 KB
#6677 WriteAndFlushEnrichedTraces net472 842μs 788ns 2.95μ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 133μs 411ns 1.59μs 0.199 0 0 14.47 KB
master SendRequest netcoreapp3.1 151μs 212ns 794ns 0.227 0 0 17.27 KB
master SendRequest net472 0.000146ns 9.84E‑05ns 0.000368ns 0 0 0 0 b
#6677 SendRequest net6.0 132μs 430ns 1.66μs 0.2 0 0 14.47 KB
#6677 SendRequest netcoreapp3.1 151μs 172ns 644ns 0.226 0 0 17.27 KB
#6677 SendRequest net472 0.000287ns 0.00011ns 0.00041ns 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 549μs 2.62μs 10.5μs 0.543 0 0 41.47 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 683μs 3.34μs 13.8μs 0.324 0 0 41.84 KB
master WriteAndFlushEnrichedTraces net472 878μs 3.73μs 13.9μs 8.19 2.59 0.431 53.32 KB
#6677 WriteAndFlushEnrichedTraces net6.0 558μs 2.54μs 12.2μs 0.59 0 0 41.67 KB
#6677 WriteAndFlushEnrichedTraces netcoreapp3.1 683μs 3.54μs 18.4μs 0.338 0 0 41.97 KB
#6677 WriteAndFlushEnrichedTraces net472 867μs 3.05μs 11.4μs 8.19 2.59 0.431 53.24 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.33μs 1.28ns 4.97ns 0.014 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.82μs 1.88ns 7.28ns 0.0133 0 0 1.02 KB
master ExecuteNonQuery net472 2.12μs 1.29ns 4.81ns 0.156 0.00106 0 987 B
#6677 ExecuteNonQuery net6.0 1.28μs 1.59ns 6.16ns 0.0142 0 0 1.02 KB
#6677 ExecuteNonQuery netcoreapp3.1 1.73μs 1.38ns 5.14ns 0.0139 0 0 1.02 KB
#6677 ExecuteNonQuery net472 2.07μs 2.57ns 9.94ns 0.156 0.00103 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.26μs 0.7ns 2.62ns 0.0139 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.55μs 3.3ns 12.3ns 0.0131 0 0 976 B
master CallElasticsearch net472 2.47μs 0.758ns 2.73ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.24μs 1.08ns 4.18ns 0.0131 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 1.06ns 3.95ns 0.0131 0 0 1.02 KB
master CallElasticsearchAsync net472 2.64μs 1ns 3.62ns 0.166 0 0 1.05 KB
#6677 CallElasticsearch net6.0 1.23μs 0.992ns 3.58ns 0.0135 0 0 976 B
#6677 CallElasticsearch netcoreapp3.1 1.5μs 0.909ns 3.15ns 0.0135 0 0 976 B
#6677 CallElasticsearch net472 2.59μs 2.38ns 9.2ns 0.158 0 0 995 B
#6677 CallElasticsearchAsync net6.0 1.34μs 0.64ns 2.4ns 0.0134 0 0 952 B
#6677 CallElasticsearchAsync netcoreapp3.1 1.72μs 0.692ns 2.59ns 0.0137 0 0 1.02 KB
#6677 CallElasticsearchAsync net472 2.56μs 2.31ns 8.95ns 0.166 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.34μs 1.58ns 5.9ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.69μs 1.57ns 6.08ns 0.0128 0 0 952 B
master ExecuteAsync net472 1.85μs 0.672ns 2.6ns 0.145 0 0 915 B
#6677 ExecuteAsync net6.0 1.28μs 0.534ns 2.07ns 0.0135 0 0 952 B
#6677 ExecuteAsync netcoreapp3.1 1.65μs 0.628ns 2.17ns 0.0133 0 0 952 B
#6677 ExecuteAsync net472 1.85μs 0.403ns 1.56ns 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.36μs 1.04ns 3.75ns 0.0325 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.22μs 2.2ns 7.94ns 0.0393 0 0 2.85 KB
master SendAsync net472 7.45μs 2.36ns 9.15ns 0.492 0 0 3.12 KB
#6677 SendAsync net6.0 4.34μs 1.75ns 6.78ns 0.0324 0 0 2.31 KB
#6677 SendAsync netcoreapp3.1 5.31μs 1.25ns 4.67ns 0.037 0 0 2.85 KB
#6677 SendAsync net472 7.47μs 2.54ns 9.52ns 0.496 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.781ns 3.03ns 0.0234 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.14μs 5.9ns 22.9ns 0.0223 0 0 1.64 KB
master EnrichedLog net472 2.63μs 2.01ns 7.8ns 0.25 0 0 1.57 KB
#6677 EnrichedLog net6.0 1.52μs 0.996ns 3.86ns 0.0228 0 0 1.64 KB
#6677 EnrichedLog netcoreapp3.1 2.19μs 1.04ns 3.87ns 0.0219 0 0 1.64 KB
#6677 EnrichedLog net472 2.65μs 0.92ns 3.56ns 0.25 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 114μs 158ns 612ns 0.0563 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 118μs 179ns 692ns 0 0 0 4.28 KB
master EnrichedLog net472 149μs 211ns 817ns 0.668 0.223 0 4.46 KB
#6677 EnrichedLog net6.0 114μs 147ns 568ns 0.0564 0 0 4.28 KB
#6677 EnrichedLog netcoreapp3.1 120μs 172ns 642ns 0 0 0 4.28 KB
#6677 EnrichedLog net472 151μs 143ns 515ns 0.675 0.225 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 2.9μs 0.691ns 2.59ns 0.0318 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.16μs 3.18ns 11.5ns 0.029 0 0 2.2 KB
master EnrichedLog net472 5.01μs 1.69ns 6.54ns 0.32 0 0 2.02 KB
#6677 EnrichedLog net6.0 3.09μs 0.857ns 3.21ns 0.031 0 0 2.2 KB
#6677 EnrichedLog netcoreapp3.1 4.09μs 0.582ns 2.25ns 0.0307 0 0 2.2 KB
#6677 EnrichedLog net472 4.94μs 1.21ns 4.52ns 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.36μs 0.605ns 2.34ns 0.0156 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.74μs 0.624ns 2.41ns 0.0155 0 0 1.14 KB
master SendReceive net472 2.11μs 1.34ns 5.2ns 0.183 0 0 1.16 KB
#6677 SendReceive net6.0 1.38μs 0.433ns 1.68ns 0.0158 0 0 1.14 KB
#6677 SendReceive netcoreapp3.1 1.74μs 1.06ns 4.11ns 0.0156 0 0 1.14 KB
#6677 SendReceive net472 2.13μs 1.04ns 4.02ns 0.183 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.74μs 0.565ns 2.19ns 0.022 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.9μs 2.99ns 11.6ns 0.0216 0 0 1.65 KB
master EnrichedLog net472 4.46μs 2.17ns 8.11ns 0.324 0 0 2.04 KB
#6677 EnrichedLog net6.0 2.79μs 1.04ns 4.04ns 0.0224 0 0 1.6 KB
#6677 EnrichedLog netcoreapp3.1 3.97μs 2.48ns 9.59ns 0.0219 0 0 1.65 KB
#6677 EnrichedLog net472 4.43μs 3.78ns 14.6ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 392ns 0.434ns 1.68ns 0.00798 0 0 576 B
master StartFinishSpan netcoreapp3.1 606ns 1.38ns 5.36ns 0.0079 0 0 576 B
master StartFinishSpan net472 589ns 0.892ns 3.46ns 0.0916 0 0 578 B
master StartFinishScope net6.0 481ns 0.798ns 3.09ns 0.00986 0 0 696 B
master StartFinishScope netcoreapp3.1 725ns 1.74ns 6.72ns 0.00921 0 0 696 B
master StartFinishScope net472 842ns 1.98ns 7.67ns 0.104 0 0 658 B
#6677 StartFinishSpan net6.0 404ns 0.721ns 2.79ns 0.00812 0 0 576 B
#6677 StartFinishSpan netcoreapp3.1 619ns 0.387ns 1.5ns 0.00778 0 0 576 B
#6677 StartFinishSpan net472 645ns 0.247ns 0.956ns 0.0917 0 0 578 B
#6677 StartFinishScope net6.0 481ns 0.112ns 0.435ns 0.00977 0 0 696 B
#6677 StartFinishScope netcoreapp3.1 748ns 0.869ns 3.36ns 0.00931 0 0 696 B
#6677 StartFinishScope net472 824ns 0.155ns 0.56ns 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 615ns 1.18ns 4.58ns 0.00981 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 922ns 1.49ns 5.78ns 0.00937 0 0 696 B
master RunOnMethodBegin net472 1.06μs 2.1ns 8.12ns 0.104 0 0 658 B
#6677 RunOnMethodBegin net6.0 667ns 0.348ns 1.35ns 0.00963 0 0 696 B
#6677 RunOnMethodBegin netcoreapp3.1 1μs 0.515ns 1.93ns 0.00944 0 0 696 B
#6677 RunOnMethodBegin net472 1.02μs 0.335ns 1.3ns 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 2 times, most recently from 6b51050 to f488df3 Compare February 21, 2025 14:36
@kevingosse kevingosse force-pushed the kevin/wer_single_file branch from f488df3 to a48a732 Compare March 4, 2025 09:59
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Mar 4, 2025

Datadog Report

All test runs 118aaff 🔗

2 Total Test Services: 0 Failed, 2 Passed

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Test Service View
dd-trace-dotnet 0 0 0 247759 2899 21h 18m 41.46s Link
exploration_tests 0 0 0 22085 3 2m 9.03s Link

@kevingosse kevingosse merged commit fe97103 into master Mar 5, 2025
149 of 154 checks passed
@kevingosse kevingosse deleted the kevin/wer_single_file branch March 5, 2025 14:52
@github-actions github-actions bot added this to the vNext-v3 milestone Mar 5, 2025
ddyurchenko pushed a commit that referenced this pull request Mar 31, 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]>
ddyurchenko pushed a commit that referenced this pull request Mar 31, 2025
## 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.

---------

Co-authored-by: Andrew Lock <[email protected]>
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