getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.68k stars 1.49k forks source link

Breadcrumbs related to an event are only visible in the next events, and also breadcrumbs are not isolated in the event. #11825

Closed apaschenko closed 3 weeks ago

apaschenko commented 3 weeks ago

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.0.0-beta.4

Framework Version

Node v20.10.0

Link to Sentry event

https://bringlynl.sentry.io/performance/trace/75cb252cba585d363aca45ea7cff6bf8/?field=title&field=event.type&field=project&field=user.display&field=timestamp&name=All+Events&node=txn-ddae5123833a446085d16d8406daa356&project=4507056912269312&query=&sort=-timestamp&statsPeriod=24h&timestamp=1714357793&yAxis=count%28%29

SDK Setup

const Sentry = require('@sentry/node');
const { config } = require('dotenv');

config();

Sentry.init({
  dsn: process.env.DSN,
  integrations: [
    Sentry.httpIntegration({ tracing: true, breadcrumbs: true }),
  ],
  tracesSampleRate: 1.0,
  profilesSampleRate: 1.0,
});

const express = require('express');

const app = express();

app.get("/breadcrumb/:name", function rootHandler(req, res) {
  Sentry.addBreadcrumb({
    message: `It's a breadcrum for "${req.params.name}"`
  })

  res.end(req.params.name);
});

app.get("/error", function mainHandler(req, res) {
  const message = 'It\'s a breadcrumb for exception!';
  console.log(message);
  Sentry.addBreadcrumb({ message });
  throw new Error("My first Sentry error!");
});

Sentry.setupExpressErrorHandler(app);

// Optional fallthrough error handler
app.use(function onError(err, req, res, next) {
  // The error id is attached to `res.sentry` to be returned
  // and optionally displayed to the user for support.
  res.statusCode = 500;
  res.end(`${res.sentry}\n`);
});

app.listen(3000);

Steps to Reproduce

  1. Clone, install and start the test project (you will need to create .env file in the root directory containing the line "DSN=")
  2. Type in the address bar of your browser:
    • 127.0.0.1/breadcrumb/br-1
    • 127.0.0.1/breadcrumb/br-2
    • 127.0.0.1/breadcrumb/br-3
    • 127.0.0.1/breadcrumb/br-4

Expected Result

In breadcrumbs section of corresponding event pages (sentry.io):

Actual Result

HazAT commented 3 weeks ago

First of all, thanks for the awesome repro 🥇 Indeed if I look at your data, it looks wrong, however, if I use your example repo you provided and run it locally myself with a test DSN I get correct data (I also run the same Node version 20.10)

image image image image
apaschenko commented 3 weeks ago

@HazAT Thank you so much for your quick and comprehensive response and for the time you spent trying to reproduce the bug. Hence I have some kind of local problem. I'll sort this out.