Skip to content
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

Simplify RPC logs #1473

Merged
merged 1 commit into from
Dec 20, 2022
Merged

Simplify RPC logs #1473

merged 1 commit into from
Dec 20, 2022

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Dec 19, 2022

Fixes issues like: https://sentry.io/organizations/mui-org/issues/3783806362/?environment=production&project=6763402&query=&referrer=issue-stream&statsPeriod=14d

We're not using JSON to transfer messages in RPC (Though it looks like it 🙂 )

  • Deserializing the RPC message just for logging is a leaky abstraction, why not just log directly in the rpc code?
  • Why disable server logs? By default we log the things we want to monitor in production, if you want more/less in your local, adjust the loglevel. This serves as a forcing function for us to not overlog.
  • expand error serializer to have name and stacktrace

@oliviertassinari oliviertassinari requested a deployment to logger - toolpad-db PR #1473 December 19, 2022 15:52 — with Render Abandoned
@Janpot Janpot added the core Infrastructure work going on behind the scenes label Dec 19, 2022
@oliviertassinari oliviertassinari temporarily deployed to logger - toolpad PR #1473 December 19, 2022 15:53 — with Render Destroyed
@Janpot Janpot marked this pull request as ready for review December 19, 2022 16:19
Copy link
Member

@apedroferreira apedroferreira left a comment

Choose a reason for hiding this comment

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

This is definitely an improvement - I was trying to log the error from the response body before I think, but then the stack wasn't working with JSON.
Also getting the response body in Next.js doesn't seem very straightforward, I hadn't found any alternative to that complicated part with the chunks...


type LogPayload = ReqResLogPayload | RpcReqResLogPayload;

function logMethod(method: 'info' | 'trace' | 'error' | 'warn' | 'fatal') {
Copy link
Member

Choose a reason for hiding this comment

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

nice, this works better than a function just for logInfo

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'm thinking roughly:

  • fatal: Unrecoverable errors, the node process should crash (or has crashed and this is the report).
  • error: Unexpected, but we can degrade in a safe way. The user experience is impacted, so this must be investigated
  • warn: Unexpected, but we can degrade in a safe way. The user experience isn't really impacted, investigate when lots of these happen.
  • info: informational, we want to see these appear in a log aggregator for metrics

We play with logelevel on different use-cases

  • production: info
  • local: warn, info will most likely lead to too many logs

Copy link
Member

Choose a reason for hiding this comment

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

Sounds great, one of the alerts I set up in Sentry was for frequent warnings too.

@Janpot Janpot merged commit 79b128a into master Dec 20, 2022
@Janpot Janpot deleted the logger branch December 20, 2022 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants