Skip to content

Commit c7d43a3

Browse files
authored
fix(android): Connect services note about okhttp and apollo integrations (#4980)
1 parent d094ee4 commit c7d43a3

File tree

3 files changed

+45
-37
lines changed

3 files changed

+45
-37
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### HTTP and GraphQL Requests
2+
3+
For traces that begin in the mobile app, any requests made (and any requests your backend makes as a result) are linked through the request header `sentry-trace`.
4+
5+
The Sentry Android SDK offers [OkHttp](/platforms/android/configuration/integrations/okhttp/) and [Apollo](/platforms/android/configuration/integrations/apollo/) integrations for HTTP and GraphQL requests respectively.
6+
7+
These integrations either generate or pick up and propagate the trace header automatically, as appropriate, for all transactions and spans that they generate.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
### Navigation and Other XHR Requests
2+
3+
For traces that begin in the front end, any requests made (and any requests your backend makes as a result) are linked through the request header `sentry-trace`.
4+
5+
All of Sentry's tracing-related integrations (`BrowserTracing`, `Http`, and `Express`), as well as the Next.JS SDK, either generate or pick up and propagate the trace header automatically, as appropriate, for all transactions and spans that they generate.
6+
7+
The JavaScript SDK will only attach the trace header to outgoing HTTP requests for which the destination is a substring or regex match to the <PlatformLink to="/performance/instrumentation/automatic-instrumentation/#tracingorigins">tracingOrigins</PlatformLink> list.
8+
9+
<!-- copied from automatic-instrumentation to emphasize this point -->
10+
11+
You'll need to configure your web server [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers) to allow the `sentry-trace` header. The configuration might look like `"Access-Control-Allow-Headers: sentry-trace"`, but the configuration depends on your setup. If you don't allow the `sentry-trace` header, the request might be blocked.
12+
13+
### Pageload
14+
15+
For traces that begin in your backend, you can connect the automatically-generated `pageload` transaction on the frontend with the request transaction that serves the page on the backend. Because JavaScript code running in a browser cannot read the response headers of the current page, the `trace_id` must be transmitted in the response itself, specifically in a `<meta>` tag in the `<head>` of the HTML sent from your backend.
16+
17+
```html
18+
<html>
19+
<head>
20+
<meta name="sentry-trace" content="{{ span.toSentryTrace() }}" />
21+
<!-- ... -->
22+
</head>
23+
</html>
24+
```
25+
26+
The `name` attribute must be the string `"sentry-trace"` and the `content` attribute must be generated by your backend Sentry SDK using `span.toSentryTrace()` (or equivalent, depending on the backend platform). This guarantees that a new and unique value will be generated for each request.
27+
28+
<Note>
29+
30+
The `span.toSentryTrace()` was previously called `span.toTraceparent()`, so that's what you may find depending on the SDK and version.
31+
32+
</Note>
33+
34+
The `span` reference is either the transaction that serves the HTML or any of its child spans. It defines the parent of the `pageload` transaction.
35+
36+
Once the data is included in the `<meta>` tag, our `BrowserTracing` integration will pick it up automatically and link it to the transaction generated on pageload. (Note that it will not be linked to automatically-generated `navigation` transactions that is, those that don't require a full page reload. Each of those will be the result of a different request transaction on the backend and, therefore, should have a unique `trace_id`.)

src/platforms/common/performance/connect-services.mdx

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,8 @@ SDKs with performance monitoring support listen to incoming requests and typical
1212

1313
If the instrumentation you are using doesn't automatically pick up the `sentry-trace` header, you can also continue a trace manually by using the `continueFromHeaders` function on a `Transaction`, which you can learn more about in our content for [the Transaction Interface](https://develop.sentry.dev/sdk/performance/#new-span-and-transaction-classes).
1414

15-
<PlatformSection supported={["javascript"]} notSupported={["node"]} >
15+
<PlatformSection supported={["android", "javascript"]} notSupported={["node"]}>
1616

17-
### Navigation and Other XHR Requests
18-
19-
For traces that begin in the front end, any requests made (and any requests your backend makes as a result) are linked through the request header `sentry-trace`.
20-
21-
All of Sentry's tracing-related integrations (`BrowserTracing`, `Http`, and `Express`), as well as the Next.JS SDK, either generate or pick up and propagate the trace header automatically as appropriate, for all transactions and spans that they generate.
22-
23-
The JavaScript SDK will only attach the trace header to outgoing HTTP requests whose destination is a substring or regex match to the <PlatformLink to="/performance/instrumentation/automatic-instrumentation/#tracingorigins">tracingOrigins</PlatformLink> list.
24-
25-
<!-- copied from automatic-instrumentation to emphasize this point -->
26-
27-
You will need to configure your web server [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers) to allow the `sentry-trace` header. The configuration might look like `"Access-Control-Allow-Headers: sentry-trace"`, but the configuration depends on your set up. If you do not allow the `sentry-trace` header, the request might be blocked.
28-
29-
### Pageload
30-
31-
For traces that begin in your backend, you can connect the automatically-generated `pageload` transaction on the frontend with the request transaction that serves the page on the backend. Because JavaScript code running in a browser cannot read the response headers of the current page, the `trace_id` must be transmitted in the response itself, specifically in a `<meta>` tag in the `<head>` of the HTML sent from your backend.
32-
33-
```html
34-
<html>
35-
<head>
36-
<meta name="sentry-trace" content="{{ span.toSentryTrace() }}" />
37-
<!-- ... -->
38-
</head>
39-
</html>
40-
```
41-
42-
The `name` attribute must be the string `"sentry-trace"` and the `content` attribute must be generated by your backend's Sentry SDK using `span.toSentryTrace()` (or equivalent, depending on the backend platform). This guarantees that a new and unique value will be generated for each request.
43-
44-
<Note>
45-
46-
The `span.toSentryTrace()` was previously called `span.toTraceparent()`, so that's what you may find depending on the SDK and version.
47-
48-
</Note>
49-
50-
The `span` reference is either the transaction that serves the HTML, or any of its child spans. It defines the parent of the `pageload` transaction.
51-
52-
Once the data is included in the `<meta>` tag, our `BrowserTracing` integration will pick it up automatically and link it to the transaction generated on pageload. (Note that it will not get linked to automatically-generated `navigation` transactions, that is, those which don't require a full page reload. Each of those will be the result of a different request transaction on the backend, and therefore should have a unique `trace_id`.)
17+
<PlatformContent includePath="performance/connect-services" />
5318

5419
</PlatformSection>

0 commit comments

Comments
 (0)