-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(winston): Add customLevelMap for winston transport #18922
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
base: develop
Are you sure you want to change the base?
Conversation
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.
|
s1gr1d
left a comment
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.
Looks good, but I am wondering if we can auto-detect those levels so users don't have to manually add them 🤔
| attributes[SPLAT_SYMBOL] = undefined; | ||
|
|
||
| const logSeverityLevel = WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[levelFromSymbol as string] ?? 'info'; | ||
| const customLevel = sentryWinstonOptions?.customLevelMap?.[levelFromSymbol as string]; |
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.
m: would it make sense to warn the user in case he provides a sentry level that does not exist?
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.
That could actually make sense
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.
@nicohrubec I added a debug warning now. This is however only then when levels are overwritten. In all other cases they will default to info already
That shouldn't be a problem. The main problem is what it should get mapped to. |
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| DEBUG_BUILD && | ||
| debug.log( | ||
| `Winston log level ${levelFromSymbol} is not captured by Sentry. Please add ${levelFromSymbol} to the "customLevelMap" option of the Sentry Winston transport.`, | ||
| ); |
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.
Warning message misleads for known winston levels
Low Severity
The debug warning condition at line 114 (else if (!customLevel)) fires for known winston levels (like warn, info, http) when they're excluded via the levels option. The warning message tells users to add the level to customLevelMap, but for known levels that already exist in WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP, this suggestion is misleading since adding { warn: 'warn' } wouldn't change anything. The condition needs to also verify the level is truly unknown (not in the built-in map) before recommending customLevelMap.
nicohrubec
left a comment
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.
nice
closes #18868
closes JS-1498
ATM it is not possible to map custom levels to OpenTelemetry levels. The option
customLevelMaphas been added to make this possible. Which means that custom levels would have never been send to Sentry, as they were not mapped correctly.Now when there are custom levels it can be used like this:
Merge checklist