Skip to content

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Oct 14, 2025

Pino loggers can be named but we didn't capture this information:

import pino from 'pino';

const logger = pino({ name: 'my-component' });

This PR changes the hook from start to end which means we can parse the output JSON and fetch the name if one was supplied.

'pino.logger.level': levelNumber,
};

const parsedResult = JSON.parse(result) as { name?: string };
Copy link

Choose a reason for hiding this comment

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

Bug: Pino JSON Parsing Fails Without Error Handling

The JSON.parse(result) call lacks error handling. If the result string from Pino's asJson function is malformed, it throws an uncaught exception. This can crash the integration and prevent log capture.

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the string doesn't parse as json we've got more fundamental issues!

Copy link
Contributor

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,914 - 8,595 +4%
GET With Sentry 1,450 16% 1,326 +9%
GET With Sentry (error only) 6,330 71% 5,994 +6%
POST Baseline 1,212 - 1,189 +2%
POST With Sentry 528 44% 496 +6%
POST With Sentry (error only) 1,079 89% 1,038 +4%
MYSQL Baseline 3,425 - 3,247 +5%
MYSQL With Sentry 548 16% 432 +27%
MYSQL With Sentry (error only) 2,779 81% 2,674 +4%

View base workflow run

@AbhiPrasad AbhiPrasad merged commit ed98c1f into develop Oct 14, 2025
138 checks passed
@AbhiPrasad AbhiPrasad deleted the timfish/feat/pino-capture-name branch October 14, 2025 17:58
andreiborza pushed a commit to thedanchez/sentry-javascript that referenced this pull request Oct 15, 2025
Pino loggers can be named but we didn't capture this information:

```ts
import pino from 'pino';

const logger = pino({ name: 'my-component' });
```

This PR changes the hook from `start` to `end` which means we can parse
the output JSON and fetch the name if one was supplied.
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