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

Track how often breadcrumbs are dropped by SDKs #116

Open
3 of 5 tasks
AbhiPrasad opened this issue Jan 14, 2025 · 2 comments
Open
3 of 5 tasks

Track how often breadcrumbs are dropped by SDKs #116

AbhiPrasad opened this issue Jan 14, 2025 · 2 comments
Assignees

Comments

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Jan 14, 2025

Description

For the upcoming logging product, we want to leverage breadcrumbs in the SDK. To get a better understanding of how breadcrumbs are created and used by the SDK, we would like to track how often breadcrumbs are dropped by the SDK.

We can do this with client outcomes in the SDK.

Why should we be doing this?

In short we want to know: "How many breadcrumbs are being dropped by Sentry". If we can get this number for at least JavaScript, Python, and a single mobile SDK, we can make much better decisions around how the logging product will proceed at Sentry.

Why now?

We're working on logs - we want to ship soon, so this is important.

RFC

No response

Slack-Channel

#proj-structured-logs

Notion Document(s)

No response

Stakeholder(s)

@getsentry/product-owners-explore-logs

Team(s)

Web Frontend

SDKs

Pre-work

Preview Give feedback
  1. AbhiPrasad
  2. AbhiPrasad

SDKs

Preview Give feedback
  1. AbhiPrasad
  2. AbhiPrasad

Post SDK Work

Preview Give feedback

TBD on the mobile SDK

@AbhiPrasad AbhiPrasad self-assigned this Jan 14, 2025
@AbhiPrasad
Copy link
Member Author

diff --git a/packages/core/src/scope.ts b/packages/core/src/scope.ts
index 995be01bb..52bd4aae5 100644
--- a/packages/core/src/scope.ts
+++ b/packages/core/src/scope.ts
@@ -481,7 +481,11 @@ export class Scope {
 
     const breadcrumbs = this._breadcrumbs;
     breadcrumbs.push(mergedBreadcrumb);
-    this._breadcrumbs = breadcrumbs.length > maxCrumbs ? breadcrumbs.slice(-maxCrumbs) : breadcrumbs;
+
+    if (breadcrumbs.length > maxCrumbs) {
+      this._client?.recordDroppedEvent('breadcrumb_dropped', 'log', 1);
+      this._breadcrumbs = breadcrumbs.slice(-maxCrumbs);
+    }
 
     this._notifyScopeListeners();

Approx implementation in the JS SDK.

We need to decide what data category the breadcrumb data belongs to, and what the outcome name will be.

@AbhiPrasad
Copy link
Member Author

data categories: getsentry/relay#4455

AbhiPrasad added a commit to getsentry/snuba that referenced this issue Jan 21, 2025
ref getsentry/team-sdks#116

This PR implements a new client discard reason for `buffer_overflow`.
This will be used to track when the internal breadcrumbs buffer
overflows for the new logs product that we are working on. This is
documented in develop here:
getsentry/sentry-docs#12395

I also went ahead and added code comments that describes what all the
different client discard reasons mean. This is done in commit
b3dcd67, while the actual change to add
the `buffer_overflow` discard reason was added in
dd25dde.

Note: The reason we have `buffer_overflow` as a separate item to
`queue_overflow` is that in the future when we send log items in
envelopes we'll increment `queue_overflow` for the transport queue. We
want to differentiate between the transport queue and the internal
buffer explicitly.

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
AbhiPrasad added a commit to getsentry/sentry-javascript that referenced this issue Jan 23, 2025
ref getsentry/team-sdks#116

This PR implements a new client discard reason for `buffer_overflow`.
This will be used to track when the internal breadcrumbs buffer
overflows for the new logs product that we are working on. This is
documented in develop here:
getsentry/sentry-docs#12395

Note: The reason we have `buffer_overflow` as a separate item to
`queue_overflow` is that in the future when we send log items in
envelopes we'll increment `queue_overflow` for the transport queue. We
want to differentiate between the transport queue and the internal
buffer explicitly.
AbhiPrasad added a commit to getsentry/sentry-javascript that referenced this issue Jan 23, 2025
ref getsentry/team-sdks#116

This PR implements a new client discard reason for `buffer_overflow`.
This will be used to track when the internal breadcrumbs buffer
overflows for the new logs product that we are working on. This is
documented in develop here:
getsentry/sentry-docs#12395

Note: The reason we have `buffer_overflow` as a separate item to
`queue_overflow` is that in the future when we send log items in
envelopes we'll increment `queue_overflow` for the transport queue. We
want to differentiate between the transport queue and the internal
buffer explicitly.
AbhiPrasad added a commit to getsentry/sentry-javascript that referenced this issue Jan 24, 2025
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

No branches or pull requests

1 participant