Skip to content

Add a Continuous Profiler availability check#7534

Merged
andrewlock merged 4 commits into
masterfrom
andrew/add-is-profiler-available-api
Sep 19, 2025
Merged

Add a Continuous Profiler availability check#7534
andrewlock merged 4 commits into
masterfrom
andrew/add-is-profiler-available-api

Conversation

@andrewlock

Copy link
Copy Markdown
Member

Summary of changes

Add a checker to decide whether the profiler is available

Reason for change

We are going to be (and are currently) making P/Invoke calls on startup to call the profiler. If the ClrProfiler is not attached, or the CP file is not available (and so P/Invokes are not re-written) then this can cause additional delays.

Implementation details

Add explicit checks for

  • Unsupported environments
  • Has the profiler set the "profiler available" env var (only works on Windows right now)
  • Are we in known unsupported environments (lambda and Azure functions outside of AAS extension)
  • Is the ClrProfiler attached

Test coverage

If everything still works, this should work

Other details

A blocker for #7287

@andrewlock
andrewlock requested review from a team as code owners September 18, 2025 14:57
@andrewlock andrewlock added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:profiler Issues related to the continous-profiler labels Sep 18, 2025

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerStatus.cs Outdated
@andrewlock
andrewlock force-pushed the andrew/add-is-profiler-available-api branch 2 times, most recently from 0944855 to b17361c Compare September 18, 2025 15:17

@chrisnas chrisnas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with just a log level question

Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerStatus.cs Outdated
// Now we're into fuzzy territory. The CP is not available in some environments
// - AWS Lambda
// - Azure Functions where the site extension is _not_ used
var isUnsupported = EnvironmentHelpers.IsAwsLambda()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it ok if it tries logging here? as this ends up there

otherwise there's this beautiful solution 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I originally used your solution, but I can't use IsServerless() as it excludes too much. Also, this isn't used in the critical config loading paths, so I think it's ok for us to log if we have to 🙂

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok :) also, you probably know already, FrameworkDescription has a static logger field 😅

@andrewlock
andrewlock force-pushed the andrew/add-is-profiler-available-api branch from b17361c to 6ff0c01 Compare September 18, 2025 15:26
@andrewlock
andrewlock force-pushed the andrew/add-is-profiler-available-api branch from 6ff0c01 to f717f50 Compare September 18, 2025 15:42
@datadog-official

This comment has been minimized.

@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Sep 18, 2025

Copy link
Copy Markdown

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.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (72ms)  : 71, 73
     .   : milestone, 72,
    master - mean (72ms)  : 71, 73
     .   : milestone, 72,

    section Baseline
    This PR (7534) - mean (68ms)  : 66, 70
     .   : milestone, 68,
    master - mean (68ms)  : 66, 70
     .   : milestone, 68,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (1,001ms)  : 977, 1026
     .   : milestone, 1001,
    master - mean (1,003ms)  : 980, 1026
     .   : milestone, 1003,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (106ms)  : 105, 107
     .   : milestone, 106,
    master - mean (106ms)  : 105, 107
     .   : milestone, 106,

    section Baseline
    This PR (7534) - mean (105ms)  : 103, 108
     .   : milestone, 105,
    master - mean (105ms)  : 103, 108
     .   : milestone, 105,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (707ms)  : 689, 724
     .   : milestone, 707,
    master - mean (714ms)  : 699, 729
     .   : milestone, 714,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (94ms)  : 93, 95
     .   : milestone, 94,
    master - mean (94ms)  : 93, 95
     .   : milestone, 94,

    section Baseline
    This PR (7534) - mean (93ms)  : 92, 95
     .   : milestone, 93,
    master - mean (93ms)  : 92, 95
     .   : milestone, 93,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (663ms)  : 648, 679
     .   : milestone, 663,
    master - mean (669ms)  : 656, 682
     .   : milestone, 669,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (93ms)  : 92, 94
     .   : milestone, 93,
    master - mean (93ms)  : 92, 94
     .   : milestone, 93,

    section Baseline
    This PR (7534) - mean (92ms)  : 89, 95
     .   : milestone, 92,
    master - mean (92ms)  : 90, 94
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (596ms)  : 580, 612
     .   : milestone, 596,
    master - mean (599ms)  : 586, 612
     .   : milestone, 599,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (195ms)  : 193, 198
     .   : milestone, 195,
    master - mean (195ms)  : 190, 200
     .   : milestone, 195,

    section Baseline
    This PR (7534) - mean (192ms)  : 188, 195
     .   : milestone, 192,
    master - mean (191ms)  : 186, 195
     .   : milestone, 191,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (1,110ms)  : 1085, 1135
     .   : milestone, 1110,
    master - mean (1,104ms)  : 1071, 1138
     .   : milestone, 1104,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (277ms)  : 273, 281
     .   : milestone, 277,
    master - mean (274ms)  : 269, 279
     .   : milestone, 274,

    section Baseline
    This PR (7534) - mean (275ms)  : 271, 279
     .   : milestone, 275,
    master - mean (272ms)  : 266, 279
     .   : milestone, 272,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (901ms)  : 861, 940
     .   : milestone, 901,
    master - mean (893ms)  : 865, 921
     .   : milestone, 893,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (269ms)  : 266, 272
     .   : milestone, 269,
    master - mean (266ms)  : 260, 272
     .   : milestone, 266,

    section Baseline
    This PR (7534) - mean (268ms)  : 264, 272
     .   : milestone, 268,
    master - mean (269ms)  : 263, 275
     .   : milestone, 269,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (877ms)  : 846, 908
     .   : milestone, 877,
    master - mean (877ms)  : 846, 908
     .   : milestone, 877,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7534) - mean (268ms)  : 263, 272
     .   : milestone, 268,
    master - mean (266ms)  : 260, 272
     .   : milestone, 266,

    section Baseline
    This PR (7534) - mean (268ms)  : 263, 272
     .   : milestone, 268,
    master - mean (266ms)  : 260, 272
     .   : milestone, 266,

    section CallTarget+Inlining+NGEN
    This PR (7534) - mean (789ms)  : 762, 815
     .   : milestone, 789,
    master - mean (785ms)  : 763, 807
     .   : milestone, 785,

Loading

@andrewlock
andrewlock enabled auto-merge (squash) September 19, 2025 08:34
@andrewlock
andrewlock force-pushed the andrew/add-is-profiler-available-api branch 2 times, most recently from 638001b to a7efcbb Compare September 19, 2025 10:15
@andrewlock
andrewlock force-pushed the andrew/add-is-profiler-available-api branch from a7efcbb to 1032927 Compare September 19, 2025 11:41
@andrewlock
andrewlock merged commit 6a6d4e9 into master Sep 19, 2025
155 of 158 checks passed
@andrewlock
andrewlock deleted the andrew/add-is-profiler-available-api branch September 19, 2025 13:40
@github-actions github-actions Bot added this to the vNext-v3 milestone Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:profiler Issues related to the continous-profiler area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants