[Issue #22] Add EventBroadcaster metrics #49
Reference in New Issue
Block a user
Delete Branch "issue-22-eventbroadcaster-metrics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add comprehensive metrics tracking for EventBroadcaster implementations to enable observability and debugging of event publishing and subscription across namespaces.
Changes
BroadcasterMetricsinterface for reading metrics per namespaceMetricsCollectorinterface andDefaultMetricsCollectorimplementation with thread-safe countersevents_publishedandevents_receivedcounters per namespaceactive_subscriptionsgauge per namespacepublish_errors,subscribe_errors, anddropped_eventscountersMetricsProviderinterface for EventBroadcaster implementations to expose metricsEventBusandNATSEventBusPrometheusMetricsAdapterthat implementsprometheus.CollectorUsage Example
Closes #22
71c6011f49todae751a6efRebased on main and fixed the implementation to work with the wildcard subscription support. The metrics are now integrated with both exact and wildcard subscriptions. All tests pass.
AI Code Review
Summary
This PR adds comprehensive metrics tracking for EventBroadcaster implementations. The implementation is well-structured with clean interfaces and thread-safe operations using atomics. However, there are several issues ranging from logic bugs to missing test coverage.
Findings
Code Quality
Potential Bugs
Security Concerns
Style Notes
Test Coverage
Recommendations
Verdict
Needs Changes
The PR has good structure and comprehensive metrics coverage, but contains logic bugs that will result in incorrect metric values, particularly around EventsReceived counting. These issues should be addressed before merge.