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

Accessing log level label from transport #1925

Closed
10xLaCroixDrinker opened this issue Mar 16, 2024 · 7 comments
Closed

Accessing log level label from transport #1925

10xLaCroixDrinker opened this issue Mar 16, 2024 · 7 comments

Comments

@10xLaCroixDrinker
Copy link
Contributor

Related: pinojs/pino-opentelemetry-transport#155

In the pino-opentelemetry-transport, I'm using the level label as SeverityText on the log record. Since the log object only has the level number, and the transport doesn't have access to the logger itself to read logger.levels, I'm using the label from pino.levels for SeverityText. This becomes a bit of a problem though for custom levels.

If a user is using any custom levels in their pino configuration, they'll have to pass that same configuration again to the transport in order to be able to use the level label.

Is there a way that I'm missing that exists to access the level label from the transport without having to do this?

@mcollina
Copy link
Member

Your assessment is correct. I think passing the custom level information down to the worker thread would be a very nice feature addition, if you'd like to send a PR.

@10xLaCroixDrinker
Copy link
Contributor Author

@mcollina PRs are open for this now.

Most of the changes are in pino-abstract-transport. Looking forward to your feedback.

@mcollina
Copy link
Member

I think it would be safer/easier to pass it via workerData. Why did you pass it via postMessage?

@10xLaCroixDrinker
Copy link
Contributor Author

I passed it via postMessage because the worker is created before the pino instance, so that information isn't available to include in workerData.

@10xLaCroixDrinker
Copy link
Contributor Author

WorkerData could potentially work for

pino({
  transport: {
    target: '/absolute/path/to/my-transport.mjs'
  }
})

But would not support

pino(pino.transport({
  target: '/absolute/path/to/my-transport.mjs'
})

@10xLaCroixDrinker
Copy link
Contributor Author

@mcollina what are your thoughts?

Do you want to only support this feature when including the transport on the config? Or am I missing something here that would work for workerData when calling pino.transport() directly?

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants