-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(js): Add back node performance API docs (#7796)
- Loading branch information
1 parent
b2ad1e5
commit 9949cf4
Showing
15 changed files
with
135 additions
and
143 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
src/platform-includes/performance/add-active-span/javascript.mdx
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
src/platform-includes/performance/add-active-span/node.mdx
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/platform-includes/performance/add-independent-span/javascript.mdx
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/platform-includes/performance/add-independent-span/node.mdx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/platform-includes/performance/span-api-version/javascript.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<Note> | ||
|
||
The below span APIs (`startActiveSpan`, `startSpan`, and `getActiveSpan`) require SDK version `7.65.0` or higher. If you are using an older version of the SDK, you can use the [explicit transaction APIs](#start-transaction) for custom instrumentation. | ||
The below span APIs (`startSpan`, `startInactiveSpan`, and `startSpanManual`) require SDK version `7.69.0` or higher. If you are using an older version of the SDK, you can use the [explicit transaction APIs](#start-transaction) for custom instrumentation. | ||
|
||
</Note> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<Note> | ||
|
||
The below span APIs (`startActiveSpan`, `startSpan`, and `getActiveSpan`) require SDK version `7.65.0` or higher. If you are using an older version of the SDK, you can use the [explicit transaction APIs](#start-transaction) for custom instrumentation. | ||
The below span APIs (`startSpan`, `startInactiveSpan`, and `startSpanManual`) require SDK version `7.69.0` or higher. If you are using an older version of the SDK, you can use the [explicit transaction APIs](#start-transaction) for custom instrumentation. | ||
|
||
</Note> |
2 changes: 1 addition & 1 deletion
2
src/platform-includes/performance/span-operations/javascript.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
```JavaScript | ||
const result = Sentry.startActiveSpan({ name: 'GET /users', op: 'http.client' }, () => { | ||
const result = Sentry.startSpan({ name: 'GET /users', op: 'http.client' }, () => { | ||
return fetchUsers(); | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
```JavaScript | ||
const result = Sentry.startActiveSpan({ name: 'SELECT * FROM TABLE', op: 'db.query' }, () => { | ||
const result = Sentry.startSpan({ name: 'SELECT * FROM TABLE', op: 'db.query' }, () => { | ||
return execQuery(); | ||
}) | ||
``` |
17 changes: 17 additions & 0 deletions
17
src/platform-includes/performance/start-inactive-span/javascript.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```javascript | ||
const span1 = Sentry.startInactiveSpan({ name: "span1" }); | ||
|
||
someWork(); | ||
|
||
const span2 = Sentry.startInactiveSpan({ name: "span2" }); | ||
|
||
moreWork(); | ||
|
||
const span3 = Sentry.startInactiveSpan({ name: "span3" }); | ||
|
||
evenMoreWork(); | ||
|
||
span1?.finish(); | ||
span2?.finish(); | ||
span3?.finish(); | ||
``` |
17 changes: 17 additions & 0 deletions
17
src/platform-includes/performance/start-inactive-span/node.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```javascript | ||
const span1 = Sentry.startInactiveSpan({ name: "span1" }); | ||
|
||
someWork(); | ||
|
||
const span2 = Sentry.startInactiveSpan({ name: "span2" }); | ||
|
||
moreWork(); | ||
|
||
const span3 = Sentry.startInactiveSpan({ name: "span3" }); | ||
|
||
evenMoreWork(); | ||
|
||
span1?.finish(); | ||
span2?.finish(); | ||
span3?.finish(); | ||
``` |
42 changes: 42 additions & 0 deletions
42
src/platform-includes/performance/start-span/javascript.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
You can use the `Sentry.startSpan` method to wrap a callback in a span to measure how long it will take. The span will automatically be finished when the callback finishes. This works with both synchronous and async callbacks. | ||
|
||
```javascript | ||
const result = Sentry.startSpan({ name: "Important Function" }, () => { | ||
return expensiveFunction(); | ||
}); | ||
|
||
const result = await Sentry.startSpan( | ||
{ name: "Important Function" }, | ||
async () => { | ||
const res = Sentry.startSpan({ name: "Child Span" }, () => { | ||
return expensiveFunction(); | ||
}); | ||
|
||
return updateRes(res); | ||
} | ||
); | ||
|
||
const result = Sentry.startSpan({ name: "Important Function" }, (span) => { | ||
// You can access the span to add data or set specific status. | ||
// The span may be undefined if the span was not sampled or if performance monitoring is disabled. | ||
span?.setData("foo", "bar"); | ||
return expensiveFunction(); | ||
}); | ||
``` | ||
In this example, the span named `Important Function` will become the active span for the duration of the callback. | ||
If you need to override when the span finishes, you can use `Sentry.startSpanManual`. This is useful for creating parallel spans that are not related to each other. | ||
```javascript | ||
// Start a span that tracks the duration of middleware | ||
function middleware(_req, res, next) { | ||
return Sentry.startSpanManual({ name: "middleware" }, (span, finish) => { | ||
res.once("finish", () => { | ||
span?.setHttpStatus(res.status); | ||
finish(); | ||
}); | ||
return next(); | ||
}); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
You can use the `Sentry.startSpan` method to wrap a callback in a span to measure how long it will take. The span will automatically be finished when the callback finishes. This works with both synchronous and async callbacks. | ||
|
||
```javascript | ||
const result = Sentry.startSpan({ name: "Important Function" }, () => { | ||
return expensiveFunction(); | ||
}); | ||
|
||
const result = await Sentry.startSpan( | ||
{ name: "Important Function" }, | ||
async () => { | ||
const res = Sentry.startSpan({ name: "Child Span" }, () => { | ||
return expensiveFunction(); | ||
}); | ||
|
||
return updateRes(res); | ||
} | ||
); | ||
|
||
const result = Sentry.startSpan({ name: "Important Function" }, (span) => { | ||
// You can access the span to add data or set specific status. | ||
// The span may be undefined if the span was not sampled or if performance monitoring is disabled. | ||
span?.setData("foo", "bar"); | ||
return expensiveFunction(); | ||
}); | ||
``` | ||
In this example, the span named `Important Function` will become the active span for the duration of the callback. | ||
If you need to override when the span finishes, you can use `Sentry.startSpanManual`. This is useful for creating parallel spans that are not related to each other. | ||
```javascript | ||
// Start a span that tracks the duration of middleware | ||
function middleware(_req, res, next) { | ||
return Sentry.startSpanManual({ name: "middleware" }, (span, finish) => { | ||
res.once("finish", () => { | ||
span?.setHttpStatus(res.status); | ||
finish(); | ||
}); | ||
return next(); | ||
}); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9949cf4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sentry-docs – ./
sentry-docs-git-master.sentry.dev
sentry-docs.sentry.dev
docs.sentry.io