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

fix: replace bunyan logger #1447

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

fix: replace bunyan logger #1447

wants to merge 12 commits into from

Conversation

abhilash-sivan
Copy link
Contributor

@abhilash-sivan abhilash-sivan commented Nov 13, 2024

  • lock file change
  • check and verify concatenated strings using %s and correct it
  • pass logs to agent stream
  • fix tests for pino and logger_test
  • fix test for pino/test
  • fix instrumentation - We don't want to trace Instana's own loggers ( __in)

@abhilash-sivan abhilash-sivan changed the title Fix replace bunyan fix: replace bunyan logger Nov 18, 2024
@@ -267,9 +267,11 @@ exports.sendSpans = function sendSpans(spans, cb) {
if (err && !maxContentErrorHasBeenLogged && err instanceof PayloadTooLargeError) {
logLargeSpans(spans);
} else if (err) {
logger.debug('Failed to send: %s', getSpanLengthInfo(spans));
const obj = getSpanLengthInfo(spans);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pino does not support concatenated strings using %s if an object is passed instead of a string.

* Custom write method to send logs to multiple destinations
* @param {string} chunk
*/
write(chunk) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

custom write method which writes the log to stdout and agent stream function (pinoToAgentStream)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried implementing this use case using pino.transport, pino.destination and pino.multistream etc. And finally ended up with the current implementation which is working as expected like previous bunyan stream

@@ -31,40 +31,57 @@ const registry = {};
* @param {boolean} [isReInit]
*/
exports.init = function init(config, isReInit) {
const consoleStream = pino.destination(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If multistream is used, we need to specify the log streams where it is going. Here this is defined for logging into the process.stdout

parentLogger = pino(
{
...parentLogger.levels,
base: parentLogger.bindings()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we want to change something in pino logger after it is initialized, we need to create a new logger and assign initial logger bindings to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant