-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(logs): Add experimental user-callable logging methods #15442
base: develop
Are you sure you want to change the base?
Conversation
size-limit report 📦
|
1328016
to
c5eb7fe
Compare
@@ -223,6 +223,7 @@ const ITEM_TYPE_TO_DATA_CATEGORY_MAP: Record<EnvelopeItemType, DataCategory> = { | |||
feedback: 'feedback', | |||
span: 'span', | |||
raw_security: 'security', | |||
otel_log: 'log_item', |
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.
Will there be any other type than otel_log
? If not in the foreseeable future, I'd suggest we change it to
otel_log: 'log_item', | |
log: 'log', |
Again singular, as in span
, or replay
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.
This is done because it matches the code in relay for data categories (rate limiting and client outcomes) https://github.com/getsentry/relay/blob/e36886a98c89af645e5c0d2109657deafa25d902/relay-server/src/envelope.rs#L182
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
packages/core/src/log.ts
Outdated
|
||
const SEVERITY_TEXT_TO_SEVERITY_NUMBER: Partial<Record<LogSeverityLevel | 'log', number>> = { | ||
trace: 1, | ||
log: 2, |
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.
I wouldn't expect sentry.log
to be lower priority than sentry.debug
- is this actually what otel says?
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.
I put this in the wrong place 🤦
just saw it while I saw debugging, more reason to add tests for this
packages/core/src/log.ts
Outdated
trace: 1, | ||
log: 2, | ||
debug: 5, | ||
info: 9, | ||
warn: 13, | ||
error: 17, | ||
fatal: 21, |
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.
trace: 1, | |
log: 2, | |
debug: 5, | |
info: 9, | |
warn: 13, | |
error: 17, | |
fatal: 21, | |
trace: 1, | |
debug: 5, | |
info: 9, | |
log: 10, | |
warn: 13, | |
error: 17, | |
fatal: 21, |
2a02335
to
3e936c9
Compare
It's strange how this impacts bundle size. I would have expected the additional code to tree-shake out when it's not used! Why is the |
This PR adds logging APIs to the SDK. At the moment this is only exposed in
@sentry/core
and@sentry/browser
.Logging is gated by an experimental option,
_experiments.enableLogs
. Just picked this for now, name is subject to change.These API are exposed in the
Sentry._experiment_log
namespace.On the high level, there are functions for each of the logging severity levels
critical
,fatal
,error
,warn
,info
,debug
,trace
. These functions are tagged template functions, so they use a special string template syntax that we use to parameterize functions accordingly.If you want more custom usage, we also expose a
captureLog
method that allows you to pass custom attributes, but it's less easy to use than the tagged template functions.There is a buffer of logs that flushes every 5 seconds, or when you hit 25 logs, whichever comes first.