Skip to content

feat: Extend outbox processor with operational metrics (pulse.outbox.*)#155

Merged
samtrion merged 1 commit intomainfrom
copilot/extend-outbox-processor-metrics
Mar 28, 2026
Merged

feat: Extend outbox processor with operational metrics (pulse.outbox.*)#155
samtrion merged 1 commit intomainfrom
copilot/extend-outbox-processor-metrics

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

The outbox processor emitted no metrics, creating a blind spot for teams monitoring message delivery health in production.

New Metrics

Five instruments registered on the existing "NetEvolve.Pulse" meter:

Instrument Type Unit Description
pulse.outbox.pending ObservableGauge<long> messages Live pending count, sourced from IOutboxRepository
pulse.outbox.processed.total Counter<long> messages Cumulative successfully processed
pulse.outbox.failed.total Counter<long> messages Cumulative failed attempts
pulse.outbox.deadletter.total Counter<long> messages Cumulative dead-lettered
pulse.outbox.processing.duration Histogram<double> ms Elapsed time per polling cycle

Implementation

  • IOutboxRepository — new default method GetPendingCountAsync() returning 0L; backward-compatible, no existing implementations need changes.
  • OutboxProcessorHostedService — counters/histogram are static fields; the observable gauge is registered per-instance in the constructor, its callback reading a _pendingCount field updated via RefreshPendingCountAsync at the start of each cycle. All metric calls are wrapped in try/catch and log at Warning on failure — metric errors never interrupt message processing.
  • Both individual (ProcessMessageAsync) and batch (ProcessBatchSendAsync) processing paths increment the appropriate counters.
// Pending count refreshed before each poll cycle, observed by the gauge callback
await RefreshPendingCountAsync(stoppingToken).ConfigureAwait(false);

var batchStartTime = Stopwatch.GetTimestamp();
var processedCount = await ProcessBatchAsync(stoppingToken).ConfigureAwait(false);
ProcessingDurationHistogram.Record(Stopwatch.GetElapsedTime(batchStartTime).TotalMilliseconds);

Tests

  • 5 unit tests (one per instrument) using MeterListener to verify measurements are recorded.
  • 2 integration tests verifying non-zero metrics after a full processing cycle.
  • Test doubles updated to implement GetPendingCountAsync.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI linked an issue Mar 28, 2026 that may be closed by this pull request
9 tasks
Copilot AI changed the title [WIP] Add operational metrics for outbox processor feat: Extend outbox processor with operational metrics (pulse.outbox.*) Mar 28, 2026
Copilot AI requested a review from samtrion March 28, 2026 01:34
@samtrion samtrion force-pushed the copilot/extend-outbox-processor-metrics branch from bcb0f84 to 703d26f Compare March 28, 2026 08:27
@samtrion samtrion force-pushed the copilot/extend-outbox-processor-metrics branch from 703d26f to 48107c9 Compare March 28, 2026 08:27
@samtrion samtrion marked this pull request as ready for review March 28, 2026 08:28
@samtrion samtrion requested a review from a team as a code owner March 28, 2026 08:28
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.12%. Comparing base (19680ce) to head (48107c9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...volve.Pulse/Outbox/OutboxProcessorHostedService.cs 67.60% 23 Missing ⚠️
...NetEvolve.Pulse.Extensibility/IOutboxRepository.cs 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (66.66%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
- Coverage   86.12%   85.12%   -1.01%     
==========================================
  Files          42       42              
  Lines        1312     1385      +73     
  Branches      123      125       +2     
==========================================
+ Hits         1130     1179      +49     
- Misses        145      169      +24     
  Partials       37       37              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtrion samtrion merged commit 8ef9dbe into main Mar 28, 2026
11 of 12 checks passed
@samtrion samtrion deleted the copilot/extend-outbox-processor-metrics branch March 28, 2026 08:51
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.

feat: Extend outbox processor with operational metrics (pulse.outbox.*)

2 participants