Skip to content

Commit dd79564

Browse files
committed
warn against consecutive super
1 parent 582ff70 commit dd79564

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Monitoring-and-Logging.md

+4
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ end
542542

543543
Such a custom monitor will intercept specific events while delegating to the parent monitor to maintain framework functionality. This pattern enables proper error handling, cleanup, and integration with external monitoring systems that require execution to be wrapped in a block.
544544

545+
!!! Warning "Avoid Calling super Multiple Times in Custom Monitors"
546+
547+
When overriding Karafka’s instrumentation monitor (`Karafka::Instrumentation::Monitor`), it's crucial **not** to invoke `super` more than once within the `instrument` method. Calling `super` multiple times will cause the original wrapped block of code to execute repeatedly. This can lead to severe and unintended side-effects, such as duplicated message processing, incorrect consumption behaviors, and unexpected logic execution. Always ensure your custom monitor calls `super` exactly once per event, guarding against unintended duplicate invocations.
548+
545549
## Implications of Broken Instrumentation listeners/listeners Causing Errors
546550

547551
Instrumentation and monitoring listeners are essential components in Karafka-based applications as they provide insight into the app's performance and behavior. They are critical in collecting metrics, measuring response times, and tracking other performance data. When functioning correctly, they enable efficient identification of issues and performance optimization. However, their malfunctioning could lead to several challenges and problems.

0 commit comments

Comments
 (0)