@@ -49,12 +49,54 @@ Currently, this SDK:
49
49
50
50
* Will capture errors (same as @sentry/node )
51
51
* Auto-instrument for performance - see below for which performance integrations are available.
52
+ * Provide _ some_ manual instrumentation APIs
53
+ * Sync OpenTelemetry Context with our Sentry Hub/Scope
52
54
53
55
### Manual Instrumentation
54
56
55
- ** Manual instrumentation is not supported!**
56
- This is because the current Sentry-Performance-APIs like ` Sentry.startTransaction() ` are not compatible with the OpenTelemetry tracing model.
57
- We may add manual tracing capabilities in a later version.
57
+ You can manual instrument using the following APIs:
58
+
59
+ ``` js
60
+ const Sentry = require (' @sentry/node-experimental' );
61
+
62
+ Sentry .startActiveSpan ({ description: ' outer' }, function (span ) {
63
+ span .setData (customData);
64
+ doSomethingSlow ();
65
+ Sentry .startActiveSpan ({ description: ' inner' }, function () {
66
+ // inner span is a child of outer span
67
+ doSomethingVerySlow ();
68
+ // inner span is auto-ended when this callback ends
69
+ });
70
+ // outer span is auto-ended when this callback ends
71
+ });
72
+ ```
73
+
74
+ You can also create spans without marking them as the active span.
75
+ Note that for most scenarios, we recommend the ` startActiveSpan ` syntax.
76
+
77
+ ``` js
78
+ const Sentry = require (' @sentry/node-experimental' );
79
+
80
+ // This will _not_ be put on the scope/set as active, so no other spans will be attached to it
81
+ const span = Sentry .startSpan ({ description: ' non-active span' });
82
+
83
+ doSomethingSlow ();
84
+
85
+ span? .finish ();
86
+ ` ` `
87
+
88
+ Finally you can also get the currently active span, if you need to do more with it:
89
+
90
+ ` ` ` js
91
+ const Sentry = require (' @sentry/node-experimental' );
92
+ const span = Sentry .getActiveSpan ();
93
+ ` ` `
94
+
95
+ ### Async Context
96
+
97
+ We leverage the OpenTelemetry context forking in order to ensure isolation of parallel requests.
98
+ This means that as long as you are using an OpenTelemetry instrumentation for your framework of choice
99
+ (currently: Express or Fastify), you do not need to setup any ` requestHandler` or similar.
58
100
59
101
### ESM Support
60
102
0 commit comments