-
-
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
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 |
Yeah that feels weird to me too. I wonder if it's because of the log buffer side effect.
Because we'll eventually also forward the console calls as logs, and that will be gated by |
It's all nicely decoupled so it has to be something like that. |
ref #15526 Based on the work in #15442, we add definitions for the logs protocol and envelope to the JavaScript SDKs. Relay data category: https://github.com/getsentry/relay/blob/e36886a98c89af645e5c0d2109657deafa25d902/relay-server/src/envelope.rs#L182 Relay log protocol: https://github.com/getsentry/relay/blob/ad04adf6d6756c4e36328c8217bea0ee01f289ec/relay-event-schema/src/protocol/ourlog.rs#L12
* fatal(fmt`user ${username} just bought ${item}!`); | ||
* ``` | ||
*/ | ||
fatal: sendLog('fatal'), |
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 the side-effect y'all are probably looking for.
@AbhiPrasad we have to change the typing on the |
@AbhiPrasad this #15600 maybe? |
How does this integrate with loggers like |
For now the focus is on frontend logging, but we'll have integrations for popular logging frameworks. You can see getsentry/sentry-docs#12920 for more details how SDKs will work with logging frameworks. |
Is there a reason that this couldn't be added to the Angular package as well? Would be very nice if it could please 🥺 |
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
.These API are exposed in the
Sentry._experiment_log
namespace.On the high level, there are functions for each of the logging severity levels
fatal
,error
,warn
,info
,debug
,trace
. There is also alog
function that is an alias toinfo
.If you want to do structured logging, you'll need to use the
fmt
helper exposed in theSentry._experiment_log
namespace.There is a buffer of logs that flushes every 5 seconds, or when you hit 25 logs, whichever comes first.