LogDrop

Tracing

Trace React Native requests from the device into your backend with the LogDrop React Native SDK.

The native LogDrop SDKs that the React Native package depends on trace the HTTP requests your app makes with fetch, XMLHttpRequest and libraries built on them, such as axios: each request gets a W3C traceparent header and is sent as one client span. The JavaScript layer creates, queues and sends no spans, so there is no OpenTelemetry package to add and nothing to configure in JavaScript.

A backend traced by LogDrop continues the same trace, so one request shows up in Trace Explorer from the device into your services.

Rules that all LogDrop mobile SDKs share (authentication, which requests are traced, delivery and limits) are on End-to-end Tracing.

1. Use SDK 2.1.2 or later

Tracing needs React Native SDK 2.1.2 or later. Update the package, then run pod install so the iOS app gets the matching native SDK:

npm install @log-drop/react-native@2.2.0
cd ios && pod install && cd ..

Version 2.1.2 brings the native Android and iOS SDKs 2.1.11, which contain the tracing. An app can pin a newer native Android SDK with ext.logdropSdkVersion in its root build.gradle.

Android: apply the LogDrop Gradle plugin, as in Android setup. It adds LogDrop's interceptor to every OkHttp client in the app, including the one React Native's networking uses. Without it, nothing is traced on Android.

iOS: nothing beyond pod install and the usual initialization: React Native's networking uses the default URLSession configuration, which the SDK instruments.

2. Initialize as usual

Tracing uses the initialization your app already has; there is no separate tracing call. The Android and iOS SDKs start in different places:

Android, in MainApplication.kt:

val config = LogDropReactNativeConfig.Builder(this)
    .appId("YOUR_APP_ID")
    .baseUrl("YOUR_BASE_URL")
    .build()
LogDropReactNative.initLogDrop(config)

JavaScript, in index.js before AppRegistry.registerComponent (this initializes the iOS SDK):

import { LogDrop, LogDropConfigBuilder } from '@log-drop/react-native';

LogDrop.init(new LogDropConfigBuilder().setAppId('YOUR_APP_ID').setBaseUrl('YOUR_BASE_URL').build());

The App ID is all the SDK needs: spans go to <base URL>/v1/traces with the header x-logdrop-app-id. Turn on HTTP Logging for the project in the panel. On the first launch after install, tracing starts once the SDK has the project's settings from LogDrop; requests sent before that carry no header.

Your backend must send its traces to the same LogDrop project as this app, with an ingest key created in the app's project (why).

What is traced

Not every request gets a trace. This list shows which requests get a traceparent header and a span, and what a span contains.

  • fetch, XMLHttpRequest and libraries built on them. Requests that native modules make are traced by the native SDKs, as described for Android and iOS.
  • A valid traceparent you set yourself is kept, sampled or not, and no span is sent for it; a missing, malformed or all-zero one is replaced. Requests to LogDrop's own endpoints are never traced.
  • A span carries the method, scheme, host and port, the status code or an error type, timing, the trace and span IDs, and your app's identifier and version. No paths, query strings, headers or bodies.

The other rules are in Which requests are traced.

Delivery

The native SDKs store spans encrypted, then send them in the background with the limits and retries in Delivery. LogDrop.setAppId(...) drops the spans queued for the previous App ID.

Send queued spans now (optional)

The SDK sends spans on its own. flushOtlpTracing asks it to send the queued spans now and tells you whether that worked.

const delivered = await LogDrop.flushOtlpTracing(3000);   // milliseconds: 1 to 5,000, default 2,000
  • It resolves true only when the native queue was delivered. A timeout outside 1 to 5,000 ms is brought into that range.
  • It resolves false on timeout, while delivery is still pending, after spans were dropped since the previous flush, when the SDK is not initialized, and on platforms other than Android and iOS. It never rejects.
  • When the SDK or HTTP Logging is off, it resolves false on iOS but true on Android, where the queue is cleared. The result does not tell you whether tracing is on.

Use it, for example, before a test ends or before the user signs out.

Check it

To confirm that tracing works, make one request from the app and find its trace in the panel. Follow Check it. The device span is under your app's package name (Android) or bundle identifier (iOS) in Trace Explorer.

Known limits

In these cases a trace can miss device spans, or a request sent again shows up as a separate trace.

  • iOS: URLSession's own retries share one client span. When a reused connection closes before any response, URLSession may resend an idempotent request (a GET from fetch, for example) by itself; both attempts carry the same traceparent. The trace stays connected, but the device side shows one attempt. Android gives each attempt its own span.
  • App-level retries start a new trace, for example a request that axios-retry sends again.
  • The device clock must not run more than 5 minutes ahead of LogDrop's.

On this page