chore: Improve incoming webhook logging & add middleware#37948
chore: Improve incoming webhook logging & add middleware#37948kodiakhq[bot] merged 6 commits intodevelopfrom
Conversation
|
WalkthroughAdds middleware (logger, metrics, tracer) to the integrations WebHook API router, exports a shared Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant WebHookAPI
participant LoggerMiddleware as Logger/Tracer/Metrics
participant executeIntegrationRest as Executor
participant incomingLogger
Client->>WebHookAPI: POST /hooks/...
WebHookAPI->>LoggerMiddleware: apply logger/metrics/tracer
LoggerMiddleware-->>WebHookAPI: enriched request (trace/metrics/log context)
WebHookAPI->>executeIntegrationRest: process webhook
activate executeIntegrationRest
alt success
executeIntegrationRest-->>WebHookAPI: 200 OK
LoggerMiddleware-->>Client: 200 OK (metrics recorded)
else error
executeIntegrationRest->>incomingLogger: log error (err)
incomingLogger-->>WebHookAPI: logged error details
executeIntegrationRest-->>WebHookAPI: failure(payload: err or message)
LoggerMiddleware-->>Client: error response (metrics/tracing recorded)
end
deactivate executeIntegrationRest
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #37948 +/- ##
===========================================
+ Coverage 70.63% 70.67% +0.04%
===========================================
Files 3145 3145
Lines 108772 108772
Branches 19570 19570
===========================================
+ Hits 76826 76871 +45
+ Misses 29943 29896 -47
- Partials 2003 2005 +2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/meteor/app/integrations/server/api/api.ts (1)
386-389: Remove redundant RegExp constructor.The middleware application correctly enables observability for webhook routes. However,
new RegExp(/^\/hooks\//)is redundant since/^\/hooks\//is already a RegExp literal.🔎 Simplify RegExp usage
Api.router .use(loggerMiddleware(integrationLogger)) - .use(metricsMiddleware({ basePathRegex: new RegExp(/^\/hooks\//), api: Api, settings, summary: metrics.rocketchatRestApi })) + .use(metricsMiddleware({ basePathRegex: /^\/hooks\//, api: Api, settings, summary: metrics.rocketchatRestApi })) .use(tracerSpanMiddleware);
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/meteor/app/integrations/server/api/api.tsapps/meteor/app/integrations/server/logger.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/app/integrations/server/api/api.tsapps/meteor/app/integrations/server/logger.ts
🧬 Code graph analysis (1)
apps/meteor/app/integrations/server/api/api.ts (2)
apps/meteor/app/integrations/server/logger.ts (2)
incomingLogger(5-5)integrationLogger(3-3)apps/meteor/app/metrics/server/lib/metrics.ts (1)
metrics(5-249)
🔇 Additional comments (4)
apps/meteor/app/integrations/server/logger.ts (1)
3-6: LGTM! Clean logger hierarchy.The logger structure is well-organized with a base
integrationLoggerand appropriate sections for incoming and outgoing webhooks. This enables better log filtering and contextual logging.apps/meteor/app/integrations/server/api/api.ts (3)
17-19: LGTM! Middleware imports for observability.The imported middleware will enhance observability for webhook requests with logging, metrics, and tracing capabilities.
22-22: LGTM! Metrics import for Prometheus.The metrics import enables Prometheus metric collection for webhook API calls.
25-25: LGTM! Updated import aligns with logger hierarchy.The import now includes
integrationLoggerto support the middleware configuration, aligning with the refactored logger structure.
|
Looks like this PR is ready to merge! 🎉 |
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/meteor/app/integrations/server/api/api.ts">
<violation number="1" location="apps/meteor/app/integrations/server/api/api.ts:256">
P2: Accessing `err.error` or `err.message` without null-safety could throw if `err` is null/undefined. Consider using optional chaining with a fallback to handle edge cases where non-Error values are thrown.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Proposed changes (including videos or screenshots)
https://rocketchat.atlassian.net/browse/CORE-1716
Issue(s)
Steps to test or reproduce
Further comments
/hooksapi (the one incoming integrations use)/hooksapiCurrently we're on the blind side when these calls fail, after this, we'll be a little bit less blind
Summary by CodeRabbit
New Features
Improvements
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.