feat: add wire tap pattern support#279
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 2m 44s ⏱️ Results for commit d124b58. |
Code Coverage |
There was a problem hiding this comment.
Pull request overview
Adds first-class Wire Tap support to PatternKit’s messaging/routing surface area, including a runtime fluent API, a Roslyn incremental source generator path, and a DI-importable “production-shaped” observability example with accompanying docs and catalog/test coverage.
Changes:
- Introduces
WireTap<TPayload>+WireTapResult<TPayload>runtime API for side-channel observation while preserving the original message. - Adds
[GenerateWireTap]/[WireTapHandler]abstractions andWireTapGeneratorwith diagnostics + generator tests. - Adds Order Wire Tap example (runtime + generated paths), DI registration, docs, and catalog/coverage updates.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Messaging/Routing/WireTapTests.cs | Adds TinyBDD coverage for the runtime fluent WireTap<TPayload> API. |
| test/PatternKit.Generators.Tests/WireTapGeneratorTests.cs | Adds generator tests for codegen + diagnostics IDs PKWT001–PKWT004. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Ensures new wire tap attributes are included in attribute coverage tests. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates enterprise integration pattern list/count to include Wire Tap. |
| test/PatternKit.Examples.Tests/Messaging/OrderWireTapExampleTests.cs | Adds example coverage for fluent, generated, and DI-import paths. |
| test/PatternKit.Examples.Tests/DependencyInjection/PatternKitExampleDependencyInjectionTests.cs | Verifies aggregate DI import includes the wire tap example service. |
| src/PatternKit.Generators/Messaging/WireTapGenerator.cs | Implements the incremental source generator + diagnostics for wire tap factories. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Documents new analyzer IDs PKWT001–PKWT004. |
| src/PatternKit.Generators.Abstractions/Messaging/WireTapAttributes.cs | Adds [GenerateWireTap] and [WireTapHandler] attribute definitions. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Registers Wire Tap in the pattern catalog with docs/source/tests/example links. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Registers “Order Wire Tap” in the example catalog. |
| src/PatternKit.Examples/Messaging/OrderWireTapExample.cs | Adds the observability example (sinks, fluent builder, generated handlers, DI helpers). |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the example into AddPatternKitExamples() and adds a service descriptor record. |
| src/PatternKit.Core/Messaging/Routing/WireTap.cs | Adds the core WireTap<TPayload> pattern implementation and result type. |
| docs/patterns/toc.yml | Adds Wire Tap to patterns TOC. |
| docs/patterns/messaging/wire-tap.md | Adds runtime wire tap pattern documentation. |
| docs/guides/pattern-coverage.md | Adds Wire Tap to the pattern coverage matrix. |
| docs/generators/wire-tap.md | Documents the wire tap generator usage and constraints. |
| docs/generators/toc.yml | Adds Wire Tap to generators TOC. |
| docs/generators/index.md | Adds Wire Tap entry to generators index table. |
| docs/examples/toc.yml | Adds Order Wire Tap to examples TOC. |
| docs/examples/order-wire-tap.md | Adds Order Wire Tap example documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private readonly List<string> _entries = []; | ||
|
|
||
| public IReadOnlyList<string> Entries => _entries; | ||
|
|
||
| public void Record(OrderWireTapEvent evt, MessageContext context) | ||
| => _entries.Add($"{context.Headers.CorrelationId ?? "uncorrelated"}:{evt.TenantId}:{evt.OrderId}"); | ||
| } |
| private readonly List<string> _measurements = []; | ||
|
|
||
| public IReadOnlyList<string> Measurements => _measurements; | ||
|
|
||
| public void Record(OrderWireTapEvent evt) | ||
| => _measurements.Add($"{evt.TenantId}:{evt.Total:0.00}"); | ||
| } |
| public static class OrderWireTapSinkRegistry | ||
| { | ||
| public static OrderWireTapAuditSink Audit { get; set; } = new(); | ||
|
|
||
| public static OrderWireTapMetricsSink Metrics { get; set; } = new(); | ||
| } |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #279 +/- ##
==========================================
+ Coverage 90.42% 96.00% +5.57%
==========================================
Files 376 380 +4
Lines 33087 33338 +251
Branches 4638 4673 +35
==========================================
+ Hits 29919 32006 +2087
+ Misses 1436 1332 -104
+ Partials 1732 0 -1732
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #276
Adds the Wire Tap enterprise integration pattern with: