Skip to content

Commit 3887c43

Browse files
committed
Merge branch 'master' into byk/ci/mdx-cache
2 parents 08df8fc + 5d39d73 commit 3887c43

File tree

15 files changed

+444
-28
lines changed

15 files changed

+444
-28
lines changed

docs/platforms/dotnet/common/configuration/options.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,17 @@ Broadly, the ExecutionContext passes to child tasks and threads, but not to pare
5555

5656
When Global Mode is **enabled**, a single scope stack is shared by the whole application.
5757

58+
<Alert title="💡 Note">
59+
5860
Since version 5.0.0 the transaction is always set on the current ExecutionContext, regardless of the Global Mode, so that spans from the UI don't get mixed up with transactions in background services.
5961

60-
See the <PlatformLink to="/enriching-events/scopes/">Scopes and Hubs documentation</PlatformLink> for more information.
62+
There may be situations in which this isn't what you want. For example, you could start a transaction and then run multiple tasks in parallel, each of which makes an HTTP Request. By default, Sentry's <PlatformLink to="/tracing/instrumentation/automatic-instrumentation/">Automatic Instrumentation</PlatformLink> will create spans as children of the transaction it finds stored in `Scope.Transaction` (which is now ExecutionContext specific, even in Global Mode).
63+
64+
You can override this behavior and force auto-instrumented spans to have a specific parent by setting `Scope.Span`. [An example of doing this](https://github.com/getsentry/symbol-collector/blob/8a0fdb2594c3028f63f180b9b56b1efea1cbce34/src/SymbolCollector.Core/Client.cs#L74-L83) can be found in the Symbol Collector.
6165

66+
</Alert>
67+
68+
See the <PlatformLink to="/enriching-events/scopes/">Scopes and Hubs documentation</PlatformLink> for more information.
6269

6370
</ConfigKey>
6471

docs/platforms/go/guides/logrus/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ For a quick reference, there is a [complete example](https://github.com/getsentr
77

88
Go API documentation for the [`sentrylogrus` package](https://pkg.go.dev/github.com/getsentry/sentry-go/logrus) is also available.
99

10+
## Requirements
11+
12+
Logrus structured logging is supported in Sentry Go SDK version `0.34.0` and above.
13+
1014
## Install
1115

1216
```bash

docs/platforms/go/guides/slog/index.mdx

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ For a quick reference, there is a [complete example](https://github.com/getsentr
77

88
Go API documentation for the [`sentryslog` package](https://pkg.go.dev/github.com/getsentry/sentry-go/slog) is also available.
99

10+
## Requirements
11+
12+
Slog structured logging is supported in Sentry Go SDK version `0.34.0` and above.
13+
1014
## Install
1115

1216
```bash
@@ -21,6 +25,7 @@ To integrate Sentry with slog, you need to set up a Sentry handler and configure
2125

2226
```go
2327
import (
28+
"context"
2429
"fmt"
2530
"log"
2631
"time"
@@ -49,8 +54,8 @@ func main() {
4954
// Configure `slog` to use Sentry as a handler
5055
ctx := context.Background()
5156
handler := sentryslog.Option{
52-
EventLevel: []slog.Level{slog.LevelError, sentryslog.LevelFatal}, // Only Error and Fatal as events
53-
LogLevel: []slog.Level{slog.LevelWarn, slog.LevelInfo}, // Only Warn and Info as logs
57+
EventLevel: []slog.Level{slog.LevelError}, // Only Error level will be sent as events
58+
LogLevel: []slog.Level{slog.LevelWarn, slog.LevelInfo}, // Only Warn and Info levels will be sent as logs
5459
}.NewSentryHandler(ctx)
5560
logger := slog.New(handler)
5661
logger = logger.With("release", "v1.0.0")
@@ -110,27 +115,40 @@ Sentry allows you to send logs either as log entries or as events. The minimum l
110115
### Example: Sending Logs as Events
111116

112117
```go
113-
logger := slog.New(sentryslog.Options
114-
EventLevel: []slog.Level{slog.LevelError, sentryslog.LevelFatal},
118+
ctx := context.Background()
119+
logger := slog.New(sentryslog.Option{
120+
// specify all event levels
121+
EventLevel: []slog.Level{
122+
slog.LevelDebug,
123+
slog.LevelInfo,
124+
slog.LevelWarn,
125+
slog.LevelError,
126+
},
115127
LogLevel: []slog.Level{}, // disable log entries
116128
AttrFromContext: []func(ctx context.Context) []slog.Attr{
117129
func(ctx context.Context) []slog.Attr {
118130
return []slog.Attr{slog.String("request_id", "123")}
119131
},
120132
},
121-
}.NewSentryHandler())
133+
}.NewSentryHandler(ctx))
122134

123135
logger.Error("This log is sent as an event")
124136
```
125137

126138
### Example: Sending Logs as Logs
127139

128140
```go
129-
logger := slog.New(sentryslog.Options{
130-
EventLevel: []slog.Level{}, // disable events
131-
LogLevel: []slog.Level{slog.LevelError},
132-
},
133-
}.NewSentryHandler())
141+
ctx := context.Background()
142+
logger := slog.New(sentryslog.Option{
143+
EventLevel: []slog.Level{}, // disable events
144+
// specify all log levels
145+
LogLevel: []slog.Level{
146+
slog.LevelDebug,
147+
slog.LevelInfo,
148+
slog.LevelWarn,
149+
slog.LevelError,
150+
},
151+
}.NewSentryHandler(ctx))
134152

135153
logger.Error("This log is sent as a log")
136154
```
@@ -154,14 +172,16 @@ func myAsyncHandler(w http.ResponseWriter, r *http.Request) {
154172
// The sentryhttp middleware adds a Hub with transaction information to the request context.
155173
ctx := r.Context()
156174
// By using InfoContext, the log entry will be associated with the transaction from the request.
157-
logger.InfoContext(ctx, "Log inside handler")
175+
slog.InfoContext(ctx, "Log inside handler")
158176
w.WriteHeader(http.StatusOK)
159177
fmt.Fprintln(w, "Handler finished, async task running in background.")
160178
}
161179

162-
// Wrap your handler with sentryhttp to automatically start transactions for requests.
163-
sentryHandler := sentryhttp.New(sentryhttp.Options{})
164-
http.Handle("/async", sentryHandler.Handle(http.HandlerFunc(myAsyncHandler)))
180+
func main() {
181+
// Wrap your handler with sentryhttp to automatically start transactions for requests.
182+
sentryHandler := sentryhttp.New(sentryhttp.Options{})
183+
http.Handle("/async", sentryHandler.Handle(http.HandlerFunc(myAsyncHandler)))
184+
}
165185
```
166186

167187
Note: Ensure Sentry is flushed before the application exits to avoid losing any pending events.

docs/platforms/javascript/common/session-replay/troubleshooting.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,25 @@ Clicks in replays can appear in the incorrect location due to rendering differen
181181

182182
Text masking of variable-width fonts can also cause this because the size of the masking text ("*") will not necessarily have the same dimensions as the original character it replaced. There is currently no workaround; please [follow this GitHub Issue](https://github.com/getsentry/sentry-javascript/issues/15449) for updates.
183183
</Expandable>
184+
185+
<Expandable title="I'm not receiving any replays" permalink>
186+
187+
If you're not receiving any Session Replay data, it's likely due to Content Security Policy (CSP) restrictions. This can happen in any application that explicitly sets CSP values. The Session Replay integration uses web workers to process replay data, which requires specific CSP permissions.
188+
189+
To resolve this issue, make sure to include `worker-src 'self' blob:` in your `Content-Security-Policy` header or meta tag. This directive allows the integration to create and use web workers from the same origin (`'self'`) and from blob URLs (`blob:`), which are necessary for the replay functionality to work properly.
190+
191+
For example, if you're setting the CSP via a meta tag:
192+
193+
```html
194+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; worker-src 'self' blob:; ...">
195+
```
196+
197+
Or if you're setting it via an HTTP header:
198+
199+
```
200+
Content-Security-Policy: default-src 'self'; worker-src 'self' blob:; ...
201+
```
202+
203+
Without the proper `worker-src` directive, the browser will block the web worker creation, preventing Session Replay from functioning correctly in your application.
204+
205+
</Expandable>
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
title: Wrangler
3+
description: "Upload your Cloudflare Workers source maps using Wrangler and Sentry CLI."
4+
sidebar_order: 10
5+
supported:
6+
- javascript.cloudflare
7+
---
8+
9+
10+
<Include name="debug-id-requirement.mdx" />
11+
12+
<Alert level="info">
13+
14+
This guide is specifically for Cloudflare Workers using Wrangler. For other build tools like Vite with Cloudflare, use the corresponding Vite guide instead.
15+
16+
We recommend using Vite to build your worker for an easier and more reliable setup. Learn more about [Cloudflare's Vite setup](https://developers.cloudflare.com/workers/vite-plugin/get-started/).
17+
18+
</Alert>
19+
20+
## Automatic Setup
21+
22+
The easiest way to configure source map uploading with Wrangler is by using the Sentry Wizard:
23+
24+
<Include name="sourcemaps-wizard-instructions.mdx" />
25+
26+
If you'd rather configure source maps manually, follow the steps below.
27+
28+
## Manual Setup
29+
30+
### 1. Install Sentry CLI
31+
32+
First, install Sentry CLI as a dev dependency:
33+
34+
```bash {tabTitle:npm}
35+
npm install --save-dev @sentry/cli
36+
```
37+
38+
```bash {tabTitle:yarn}
39+
yarn add --dev @sentry/cli
40+
```
41+
42+
```bash {tabTitle:pnpm}
43+
pnpm add --save-dev @sentry/cli
44+
```
45+
46+
### 2. Configure Sentry CLI
47+
48+
For more info on `sentry-cli` configuration visit the [Sentry CLI configuration docs](/cli/configuration/).
49+
50+
Make sure `sentry-cli` is configured for your project. For that you can use environment variables:
51+
52+
```bash {filename:.env.local}
53+
SENTRY_ORG=example-org
54+
SENTRY_PROJECT=example-project
55+
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE
56+
```
57+
58+
### 3. Modify Your Deploy Script
59+
60+
Update your Wrangler deploy script in `package.json` to include the necessary flags for source map generation and upload:
61+
62+
```json {filename:package.json}
63+
{
64+
"scripts": {
65+
"deploy": "wrangler deploy --outdir dist --upload-source-maps --var SENTRY_RELEASE:$(sentry-cli releases propose-version)"
66+
}
67+
}
68+
```
69+
70+
The key flags are:
71+
72+
- `--outdir dist`: Specifies the output directory where source maps will be generated
73+
- `--upload-source-maps`: Forces Wrangler to generate source maps
74+
- `--var SENTRY_RELEASE:$(sentry-cli releases propose-version)`: Injects the release version as an environment variable
75+
76+
### 4. Create a Source Map Upload Script
77+
78+
Add a script to upload source maps to Sentry in your `package.json`:
79+
80+
```json {filename:package.json}
81+
{
82+
"scripts": {
83+
"sentry:sourcemaps": "_SENTRY_RELEASE=$(sentry-cli releases propose-version) && sentry-cli releases new $_SENTRY_RELEASE --org=your-org --project=your-project && sentry-cli sourcemaps upload --org=your-org --project=your-project --release=$_SENTRY_RELEASE --strip-prefix 'dist/..' dist"
84+
}
85+
}
86+
```
87+
88+
Replace `your-org` and `your-project` with your actual Sentry organization and project slugs.
89+
90+
### 5. Add a Post-Deploy Hook
91+
92+
Create a post-deploy script that automatically uploads source maps after deployment:
93+
94+
```json {filename:package.json}
95+
{
96+
"scripts": {
97+
"deploy": "wrangler deploy --outdir dist --upload-source-maps --var SENTRY_RELEASE:$(sentry-cli releases propose-version)",
98+
"postdeploy": "npm run sentry:sourcemaps"
99+
}
100+
}
101+
```
102+
103+
This ensures that source maps are uploaded to Sentry immediately after a successful deployment.
104+
105+
### 6. Configure Your Sentry SDK
106+
107+
Make sure your Sentry SDK configuration includes the release information:
108+
109+
```typescript {filename:index.ts}
110+
import * as Sentry from "@sentry/cloudflare";
111+
112+
export default Sentry.withSentry(
113+
(env: Env) => ({
114+
dsn: "YOUR_DSN_HERE",
115+
// The release name should match what's used during source map upload
116+
release: env.SENTRY_RELEASE,
117+
// other options...
118+
}),
119+
{
120+
async fetch(request, env, ctx) {
121+
// Your worker logic here
122+
return new Response("Hello World!");
123+
},
124+
} satisfies ExportedHandler<Env>
125+
);
126+
```
127+
128+
### 7. Deploy Your Application
129+
130+
Run your deploy command:
131+
132+
```bash
133+
npm run deploy
134+
```
135+
136+
This will:
137+
138+
1. Build your worker with source maps enabled
139+
2. Deploy to Cloudflare with the release version injected
140+
3. Automatically upload source maps to Sentry via the post-deploy hook
141+
142+
### 8. Verify Source Maps Upload
143+
144+
You can verify that your source maps were uploaded successfully by:
145+
146+
1. Going to **Project Settings > Source Maps** in Sentry
147+
2. Checking for your release in the "Artifact Bundles" tab
148+
3. Confirming that source maps are working by triggering an error and checking that the stack trace shows your original source code
149+
150+
## Troubleshooting
151+
152+
### Source Maps Not Working
153+
154+
If your source maps aren't working as expected:
155+
156+
1. Verify that the `SENTRY_RELEASE` environment variable is being set correctly in your worker
157+
2. Check that the release name in your Sentry SDK configuration matches the one used during upload
158+
3. Ensure that source maps are being generated in the specified `--outdir`
159+
160+
### Build Errors
161+
162+
If you encounter build errors when adding source map flags:
163+
164+
1. Make sure you're using Wrangler `3.x` or above
165+
2. Verify that your project structure supports the `--outdir` flag
166+
3. Consider switching to Vite for a more robust build pipeline
167+
168+
## Additional Resources
169+
170+
- [Cloudflare Wrangler Documentation](https://developers.cloudflare.com/workers/wrangler/)
171+
- [Cloudflare Vite Plugin](https://developers.cloudflare.com/workers/vite-plugin/get-started/)
172+
- [Using sentry-cli to Upload Source Maps](/cli/releases/#sentry-cli-sourcemaps)

docs/platforms/python/integrations/index.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
3838

3939
### AI
4040

41-
| | **Auto-enabled** |
42-
| ------------------------------------------------------------------------------------------------------------------------------------ | :--------------: |
43-
| <LinkWithPlatformIcon platform="anthropic" label="Anthropic" url="/platforms/python/integrations/anthropic" /> ||
44-
| <LinkWithPlatformIcon platform="huggingface" label="Huggingface Hub" url="/platforms/python/integrations/huggingface_hub" /> ||
45-
| <LinkWithPlatformIcon platform="langchain" label="Langchain" url="/platforms/python/integrations/langchain" /> ||
46-
| <LinkWithPlatformIcon platform="openai" label="OpenAI" url="/platforms/python/integrations/openai" /> ||
41+
| | **Auto-enabled** |
42+
| -------------------------------------------------------------------------------------------------------------------------------------- | :--------------: |
43+
| <LinkWithPlatformIcon platform="anthropic" label="Anthropic" url="/platforms/python/integrations/anthropic" /> ||
44+
| <LinkWithPlatformIcon platform="huggingface" label="Huggingface Hub" url="/platforms/python/integrations/huggingface_hub" /> ||
45+
| <LinkWithPlatformIcon platform="langchain" label="Langchain" url="/platforms/python/integrations/langchain" /> ||
46+
| <LinkWithPlatformIcon platform="openai" label="OpenAI" url="/platforms/python/integrations/openai" /> ||
47+
| <LinkWithPlatformIcon platform="openai-agents" label="OpenAI Agents SDK" url="/platforms/python/integrations/openai-agents" /> | |
4748

4849
### Data Processing
4950

0 commit comments

Comments
 (0)