Skip to content

Conversation

@JPeer264
Copy link
Member

No description provided.

timfish and others added 24 commits October 15, 2025 09:56
- Closes #17904

This PR adds two methods to the `pinoIntegration` export. `trackLogger`
and `untrackLogger`;

`untrackLogger` can be used to disable capturing from a specific logger.

You can also disable `autoInstrument` and only track specific loggers:

```ts
import * as Sentry from '@sentry/node';
import pino from 'pino';

Sentry.init({
  dsn: '__DSN__',
  integrations: [Sentry.pinoIntegration({ autoInstrument: false })],
});

const logger = pino({});
Sentry.pinoIntegration.trackLogger(logger);

logger.debug('This will be captured!');
```
…rs (#17786)

I was running tests locally and noticed that they are stays running if
something wents wrong that's why I've added:
04d2fbf

fixes #17514

Is there a way to run e2e tests pipeline without merging to develop?

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Introduce `copyExecutionContext` with tests; make Cloudflare
integration test runner accept `AbortSignal` and update tests; ignore
JUnit reports.
> 
> - **Cloudflare SDK**:
> - **Utility**: Add
`packages/cloudflare/src/utils/copyExecutionContext.ts` to clone
`ExecutionContext`/`DurableObjectState` with overridable, bound methods.
> - **Tests**: Add
`packages/cloudflare/test/copy-execution-context.test.ts` covering
method overriding, immutability safety, and symbol property
preservation.
> - **Integration Tests (Cloudflare)**:
> - **Runner**: `dev-packages/cloudflare-integration-tests/runner.ts`
`start` now accepts optional `AbortSignal` and forwards it to `spawn`.
> - **Suites**: Update tests (`basic`, `tracing/anthropic-ai`,
`tracing/durableobject`, `tracing/openai`) to pass `{ signal }` from
Vitest and call `.start(signal)`.
> - **Repo**:
>   - `.gitignore`: Ignore `packages/**/*.junit.xml` JUnit reports.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
cb97187. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: cod1k <cod1k@centro.team>
…tion (#17884)

This PR aims to address #9643 partially by introducing a
`onRequestSpanEnd` hook to the browser integration. These changes make
it easier for users to enrich tracing spans with response header data.

#### Example

```ts
import * as Sentry from '@sentry/browser';

Sentry.init({
  // ...
  integrations: [
    Sentry.browserTracingIntegration({
      onRequestSpanEnd(span, responseInformation) {
        span.setAttributes({
          response_type: 'JSON',
        });
      },
    }),
  ],
});
```

#### Tracing Integration and API Improvements

* Added `onRequestSpanEnd` callback to `BrowserTracingOptions` and
`RequestInstrumentationOptions`, allowing users to access response
headers when a request span ends. This enables custom span annotation
based on response data.
* Updated internal request instrumentation logic to call
`onRequestSpanEnd` for both Fetch and XHR requests, passing parsed
response headers to the callback.

#### Utility and Refactoring

* Centralized header parsing and filtering utilities
(`parseXhrResponseHeaders`, `getFetchResponseHeaders`,
`filterAllowedHeaders`) in `networkUtils.ts`, and exported them for
reuse across packages.
* Moved helper functions for baggage header checking, URL resolution,
performance timing checks, and safe header creation to a new `utils.ts`
file to avoid failing the file size limit lint rule.

I was hesitant to hoist up those replay utils initially but a few of
them were needed to expose them on the hook callback.

#### Type and API Consistency

* Introduced new types `RequestHookInfo` and `ResponseHookInfo` to
standardize the information passed to request span hooks, and exported
them from the core package for use in integrations.

I also added the necessary tests to test out the new hook.
…s existed (#17950)

#13335 added a plural
`s` to the contribution message when multiple people contributed to the
repo but the regex for the lookup lacks this.
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #17786

Co-authored-by: JPeer264 <10677263+JPeer264@users.noreply.github.com>
## What

This PR adds automatic instrumentation for Nuxt's storage layer (powered
by [unstorage](https://unstorage.unjs.io/)), enabling performance
monitoring for cache and key-value storage operations in Nuxt/Nitro
applications.

Storage operations will now automatically create performance spans with
detailed attributes for observability in Sentry.

### What's New

- **Automatic Storage Instrumentation**: Instruments all storage drivers
configured in `nuxt.config.ts` via `nitro.storage`
- **Comprehensive Coverage**: Tracks all storage operations including:
  - `getItem`, `setItem`, `hasItem`, `removeItem` 
  - Raw variants: `getItemRaw`, `setItemRaw`
  - Batch operations: `getItems`, `setItems`
  - Utility methods: `getKeys`, `clear`
  - Aliases: `get`, `set`, `has`, `del`, `remove`

### Implementation Details

**Span Attributes:**
- `sentry.op`: `cache.{operation}` (e.g., `cache.get_item`,
`cache.set_item`)
- `sentry.origin`: `auto.cache.nuxt`
- `cache.key`: Full key including mount prefix
- `cache.hit`: `true` for successful get/has operations
- `db.operation.name`: Original method name
- `db.collection.name`: Storage mount point
- `db.system.name`: Driver name (e.g., `memory`, `fs`, `redis`)

**Files Changed:**
- `packages/nuxt/src/runtime/plugins/storage.server.ts` - Runtime
instrumentation plugin
- `packages/nuxt/src/vite/storageConfig.ts` - Build-time configuration
- `packages/nuxt/src/module.ts` - Module integration
- E2E tests for Nuxt 3 & 4
Adds [Nitro/Nuxt Cache API](https://nitro.build/guide/cache)
instrumentation by building upon the storage instrumentation in #17858
since both use `unstorage` under the hood.

#### How it works

Nitro injects the cache storage on either `cache:` or the root mount
depending on user configuration, also in production the `cache` storage
is placed on the root mount unless the user configures it explicitly to
redis or something else. We instrument both mount drivers to cover other
cache use cases.

---

I made sure to add e2e tests as well for `cachedEventListner` and
`cachedFunction` calls which are the main ways to use the Cache API.

This PR depends on the storage PR #17858.

---------

Co-authored-by: Sigrid Huemer <32902192+s1gr1d@users.noreply.github.com>
### Problem

When using Next.js 15 App Router with `next-intl` and `localePrefix:
"as-needed"`, Web Vitals and transaction names were inconsistent across
locales:

- `/foo` (default locale, no prefix) → Transaction: `/:locale` ❌
- `/ar/foo` (non-default locale, with prefix) → Transaction:
`/:locale/foo` ✅

This caused all default locale pages to collapse into a single
`/:locale` transaction, making Web Vitals data unusable for apps with
i18n routing.

After investigation it seems like the route parameterization logic
couldn't match `/foo` (1 segment) to the `/:locale/foo` pattern (expects
2 segments) because the locale prefix is omitted in default locale URLs.

### Solution

Implemented enhanced route matching with automatic i18n prefix
detection:

1. **Route Manifest Metadata** - Added `hasOptionalPrefix` flag to route
info to identify routes with common i18n parameter names (`locale`,
`lang`, `language`)
2. **Smart Fallback Matching** - When a route doesn't match directly,
the matcher now tries prepending a placeholder segment for routes
flagged with `hasOptionalPrefix`
- Example: `/foo` → tries matching as `/PLACEHOLDER/foo` → matches
`/:locale/foo` ✓
3. **Updated Specificity Scoring** - changed route specificity
calculation to prefer longer routes when dynamic segment counts are
equal
- Example: `/:locale/foo` (2 segments) now beats `/:locale` (1 segment)

### Result

**After fix:**
```
URL: /foo         → Transaction: /:locale/foo    ✅
URL: /ar/foo      → Transaction: /:locale/foo    ✅
URL: /products    → Transaction: /:locale/products ✅
URL: /ar/products → Transaction: /:locale/products ✅
```

All routes now consistently use the same parameterized transaction name
regardless of locale, making Web Vitals properly grouped and usable.

### Backwards Compatibility

- No breaking changes - only applies when direct matching would fail
- Only affects routes with first param named `locale`/`lang`/`language`
- Non-i18n apps completely unaffected
- Direct matches always take precedence over optional prefix matching

Fixes #17775

---

Maybe we should make certain aspects of this configurable, like the
`['locale', 'lang', 'language']` collection
This updates the TS version we use to 5.8.0.

We still downlevel to 3.8 so this should not be breaking (even if we
were to use newer features eventually), downlevel-dts will fail/or our
tests anyhow if we use some features that cannot be downlevelled.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Upgrade TypeScript to 5.8 across the repo, adjust tsconfigs and deps,
and fix minor type issues to satisfy stricter checks.
> 
> - **Tooling/Versions**:
> - Bump `typescript` to `~5.8.0` and update version guard in
`scripts/verify-packages-versions.js`.
> - Update `yarn.lock` and package constraints; add new e2e app
`dev-packages/e2e-tests/test-applications/generic-ts5.0`.
> - **TS Configs**:
> - Add `moduleResolution: "Node16"` in multiple `tsconfig.json` files
and test configs.
> - Add `@types/node` and include `"node"` in `types` where needed
(e.g., Hydrogen test app).
> - **Type/Code Adjustments**:
> - Remove unnecessary casts and add explicit non-null assertions for
`Map.keys().next().value`.
> - Simplify handler registration (`handlers[type].push(handler)`), and
minor TS cleanups in profiling/LRU/debug-id utilities.
> - Cloudflare/Nuxt/SvelteKit: relax Request typing and use
`@ts-expect-error` for `cf` init property; avoid unused CF type import.
> - Next.js webpack: remove unnecessary non-null assertion when joining
`appDirPath`.
> - Remix: streamline FormData attribute handling and vendor
instrumentation check.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5ec5959. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: s1gr1d <sigrid.huemer@posteo.at>
- Supports providing a `proxy.ts` file for global middleware as
`middleware.ts` will be deprecated with Next.js 16
- Forks Isolation Scope on span start in the edge SDK as we don't wrap
middleware/proxy files anymore when using turbopack
- Adds middleware e2e tests for next-16


closes #17894
This pull request introduces automatic instrumentation for database
queries in Nuxt applications in server side handlers using Sentry.

#### Implementation Details

- Instruments database `.sql`, `.prepare` and `.exec` calls.
- Adds breadcrumbs and spans following cloudflare's D1 implementation.

This relies on the work done in #17858 and #17886
Change to record an outcome when failed to add to replay event buffer
due to size limitations. This also moves up the `internal_sdk_error`
outcome to be recorded before we stop the replay.

Note we use the `buffer_overflow` outcome as it is the closest in
meaning (source
https://github.com/getsentry/snuba/blob/6c73be60716c2fb1c30ca627883207887c733cbd/rust_snuba/src/processors/outcomes.rs#L39)
Got inspired at jsconf to do some dep upgrades.

There are no breaking changes for nodemon that affect us when going from
v2 -> v3: https://github.com/remy/nodemon/releases
Test were failing due to missing value injection, because the bundler
was incorrectly detected.

We can rely on `process.env.TURBOPACK` being set, confirmed this with
Vercel.

So this PR

- simplifies the bundler detection by just checking the env var
- brings back webpack dev tests

closes
https://linear.app/getsentry/issue/FE-618/webpack-breaks-instrumentation-for-dev-mode-in-next-16
…t 16 (#17978)

Updated the logic to determine if the instrumentation hook is required
or not, as this was wrongly set in next.js 16 apps.

closes #17965
[Ember E2E tests
fail](https://github.com/getsentry/sentry-javascript/actions/runs/18656635954/job/53191164591)
with `util.isRegExp is not a function`. Apparently, this is a JSDoc/Node
issue that was already resolved last year:
jsdoc/jsdoc#2126

It is happening since the tests run with Node 24.10.0 instead of
22.20.0. The `isRegExp` API was removed from Node, so I updated the
`clean-css` package as it's mentioned in the error stack. However, it
could be that we either need to update `ember-cli` or just downgrade the
node version for this test.
…17619)

Adds the `trace` lifecycle mode and sends `profile_chunk` envelopes.
Also adds test for either overlapping root spans (one chunk) or single
root spans (multiple chunks).



The "manual" mode comes in another PR to keep this from growing too
large.


 **Browser trace-lifecycle profiler (v2):**
  - Starts when the first sampled root span starts
  - Stops when the last sampled root span ends
- While running, periodically stops and restarts the JS self-profiling
API to collect chunks
 
**Profiles are emitted as standalone `profile_chunk` envelopes either
when:**
  - there are no more sampled root spans, or
  - the 60s chunk timer elapses while profiling is running.
  
  **Handling never-ending root spans**
In the trace lifecycle, profiling continues as long as a root span is
active. To prevent profiling endlessly, each root span has its own
profile timeout and is terminated if it is too long (5 minutes). If
another root span is still active, profiling will continue regardless.
 

part of #17279

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds UI profiling trace lifecycle mode that samples sessions, streams
profile_chunk envelopes, and attaches thread data, with accompanying
tests and type options.
> 
> - **Browser Profiling (UI Profiling v2)**:
> - Add `profileLifecycle: 'trace'` with session sampling via
`profileSessionSampleRate`; defaults lifecycle to `manual` when
unspecified.
> - Stream profiling as `profile_chunk` envelopes; periodic chunking
(60s) and 5‑min root-span timeout.
> - New `BrowserTraceLifecycleProfiler` manages start/stop across root
spans and chunk sending.
> - Attach profiled thread data to events/spans; warn if trace mode
without tracing.
> - **Profiling Utils**:
> - Convert JS self profile to continuous format; validate chunks;
main/worker thread constants; helper to attach thread info.
> - Split legacy logic: `hasLegacyProfiling`, `shouldProfileSpanLegacy`,
`shouldProfileSession`.
> - **Integration Changes**:
> - Browser integration branches between legacy and trace lifecycle;
adds `processEvent` to attach thread data.
>   - Minor fix in `startProfileForSpan` (processed profile handling).
> - **Tests**:
> - Add Playwright suites for trace lifecycle (multiple chunks,
overlapping spans) and adjust legacy tests.
> - Add unit tests for lifecycle behavior, warnings, profiler_id reuse,
and option defaults.
> - **Types/Config**:
> - Extend `BrowserClientProfilingOptions` with
`profileSessionSampleRate` and `profileLifecycle`; refine Node types
docs.
> - Size-limit: add entry for `@sentry/browser` incl. Tracing, Profiling
(48 KB).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
765f89d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
With the relay now handling cache token attributes (instead of scrubbing
them), some Anthropic related token attributes were still missing. This
PR adds the missing cache attributes and corrects the types in the
Anthropic provider metadata used for extracting token data.

Fixes: #17890
I did some benchmarking:
-
#15862 (comment)

```
┌─────────┬─────────────────────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name                               │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼─────────────────────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'crypto.randomUUID()'                   │ '269.64 ± 0.24%' │ '250.00 ± 0.00'  │ '3879372 ± 0.01%'      │ '4000000 ± 0'          │ 3708647 │
│ 1       │ 'crypto.randomUUID().replace(/-/g, "")' │ '445.09 ± 6.08%' │ '417.00 ± 0.00'  │ '2377301 ± 0.01%'      │ '2398082 ± 0'          │ 2246729 │
│ 2       │ 'crypto.getRandomValues()'              │ '32130 ± 9.11%'  │ '28083 ± 834.00' │ '35202 ± 0.07%'        │ '35609 ± 1076'         │ 31124   │
│ 3       │ 'Math.random()'                         │ '1929.0 ± 1.02%' │ '1916.0 ± 42.00' │ '525124 ± 0.01%'       │ '521921 ± 11413'       │ 518396  │
│ 4       │ '@lukeed/uuid'                          │ '273.79 ± 0.07%' │ '250.00 ± 0.00'  │ '3770742 ± 0.01%'      │ '4000000 ± 0'          │ 3652395 │
│ 5       │ '@lukeed/uuid (custom no hyphens)'      │ '262.20 ± 5.68%' │ '250.00 ± 0.00'  │ '4089440 ± 0.01%'      │ '4000000 ± 0'          │ 3813889 │
└─────────┴─────────────────────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
```

I found that in Node.js at least, getting a single byte via
`crypto.getRandomValues()` is 10x slower than the `Math.random()`
version so we should drop `getRandomValues` usage entirely.

I also found that for the `Math.random()` fallback code, we generated
the base starting string (`10000000100040008000100000000000`) on every
call to `uuid4()`. If we cache this value we get a ~20% improvement in
this path.

In the browser `crypto.randomUUID()` is only available in secure
contexts so our fallback code should have good performance too!
@JPeer264 JPeer264 requested a review from andreiborza October 21, 2025 13:16
@JPeer264 JPeer264 requested a review from a team as a code owner October 21, 2025 13:16
@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.63 kB added added
@sentry/browser - with treeshaking flags 23.11 kB added added
@sentry/browser (incl. Tracing) 40.97 kB added added
@sentry/browser (incl. Tracing, Profiling) 45.26 kB added added
@sentry/browser (incl. Tracing, Replay) 79.29 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.97 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 83.99 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 96.16 kB added added
@sentry/browser (incl. Feedback) 41.3 kB added added
@sentry/browser (incl. sendFeedback) 29.29 kB added added
@sentry/browser (incl. FeedbackAsync) 34.22 kB added added
@sentry/react 26.31 kB added added
@sentry/react (incl. Tracing) 42.97 kB added added
@sentry/vue 29.11 kB added added
@sentry/vue (incl. Tracing) 42.75 kB added added
@sentry/svelte 24.64 kB added added
CDN Bundle 26.9 kB added added
CDN Bundle (incl. Tracing) 41.62 kB added added
CDN Bundle (incl. Tracing, Replay) 77.87 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 83.35 kB added added
CDN Bundle - uncompressed 78.86 kB added added
CDN Bundle (incl. Tracing) - uncompressed 123.44 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.48 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251.24 kB added added
@sentry/nextjs (client) 45.11 kB added added
@sentry/sveltekit (client) 41.4 kB added added
@sentry/node-core 50.75 kB added added
@sentry/node 154.44 kB added added
@sentry/node - without tracing 92.61 kB added added
@sentry/aws-serverless 106.33 kB added added

@AbhiPrasad
Copy link
Member

We just had #17982 and #17938 merge in, we should rebase to include those two commits as well.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,889 - - added
GET With Sentry 1,284 14% - added
GET With Sentry (error only) 5,833 66% - added
POST Baseline 1,161 - - added
POST With Sentry 472 41% - added
POST With Sentry (error only) 1,015 87% - added
MYSQL Baseline 3,220 - - added
MYSQL With Sentry 316 10% - added
MYSQL With Sentry (error only) 2,635 82% - added

@JPeer264 JPeer264 force-pushed the prepare-release/10.21.0 branch from 60acd7b to 5bc35a7 Compare October 21, 2025 13:29
@JPeer264
Copy link
Member Author

@AbhiPrasad good catch, I just rebased and added it to the CHANGELOG.

@JPeer264 JPeer264 merged commit 300dce1 into master Oct 21, 2025
374 of 376 checks passed
@JPeer264 JPeer264 deleted the prepare-release/10.21.0 branch October 21, 2025 14:45
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

Successfully merging this pull request may close these issues.