Skip to content

feat(log): Implement structured logging#4

Open
ibreakthecloud wants to merge 2 commits into
crl-mainfrom
logging-fix
Open

feat(log): Implement structured logging#4
ibreakthecloud wants to merge 2 commits into
crl-mainfrom
logging-fix

Conversation

@ibreakthecloud
Copy link
Copy Markdown
Member

@ibreakthecloud ibreakthecloud commented Apr 11, 2025

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)

//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.

@ibreakthecloud ibreakthecloud force-pushed the logging-fix branch 2 times, most recently from 21d94d1 to 049ba9d Compare April 14, 2025 07:44
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 14, 2025

Pull Request Test Coverage Report for Build 14571679809

Details

  • 38 of 51 (74.51%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 71.091%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/server/src/services/logger.js 38 51 74.51%
Files with Coverage Reduction New Missed Lines %
src/server/src/services/logger.js 1 63.04%
Totals Coverage Status
Change from base Build 13179434831: 0.02%
Covered Lines: 149
Relevant Lines: 194

💛 - 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.
@ibreakthecloud ibreakthecloud changed the title wip: logging: more verbose logging feat(log): Implement structured logging Apr 14, 2025
@ibreakthecloud ibreakthecloud marked this pull request as ready for review April 15, 2025 06:57
Copy link
Copy Markdown

@celiala celiala left a 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)

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({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice improvement!

Comment thread src/server/src/webhooks/pull_request.js Outdated
})
} catch (error) {
logger.warn(new Error(error).stack)
logger.error({
Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Member Author

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.

Comment thread src/server/src/services/cla.js Outdated
error: error,
msg: 'Warning in CLA operation'
})
logger.warn({
Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Member Author

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.

Comment thread src/server/src/services/cla.js Outdated
error: error,
msg: 'Warning in CLA operation'
})
logger.warn({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same: double-logging)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rail
Copy link
Copy Markdown
Member

rail commented Apr 22, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants