[Serverless] Cache serverless platform detection results#8231
Conversation
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8231) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-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 highlighted in **red**. The following thresholds were used for comparing the execution times:
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). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (72ms) : 70, 75
master - mean (72ms) : 68, 76
section Bailout
This PR (8231) - mean (76ms) : 75, 78
master - mean (76ms) : 74, 78
section CallTarget+Inlining+NGEN
This PR (8231) - mean (1,079ms) : 1031, 1127
master - mean (1,077ms) : 1036, 1118
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (113ms) : 108, 117
master - mean (113ms) : 109, 116
section Bailout
This PR (8231) - mean (114ms) : 110, 117
master - mean (113ms) : 110, 117
section CallTarget+Inlining+NGEN
This PR (8231) - mean (794ms) : 780, 809
master - mean (794ms) : 773, 815
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (99ms) : 96, 102
master - mean (100ms) : 97, 103
section Bailout
This PR (8231) - mean (101ms) : 98, 104
master - mean (100ms) : 97, 103
section CallTarget+Inlining+NGEN
This PR (8231) - mean (948ms) : 910, 986
master - mean (948ms) : 912, 984
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (99ms) : 95, 102
master - mean (98ms) : 95, 101
section Bailout
This PR (8231) - mean (100ms) : 98, 102
master - mean (100ms) : 97, 102
section CallTarget+Inlining+NGEN
This PR (8231) - mean (833ms) : 800, 867
master - mean (834ms) : 796, 871
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (217ms) : 207, 228
master - mean (226ms) : 210, 241
section Bailout
This PR (8231) - mean (219ms) : 208, 230
master - mean (230ms) : 215, 245
section CallTarget+Inlining+NGEN
This PR (8231) - mean (1,256ms) : 1206, 1306
master - mean (1,257ms) : 1210, 1305
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (319ms) : 298, 339
master - mean (321ms) : 300, 342
section Bailout
This PR (8231) - mean (316ms) : 299, 333
master - mean (324ms) : 303, 345
section CallTarget+Inlining+NGEN
This PR (8231) - mean (1,027ms) : 1000, 1055
master - mean (1,030ms) : 1000, 1060
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (310ms) : 291, 329
master - mean (306ms) : 292, 321
section Bailout
This PR (8231) - mean (312ms) : 288, 335
master - mean (306ms) : 296, 316
section CallTarget+Inlining+NGEN
This PR (8231) - mean (1,213ms) : 1149, 1276
master - mean (1,206ms) : 1155, 1257
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8231) - mean (309ms) : 293, 325
master - mean (311ms) : 292, 329
section Bailout
This PR (8231) - mean (308ms) : 295, 322
master - mean (308ms) : 295, 321
section CallTarget+Inlining+NGEN
This PR (8231) - mean (1,185ms) : 1085, 1284
master - mean (1,169ms) : 1076, 1261
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BenchmarksBenchmark execution time: 2026-03-27 17:12:25 Comparing candidate commit b3347ce in PR branch Found 5 performance improvements and 6 performance regressions! Performance is the same for 264 metrics, 13 unstable metrics.
|
49ea851 to
f0dfbe2
Compare
|
@codex review |
d5415d7 to
989bf74
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5415d7f3d
ℹ️ 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
- 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 address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
989bf74 to
1222ea7
Compare
andrewlock
left a comment
There was a problem hiding this comment.
Nice 👍
Just to be sure, these env vars won't ever be changed in-process, right? I can't see that we would ever set them ourselves, so I think so.
Good call just doing this for the serverless stuff, definitely the safer option.
3d71773 to
e277348
Compare
832e846 to
fe91f7f
Compare
Create AzurePlatformDetection, AwsPlatformDetection, and GcpPlatformDetection under Datadog.Trace.Serverless namespace. Each caches detection results in static fields to avoid repeated env-var reads. Promote EnvironmentVariableExists to internal visibility for use by the new classes. 🤖 Co-Authored-By: Claude Code <[email protected]>
Replace EnvironmentHelpers.IsXxx() calls with the corresponding properties on AzurePlatformDetection, AwsPlatformDetection, and GcpPlatformDetection. Update tests to assert on the new types. 🤖 Co-Authored-By: Claude Code <[email protected]>
All callers now use AzurePlatformDetection, AwsPlatformDetection, and GcpPlatformDetection directly. EnvironmentVariableExists remains as internal for use by the new detection classes. 🤖 Co-Authored-By: Claude Code <[email protected]>
🤖 Co-Authored-By: Claude Code <[email protected]>
🤖 Co-Authored-By: Claude Code <[email protected]>
🤖 Co-Authored-By: Claude Code <[email protected]>
🤖 Co-Authored-By: Claude Code <[email protected]>
The tests set environment variables after construction, but AwsPlatformDetection and AzurePlatformDetection cache their results. Reset the caches before each test so env vars are read fresh. 🤖 Co-Authored-By: Claude Code <[email protected]>
🤖 Co-Authored-By: Claude Code <[email protected]>
Replace static AwsPlatformDetection, AzurePlatformDetection, and GcpPlatformDetection with non-static Aws, Azure, and Gcp classes. Each has a Default singleton for production and supports new instances for test isolation, removing the need for Reset() methods and EnvironmentRestorer workarounds. 🤖 Co-Authored-By: Claude Code <[email protected]>
🤖 Co-Authored-By: Claude Code <[email protected]>
fe91f7f to
b3347ce
Compare
Master #8231 extracted serverless platform detection from EnvironmentHelpers into dedicated cached classes under Datadog.Trace.Serverless. Update the Azure-Functions pipe-name generation gate to call AzureInfo.Instance.IsAzureFunction and IsUsingSiteExtension instead of the removed EnvironmentHelpers methods. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Master #8231 extracted serverless platform detection from EnvironmentHelpers into dedicated cached classes under Datadog.Trace.Serverless. Update the Azure-Functions pipe-name generation gate to call AzureInfo.Instance.IsAzureFunction and IsUsingSiteExtension instead of the removed EnvironmentHelpers methods. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Master #8231 extracted serverless platform detection from EnvironmentHelpers into dedicated cached classes under Datadog.Trace.Serverless. Update the Azure-Functions pipe-name generation gate to call AzureInfo.Instance.IsAzureFunction and IsUsingSiteExtension instead of the removed EnvironmentHelpers methods. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Master #8231 extracted serverless platform detection from EnvironmentHelpers into dedicated cached classes under Datadog.Trace.Serverless. Update the Azure-Functions pipe-name generation gate to call AzureInfo.Instance.IsAzureFunction and IsUsingSiteExtension instead of the removed EnvironmentHelpers methods. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Master #8231 extracted serverless platform detection from EnvironmentHelpers into dedicated cached classes under Datadog.Trace.Serverless. Update the Azure-Functions pipe-name generation gate to call AzureInfo.Instance.IsAzureFunction and IsUsingSiteExtension instead of the removed EnvironmentHelpers methods. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary of changes
Extract serverless platform detection logic from
EnvironmentHelpersinto dedicated cached detection classes underDatadog.Trace.Serverless:AzureInfo— Azure App Services, Azure Functions (including isolated host/worker detection)AwsInfo— AWS LambdaGcpInfo— Google Cloud FunctionsEach class caches environment variable lookups in instance fields to avoid repeated reads (which incur heap allocations) on hot paths. An
Instancesingleton is used in production; tests create fresh instances for isolation.Reason for change
Platform detection methods (e.g.,
IsAzureAppService(),IsAwsLambda()) were called repeatedly from hot paths like span creation and peer service derivation. Each call re-read environment variables, adding unnecessary overhead. Caching the results eliminates redundant lookups.This change also moves serverless-specific code out of
EnvironmentHelpersand into theDatadog.Trace.Serverlessnamespace.Implementation details
AzureInfo,AwsInfo, andGcpInfoclasses underDatadog.Trace.Serverlessnamespaceboolproperties (e.g.,AzureInfo.Instance.IsAzureAppService,AwsInfo.Instance.IsAwsLambda,GcpInfo.Instance.IsCloudFunction)AzureInfoalso cachesAzureFunctionsWorkerRuntime,AzureFunctionsExtensionVersion, and derived properties likeIsIsolatedFunction,IsIsolatedFunctionHostProcess, andIsIsolatedFunctionWorkerProcessInstancesingleton enables test isolation withoutReset()methodsboolvalues from the detection classes rather than taking a dependency on the platform objects themselves (e.g.,ProfilerAvailabilityHelper)EnvironmentHelpers.EnvironmentVariableExiststointernalvisibility for use by the new classesEnvironmentHelpers.IsXxx()methodsEnvironmentHelpersTest coverage
AwsInfoTests,AzureInfoTests, andGcpInfoTestsunderServerless/ProfilerAvailabilityHelperTeststo pass platform detection bools explicitlyEnvironmentHelpersTeststhat tested the now-removed methodsOther details
n/a