Skip to main content

Network Instrumentation

Generates: Spans

Automatically instruments HTTP requests made via fetch, XMLHttpRequest, and axios.

How It Works

Pulse React Native SDK intercepts XMLHttpRequest (XHR) to automatically capture all HTTP requests:

Each network request automatically captures HTTP method, URL, status code, request type, and error information. GraphQL requests are automatically detected and enhanced with operation name and type attributes. See the Attributes section below for complete details.

Configuration

Network instrumentation is enabled by default. You can disable it if needed:

Pulse.start({
autoDetectNetwork: true // Enabled by default
});

When autoDetectNetwork: false, network requests are not automatically tracked. No spans are created for HTTP requests.

Note: You can still manually instrument network requests using Custom Spans.

Generated Telemetry

Type: Span
Span Name: HTTP {method} (e.g., HTTP GET, HTTP POST)
Span Kind: INTERNAL

Attributes

Network-Specific Attributes

AttributeDescriptionExampleAlways Present
pulse.typeInstrumentation type with Network code"network.200"✅ Yes
http.methodHTTP method"GET", "POST"✅ Yes
http.urlFull request URL"https://api.example.com/users/123"✅ Yes
http.request.typeRequest type"xmlhttprequest" (all requests, including fetch and Axios)✅ Yes
http.schemeURL scheme"https"⚠️ Only if URL is parseable
http.hostRequest hostname"api.example.com"⚠️ Only if URL is parseable
http.targetRequest path + query"/users/123" or "/api/users?id=123"⚠️ Only if URL is parseable
net.peer.nameServer hostname"api.example.com"⚠️ Only if URL is parseable
net.peer.portPort number8080⚠️ Only if URL contains port
http.status_codeResponse status code200, 404, 500⚠️ Only if response received
platformReact Native platform"android", "ios", "web"✅ Yes

GraphQL Attributes (for GraphQL requests)

AttributeDescriptionExampleAlways Present
graphql.operation.nameGraphQL operation name"GetUser", "CreatePost"Only if operation name is available
graphql.operation.typeGraphQL operation type"query", "mutation", "subscription"Only if operation type is available

Note: GraphQL attributes are automatically added when a request is detected as GraphQL. Detection is based on the URL containing "graphql" (case-insensitive). Attributes are extracted from the request body (POST) or query parameters (GET).

Error Attributes (on failure)

AttributeDescriptionExample
errorError flagtrue

Note: When a network request fails (HTTP error status codes 4xx/5xx or network failures), the span includes error: true and the http.status_code (if available). Network failures may have http.status_code: 0 or missing status code.

Sample Payload: Successful Network Request

{
"name": "HTTP GET",
"kind": "INTERNAL",
"startTimeUnixNano": "1732735072000000000",
"endTimeUnixNano": "1732735072427640000",
"duration": "427.64ms",
"attributes": {
"pulse.type": "network",
"http.method": "GET",
"http.url": "https://jsonplaceholder.typicode.com/comments/1",
"http.scheme": "https",
"http.host": "jsonplaceholder.typicode.com",
"http.target": "/comments/1",
"http.status_code": 200,
"http.request.type": "xmlhttprequest",
"net.peer.name": "jsonplaceholder.typicode.com",
"platform": "android",
"service.name": "PulseReactNativeOtelExample",
"service.version": "1.0_1",
"device.manufacturer": "Google",
"device.model.name": "sdk_gphone64_arm64",
"os.name": "Android",
"os.version": "16",
"network.connection.type": "cell",
"network.carrier.name": "T-Mobile",
"session.id": "e19b517c705f78d5937c38005259ee1f"
}
}

Note: http.request.type is always "xmlhttprequest" because all requests (including fetch() and Axios) are intercepted via XHR in React Native.

Sample Payload: Failed Network Request (404)

{
"name": "HTTP GET",
"kind": "INTERNAL",
"status": "ERROR",
"startTimeUnixNano": "1732735075000000000",
"endTimeUnixNano": "1732735075135340000",
"duration": "135.34ms",
"attributes": {
"pulse.type": "network",
"http.method": "GET",
"http.url": "https://jsonplaceholder.typicode.com/posts/999999",
"http.scheme": "https",
"http.host": "jsonplaceholder.typicode.com",
"http.target": "/posts/999999",
"http.status_code": 404,
"http.request.type": "xmlhttprequest",
"net.peer.name": "jsonplaceholder.typicode.com",
"error": true,
"platform": "android",
"service.name": "PulseReactNativeOtelExample",
"service.version": "1.0_1",
"device.manufacturer": "Google",
"device.model.name": "sdk_gphone64_arm64",
"os.name": "Android",
"os.version": "16",
"network.connection.type": "cell",
"network.carrier.name": "T-Mobile",
"session.id": "e19b517c705f78d5937c38005259ee1f"
}
}

Note: HTTP error status codes (4xx, 5xx) result in spans with status: "ERROR" and include error: true. Network failures (connection errors, timeouts) also include error: true and may have http.status_code: 0 or missing status code.

Sample Payload: GraphQL Request

{
"name": "HTTP POST",
"kind": "INTERNAL",
"startTimeUnixNano": "1732735072000000000",
"endTimeUnixNano": "1732735072427640000",
"duration": "427.64ms",
"attributes": {
"pulse.type": "network",
"http.method": "POST",
"http.url": "https://api.example.com/graphql",
"http.scheme": "https",
"http.host": "api.example.com",
"http.target": "/graphql",
"http.status_code": 200,
"http.request.type": "xmlhttprequest",
"graphql.operation.name": "GetUser",
"graphql.operation.type": "query",
"platform": "android"
}
}

Note: GraphQL requests are automatically detected when the URL contains "graphql" (case-insensitive). Operation name and type are extracted from the request body (POST) or query parameters (GET).

Global Attributes

All network spans include global attributes (service, device, OS, session, etc.). See Global Attributes for complete list.