Skip to content

Commit d525cb9

Browse files
authored
feat(cloudflare): Add docs for durable objects instrumentation (#13626)
1 parent 7a235c5 commit d525cb9

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Cloudflare Durable Objects
3+
description: "Learn how to add Sentry instrumentation for Cloudflare Durable Objects."
4+
---
5+
6+
_(Available in version [9.16.0](https://github.com/getsentry/sentry-javascript/releases/tag/9.16.0) and above)_
7+
8+
You can use the `instrumentDurableObjectWithSentry` method to instrument [Cloudflare Durable Objects](https://developers.cloudflare.com/durable-objects/).
9+
10+
```javascript
11+
import * as Sentry from "@sentry/cloudflare";
12+
13+
class MyDurableObjectBase extends DurableObject<Env> {
14+
// impl
15+
}
16+
17+
// Export your named class as defined in your wrangler config
18+
export const MyDurableObject = Sentry.instrumentDurableObjectWithSentry(
19+
(env) => ({
20+
dsn: "___PUBLIC_DSN___",
21+
tracesSampleRate: 1.0,
22+
}),
23+
MyDurableObjectBase,
24+
);
25+
```

docs/platforms/javascript/guides/cloudflare/index.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ export const onRequest = [
7272
// Make sure Sentry is the first middleware
7373
Sentry.sentryPagesPlugin((context) => ({
7474
dsn: "___PUBLIC_DSN___",
75-
75+
7676
// Adds request headers and IP for users, for more info visit:
7777
// https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii
7878
sendDefaultPii: true,
79-
79+
8080
// ___PRODUCT_OPTION_START___ performance
8181
// Set tracesSampleRate to 1.0 to capture 100% of spans for tracing.
8282
// Learn more at
@@ -118,7 +118,7 @@ If you do not have access to the `onRequest` middleware API, you can use the `wr
118118

119119
```javascript
120120
// hooks.server.js
121-
import * as Sentry from '@sentry/cloudflare';
121+
import * as Sentry from "@sentry/cloudflare";
122122

123123
export const handle = ({ event, resolve }) => {
124124
const requestHandlerOptions = {
@@ -133,6 +133,12 @@ export const handle = ({ event, resolve }) => {
133133
};
134134
```
135135

136+
### Cloudflare Durable Objects
137+
138+
You can use the `instrumentDurableObjectWithSentry` method to instrument [Cloudflare Durable Objects](https://developers.cloudflare.com/durable-objects/). This will need to be done alongside the worker setup.
139+
140+
See the [Cloudflare Durable Objects](features/durableobject/) guide for more information.
141+
136142
## Add Readable Stack Traces to Errors
137143

138144
Depending on how you've set up your project, the stack traces in your Sentry errors probably don't look like your actual code.

0 commit comments

Comments
 (0)