feat(adapter): log time taken by controller to process webhook events - #2960
feat(adapter): log time taken by controller to process webhook events#2960zakisk wants to merge 1 commit into
Conversation
Paco Review
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2960 +/- ##
==========================================
- Coverage 85.56% 85.56% -0.01%
==========================================
Files 164 164
Lines 12475 12494 +19
==========================================
+ Hits 10674 10690 +16
- Misses 1800 1803 +3
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f872888 to
610b13c
Compare
chmouel
left a comment
There was a problem hiding this comment.
Thanks for the update — the flaky test assertion (comment 1) is fixed 👍
However the nil-logger panic (comment 2) is still present. The logger variable initialized at the top of handleEvent gets overwritten on lines 248/250:
gitProvider, logger, err = l.processIncoming(event, targettedRepo)
// or
gitProvider, logger, err = l.detectProvider(request, string(payload))Both can return (nil, nil, err), which sets logger = nil. Then line 256 does logger.Infof(...) unconditionally → nil dereference panic.
Suggestion: introduce a separate variable for the event-scoped logger (e.g. eventLogger) at the top, and use a single defer for the timing log:
eventLogger := l.logger.With("event-id", eventID)
start := time.Now().UnixMilli()
defer func() {
eventLogger.Infof("controller responded to event %s in %dms", eventID, time.Now().UnixMilli()-start)
}()This way:
- The timing log is immune to
loggerbeing reassigned to nil byprocessIncoming/detectProvider - You don't need to copy-paste the timing log at every return point (currently 8 times)
theakshaypant
left a comment
There was a problem hiding this comment.
Agree with Chmouel's comment, defer seems like a better option to calculate/log total time taken to process the event.
610b13c to
d0ccf1b
Compare
Log the duration from when a webhook request is received until the controller responds, and separately the async event processing time. The event ID is extracted from provider-specific headers (GitHub, GitLab, Gitea, Bitbucket Cloud/DC) for log correlation. https://redhat.atlassian.net/browse/SRVKP-14040 Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
d0ccf1b to
9fb1886
Compare
📝 Description of the Change
Log the duration from when a webhook request is received until the controller responds, and separately the async event processing time. The event ID is extracted from provider-specific headers (GitHub, GitLab, Gitea, Bitbucket Cloud/DC) for log correlation.
🔗 Linked GitHub Issue
Fixes #
https://redhat.atlassian.net/browse/SRVKP-14040
🧪 Testing Strategy
🤖 AI Assistance
AI assistance can be used for various tasks, such as code generation,
documentation, or testing.
Please indicate whether you have used AI assistance
for this PR and provide details if applicable.
Important
Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Claude noreply@anthropic.com
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.