You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`http.target`, `http.host`, `http.scheme` — parts of the request URL when available
40
+
-`http.status_code` — response status code
41
+
-`http.flavor` — protocol (e.g. `1.1`)
42
+
-`net.peer.name` — server host
43
+
-`net.peer.port` — server port
44
+
- Request and response headers captured according to configuration: `http.request.header.*` / `http.response.header.*`
45
+
46
+
If the request throws an IOException, the span is ended and the exception is recorded.
47
+
48
+
### Configuration impact on telemetry
49
+
50
+
You can customize which request and response headers are captured and other behavior via
51
+
the `HttpUrlInstrumentation` setters exposed through `AndroidInstrumentationLoader`.
52
+
These settings are applied when `HttpUrlConnectionSingletons.configure(...)` is called
53
+
during instrumentation setup. See the `Configurations` section above for how to access
54
+
the instrumentation instance.
55
+
56
+
### Distributed tracing propagation
57
+
58
+
The instrumentation injects the configured context propagators into the request using
59
+
request properties (via a TextMap setter), allowing distributed tracing across services.
60
+
10
61
## Quickstart
11
62
12
63
### Overview
13
64
14
65
This plugin enhances the Android application host code by instrumenting all critical APIs (specifically those that initiate a connection). It intercepts calls to these APIs to ensure the following actions are performed:
66
+
15
67
- Context is added for distributed tracing before actual API is called (i.e before connection is initiated).
16
68
- Traces and spans are generated and properly closed.
17
69
- Any exceptions thrown are recorded.
18
70
19
71
A span associated with a given request is concluded in the following scenarios:
72
+
20
73
- When the getInputStream()/getErrorStream() APIs are called, the span concludes after the stream is fully read, an IOException is encountered, or the stream is closed.
21
74
- When the disconnect API is called.
22
75
23
76
Spans won't be automatically ended and reported otherwise. If any of your URLConnection requests do not call the span concluding APIs mentioned above, refer the section entitled ["Scheduling Harvester Thread"](#scheduling-harvester-thread). This section provides guidance on setting up a recurring thread that identifies unreported, idle connections and ends/reports any open spans associated with them. Idle connections are those that have been read from previously but have been inactive for a particular configurable time interval (defaults to 10 seconds).
24
77
25
78
> The minimum supported Android SDK version is 21, though it will also instrument APIs added in the Android SDK version 26 when running on devices with API level 26 and above.
26
-
27
79
> If your project's minSdk is lower than 26, then you must enable
To schedule a periodically running thread to conclude/report spans on any unreported, idle connections, add the below code in the function where your application starts ( that could be onCreate() method of first Activity/Fragment/Service):
instrumentation.setConnectionInactivityTimeoutMs(customTimeoutValue); //This is optional. Replace customTimeoutValue with a long data type value which denotes the connection inactivity timeout in milli seconds. Defaults to 10000ms
- It is efficient to run the harvester thread at the same time interval as the connection inactivity timeout used to identify the connections to be reported. `instrumentation.getReportIdleConnectionInterval()` is the API to get the same connection inactivity timeout interval (milliseconds) you have configured or the default value of 10000ms if not configured.
73
127
74
128
#### Other Optional Configurations
129
+
75
130
You can optionally configure the automatic instrumentation by using the setters from [HttpUrlInstrumentation](library/src/main/java/io/opentelemetry/instrumentation/library/httpurlconnection/HttpUrlInstrumentation.kt)
76
131
instance provided via the AndroidInstrumentationLoader as shown below:
0 commit comments