Skip to content

meta: Add CHANGELOG entry for 8.5.0 #12236

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

Merged
merged 27 commits into from
May 27, 2024
Merged

meta: Add CHANGELOG entry for 8.5.0 #12236

merged 27 commits into from
May 27, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented May 27, 2024

No description provided.

github-actions bot and others added 25 commits May 23, 2024 16:13
[Gitflow] Merge master into develop
Noticed we forgot to set this.
…12203)

The action sets up node 18 currently anyway, this doesn't seem to have
any effect.
Closes #12200

From my personal testing everything works with with React 19, so we can
bump the peer dep.

For the new error APIs, there is
#12147, but that PR
is draft while we get feedback from the React team.
#12210)

resolves #12176

Given the test apps are having issues, disable these tests for now.
Based on the great feedback in
#12191, this
does some small adjustments to ensure that you actually can use the Node
SDK properly with a custom OTEL setup:

## 1. Ensure we do not run `validateOpenTelemetrySetup()` when
`skipOpenTelemetrySetup` is configured.

Today, this is impossible to fix because you need a client to create the
sampler, and you need the sampler to satisfy the validation, but the
validation runs in `init()`. So either you call init() before doing your
manual setup, which means you get the warning, or you do the manual
setup first, but then you can't actually add the sampler, and still get
the warning.

This change means that users that configure `skipOpenTelemetrySetup` can
manually call `Sentry.validateOpenTelemetrySetup()` if they want to get
the validation, else there will be no validation automtically.

## 2. Export `SentryContextManager` from `@sentry/node`

This is easier to use than to use the primitive
`wrapContextManagerClass` from `@sentry/opentelemetry`.

## 3. Ensure we always run `setupEventContextTrace`, not tied to
`skipOpenTelemetrySetup`

There is no reason to tie this together, this now just always runs in
`init()` - it's just an event processor!
This allows to pass a custom scope to `Sentry.captureFeedback()`, like
this:

```js
Sentry.captureFeedback({message : 'test' }, {}, scope);
```

This should fix the use case from
#11072 (comment)
Add a new `Sentry.startNewTrace` function that allows users to
start a trace in isolation of a potentially still active trace. When
this function is called, a new trace will be started on a forked scope
which remains valid throughout the callback lifetime.
This PR adds a new way to initialize `@sentry/node`, which allows to use
the SDK with performance instrumentation even if you cannot (for
whatever reason) call `Sentry.init()` at the very start of your app.

## CJS usage

In CommonJS mode, you can run the SDK like this:

```bash
node --require @sentry/node/preload ./app.js
```

```js
// app.js
const express = require('express');
const Sentry = require('@sentry/node');

const dsn = await getSentryDsn();
Sentry.init({ dsn });

// express is instrumented even though we initialized Sentry late
```

## ESM usage

in ESM mode, you can run the SDK like this:

```bash
node --import @sentry/node/preload ./app.mjs
```

```js
// app.mjs
import express from 'express';
import * as Sentry from '@sentry/node';

const dsn = await getSentryDsn();
Sentry.init({ dsn });

// express is instrumented even though we initialized Sentry late
```

## Configuration options

This script will by default preload all opentelemetry instrumentation.
You can choose to instrument only specific packages like this:

```bash
SENTRY_PRELOAD_INTEGRATIONS="Http,Express,Graphql" --import @sentry/node/preload ./app.mjs
```

You can also enable debug logging for the script via
`SENTRY_DEBUG=true`.

## Manually preloading

It is also possible to manually call `preloadOpenTelemetry()` to achieve
the same thing. For example, in a CJS app you could do the following
thing if you want to initialize late but don't want to use `--require`:

```js
// preload.js
const Sentry = require('@sentry/node');
Sentry.preloadOpenTelemetry();

// app.js
// call this first, before any other requires!
require('./preload.js');
// Then, other stuff
const express = require('express');
const Sentry = require('@sentry/node');

const dsn = await getSentryDsn();
Sentry.init({ dsn });
```
We had no entry covering the bundle size of metrics so far.
…bda layer bundle (#12232)

FIx one of the two issues that currently cause our lambda
layer to break. When we build the lambda layer bundle we applied
minification via our terser plugin which mangles `_`-prefixed private
variables - like `Module._resolveFilename`. This patch adds the method
to the list of excluded `_`-prefixed symbols.
Closes #12223

I've added a test that uses `import-in-the-middle` to throw if
`inspector` is imported without enabling the `LocalVariables`
integration so this should not regress in the future.

Note that we don't need to import asynchronously in the worker scripts
since these are not evaluated if the features aren't used.
…ddle` (#12233)

Our lambda layer relies on one bundled Sentry SDK, which caused problems
raised in #12089 and
#12009 (comment).
Specifically, by bundling `import-in-the-middle` code into one file, it
seems like the library's way of declaring its exports conflict, causing
the "ImportInTheMiddle is not a constructor" error to be thrown. While
this should ideally be fixed soon in `import-in-the-middle`, for now
this patch adds a small Rollup plugin to transform `new
ImportInTheMiddle(...)` calls to `new ImportInTheMiddle.default(...)` to
our AWS Lambda Layer bundle config.
Make our check for when we abort and log an error due to
`Sentry.init` being used in a browser extension a bit more fine-gained.
In particular, we now do not abort the SDK initialization if we detect
that the SDK is running in a browser-extension dedicated window (e.g. a
URL starting with `chrome-extension://`).
CHANGELOG.md Outdated
```

For a detailed guide, head over to our
[Sentry Node SDK documentation](https://docs.sentry.io/platforms/javascript/guides/node/)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs aren't merged yet but we can edit the link in the GH release once they are merged

@Lms24 Lms24 requested review from a team, stephanie-anderson and lforst and removed request for a team May 27, 2024 14:19
@Lms24 Lms24 requested review from mydea and andreiborza and removed request for stephanie-anderson May 27, 2024 14:19
@Lms24 Lms24 force-pushed the prepare-release/8.5.0 branch from 77d8f89 to 82728b0 Compare May 27, 2024 14:20
@Lms24 Lms24 changed the base branch from develop to master May 27, 2024 15:16
@Lms24 Lms24 requested review from a team as code owners May 27, 2024 15:16
Metrics are only included when performance is included, reducing the
base bundle size.

We always expose a shim so there is no API breakage, it just does
nothing.

I noticed this while working on
#12226.
First, run the SDK like this:

```bash
node --require @sentry/node/preload ./app.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
node --require @sentry/node/preload ./app.js
node --import @sentry/node/preload ./app.mjs

not 100% sure, should we use the cjs or esm example here? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess CJS is probably fine, thinking about this... so disregard this comment I guess!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I asked myself the same thing 😅 I guess CJS is still used more frequently so... 🤷
Basically I wanted to add a small snippet to show the use case but not copy the entire PR description.

@Lms24 Lms24 changed the base branch from master to develop May 27, 2024 15:27
@Lms24 Lms24 force-pushed the prepare-release/8.5.0 branch from 82728b0 to 5ff736c Compare May 27, 2024 15:29
@Lms24 Lms24 force-pushed the prepare-release/8.5.0 branch from 5ff736c to f32f88d Compare May 27, 2024 15:37
@Lms24 Lms24 changed the base branch from develop to master May 27, 2024 15:41
@Lms24 Lms24 merged commit 27a47f2 into master May 27, 2024
28 checks passed
@Lms24 Lms24 deleted the prepare-release/8.5.0 branch May 27, 2024 15:41
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.

5 participants