Skip to content

Commit 78af134

Browse files
Apply suggestions from code review
Co-authored-by: Liza Mock <[email protected]>
1 parent 8e59c7c commit 78af134

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

docs/platforms/react-native/tracing/instrumentation/custom-instrumentation.mdx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ There are three key functions for creating spans:
2626

2727
## Active vs. Inactive Spans
2828

29-
When a new span is started, it will automatically be started as a child of the currently active span, if there is one. This means that if a span is started as an **active span**, any spans that are created inside of the callback where the span is active will be children of that span. Additionally, errors will be tied to the currently active span, if there is one.
29+
If there's a currently active span when a new span is started, the new span will automatically start as a child span of the currently active one. This means, that if a span is started as an **active span**, it will be the parent span and any spans created inside the callback will be children of that span. Errors will be tied to the parent span, if there is one.
3030

31-
In contrast, **inactive spans** will never have children automatically associated with them. This is useful if you do not care about capturing child activity.
31+
In contrast, **inactive spans** will never have children automatically associated with them. This is useful if you don't care about capturing child activity.
3232

33-
A key constraint for active spans is that they can only be made active inside of a callback. This constraint exists because otherwise it becomes impossible to associate spans with the correct parent span when working with asynchronous code.
33+
A key constraint for active spans is that they can only be made active inside of a callback. This constraint exists because otherwise it would be impossible to associate child spans with the correct parent span when working with asynchronous code.
3434

35-
In places where you are not able to wrap executing code in a callback (e.g. when working with hooks or similar) you have to work with inactive spans, and can combine this with [withActiveSpan](#withactivespan) to manually associate child spans with the correct parent span.
35+
If you're unable to wrap executing code in a callback (for example, when working with hooks or similar) you'll have to work with inactive spans, and can combine this with [withActiveSpan](#withactivespan) to manually associate child spans with the correct parent span.
3636

3737
## Span Hierarchy
3838

39-
In browser and mobile environments, spans are by default collected in a flat hierarchy where every span is the direct child of the root span.
39+
In browser and mobile environments, spans are collected in a flat hierarchy where every span is the direct child of the root span by default.
4040

41-
The key reason for keeping a flat hierarchy is because it's impossible to reliably keep track of the active span across asynchronous boundaries. This means that if multiple asynchronous operations are started in parallel, it is not possible to determine which span is the parent of which child span. Imagine the following example:
41+
The key reason for keeping a flat hierarchy is because if multiple asynchronous operations were started in parallel, it wouldn't be possible to determine which span is the parent of which child span. Imagine the following example:
4242

4343
```javascript
4444
Sentry.startSpan({ name: "span 1" }, async () => {
@@ -54,17 +54,17 @@ Sentry.startSpan({ name: "span 2" }, async () => {
5454
});
5555
```
5656

57-
In the browser, there would be no way to know that `span 1` is only active inside of its callback, while `span 2` is active in the other callback. Because of this, in reality, _all_ fetch spans would become children of `span 2`. This is misleading and confusing, which is why by default in the browser, **all spans will become children of the root span** (which is usually the pageload or navigation span). This means that you will always have a flat hierarchy of spans.
57+
In the browser, there would be no way to know that `span 1` is only active inside of its callback, while `span 2` is active in the other callback. Without a flat hierarchy, _all_ fetch spans would become children of `span 2`. This would be misleading and confusing, which is why we've made it so that in the browser, **all spans become children of the root span** (which is usually the pageload or navigation span) by default. This makes it so that you'll always have a flat hierarchy of spans.
5858

59-
This is a tradeoff that we have made to ensure that the data that is captured is accurate and reliable. If you need to capture a more complex hierarchy of spans, you can opt-out of this behavior by setting `parentSpanIsAlwaysRootSpan: false`:
59+
This is a tradeoff we've made to ensure that the data that's captured is accurate and reliable. If you need to capture a more complex hierarchy of spans, you can opt out of this behavior by setting `parentSpanIsAlwaysRootSpan: false`:
6060

6161
```javascript
6262
Sentry.init({
6363
parentSpanIsAlwaysRootSpan: false,
6464
});
6565
```
6666

67-
This will revert to use the full hierarchy behavior, where spans are children of the currently active span. However, this may lead to incorrect data in the case of multiple parallel asynchronous operations - it is up to you to ensure there are no multiple parallel asynchronous operations that start spans in this case.
67+
If you choose to revert to using full hierarchy behavior where spans are children of the currently active span, you'll have to make sure there are no multiple parallel asynchronous operations that start spans. Otherwise, you may get incorrect data.
6868

6969
## Span Starting Options
7070

@@ -76,11 +76,11 @@ The following options can be used for all span starting functions:
7676
| `op` | `string` | The operation of the span. |
7777
| `startTime` | `number` | The start time of the span. |
7878
| `attributes` | `Record<string, Primitive>` | Attributes to attach to the span. |
79-
| `parentSpan` | `Span` | If set, make the span a child of the specified span. Otherwise, the span will be a child of the currently active span. |
80-
| `onlyIfParent` | `boolean` | If true, ignore the span if there is no active parent span. |
81-
| `forceTransaction` | `boolean` | If true, ensure this span shows up as transaction in the Sentry UI. |
79+
| `parentSpan` | `Span` | If set, makes the span a child of the specified span. Otherwise, the span will be a child of the currently active span. |
80+
| `onlyIfParent` | `boolean` | If true, ignores the span if there's no active parent span. |
81+
| `forceTransaction` | `boolean` | If true, ensures this span shows up as a transaction in the Sentry UI. |
8282

83-
Only `name` is required, all other options are optional.
83+
The only option that's required is `name`. All other options are optional.
8484

8585
## Starting an Active Span (`startSpan`)
8686

@@ -90,19 +90,19 @@ For most scenarios, we recommend to start active spans with `Sentry.startSpan()`
9090

9191
## Starting an Active Span with Manual End (`startSpanManual`)
9292

93-
Sometimes, you do not want the span to be ended automatically when the callback is done. In this case, you can use `Sentry.startSpanManual()`. This will start a new span that is active in the provided callback, but will not be automatically ended when the callback is done. You have to manually end the span by calling `span.end()`.
93+
There are times when you don't want a span to be ended automatically as soon as the callback is done. In this case, you can use `Sentry.startSpanManual()`. This will start a new active span in the provided callback, but it won't be automatically ended when the callback is done. You'll have to manually end the span by calling `span.end()`.
9494

9595
<PlatformContent includePath="performance/start-span-manual" />
9696

9797
## Starting Inactive Spans (`startInactiveSpan`)
9898

99-
To add spans that aren't active, you can create independent spans. This is useful when you have work that is grouped together under a single parent span, but is independent from the currently active span. However, in most cases you'll want to create and use the [startSpan](#starting-an-active-span-startspan) API from above.
99+
To add spans that aren't active, you can create independent spans. This is useful when you have work that's grouped together under a single parent span, but is independent from the currently active span. However, in most cases you'll want to create and use the [startSpan](#starting-an-active-span-startspan) API from above.
100100

101101
<PlatformContent includePath="performance/start-inactive-span" />
102102

103103
## Starting Spans as Children of a Specific Span
104104

105-
By default, any span that is started will be the child of the currently active span. If you want to have a different behavior, you can force spans to be the children of a specific span with the `parentSpan` option:
105+
By default, any span that's started will be the child of the currently active span. If you want to have a different behavior, you can force spans to be the children of a specific span with the `parentSpan` option:
106106

107107
```js
108108
const parentSpan = Sentry.startInactiveSpan({ name: "Parent Span" });
@@ -114,7 +114,7 @@ parentSpan.end();
114114

115115
This option is also available for `startSpan` and `startSpanManual`.
116116

117-
## Utilities to work with Spans
117+
## Utilities That Work With Spans
118118

119119
We expose some helpful utilities that can help you with custom instrumentation.
120120

@@ -161,7 +161,7 @@ Sentry.withActiveSpan(null, () => {
161161
});
162162
```
163163

164-
Alternatively you can also use the `parentSpan` option to achieve the same:
164+
Alternatively, you can use the `parentSpan` option to achieve the same:
165165

166166
```javascript
167167
const span = Sentry.startInactiveSpan({ name: "Parent Span" });
@@ -173,7 +173,7 @@ const childSpan = Sentry.startInactiveSpan({
173173

174174
### `suppressTracing`
175175

176-
Suppress the creation of sampled spans for the duration of the callback. This is useful when you want to prevent certain spans from being captured. For example, if you do not want to create spans for a given fetch request, you can do:
176+
Suppress the creation of sampled spans for the duration of the callback. This is useful when you want to prevent certain spans from being captured. For example, if you don't want to create spans for a given fetch request, you can do:
177177

178178
```javascript
179179
Sentry.suppressTracing(() => {
@@ -185,7 +185,7 @@ Sentry.suppressTracing(() => {
185185

186186
### Adding Span Attributes
187187

188-
You can capture span attributes along with your spans. Span attributes can be of type `string`, `number` or `boolean`, as well as (non-mixed) arrays of these types. You can specify attributes when starting a span:
188+
You can capture span attributes along with your spans. Span attributes can be of type: `string`, `number`, or `boolean`, as well as (non-mixed) arrays of these types. You can specify attributes when starting a span:
189189

190190
```javascript
191191
Sentry.startSpan(
@@ -202,7 +202,7 @@ Sentry.startSpan(
202202
);
203203
```
204204

205-
Or you can also add attributes to an existing span:
205+
You can also add attributes to an existing span:
206206

207207
```javascript
208208
const span = Sentry.getActiveSpan();
@@ -218,7 +218,7 @@ if (span) {
218218

219219
### Adding Span Operations ("op")
220220

221-
Spans can have an operation associated with them, which help activate Sentry identify additional context about the span. For example database related spans have the `db` span operation associated with them. The Sentry product offers additional controls, visualizations and filters for spans with known operations.
221+
Spans can have an operation associated with them, which help activate Sentry and identify additional context about the span. For example, database-related spans have the `db` span operation associated with them. The Sentry product offers additional controls, visualizations, and filters for spans with known operations.
222222

223223
Sentry maintains a [list of well known span operations](https://develop.sentry.dev/sdk/performance/span-operations/#list-of-operations) and it is recommended that you use one of those operations if it is applicable to your span.
224224

@@ -235,7 +235,7 @@ if (span) {
235235
}
236236
```
237237

238-
Please note that in certain scenarios, the span name will be overwritten by the SDK. This is the case for spans with any of the following attribute combinations:
238+
Please note, that in certain scenarios, the span name will be overwritten by the SDK. This is the case for spans with any of the following attribute combinations:
239239

240240
* Spans with `http.method` or `http.request.method` attributes will automatically have their name set to the method + the URL path
241241
* Spans with `db.system` attributes will automatically have their name set to the system + the statement

0 commit comments

Comments
 (0)