Skip to content

Commit 5261b20

Browse files
authored
docs: some observability doc tweaks (#14234)
* some tweaks * reword * spacing * reads better * add file name and change to .js to align with other docs * nit * Apply suggestion from @eltigerchino * Apply suggestion from @eltigerchino * Apply suggestion from @eltigerchino * Apply suggestion from @eltigerchino * Apply suggestion from @eltigerchino
1 parent 0ff9d5b commit 5261b20

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

documentation/docs/20-core-concepts/60-remote-functions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ This feature is currently experimental, meaning it is likely to contain bugs and
1414

1515
```js
1616
/// file: svelte.config.js
17-
export default {
17+
/** @type {import('@sveltejs/kit').Config} */
18+
const config = {
1819
kit: {
1920
experimental: {
2021
+++remoteFunctions: true+++
2122
}
2223
}
2324
};
25+
26+
export default config;
2427
```
2528

2629
## Overview

documentation/docs/30-advanced/68-observability.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,39 @@ title: Observability
66
<p>Available since 2.29</p>
77
</blockquote>
88

9-
> [!NOTE] This feature is experimental. Expect bugs and breaking changes in minor versions (though we'll do our best to keep those to an absolute minimum). Please provide feedback!
10-
119
Sometimes, you may need to observe how your application is behaving in order to improve performance or find the root cause of a pesky bug. To help with this, SvelteKit can emit server-side [OpenTelemetry](https://opentelemetry.io) spans for the following:
1210

13-
- [`handle`](hooks#Server-hooks-handle) hook (`handle` functions running in a [`sequence`](@sveltejs-kit-hooks#sequence) will show up as children of each other and the root handle hook)
14-
- [`load`](load) functions (includes universal `load` functions when they're run on the server)
11+
- The [`handle`](hooks#Server-hooks-handle) hook and `handle` functions running in a [`sequence`](@sveltejs-kit-hooks#sequence) (these will show up as children of each other and the root `handle` hook)
12+
- Server [`load`](load) functions and universal `load` functions when they're run on the server
1513
- [Form actions](form-actions)
1614
- [Remote functions](remote-functions)
1715

1816
Just telling SvelteKit to emit spans won't get you far, though — you need to actually collect them somewhere to be able to view them. SvelteKit provides `src/instrumentation.server.ts` as a place to write your tracing setup and instrumentation code. It's guaranteed to be run prior to your application code being imported, providing your deployment platform supports it and your adapter is aware of it.
1917

20-
To enable both of these features, add the following to your `svelte.config.js`:
18+
Both of these features are currently experimental, meaning they are likely to contain bugs and are subject to change without notice. You must opt in by adding the `kit.experimental.tracing.server` and `kit.experimental.instrumentation.server` option in your `svelte.config.js`:
2119

2220
```js
2321
/// file: svelte.config.js
24-
export default {
22+
/** @type {import('@sveltejs/kit').Config} */
23+
const config = {
2524
kit: {
26-
+++experimental: {
27-
tracing: {
25+
experimental: {
26+
+++tracing: {
2827
server: true
2928
},
3029
instrumentation: {
3130
server: true
32-
}
33-
}+++
31+
}+++
32+
}
3433
}
3534
};
35+
36+
export default config;
3637
```
3738

3839
> [!NOTE] Tracing — and more significantly, observability instrumentation — can have a nontrivial overhead. Before you go all-in on tracing, consider whether or not you really need it, or if it might be more appropriate to turn it on in development and preview environments only.
3940
40-
## Agumenting SvelteKit's builtin tracing
41+
## Augmenting the built-in tracing
4142

4243
SvelteKit provides access to the `root` span and the `current` span on the request event. The root span is the one associated with your root `handle` function, and the current span could be associated with `handle`, `load`, a form action, or a remote function, depending on the context. You can annotate these spans with any attributes you wish to record:
4344

@@ -65,19 +66,20 @@ async function authenticate() {
6566

6667
To view your first trace, you'll need to set up a local collector. We'll use [Jaeger](https://www.jaegertracing.io/docs/getting-started/) in this example, as they provide an easy-to-use quickstart command. Once your collector is running locally:
6768

68-
- Turn on the experimental flag mentioned above in your `svelte.config.js` file
69-
- Use your package manager to install the dependencies you'll need
69+
- Turn on the experimental flags mentioned earlier in your `svelte.config.js` file
70+
- Use your package manager to install the dependencies you'll need:
7071
```sh
7172
npm i @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node @opentelemetry/exporter-trace-oltp-proto import-in-the-middle
7273
```
73-
- Create `src/instrumentation.server.ts` with the following:
74+
- Create `src/instrumentation.server.js` with the following:
7475

75-
```ts
76+
```js
77+
/// file: src/instrumentation.server.js
7678
import { NodeSDK } from '@opentelemetry/sdk-node';
7779
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
7880
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
7981
import { createAddHookMessageChannel } from 'import-in-the-middle';
80-
import { register } from 'module';
82+
import { register } from 'node:module';
8183

8284
const { registerOptions } = createAddHookMessageChannel();
8385
register('import-in-the-middle/hook.mjs', import.meta.url, registerOptions);
@@ -91,4 +93,4 @@ const sdk = new NodeSDK({
9193
sdk.start();
9294
```
9395
94-
Any server-side requests will now begin generating traces, which you can view in Jaeger's web console at [localhost:16686](http://localhost:16686).
96+
Now, server-side requests will begin generating traces, which you can view in Jaeger's web console at [localhost:16686](http://localhost:16686).

0 commit comments

Comments
 (0)