Skip to content

Commit 5a50c5a

Browse files
committed
docs: update Span documentation
1 parent 4dd6e44 commit 5a50c5a

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,33 @@ export default defineNuxtConfig({
6161

6262
<!-- /automd -->
6363

64-
## Config
64+
## Build-time
65+
66+
### Config
6567

6668
You can configure the module with the `otel` property in your `nitro.config.ts`
6769

6870
- **preset**:
6971
- Option to configure the preset that will be used with OTEL
7072

71-
## Hooks
73+
## Runtime
74+
75+
### Span
76+
77+
A span is created for each event.
78+
79+
It is attached to the `event.context` object with the `span` property:
80+
81+
````ts
82+
interface H3EventContext {
83+
span: Span
84+
}
85+
````
86+
87+
You can manipulate this span until it ends. The span will be ended in `afterResponse` (nitro hook) with the endTime set in `beforeReponse` (nitro hook).
88+
In case of an error, if there is an event associated to the error, the span will record the exception and end. If not, nitro-opentelemetry will create a span from the ROOT_CONTEXT and end it.
89+
90+
### Hooks
7291

7392
Here are the available hooks.
7493

@@ -85,10 +104,10 @@ interface NitroRuntimeHooks {
85104
- **otel:span:end**
86105
- Called before ending a `Span`. This can happen in the `afterResponse` hook or in the `error` hook.
87106

88-
## Utils
107+
### Utils
89108

90109
`defineTracedEventHandler`
91-
- Wrap your event handler with the span affected to your event
110+
- Wrap your event handler with the span assigned to your event. This avoid loosing the context for opentelemetry.
92111

93112
## Development
94113

0 commit comments

Comments
 (0)