Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Beyond errors and performance transactions, the testkit captures a range of Sent

- **Errors** — `testkit.reports()` returns all captured error reports. Each report also exposes any evaluated feature flags via `report.flags`.
- **Transactions** — `testkit.transactions()` returns all captured performance transactions.
- **Structured logs** — `testkit.logs()` returns captured logs (requires `enableLogs: true` in your Sentry configuration).
- **Structured logs** — `testkit.logs()` returns captured logs (on SDK versions below `10.71.0`, requires `enableLogs: true` in your Sentry configuration).
- **User feedback** — `testkit.feedback()` returns submitted user feedback.
- **Cron check-ins** — `testkit.checkIns()` returns cron monitor check-ins with their status.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ _Import name: `Sentry.pinoIntegration`_

The `pinoIntegration` adds instrumentation for the `pino` library so that calls to the pino logger are captured as logs. Optionally, you can capture calls to the pino logger as errors.

<Alert>
On SDK versions below `10.71.0`, you must also set `enableLogs: true` in your
`Sentry.init` to send logs.
</Alert>

```JavaScript
Sentry.init({
enableLogs: true,
integrations: [Sentry.pinoIntegration()],
});
```
Expand Down Expand Up @@ -72,7 +76,7 @@ Configure how pino logs are captured as Sentry logs.
- Type: `Array<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'>`
- Default: `["trace", "debug", "info", "warn", "error", "fatal"]`

Levels that trigger capturing of logs. Logs are only captured if `enableLogs` is enabled in your Sentry configuration.
Levels that trigger capturing of logs.

## Supported Versions

Expand All @@ -84,7 +88,6 @@ Levels that trigger capturing of logs. Logs are only captured if `enableLogs` is

```js
Sentry.init({
enableLogs: true,
integrations: [
Sentry.pinoIntegration({ log: { levels: ["info", "warn", "error"] } }),
],
Expand All @@ -95,7 +98,6 @@ Sentry.init({

```js
Sentry.init({
enableLogs: true,
integrations: [
Sentry.pinoIntegration({ error: { levels: ["warn", "error"] } }),
],
Expand Down
44 changes: 25 additions & 19 deletions docs/platforms/javascript/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,28 @@ Sentry.init({
```

Data you set explicitly (for example, via <PlatformLink to="/apis/#setUser">`Sentry.setUser()`</PlatformLink>) is always sent, regardless of `dataCollection`.

</Alert>

</SdkOption>

<SdkOption name="dataCollection" type='DataCollection' availableSince="10.57.0">

Controls which categories of data the SDK collects automatically. All fields are optional.
By default the SDK collects rich debugging context (including user identity, request/response bodies, and generative AI content) and scrubs values whose keys match the built-in sensitive denylist (`auth`, `token`, `password`, and similar).
By default the SDK collects rich debugging context (including user identity, request/response bodies, and generative AI content) and scrubs values whose keys match the built-in sensitive denylist (`auth`, `token`, `password`, and similar).

For more on what data Sentry collects and how to control it, see <PlatformLink to="/data-management/">Data Management</PlatformLink>.

| Key | Type | Default | Description |
| --------------------- | ---------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `userInfo` | `boolean` | `true` | Populate `user.*` fields (`id`, `email`, `username`, `ip_address`) from instrumentation. |
| `cookies` | `CollectBehavior` | `true` | Collect cookies. |
| `httpHeaders` | `{ request?, response? }` | both `true`| Collect HTTP request and response headers. |
| `httpBodies` | `HttpBodyCollectionTarget[]` | all types | Body types to collect: `"incomingRequest"`, `"outgoingRequest"`, `"incomingResponse"`, `"outgoingResponse"`. Set to `[]` to disable. |
| `urlQueryParams` | `CollectBehavior` | `true` | Collect URL query parameters. |
| `genAI` | `{ inputs?, outputs? }` | both `true`| Collect generative AI input/output content. Metadata is always collected. |
| `stackFrameVariables` | `boolean` | `true` | Capture local variable values in stack frames. |
| `frameContextLines` | `number` | `5` | Source code lines captured around each stack frame. |
| Key | Type | Default | Description |
| --------------------- | ---------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `userInfo` | `boolean` | `true` | Populate `user.*` fields (`id`, `email`, `username`, `ip_address`) from instrumentation. |
| `cookies` | `CollectBehavior` | `true` | Collect cookies. |
| `httpHeaders` | `{ request?, response? }` | both `true` | Collect HTTP request and response headers. |
| `httpBodies` | `HttpBodyCollectionTarget[]` | all types | Body types to collect: `"incomingRequest"`, `"outgoingRequest"`, `"incomingResponse"`, `"outgoingResponse"`. Set to `[]` to disable. |
| `urlQueryParams` | `CollectBehavior` | `true` | Collect URL query parameters. |
| `genAI` | `{ inputs?, outputs? }` | both `true` | Collect generative AI input/output content. Metadata is always collected. |
| `stackFrameVariables` | `boolean` | `true` | Capture local variable values in stack frames. |
| `frameContextLines` | `number` | `5` | Source code lines captured around each stack frame. |

The `cookies`, `httpHeaders`, and `urlQueryParams` categories accept a `CollectBehavior` value:

Expand Down Expand Up @@ -752,9 +753,14 @@ Instead, <PlatformLink to="/tracing/streamed-spans">enable stream mode</Platform
are set.
</PlatformSection>

<SdkOption name="enableLogs" type='boolean' defaultValue='false'>
<SdkOption name="enableLogs" type='boolean' defaultValue='true'>

Controls whether the `logger` APIs send logs to Sentry. Logs are captured by default. Set this option to `false` to disable log capturing.

Set this option to `true` to enable log capturing in Sentry. Only when this is enabled will the `logger` APIs actually send logs to Sentry.
<Alert>
In SDK versions below `10.71.0`, this option defaults to `false`. On those
versions, you must set `enableLogs: true` to send logs to Sentry.
</Alert>

</SdkOption>

Expand All @@ -767,8 +773,8 @@ This function is called with a log object, and can return a modified log object,
## Metrics Options

<PlatformSection supported={["javascript.electron"]}>
**Note:** For Electron, metric options apply to the process where these options
are set.
**Note:** For Electron, metric options apply to the process where these
options are set.
</PlatformSection>

<SdkOption name="enableMetrics" type='boolean' defaultValue='true'>
Expand Down Expand Up @@ -809,8 +815,8 @@ The sample rate for replays that are recorded when an error happens. This type o

<SdkOption name="profileSessionSampleRate" type='number' availableSince="7.4.0" defaultValue="0">

A number between `0` and `1` that sets the percentage of how many sessions should have profiling enabled. `1.0` enables profiling in every session, `0.5` enables profiling for 50% of the sessions, and `0` enables it for none.
The sampling decision is made once at the beginning of a session.
A number between `0` and `1` that sets the percentage of how many sessions should have profiling enabled. `1.0` enables profiling in every session, `0.5` enables profiling for 50% of the sessions, and `0` enables it for none.
The sampling decision is made once at the beginning of a session.
This option is required to enable profiling (default is `0`).

</SdkOption>
Expand Down Expand Up @@ -838,8 +844,8 @@ A number between `0` and `1`, controlling the percentage chance a given sampled

<SdkOption name="profileSessionSampleRate" type='number' availableSince="10.27.0" defaultValue="0">

A number between `0` and `1` that sets the percentage of how many sessions should have profiling enabled. `1.0` enables profiling in every session, `0.5` enables profiling for 50% of the sessions, and `0` enables it for none.
The sampling decision is made once at the beginning of a session.
A number between `0` and `1` that sets the percentage of how many sessions should have profiling enabled. `1.0` enables profiling in every session, `0.5` enables profiling for 50% of the sessions, and `0` enables it for none.
The sampling decision is made once at the beginning of a session.
This option is required to enable profiling (default is `0`).

<PlatformCategorySection categorySupported={["server", "serverless"]}>
Expand Down
5 changes: 2 additions & 3 deletions docs/platforms/javascript/common/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Select which Sentry features you'd like to install in addition to Error Monitori
"performance",
"session-replay",
"user-feedback",
"logs",
]}
/>
</PlatformSection>
Expand All @@ -73,7 +72,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
<PlatformCategorySection notSupported={["browser"]}>
<PlatformSection notSupported={["javascript.bun"]}>
<OnboardingOptionButtons
options={["error-monitoring", "performance", "profiling", "logs"]}
options={["error-monitoring", "performance", "profiling"]}
/>
</PlatformSection>

Expand All @@ -82,7 +81,7 @@ In addition to capturing errors, you can monitor interactions between multiple s
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

<PlatformSection supported={["javascript.bun"]}>
<OnboardingOptionButtons options={["error-monitoring", "performance", "logs"]} />
<OnboardingOptionButtons options={["error-monitoring", "performance"]} />
</PlatformSection>
</PlatformCategorySection>

Expand Down
63 changes: 53 additions & 10 deletions docs/platforms/javascript/common/logs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ notSupported:

<PlatformContent includePath="llm-rules-logs" />

Stack traces tell you *what* broke. Logs tell you *why*. When an error fires, you get a snapshot of the failure, but the context leading up to it is often missing. Logs capture the journey — what the data looked like, which code paths executed, and what state the system was in.
Stack traces tell you _what_ broke. Logs tell you _why_. When an error fires, you get a snapshot of the failure, but the context leading up to it is often missing. Logs capture the journey — what the data looked like, which code paths executed, and what state the system was in.

Sentry Logs are **high-cardinality** — you can pass any attributes you want and search or filter by them later. No need to decide upfront which fields are important. Just log what might be useful and query it when you need it.

Expand All @@ -23,15 +23,14 @@ Sentry Logs are **high-cardinality** — you can pass any attributes you want an

## Setup

Enable logging by adding `enableLogs: true` to your Sentry configuration.
Logs are enabled by default. Just initialize the SDK and use `Sentry.logger` to send logs.

</SplitSectionText>
<SplitSectionCode>

```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",
enableLogs: true,
});
```

Expand Down Expand Up @@ -184,7 +183,6 @@ The log object includes: `level`, `message`, `timestamp`, and `attributes`.
```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",
enableLogs: true,
beforeSendLog: (log) => {
// Drop debug logs in production
if (log.level === "debug") {
Expand All @@ -211,7 +209,28 @@ Sentry.init({
Everything in Sentry is linked by trace. When you're viewing a log, you can jump to the parent trace to see the full request context. When you're viewing a trace, you can see all logs emitted during that operation. This connection makes it easy to move between high-level performance data and detailed diagnostic logs.

- **[Traces](/product/trace-explorer/)** — Logs emitted during an active span automatically include `sentry.trace.parent_span_id`. Click through from any log to see the full trace, or filter logs by trace ID to see everything that happened during a specific request.
- <PlatformSection notSupported={["javascript.node", "javascript.aws-lambda", "javascript.azure-functions", "javascript.connect", "javascript.express", "javascript.fastify", "javascript.gcp-functions", "javascript.hapi", "javascript.hono", "javascript.koa", "javascript.nestjs", "javascript.nitro", "javascript.bun", "javascript.cloudflare"]}>**[Session Replay](/product/session-replay/)** — Logs include `sentry.replay_id` when a replay is active. Jump from a log entry directly to the replay to see what the user was doing when the log was emitted.</PlatformSection>
- <PlatformSection
notSupported={[
"javascript.node",
"javascript.aws-lambda",
"javascript.azure-functions",
"javascript.connect",
"javascript.express",
"javascript.fastify",
"javascript.gcp-functions",
"javascript.hapi",
"javascript.hono",
"javascript.koa",
"javascript.nestjs",
"javascript.nitro",
"javascript.bun",
"javascript.cloudflare",
]}
>
**[Session Replay](/product/session-replay/)** — Logs include
`sentry.replay_id` when a replay is active. Jump from a log entry directly
to the replay to see what the user was doing when the log was emitted.
</PlatformSection>
- **[Errors](/product/issues/)** — Logs capture the journey leading up to a failure. When an error occurs, your logs show what data was processed, which code paths executed, and what state the system was in — context that stack traces alone can't provide.

## Best Practices
Expand All @@ -226,10 +245,34 @@ Everything in Sentry is linked by trace. When you're viewing a log, you can jump

Any attributes set via `Sentry.setAttribute()` / `Sentry.setAttributes()` (or directly on a scope) are automatically included on all logs. `Sentry.setAttribute(s)` requires SDK version `10.61.0` or above. See [Attributes](#shared-attributes) above for details.


## Related Features

- <PlatformLink to="/tracing/">Tracing</PlatformLink> — Logs are automatically linked to traces, so you can see logs in the context of the request or operation that produced them.
- <PlatformSection notSupported={["javascript.node", "javascript.aws-lambda", "javascript.azure-functions", "javascript.connect", "javascript.express", "javascript.fastify", "javascript.gcp-functions", "javascript.hapi", "javascript.hono", "javascript.koa", "javascript.nestjs", "javascript.nitro", "javascript.bun", "javascript.cloudflare"]}><PlatformLink to="/session-replay/">Session Replay</PlatformLink> — Logs are automatically linked to replays, letting you jump from a log entry to see what the user was doing.</PlatformSection>
- <PlatformLink to="/usage/">Error Monitoring</PlatformLink> — Use logs to add diagnostic context that helps you understand what led to an error.
- <PlatformLink to="/enriching-events/attributes/">Attributes</PlatformLink> — Set attributes once and have them automatically included on all your logs.
- <PlatformLink to="/tracing/">Tracing</PlatformLink> — Logs are automatically
linked to traces, so you can see logs in the context of the request or
operation that produced them.
- <PlatformSection
notSupported={[
"javascript.node",
"javascript.aws-lambda",
"javascript.azure-functions",
"javascript.connect",
"javascript.express",
"javascript.fastify",
"javascript.gcp-functions",
"javascript.hapi",
"javascript.hono",
"javascript.koa",
"javascript.nestjs",
"javascript.nitro",
"javascript.bun",
"javascript.cloudflare",
]}
>
<PlatformLink to="/session-replay/">Session Replay</PlatformLink> — Logs are
automatically linked to replays, letting you jump from a log entry to see
what the user was doing.
</PlatformSection>
- <PlatformLink to="/usage/">Error Monitoring</PlatformLink> — Use logs to add
diagnostic context that helps you understand what led to an error.
- <PlatformLink to="/enriching-events/attributes/">Attributes</PlatformLink> —
Set attributes once and have them automatically included on all your logs.
11 changes: 0 additions & 11 deletions docs/platforms/javascript/guides/angular/manual-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ Choose the features you want to configure, and this guide will show you how:
"performance",
"session-replay",
"user-feedback",
"logs",
]}
/>

Expand Down Expand Up @@ -164,11 +163,6 @@ Sentry.init({
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ session-replay
// ___PRODUCT_OPTION_START___ logs

// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs
});

bootstrapApplication(AppComponent, appConfig).catch((err) =>
Expand Down Expand Up @@ -232,11 +226,6 @@ Sentry.init({
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ session-replay
// ___PRODUCT_OPTION_START___ logs

// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs
});

platformBrowserDynamic()
Expand Down
1 change: 0 additions & 1 deletion docs/platforms/javascript/guides/astro/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Choose the features you want to configure, and this guide will show you how:
"profiling",
"session-replay",
"user-feedback",
"logs",
]}
/>

Expand Down
7 changes: 1 addition & 6 deletions docs/platforms/javascript/guides/azure-functions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ categories:
Choose the features you want to configure, and this guide will show you how:

<OnboardingOptionButtons
options={["error-monitoring", "performance", "profiling", "logs"]}
options={["error-monitoring", "performance", "profiling"]}
/>

<Include name="quick-start-features-expandable" />
Expand Down Expand Up @@ -86,11 +86,6 @@ Sentry.init({
// https://docs.sentry.io/platforms/javascript/configuration/options/#profileSessionSampleRate
profileSessionSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ profiling
// ___PRODUCT_OPTION_START___ logs

// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs
});

// your function code
Expand Down
9 changes: 1 addition & 8 deletions docs/platforms/javascript/guides/bun/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ categories:

Choose the features you want to configure, and this guide will show you how:

<OnboardingOptionButtons
options={["error-monitoring", "performance", "logs"]}
/>
<OnboardingOptionButtons options={["error-monitoring", "performance"]} />

<Include name="quick-start-features-expandable" />

Expand Down Expand Up @@ -78,11 +76,6 @@ Sentry.init({
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ performance
// ___PRODUCT_OPTION_START___ logs

// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs
});
```

Expand Down
Loading
Loading