-
Notifications
You must be signed in to change notification settings - Fork 838
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
feat(sdk-logs): added colors option to ConsoleLogRecordExporter #4524
feat(sdk-logs): added colors option to ConsoleLogRecordExporter #4524
Conversation
👋 @open-telemetry/javascript-approvers |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4524 +/- ##
=======================================
Coverage 92.84% 92.85%
=======================================
Files 328 328
Lines 9494 9498 +4
Branches 2040 2042 +2
=======================================
+ Hits 8815 8819 +4
Misses 679 679
|
24a025c
to
773750a
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.
Hi, thanks for opening this PR 🙂
I think I might be missing some context: Is this change intended for production use or is that something that you're intending to use for local debugging? 🤔
I only use the |
I'm using pino for logging with pino-opentelemetry-transport. Since its running in a worker thread there is never colorization. Currently, I'm conditionally setting |
@pichlermarc what do you think? |
@10xLaCroixDrinker would it help to have colorized output be the default behavior (also for metric and trace console exporters)? 🤔 I'm thinking something like: if |
@pichlermarc that is already the default behavior when process.stdout is a TTY. I'm running into this because the exporter is in a worker thread where it is not a TTY. When I say that I'd set the config to |
Sorry for leaving you waiting for so long.
I see. I'd like to avoid having to increase the API surface for the console exporters. A reason why we have not added any features/config options to any of the other console exporters in the past was that the exporter interface is reasonably easy to implement on one's own. We therefore usually recommend users to implement a custom exporter for use-cases like this. While I see that the feature can be useful we'd still want to apply the same principle for this exporter. |
Which problem is this PR solving?
I'm running this exporter in a worker thread (using a pino logger), and since in that context process.stdout is not a TTY, the logs are not colorized. I'd like the option to force the colorization.
Short description of the changes
Added an optional config for the
ConsoleLogRecordExporter
that has a single optioncolors
which can override the automatic color support detection to turn colorization on or off.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: