-
Notifications
You must be signed in to change notification settings - Fork 1
feat(log): Implement structured logging #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: crl-main
Are you sure you want to change the base?
Conversation
21d94d1
to
049ba9d
Compare
Pull Request Test Coverage Report for Build 14571679809Details
💛 - Coveralls |
Add structured JSON logging with request IDs, timestamps, and context across: - Logger service (standardized format, request tracking) - Request middleware (HTTP metadata, duration) - Webhook processing (timing metrics, status tracking) - Service layer (CLA, Repo, Webhook services) - Controller layer (error handling, context) Improves observability, debugging, and monitoring in Datadog while maintaining existing functionality.
049ba9d
to
55343b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall LGTM -- some questions (inline)
@@ -6,10 +6,19 @@ const logger = require('../logger') | |||
|
|||
function rateLimitLogger(octokit) { | |||
octokit.hook.after('request', async (response, options) => { | |||
logger.info(`${options.method} ${options.url}: ${response.status} || Rate Limit: ${response.headers['x-ratelimit-remaining']}/${response.headers['x-ratelimit-limit']} reset at ${new Date(Number(response.headers['x-ratelimit-reset']) * 1000).toTimeString()}`) | |||
logger.info({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice improvement!
} catch (error) { | ||
logger.warn(new Error(error).stack) | ||
logger.error({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event is WARNING
, but logger level is logger.error
-- should these match (i.e. both warning or both error)? or keep as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
changing logger.error
to logger.warn
to match previous logging level.
src/server/src/services/cla.js
Outdated
error: error, | ||
msg: 'Warning in CLA operation' | ||
}) | ||
logger.warn({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to log this twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a mistake, fixing this.
src/server/src/services/cla.js
Outdated
error: error, | ||
msg: 'Warning in CLA operation' | ||
}) | ||
logger.warn({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same: double-logging)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5f37515
to
34d84d1
Compare
34d84d1
to
0784c91
Compare
LGTM. What do you think about upstreaming this feature? If we decide yes, we should follow the guidelines: https://docs.google.com/document/d/1gnHXsXvLnynCDrDIvhJgQmPAvkdkC_A8/edit?tab=t.0 |
Add structured JSON logging with request IDs, timestamps, and context across:
//todo: Add screenshots
Improves observability, debugging, and monitoring in Datadog while maintaining existing functionality.
Part of CODESYS-80
Note: Some codes are generated by Cursor.