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

refactor(app-shell,app-shell-odd): update winston and improve logging #16516

Merged
merged 5 commits into from
Oct 18, 2024

Conversation

sfoster1
Copy link
Member

Update winston which is what we use for logging on the node side to the most recent version (3.15) so that we can use logger.child(), which lets you override logger metadata without having to create another logger instance.

The reason to do this is that each full winston logger instance hangs event listeners off its shared transports (winstonjs/winston#1334) which results in annoying node warning messages about memory leaks that aren't real and are just based on "did you add more than a magic number of listeners to this event". With the child logs, nothing adds the events, and we don't get the warnings.

Also, get rid of the file logging to /app/ODD/logs/error.log and /app/ODD/logs/combined.log, because we're already sending everything to journald via the console and using that to provide the logs via http so it's just extra storage wear and space usage that we don't actually need.

testing

  • do the logs still go

Update winston to 3.15 so that we can use the new child logger
functionality to get loggers with different labels for different modules
instead of creating whole new logger instances.

When you create a new winston logger instance, winston will attach
listeners to the transports. That means that if you create a bunch, you
trigger node's built in "you may be leaking event listeners" warnings,
which freaks out anybody who looks at the logs. By using child loggers,
we don't create those warnings anymore.
We log everything to journald, and that's where we export logs from.
Having the logs also in /data/ODD is just a waste of disk space and
storage wear.
@sfoster1 sfoster1 requested review from a team as code owners October 17, 2024 19:29
@sfoster1 sfoster1 requested review from shlokamin and mjhuff and removed request for a team October 17, 2024 19:29
Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

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

Sweet. Nice fix!

@sfoster1 sfoster1 merged commit 4be3ba6 into edge Oct 18, 2024
21 checks passed
@sfoster1 sfoster1 deleted the fix-app-shell-logging branch October 18, 2024 13:15
TamarZanzouri pushed a commit that referenced this pull request Oct 18, 2024
…#16516)

Update [winston](https://www.npmjs.com/package/winston/v/3.15.0) which
is what we use for logging on the node side to the most recent version
(3.15) so that we can use `logger.child()`, which lets you override
logger metadata without having to create another logger instance.

The reason to do this is that each full winston logger instance hangs
event listeners off its shared transports
(winstonjs/winston#1334) which results in
annoying node warning messages about memory leaks that aren't real and
are just based on "did you add more than a magic number of listeners to
this event". With the child logs, nothing adds the events, and we don't
get the warnings.

Also, get rid of the file logging to `/app/ODD/logs/error.log` and
`/app/ODD/logs/combined.log`, because we're already sending everything
to journald via the console and [using that to provide the logs via
http](https://github.com/Opentrons/opentrons/blob/edge/robot-server/robot_server/service/legacy/routers/logs.py#L16)
so it's just extra storage wear and space usage that we don't actually
need.

## testing
- [x] do the logs still go
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.

2 participants