-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update the Android OkHttp instrumentation docs and fix some Otel docs #29392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Preview links (active after the
|
content/en/real_user_monitoring/mobile_and_tv_monitoring/android/setup.md
Outdated
Show resolved
Hide resolved
content/en/real_user_monitoring/mobile_and_tv_monitoring/android/setup.md
Outdated
Show resolved
Hide resolved
This records each request processed by the `OkHttpClient` as a resource, with all the relevant information (URL, method, status code, and error) automatically filled in. Only the network requests that started when a view is active are tracked. To track requests when your application is in the background, [create a view manually][13]. | ||
|
||
In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. |
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.
maybe it is worth to link OkHttp documentation on the difference between interceptor
and networkInterceptor
?
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.
not sure, I am waiting for suggestions here from doc reviewers.
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.
We link to the OkHttp docs early in step 3, right before the tabs that you can see the closing tags for at the very top of this PR. I think that's close enough to this note to be useful, but I'm not against adding the link again if you're concerned about users getting the two confused.
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.
Yes, linking to the OkHttp docs is a good idea. I would put the link on the phrase "network interceptor."
content/en/tracing/trace_collection/custom_instrumentation/android/otel.md
Outdated
Show resolved
Hide resolved
content/en/tracing/trace_collection/custom_instrumentation/android/otel.md
Outdated
Show resolved
Hide resolved
0af7196
to
35a3855
Compare
35a3855
to
abcabfb
Compare
@@ -417,8 +417,31 @@ OkHttpClient okHttpClient = new OkHttpClient.Builder() | |||
{{% /tab %}} | |||
{{< /tabs >}} | |||
|
|||
If you want RUM resources and Spans to be automatically created for your OkHttp requests, you can use the `DatadogInterceptor` as an interceptor. |
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.
If you want RUM resources and Spans to be automatically created for your OkHttp requests, you can use the `DatadogInterceptor` as an interceptor. | |
To automatically create RUM resources and spans for your OkHttp requests, use the `DatadogInterceptor` as an interceptor. |
This records each request processed by the `OkHttpClient` as a resource, with all the relevant information (URL, method, status code, and error) automatically filled in. Only the network requests that started when a view is active are tracked. To track requests when your application is in the background, [create a view manually][13]. | ||
|
||
In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. |
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.
In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. | |
To monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. |
This records each request processed by the `OkHttpClient` as a resource, with all the relevant information (URL, method, status code, and error) automatically filled in. Only the network requests that started when a view is active are tracked. To track requests when your application is in the background, [create a view manually][13]. | ||
|
||
In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. |
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.
Yes, linking to the OkHttp docs is a good idea. I would put the link on the phrase "network interceptor."
{{% /tab %}} | ||
{{< /tabs >}} | ||
|
||
**Note**: In case you only want to have Spans without RUM resources, you can use the `TracingInterceptor` instead of `DatadogInterceptor` the same way we explained above. |
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.
**Note**: In case you only want to have Spans without RUM resources, you can use the `TracingInterceptor` instead of `DatadogInterceptor` the same way we explained above. | |
**Note**: To use spans but not RUM resources, you can use the `TracingInterceptor` instead of `DatadogInterceptor` as described above. |
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.
Looks great! I have some suggestions to try and make the structure more readable, but they're subject to what info you think would be most helpful - let me know what you think and how you think we can improve them 🙂
This records each request processed by the `OkHttpClient` as a resource, with all the relevant information (URL, method, status code, and error) automatically filled in. Only the network requests that started when a view is active are tracked. To track requests when your application is in the background, [create a view manually][13]. | ||
|
||
In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. |
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.
We link to the OkHttp docs early in step 3, right before the tabs that you can see the closing tags for at the very top of this PR. I think that's close enough to this note to be useful, but I'm not against adding the link again if you're concerned about users getting the two confused.
If you want RUM resources and Spans to be automatically created for your OkHttp requests, you can use the `DatadogInterceptor` as an interceptor. | ||
|
||
This records each request processed by the `OkHttpClient` as a resource, with all the relevant information (URL, method, status code, and error) automatically filled in. Only the network requests that started when a view is active are tracked. To track requests when your application is in the background, [create a view manually][13]. | ||
|
||
In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. | ||
|
||
{{< tabs >}} | ||
{{% tab "Kotlin" %}} | ||
```kotlin | ||
val okHttpClient = OkHttpClient.Builder() | ||
.addNetworkInterceptor(DatadogInterceptor.Builder(tracedHostsWithHeaderType).build()) | ||
.build() | ||
``` | ||
{{% /tab %}} | ||
{{% tab "Java" %}} | ||
```java | ||
OkHttpClient okHttpClient = new OkHttpClient.Builder() | ||
.addNetworkInterceptor(new DatadogInterceptor.Builder(tracedHostsWithHeaderType).build()) | ||
.build(); | ||
``` | ||
{{% /tab %}} | ||
{{< /tabs >}} |
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.
The two notes about using DatadogInterceptor
seem similar to each other; I'm wondering if someone reading quickly might skip "network" and get confused.
I'm not sure I totally understand the intended placement of the paragraphs as they are now; I suspect that more should be embedded under step 3 than currently is, and that we can use some further embedding to make the relationships between these pieces more clear. I was wondering if this would make sense to you:
If you want RUM resources and Spans to be automatically created for your OkHttp requests, you can use the `DatadogInterceptor` as an interceptor. | |
This records each request processed by the `OkHttpClient` as a resource, with all the relevant information (URL, method, status code, and error) automatically filled in. Only the network requests that started when a view is active are tracked. To track requests when your application is in the background, [create a view manually][13]. | |
In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor. | |
{{< tabs >}} | |
{{% tab "Kotlin" %}} | |
```kotlin | |
val okHttpClient = OkHttpClient.Builder() | |
.addNetworkInterceptor(DatadogInterceptor.Builder(tracedHostsWithHeaderType).build()) | |
.build() | |
``` | |
{{% /tab %}} | |
{{% tab "Java" %}} | |
```java | |
OkHttpClient okHttpClient = new OkHttpClient.Builder() | |
.addNetworkInterceptor(new DatadogInterceptor.Builder(tracedHostsWithHeaderType).build()) | |
.build(); | |
``` | |
{{% /tab %}} | |
{{< /tabs >}} | |
- If you want RUM resources and Spans to be automatically created for your OkHttp requests, you can use the `DatadogInterceptor` as an interceptor. | |
- This records each request processed by the `OkHttpClient` as a resource, with all the relevant information (URL, method, status code, and error) automatically filled in. Only the network requests that started when a view is active are tracked. To track requests when your application is in the background, [create a view manually][13]. | |
- In case you want to monitor the network redirects or retries, you can use the `DatadogInterceptor` as a network interceptor: | |
{{< tabs >}} | |
{{% tab "Kotlin" %}} | |
\```kotlin | |
val okHttpClient = OkHttpClient.Builder() | |
.addNetworkInterceptor(DatadogInterceptor.Builder(tracedHostsWithHeaderType).build()) | |
.build() | |
\``` | |
{{% /tab %}} | |
{{% tab "Java" %}} | |
\```java | |
OkHttpClient okHttpClient = new OkHttpClient.Builder() | |
.addNetworkInterceptor(new DatadogInterceptor.Builder(tracedHostsWithHeaderType).build()) | |
.build(); | |
\``` | |
{{% /tab %}} | |
{{< /tabs >}} |
Note that in order to make that suggestion render properly in GitHub, I had to escape the code samples, so if you accept that change, you have to un-escape them. I don't know how to make that less buggy 😬
**Note**: In case you only want to have Spans without RUM resources, you can use the `TracingInterceptor` instead of `DatadogInterceptor` the same way we explained above. | ||
|
||
**Note**: If you also use multiple Interceptors, add `DatadogInterceptor` first. |
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.
**Note**: In case you only want to have Spans without RUM resources, you can use the `TracingInterceptor` instead of `DatadogInterceptor` the same way we explained above. | |
**Note**: If you also use multiple Interceptors, add `DatadogInterceptor` first. | |
**Notes**: | |
- If you only want to have Spans without RUM resources, you can use the `TracingInterceptor` in the place of the `DatadogInterceptor`. | |
- If you also use multiple Interceptors, add `DatadogInterceptor` first. |
What does this PR do? What is the motivation?
This pull request updates documentation for Android setup and custom instrumentation, focusing on improving clarity and providing additional examples. The most important changes include adding instructions for using
DatadogInterceptor
withOkHttpClient
and updating code snippets to correct terminology for accessing tracers.Additions to Android setup documentation:
DatadogInterceptor
as a network interceptor withOkHttpClient
to automatically create RUM resources and Spans for network requests. Included Kotlin and Java code examples.TracingInterceptor
can be used instead ofDatadogInterceptor
if only Spans are needed, without RUM resources.Updates to custom instrumentation documentation:
tracerProvider
withtracer
for accessing tracers viaGlobalOpenTelemetry.get()
, aligning with correct terminologyMerge instructions
Merge readiness:
For Datadog employees:
Merge queue is enabled in this repo. Your branch name MUST follow the
<name>/<description>
convention and include the forward slash (/
). Without this format, your pull request will not pass in CI, the GitLab pipeline will not run, and you won't get a branch preview. Getting a branch preview makes it easier for us to check any issues with your PR, such as broken links.If your branch doesn't follow this format, rename it or create a new branch and PR.
To have your PR automatically merged after it receives the required reviews, add the following PR comment:
Additional notes