Repository navigation
fix(metrics): skip ColdStart under provisioned concurrency in Metrics.AspNetCore - #1365
Merged
Merged
Conversation
…mmon types in Release
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1365 +/- ##
========================================
Coverage 80.16% 80.16%
========================================
Files 303 303
Lines 12849 12850 +1
Branches 1529 1530 +1
========================================
+ Hits 10300 10301 +1
Misses 2094 2094
Partials 455 455 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: closes #1364
Summary
Changes
Metrics.AspNetCore(UseMetrics()and.WithMetrics()) no longer emits aColdStartmetric when the execution environment was initialized for provisioned concurrency. That matches the[Metrics]attribute, which already skips it throughLambdaLifecycleTracker.IsColdStart.ColdStartTracker.TrackColdStartstill marks the cold start as consumed on the first request. It then returns without capturing when theAWS_LAMBDA_INITIALIZATION_TYPEenvironment variable isprovisioned-concurrency. It reads the variable directly instead of usingPowertoolsConfigurations: in Release, Common is compiled into each package, so the type is ambiguous when both are referenced (CS0433).LambdaLifecycleTracker.IsColdStartisn't reused, because under ASP.NET Core hosting the first read anywhere uses up the cold start (see fix(metrics): emit ColdStart once in Metrics.AspNetCore and stop mutating default dimensions #1363).docs/core/metrics.md) saying provisioned-concurrency environments aren't counted, for both the attribute and ASP.NET Core.User experience
ColdStarton the first request in every pre-initialized environment, so the metric over-reports compared with a[Metrics]handler.ColdStartfor provisioned-concurrency environments. On-demand behaviour is unchanged.Testing
New theory tests in
MetricsMiddlewareExtensionsTestsandMetricsEndpointExtensionsTests. They send two requests withAWS_LAMBDA_INITIALIZATION_TYPEset toprovisioned-concurrency(expect 0),on-demand(expect 1) and unset (expect 1), and restore the variable afterwards.provisioned-concurrencycases failed on net8.0 and net10.0 (received 1ColdStart), and the other cases passed.dotnet test libraries/tests/AWS.Lambda.Powertools.Metrics.AspNetCore.Testspasses 17/17 on net8.0 and 17/17 on net10.0.dotnet build libraries --configuration Release(the full solution, as in CI) succeeded with 0 errors, and the tests pass in both Debug and Release.Merge danger: two-way door. Blast radius:
ColdStartmetric emission inMetrics.AspNetCorefor provisioned-concurrency functions only.Checklist
Please leave checklist items unchecked if they do not apply to your change.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.