Skip to content

Commit 6b38ded

Browse files
doralchanDora ChandcramerTien "Mimi" Nguyendashed
authored
feat(perf-docs): reorganize and regenerate screenshots (#1782)
* replaced screenshots * rename tabs * cleaning up copy * update snapshot * updating metric terminology * more links * fix broken link * readded before navigation option * summary cleanup * added summary details * fix merge problem * cleaned up event detail docs * info alerts * fix event detail * change sidebar title and remove weird merge * updating span detail section * cleaned up language and punctuation in setup * updated language and punctuation in perf index * small edits to metrics * fix snapshot * updating formatting in js * updated wording and headings in Node * updated python setup page * updated Vue page * updated transaction summary page * updated discover queries page * update query builder * updated event detail page * changed headers in JS * updated headers in Node * updated python headers * updated vue page * took test phrase out * removed unnecessary sent Co-authored-by: Dora Chan <[email protected]> Co-authored-by: David Cramer <[email protected]> Co-authored-by: Tien "Mimi" Nguyen <[email protected]> Co-authored-by: Alberto Leal <[email protected]>
1 parent a262b79 commit 6b38ded

39 files changed

+703
-697
lines changed

__tests__/__snapshots__/documentation.js.snap

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,14 @@ Array [
276276
"meta/ip-ranges/index.html",
277277
"meta/soc2/index.html",
278278
"meta/terms/index.html",
279-
"performance/discover/index.html",
280-
"performance/discover/query-builder/index.html",
281-
"performance/distributed-tracing/index.html",
282-
"performance/getting-started/index.html",
283-
"performance/performance-homepage/index.html",
284-
"performance/performance-metrics/index.html",
279+
"performance-monitoring/discover-queries/index.html",
280+
"performance-monitoring/discover-queries/query-builder/index.html",
281+
"performance-monitoring/distributed-tracing/index.html",
282+
"performance-monitoring/performance/event-detail/index.html",
283+
"performance-monitoring/performance/index.html",
284+
"performance-monitoring/performance/metrics/index.html",
285+
"performance-monitoring/performance/transaction-summary/index.html",
286+
"performance-monitoring/setup/index.html",
285287
"platforms/android/index.html",
286288
"platforms/android/migrate/index.html",
287289
"platforms/cocoa/dsym/index.html",
23.4 KB
Loading
47.7 KB
Loading
Binary file not shown.
-129 KB
Binary file not shown.
-126 KB
Binary file not shown.
Loading
257 KB
Loading
282 KB
Loading
Binary file not shown.
-25.7 KB
Binary file not shown.
144 KB
Loading
Binary file not shown.

src/_data/documentation_categories.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
- title: Enriching Error Data
1010
slug: enriching-error-data
1111

12-
- title: Performance
13-
slug: performance
12+
- title: Performance Monitoring
13+
slug: performance-monitoring
1414

1515
- title: Workflow and Integrations
1616
slug: workflow

src/collections/_documentation/data-management/advanced-datascrubbing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Select known parts of the schema using the following:
164164
* `$logentry` matches the `logentry` attribute of an event.
165165
* `$thread` matches a single thread instance in `{"threads": {"values": [...]}}`
166166
* `$breadcrumb` matches a single breadcrumb in `{"breadcrumbs": {"values": [...]}}`
167-
* `$span` matches a [trace span](/performance/distributed-tracing/#traces-transactions-and-spans)
167+
* `$span` matches a [trace span](/performance-monitoring/distributed-tracing/#traces-transactions-and-spans)
168168
* `$sdk` matches the SDK context in `{"sdk": ...}`
169169

170170
### Escaping Special Characters

src/collections/_documentation/enriching-error-data/additional-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Context includes additional diagnostic information attached to an event. By defa
2828

2929
## Predefined Data
3030

31-
The most common types of predefined data (where applicable) are level, [release](/workflow/releases/), [environment](/enriching-error-data/environments/), logger, [fingerprint](/data-management/event-grouping/), user, request, device, OS, runtime, app, browser, gpu, monitor, and [traces](/performance/distributed-tracing/).
31+
The most common types of predefined data (where applicable) are level, [release](/workflow/releases/), [environment](/enriching-error-data/environments/), logger, [fingerprint](/data-management/event-grouping/), user, request, device, OS, runtime, app, browser, gpu, monitor, and [traces](/performance-monitoring/distributed-tracing/).
3232

3333
To improve searchability, Sentry will turn the data or specific attributes on the data into tags. For example, `level` is available as a tag, and so is a user's email via the `user.email` tag. If Sentry is captures some predefined data but doesn't expose it as a tag, you can always set a [custom tag](#tags) for it.
3434

src/collections/_documentation/enriching-error-data/error-tracing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ After you configure the variable in your SDK, the variable surfaces as a tag in
144144

145145
### Searching Request IDs in Sentry
146146

147-
If you also need several example cases to supplement a unique request ID, you can use Sentry's [Discover](/performance/discover/) functionality to search for all request ids you've seen on a specific URL.
147+
If you also need several example cases to supplement a unique request ID, you can use Sentry's [Discover](/performance-monitoring/discover-queries/) functionality to search for all request ids you've seen on a specific URL.
148148

149149
[{% asset tracing/tracing_with_discover.png alt="Image of the request_id grouped with other tags." %}]({% asset tracing/tracing_with_discover.png @path %})

src/collections/_documentation/guides/enrich-data/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ For instance, the Discover query below displays all the errors (total of 143 eve
6565

6666
![Discover Query]({% asset guides/enrich-data/004.png @path %})
6767

68-
For more information, see [Discover](/performance/discover/).
68+
For more information, see [Discover](/performance-monitoring/discover-queries/).
6969

7070
### Issue Ownership
7171

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
To get started with performance monitoring using Sentry's JavaScript SDK, first install the `@sentry/apm` package:
2+
3+
```bash
4+
npm install --save @sentry/apm
5+
```
6+
7+
Next, initialize the integration in your call to `Sentry.init`:
8+
9+
```jsx
10+
import * as Sentry from '@sentry/browser';
11+
import { Integrations as ApmIntegrations } from '@sentry/apm';
12+
Sentry.init({
13+
dsn: '"___PUBLIC_DSN___"',
14+
release: 'my-project-name@' + process.env.npm_package_version,
15+
integrations: [
16+
new ApmIntegrations.Tracing(),
17+
],
18+
tracesSampleRate: 0.25, // must be present and non-zero
19+
});
20+
```
21+
22+
Performance data is transmitted using a new event type called "transactions," which you can learn about in [Distributed Tracing](/performance-monitoring/distributed-tracing/#traces-transactions-and-spans). **To capture transactions, you must install the performance package and configure your SDK to set the `tracesSampleRate` configuration to a nonzero value.** The example configuration above will transmit 25% of captured transactions.
23+
24+
Learn more about sampling in [Using Your SDK to Filter Events](/error-reporting/configuration/filtering/).
25+
26+
**JavaScript**
27+
28+
To access our tracing features, you will need to install our Tracing package `@sentry/apm`:
29+
30+
```bash
31+
$ npm install @sentry/browser
32+
$ npm install @sentry/apm
33+
```
34+
35+
Alternatively, instead of npm packages, you can use our pre-built CDN bundle that combines both `@sentry/browser` and `@sentry/apm`:
36+
37+
```html
38+
<script src="https://browser.sentry-cdn.com/{% sdk_version sentry.javascript.browser %}/bundle.apm.min.js" crossorigin="anonymous"></script>
39+
```
40+
41+
**Automatic Instrumentation**
42+
43+
For `@sentry/browser`, we provide an integration called `Tracing` that does
44+
automatic instrumentation creating `pageload` and `navigation` transactions
45+
containing spans for XHR/fetch requests and Performance API entries such as
46+
marks, measures, and resource timings.
47+
48+
The `Tracing` integration is specific to `@sentry/browser` and does not work
49+
with `@sentry/node`.
50+
51+
The `Tracing` integration resides in the `@sentry/apm` package. You can add it to your `Sentry.init` call:
52+
53+
```javascript
54+
import * as Sentry from '@sentry/browser';
55+
import { Integrations as ApmIntegrations } from '@sentry/apm';
56+
57+
Sentry.init({
58+
dsn: '___PUBLIC_DSN___',
59+
integrations: [
60+
new ApmIntegrations.Tracing(),
61+
],
62+
tracesSampleRate: 0.25,
63+
});
64+
```
65+
66+
*NOTE:* The `Tracing` integration is available under `Sentry.Integrations.Tracing` when using the CDN bundle.
67+
68+
To send traces, you will need to set the `tracesSampleRate` to a nonzero value. The configuration above will capture 25% of your transactions.
69+
70+
You can pass many different options to the `Tracing` integration (as an object of the form `{optionName: value}`), but it comes with reasonable defaults out of the box.
71+
72+
For all possible options, see [TypeDocs](https://getsentry.github.io/sentry-javascript/interfaces/apm.tracingoptions.html).
73+
74+
**tracingOrigins Option**
75+
76+
The default value of `tracingOrigins` is `['localhost', /^\//]`. The JavaScript SDK will attach the `sentry-trace` header to all outgoing XHR/fetch requests whose destination contains a string in the list or matches a regex in the list. If your frontend is making requests to a different domain, you will need to add it there to propagate the `sentry-trace` header to the backend services, which is required to link transactions together as part of a single trace.
77+
78+
*Example:*
79+
80+
- A frontend application is served from `example.com`
81+
- A backend service is served from `api.example.com`
82+
- The frontend application makes API calls to the backend
83+
- Therefore, the option needs to be configured like this: `new ApmIntegrations.Tracing({tracingOrigins: ['api.example.com']})`
84+
- Now outgoing XHR/fetch requests to `api.example.com` will get the `sentry-trace` header attached
85+
86+
*NOTE:* You need to make sure your web server CORS is configured to allow the `sentry-trace` header. The configuration might look like `"Access-Control-Allow-Headers: sentry-trace"`, but this depends a lot on your setup. If you do not whitelist the `sentry-trace` header, the request might be blocked.
87+
88+
**beforeNavigation Option**s
89+
90+
{% version_added 5.18.0 %}
91+
92+
For `pageload` and `navigation` transactions, the `Tracing` integration uses the browser's `window.location` API to generate a transaction name. To customize the name of the `pageload` and `navigation` transactions, you can supply a `beforeNavigation` option to the `Tracing` integration. This option allows you to pass in a function that takes in the location at the time of navigation and returns a new transaction name.
93+
94+
`beforeNavigation` is useful if you would like to leverage the routes from a custom routing library like `React Router` or if you want to reduce the cardinality of particular transactions.
95+
96+
```javascript
97+
import * as Sentry from '@sentry/browser';
98+
import { Integrations as ApmIntegrations } from '@sentry/apm';
99+
Sentry.init({
100+
dsn: '___PUBLIC_DSN___',
101+
integrations: [
102+
new ApmIntegrations.Tracing({
103+
beforeNavigate: (location) => {
104+
// The normalizeTransactionName function uses the given URL to
105+
// generate a new transaction name.
106+
return normalizeTransactionName(location.href);
107+
},
108+
}),
109+
],
110+
tracesSampleRate: 0.25,
111+
});
112+
```
113+
114+
**Manual Instrumentation**
115+
116+
To manually instrument certain regions of your code, you can create a transaction to capture them.
117+
This is valid for both JavaScript Browser and Node and works independently of the `Tracing` integration.
118+
119+
```javascript
120+
const transaction = Sentry.startTransaction({name: 'test-transaction'});
121+
const span = transaction.startChild({op: 'functionX'}); // This function returns a Span
122+
// functionCallX
123+
span.finish(); // Remember that only finished spans will be sent with the transaction
124+
transaction.finish(); // Finishing the transaction will send it to Sentry
125+
```
126+
127+
Here is a different example. If you want to create a transaction for a user interaction on your page, you need to do the following:
128+
129+
```javascript
130+
// Let's say this function is invoked when a user clicks on the checkout button of your shop
131+
shopCheckout() {
132+
// This will create a new Transaction for you
133+
const transaction = Sentry.startTransaction('shopCheckout');
134+
135+
// Assume this function makes an xhr/fetch call
136+
const result = validateShoppingCartOnServer();
137+
138+
const span = transaction.startChild({
139+
data: {
140+
result
141+
},
142+
op: 'task',
143+
description: `processing shopping cart result`,
144+
});
145+
processAndValidateShoppingCart(result);
146+
span.finish();
147+
148+
transaction.finish();
149+
}
150+
```
151+
152+
This example will send a transaction `shopCheckout` to Sentry. The transaction will contain a `task` span that measures how long `processAndValidateShoppingCart` took. Finally, the call to `transaction.finish()` will finish the transaction and send it to Sentry.
153+
154+
**Adding Additional Spans to the Transaction**
155+
156+
The next example contains the implementation of the hypothetical `processItem ` function called from the code snippet in the previous section. Our SDK can determine if there is currently an open transaction and add to it all newly created spans as child operations. Keep in mind that each individual span needs to be manually finished; otherwise, that span will not show up in the transaction.
157+
158+
```javascript
159+
function processItem(item, transaction) {
160+
const span = transaction.startChild({
161+
op: "http",
162+
description: "GET /"
163+
})
164+
165+
return new Promise((resolve, reject) => {
166+
http.get(`/items/${item.id}`, (response) => {
167+
response.on('data', () => {});
168+
response.on('end', () => {
169+
span.setTag("http.status_code", response.statusCode);
170+
span.setData("http.foobarsessionid", getFoobarSessionid(response));
171+
span.finish();
172+
resolve(response);
173+
});
174+
});
175+
});
176+
}
177+
```
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
To access our tracing features, you will need to install our Tracing integration.
2+
3+
**Node**
4+
5+
```bash
6+
$ npm install @sentry/node
7+
$ npm install @sentry/apm
8+
```
9+
10+
**Sending Traces**
11+
12+
To send traces, set the `tracesSampleRate` to a nonzero value. The following configuration will capture 25% of all your transactions:
13+
14+
```javascript
15+
const Sentry = require("@sentry/node");
16+
17+
// This is required since it patches functions on the hub
18+
const Apm = require("@sentry/apm");
19+
20+
Sentry.init({
21+
dsn: "___PUBLIC_DSN___",
22+
tracesSampleRate: 0.25
23+
});
24+
```
25+
26+
**Automatic Instrumentation**
27+
28+
It’s possible to add tracing to all popular frameworks; however, we only provide pre-written handlers for Express.
29+
30+
```javascript
31+
const Sentry = require("@sentry/node");
32+
const Apm = require("@sentry/apm");
33+
const express = require("express");
34+
const app = express();
35+
36+
Sentry.init({
37+
dsn: "___PUBLIC_DSN___",
38+
integrations: [
39+
// enable HTTP calls tracing
40+
new Sentry.Integrations.Http({ tracing: true }),
41+
// enable Express.js middleware tracing
42+
new Apm.Integrations.Express({ app })
43+
],
44+
tracesSampleRate: 0.25
45+
});
46+
47+
// RequestHandler creates a separate execution context using domains, so that every
48+
// transaction/span/breadcrumb is attached to its own Hub instance
49+
app.use(Sentry.Handlers.requestHandler());
50+
// TracingHandler creates a trace for every incoming request
51+
app.use(Sentry.Handlers.tracingHandler());
52+
53+
// the rest of your app
54+
55+
app.use(Sentry.Handlers.errorHandler());
56+
app.listen(3000);
57+
```
58+
59+
Spans are instrumented for the following operations within a transaction:
60+
61+
- HTTP requests made with `request`
62+
- `get` calls using native `http` and `https` modules
63+
- Middleware (Express.js only)
64+
65+
**Manual Instrumentation**
66+
67+
To manually instrument a specific region of your code, you can create a transaction to capture it.
68+
69+
The following example creates a transaction for a part of the code that contains an expensive operation (for example, `processItem`), and sends the result to Sentry:
70+
71+
```javascript
72+
app.use(function processItems(req, res, next) {
73+
const item = getFromQueue();
74+
const transaction = Sentry.startTransaction({
75+
op: "task",
76+
name: item.getTransaction()
77+
})
78+
79+
// processItem may create more spans internally (see next examples)
80+
processItem(item, transaction).then(() => {
81+
transaction.finish();
82+
next();
83+
})
84+
});
85+
```

0 commit comments

Comments
 (0)