Skip to content

Commit

Permalink
new performance API wording fixes (#7738)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanamatthews authored Sep 5, 2023
1 parent 5f54a72 commit decb070
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You can use the `Sentry.startActiveSpan` method to wrap a callback in a span to measure how long it will take. The span is automatically finished when the callback is finished. This will work with both sync and async callbacks.
You can use the `Sentry.startActiveSpan` 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.startActiveSpan({ name: "Important Function" }, () => {
Expand All @@ -19,12 +19,12 @@ const result = await Sentry.startActiveSpan(
const result = Sentry.startActiveSpan(
{ name: "Important Function" },
(span) => {
// Can access the span to add data or set specific status.
// The span can be undefined if the span was not sampled or if performance monitoring is disabled.
// 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();
}
);
```
The span named `Important Function` will become the active span for the duration of the callback.
In this example, the span named `Important Function` will become the active span for the duration of the callback.
6 changes: 3 additions & 3 deletions src/platform-includes/performance/add-active-span/node.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You can use the `Sentry.startActiveSpan` method to wrap a callback in a span to measure how long it will take. The span is automatically finished when the callback is finished. This will work with both sync and async callbacks.
You can use the `Sentry.startActiveSpan` 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.startActiveSpan({ name: "Important Function" }, () => {
Expand All @@ -19,8 +19,8 @@ const result = await Sentry.startActiveSpan(
const result = Sentry.startActiveSpan(
{ name: "Important Function" },
(span) => {
// Can access the span to add data or set specific status.
// The span can be undefined if the span was not sampled or if performance monitoring is disabled.
// 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,35 @@ To capture transactions and spans customized to your organization's needs, you m

<PlatformSection supported={["javascript", "node"]}>

To add custom performance data to your application, you need to create and use spans. Spans are a way to measure the time it takes for a specific action to occur. For example, you can create a span to measure the time it takes for a function to execute.
To add custom performance data to your application, you need to add custom instrumentation in the form of spans. Spans are a way to measure the time it takes for a specific action to occur. For example, you can create a span to measure the time it takes for a function to execute.

To start measuring timing data, you first need to import the SDK.
To get started, import the SDK.

<PlatformContent includePath="enriching-events/import" />

<PlatformContent includePath="performance/span-api-version" />

## Create Active Span

By default created spans are considered active, which means they are put on the Sentry scope. This allows child spans and Sentry errors to be associated with that span. This is the recommended way to create spans.
By default, spans you create are considered active, which means they are put on the Sentry scope. This allows child spans and Sentry errors to be associated with that span. This is the recommended way to create spans.

<PlatformContent includePath="performance/add-active-span" />

## Get Active Span

You can also get the current active span, which is useful for when you need to add new child spans.
You can also get the current active span, which is useful to add new child spans.

<PlatformContent includePath="performance/get-span" />

## Start Independent Spans

If you want to add a span that is not active, you can create a independent spans. This is useful for when you have work that is grouped together under a single parent span, but is independent from the current active span. In most cases you'll want to create and use active spans.
To add spans that aren't active, you can create independent spans. This is useful for when you have work that is grouped together under a single parent span, but is independent from the current active span. However, in most cases you'll want to create and use active spans instead.

<PlatformContent includePath="performance/add-independent-span" />

## Start Transaction

The root span (the span that is the parent of all other spans) is known as a transaction in Sentry. This can be accessed and created separately if you need more control over the timing data or if you use a version of the SDK that does not support the top level span APIs.
The root span (the span that is the parent of all other spans) is known as a **transaction** in Sentry. Transactions can be accessed and created separately if you need more control over your timing data or if you use a version of the SDK that doesn't support the top-level span APIs.

<PlatformContent includePath="performance/enable-manual-instrumentation" />

Expand Down

1 comment on commit decb070

@vercel
Copy link

@vercel vercel bot commented on decb070 Sep 5, 2023

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

Please sign in to comment.