You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Understanding how your SvelteKit application behaves in production — from request flows to performance bottlenecks — is crucial for building reliable user experiences. SvelteKit now has first-class support for observability: built-in [OpenTelemetry](https://opentelemetry.io/) tracing, and a dedicated instrumentation setup file that ensures your monitoring tools work seamlessly.
9
9
10
-
## First-party OpenTelemetry traces
11
-
12
-
SvelteKit can now emit [OpenTelemetry](https://opentelemetry.io) traces for the following:
13
-
14
-
-[`handle`](/docs/kit/hooks#Server-hooks-handle) hook (`handle` functions running in a [`sequence`](/docs/kit/@sveltejs-kit-hooks#sequence) will show up as children of each other and the root handle hook)
15
-
-[`load`](/docs/kit/load) functions (includes universal `load` functions when they run on the server)
16
-
-[Form actions](/docs/kit/form-actions)
17
-
-[Remote functions](/docs/kit/remote-functions)
18
-
19
-
To enable trace emission, add the following to `svelte.config.js`:
10
+
To opt in, upgrade SvelteKit and your adapter and add the following to your `svelte.config.js`:
20
11
21
12
```js
22
13
/// file: svelte.config.js
23
14
exportdefault {
24
15
kit: {
25
-
+++experimental: {
16
+
experimental: {
26
17
tracing: {
27
18
server:true
19
+
},
20
+
instrumentation: {
21
+
server:true
28
22
}
29
-
}+++
23
+
}
30
24
}
31
25
};
32
26
```
33
27
34
-
If there are additional attributes you think might be useful, please file an issue on the [SvelteKit GitHub issue tracker](https://github.com/sveltejs/kit/issues).
28
+
## First-party OpenTelemetry traces
35
29
36
-
## A convenient home for all of your instrumentation
30
+
SvelteKit can now emit [OpenTelemetry](https://opentelemetry.io) traces for the following:
37
31
38
-
Emitting traces alone is not enough: You also need to collect them and send them somewhere. Under normal circumstances, this can be a bit challenging. Because of the nature of observability instrumentation, it needs to be loaded prior to loading any of the code from your app. To aid in this, SvelteKit now supports a `src/instrumentation.server.ts` file which, assuming your adapter supports it, is guaranteed to be loaded prior to your application code.
32
+
-[`handle`](/docs/kit/hooks#Server-hooks-handle) hook (`handle` functions running in a [`sequence`](/docs/kit/@sveltejs-kit-hooks#sequence) will show up as children of each other and the root handle hook)
33
+
-[`load`](/docs/kit/load) functions (includes universal `load` functions when they run on the server)
34
+
-[Form actions](/docs/kit/form-actions)
35
+
-[Remote functions](/docs/kit/remote-functions)
39
36
40
-
To enable `instrumentation.server.ts`, add the following to your `svelte.config.js`:
37
+
The emitted spans include attributes describing the current request, such as `http.route`, and surrounding context, such as the `+page` or `+layout` file associated with a `load` function. If there are additional attributes you think might be useful, please file an issue on the [SvelteKit GitHub issue tracker](https://github.com/sveltejs/kit/issues).
41
38
42
-
```js
43
-
/// file: svelte.config.js
44
-
exportdefault {
45
-
kit: {
46
-
+++experimental: {
47
-
instrumentation: {
48
-
server:true
49
-
}
50
-
}+++
51
-
}
52
-
};
53
-
```
39
+
## A convenient home for all of your instrumentation
40
+
41
+
Emitting traces alone is not enough: You also need to collect them and send them somewhere. Under normal circumstances, this can be a bit challenging. Because of the nature of observability instrumentation, it needs to be loaded prior to loading any of the code from your app. To aid in this, SvelteKit now supports a `src/instrumentation.server.ts` file which, assuming your adapter supports it, is guaranteed to be loaded prior to your application code.
54
42
55
43
In Node, your instrumentation might look something like this:
0 commit comments