Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Telemetry refactoring#2985

Merged
martincostello merged 3 commits into
mainfrom
refactor-metrics
Mar 14, 2026
Merged

Telemetry refactoring#2985
martincostello merged 3 commits into
mainfrom
refactor-metrics

Conversation

@martincostello

Copy link
Copy Markdown
Member

Cherry-pick changes from #2936:

  • Move Meter to TelemetrySource class.
  • Use Polly's actual version for the meter's version.
  • Extend some test coverage.
  • Apply some minor code style refactoring.

Cherry-pick changes from #2936:

- Move `Meter` to `TelemetrySource` class.
- Use Polly's actual version for the meter's version.
- Extend some test coverage.
- Apply some minor code style refactoring.
Copilot AI review requested due to automatic review settings March 14, 2026 15:53

Copilot AI 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.

Pull request overview

Introduces a shared telemetry Meter source in Polly.Extensions so telemetry components use a consistent meter name/version derived from the assembly, and adjusts related tests and small builder refactors.

Changes:

  • Added TelemetrySource singleton to centralize meter creation/versioning, and updated TelemetryListenerImpl to use it.
  • Updated/added tests to validate the new meter behavior and adjusted existing telemetry/builder tests accordingly.
  • Minor refactors: reuse ResilienceStrategyTelemetry instance during pipeline build and modernize RegistryPipelineComponentBuilder via a primary constructor.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/Polly.Extensions.Tests/Telemetry/TelemetrySourceTests.cs Adds coverage for the new TelemetrySource meter name/version.
test/Polly.Extensions.Tests/Telemetry/TelemetryListenerImplTests.cs Updates tests to align with meter version now coming from assembly metadata.
test/Polly.Core.Tests/Telemetry/ResilienceStrategyTelemetryTests.cs Adds a constructor sanity test and minor cleanup (method group).
test/Polly.Core.Tests/StrategyBuilderContextTests.cs Makes the test class/method static and improves telemetry assertions formatting.
test/Polly.Core.Tests/ResiliencePipelineBuilderTests.cs Adds a “copy-ctor reminder” reflection-based guard test.
src/Polly.Extensions/Telemetry/TelemetrySource.cs New internal telemetry source providing the shared Meter and version parsing.
src/Polly.Extensions/Telemetry/TelemetryListenerImpl.cs Switches telemetry meter creation to use TelemetrySource.Instance.Meter.
src/Polly.Core/ResiliencePipelineBuilderBase.cs Reuses a local ResilienceStrategyTelemetry instance during pipeline component building.
src/Polly.Core/Registry/RegistryPipelineComponentBuilder.cs Refactors to a primary constructor and field initializers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Polly.Extensions/Telemetry/TelemetrySource.cs
Comment thread src/Polly.Extensions/Telemetry/TelemetrySource.cs
Comment thread test/Polly.Extensions.Tests/Telemetry/TelemetrySourceTests.cs Outdated
Comment thread test/Polly.Extensions.Tests/Telemetry/TelemetrySourceTests.cs Outdated
Fix incorrect test name.

Co-authored-by: Martin Costello <[email protected]>
@martincostello martincostello enabled auto-merge (squash) March 14, 2026 16:02
Extend assertions on the version string.
@martincostello martincostello merged commit b87f203 into main Mar 14, 2026
26 checks passed
@martincostello martincostello deleted the refactor-metrics branch March 14, 2026 16:26
martincostello added a commit that referenced this pull request Mar 14, 2026
Remove unused constant as of #2985.
martincostello added a commit that referenced this pull request Mar 14, 2026
Remove unused constant as of #2985.
@codecov

codecov Bot commented Mar 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.15%. Comparing base (af7e8b1) to head (517ce13).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2985   +/-   ##
=======================================
  Coverage   96.15%   96.15%           
=======================================
  Files         309      310    +1     
  Lines        7128     7135    +7     
  Branches     1005     1005           
=======================================
+ Hits         6854     6861    +7     
  Misses        221      221           
  Partials       53       53           
Flag Coverage Δ
linux 96.15% <100.00%> (+<0.01%) ⬆️
macos 96.15% <100.00%> (+<0.01%) ⬆️
windows 96.15% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This was referenced Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants