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

Add configurable logLevel to BunyanInstrumentation (and other logger instrumentations) for custom log sending level #1821

Open
trentm opened this issue Nov 23, 2023 · 0 comments

Comments

@trentm
Copy link
Contributor

trentm commented Nov 23, 2023

This is a spin-off from discussion on #1713
starting at #1713 (comment)

There are a couple separate things here:

  1. Adding an option to the BunyanInstrumentation constructor to set a custom log level for which log records are sent to the Logs SDK for the "log sending" feature. Something like this:

    new BunyanInstrumentation({ logLevel: "trace" })

    If that instrumentation was made active for this application:

    const logger = bunyan.createLogger({name: 'myapp', level: 'debug'})
    logger.debug('hi at debug level')
    logger.trace('hi at trace level')

    then it would result in both log messages being sent to the Logs SDK, where as the Bunyan output to stdout would only emit the "hi at debug level" record.

  2. Adding a generic environment variable that could be used to configure this log level on any instrumentations of logging frameworks (Bunyan, Winston, Pino, perhaps one instrumenting console.* logging). Something like OTEL_NODE_LOG_LEVEL.

These could be implemented separately. For each of these, there is the question of what level names should be used: (a) the level names defined by the logging framework, or (b) the severity names sort of defined by the OTel Logs data model.

These were discussed during the 2023-11-22 OTel JS SIG meeting (recording). Some notes/opinions from that call:

  • Spin this off to a separate issue (that's this issue).
  • The logLevel argument to the [Framework]Instrumentation() constructor might best be in terms of the logging framework's log levels. I.e. new BunyanInstrumentation({ logLevel }) would use Bunyan log levels.
  • If/when adding a general environment variable for configuration, we'd want those log levels to be generic OTel severity names. Documentation would need to clarify the mapping from OTel severity names for this config option to logging framework-specific level names. Perhaps that could be by adding to this table: https://opentelemetry.io/docs/specs/otel/logs/data-model-appendix/#appendix-b-severitynumber-example-mappings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants