Skip to content

beforeBreadcrumb can no longer access original Request object in v8 #12132

Closed

Description

@TheHolyWaffle

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.2.1

Framework Version

No response

Link to Sentry event

No response

SDK Setup

Sentry.init({
    dsn: '....',
    beforeBreadcrumb: beforeBreadcrumb,
    enableTracing: true,
    sampleRate: 1,
    integrations: [Sentry.httpIntegration(), Sentry.nativeNodeFetchIntegration()],
});


export function beforeBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null {
    if (breadcrumb.type !== 'http' || breadcrumb.category !== 'http' || !hint) { // <---- hint is undefined here
        return breadcrumb;
    }
    // .....
}

Steps to Reproduce

  1. Make an native node fetch api call
  2. Throw an error so that beforeBreadcrumb is triggered

Expected Result

The beforeBreadcrumb handler should receive the original fetch Request object as a hint parameter. This is used to extract the fetch request headers and apply this information to enrich the breadcrumb.

Actual Result

The beforeBreadcrumb handler does not receive the original fetch Request object anymore since Sentry v8

image

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on May 21, 2024
  2. mydea commented on May 21, 2024

    @mydea
    Member

    Hey, thanks for writing in - that is indeed not on purpose, we'll add this back, sorry about the inconvenience!

  3. TheHolyWaffle commented on May 21, 2024

    @TheHolyWaffle
    Author

    @mydea Thanks for looking into this. Just to double-check this desired behavior is expected for both httpIntegration and nativeNodeFetchIntegration 🙏

  4. mydea commented on May 21, 2024

    @mydea
    Member

    Yeah, you are right! While looking into this some more I noticed that we have some general issues there, mainly that breadcrumbs were (incorrectly) tied to spans, meaning that if performance was disabled we would not get proper breadcrumbs. I opened a PR to fix this: #12137 and ensure this is consistent, including passing the request/response as hints!

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 21, 2024
  6. TheHolyWaffle commented on May 21, 2024

    @TheHolyWaffle
    Author

    This may be related: I had to set enableTracing: true in order for beforeBreadcrumb to be called. Before v8, this flag wasn't necessary.

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on May 21, 2024
  8. mydea commented on May 21, 2024

    @mydea
    Member

    This may be related: I had to set enableTracing: true in order for beforeBreadcrumb to be called. Before v8, this flag wasn't necessary.

    Yeah, this is also fixed in my PR - should not be necessary!

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions