Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Guarded by the minified Expo release e2e (Task 28): recheck these rules on every otel-java bump.
# Guarded by the minified Expo release e2e: recheck these rules on every otel-java bump.
# otel-java references optional, compile-only classes it never loads at runtime here (no autoconfigure, no incubator,
# annotations only); R8 in a minifying app fails on them as missing.
-dontwarn com.google.auto.value.**
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/callstack/otel/core/OtelCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class OtelCore(config: CoreConfig, testMode: Boolean = false, distroVersion: Str
OtlpHttpSpanExporter.builder().setEndpoint(config.exportUrl)
.apply { config.exportHeaders.forEach { (k, v) -> addHeader(k, v) } }.build()
},
// test mode: no timed export within a device test, so only flush and background export send (Task 27)
// test mode: no timed export within a device test, so only flush and background export send
).apply { if (testMode) setScheduleDelay(120, TimeUnit.SECONDS) }.build()

/** The native TracerProvider; JS spans join its batch processor. */
Expand Down
611 changes: 0 additions & 611 deletions docs/superpowers/plans/2026-11-21-rn-otel-v0.md

This file was deleted.

5 changes: 2 additions & 3 deletions docs/superpowers/specs/2026-11-10-rn-otel-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class NativeHandOffProcessor implements SpanProcessor {
- iOS: the core (`ios/Core/*.swift`) takes opentelemetry-swift types only. Nitro's
generated Swift structs are typealiases of C++ structs, so code using them needs C++
interop, and the core must not (below): the Nitro adapter pod builds `SpanData` from
the seam structs and hands the core `ReadableSpan`s. *(R24, Task 25: the app's non-interop Swift `AppDelegate` cannot import a Nitro C++-interop module, so iOS ships
the seam structs and hands the core `ReadableSpan`s. *(R24: the app's non-interop Swift `AppDelegate` cannot import a Nitro C++-interop module, so iOS ships
two pods: pure-Swift `ReactNativeOpenTelemetryCore` (`ios/Core` + `RNOtel`) and the Nitro adapter pod that
depends on it. Autolinking links one podspec per package, so apps add `pod 'ReactNativeOpenTelemetryCore',
:path => '../node_modules/react-native-open-telemetry'` to their Podfile.)*
Expand Down Expand Up @@ -574,8 +574,7 @@ Sequencing (from review; council review 2026-11-21 added step 0):
4. Expected-file goldens and parity check on both platforms.
5. Web.

Each step is defined by the list of scenario names that must pass (9.3); the implementation
plan carries those lists.
Each step is defined by the list of scenario names that must pass (9.3).

## 9. Verification (decided)

Expand Down
2 changes: 1 addition & 1 deletion example-expo/plugins/withOtelExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tasks.matching { it.name.startsWith("createBundle") }.configureEach {
`;

/**
* Example-only (Task 28): what the bare example's native projects carry by hand, applied at `expo prebuild`. The Core
* Example-only: what the bare example's native projects carry by hand, applied at `expo prebuild`. The Core
* pod (R24) comes from the package's own plugin (`react-native-open-telemetry` in app.json), as in a real Expo app.
*/
module.exports = config => {
Expand Down
2 changes: 1 addition & 1 deletion example/modules/test-native/TestNative.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Example-only Nitro module (Task 26, R25): app native code using the public RNOtel API.
# Example-only Nitro module (R25): app native code using the public RNOtel API.
Pod::Spec.new do |s|
s.name = "TestNative"
s.version = "0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion example/modules/test-native/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Example-only Nitro module (Task 26, R25). Versions follow the app (rootProject.ext), as autolinked libraries do.
// Example-only Nitro module (R25). Versions follow the app (rootProject.ext), as autolinked libraries do.
apply plugin: "com.android.library"
apply plugin: "org.jetbrains.kotlin.android"
apply from: "../nitrogen/generated/android/TestNative+autolinking.gradle"
Expand Down
2 changes: 1 addition & 1 deletion example/modules/test-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-test-native",
"version": "0.0.0",
"private": true,
"description": "Example-only HybridObject: app native code using the public RNOtel helpers (Task 26)",
"description": "Example-only HybridObject: app native code using the public RNOtel helpers",
"scripts": {
"codegen": "../../../node_modules/.bin/nitrogen"
}
Expand Down
4 changes: 2 additions & 2 deletions example/modules/test-native/src/TestNative.nitro.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {HybridObject} from 'react-native-nitro-modules';

/** Example-only (Task 26): app native code that parents its spans with the public `RNOtel` helpers. */
/** Example-only: app native code that parents its spans with the public `RNOtel` helpers. */
export interface TestNative extends HybridObject<{ios: 'swift'; android: 'kotlin'}> {
/** Starts and ends `native.work` under `traceparent` ('' = a root) at `start`/`end` ([s, ns]), returns its traceparent. */
doWork(traceparent: string, start: number[], end: number[]): string;
/** Reloads the JS app natively, as OTA updaters do; `DevSettings.reload()` is a no-op in release (Task 27). */
/** Reloads the JS app natively, as OTA updaters do; `DevSettings.reload()` is a no-op in release. */
reload(): void;
}
6 changes: 3 additions & 3 deletions example/src/ScenariosScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import {allScenarios} from '../../verify/scenarios';
import type {TestNative} from '../modules/test-native/src/TestNative.nitro';

// Failure scenarios (Task 27) whose e2e test decides when, or whether, anything flushes.
// Failure scenarios whose e2e test decides when, or whether, anything flushes.
const NO_FLUSH = new Set(['collector-down', 'flush-after-reload', 'background-flush']);
const TEST_MODE = process.env.OTEL_TEST_MODE === '1';

// fast-refresh-idempotent (Task 27): the patched functions as first seen; `??=` keeps them across re-evaluations of
// fast-refresh-idempotent: the patched functions as first seen; `??=` keeps them across re-evaluations of
// this module, so a refresh that stacked the patch shows `changed`. The e2e edit counts in `__otelRefreshes`.
const g = globalThis as any;
g.__otelFirstPatch ??= {then: Promise.prototype.then, setTimeout: g.setTimeout};

Check warning on line 18 in example/src/ScenariosScreen.tsx

View workflow job for this annotation

GitHub Actions / static-fast

unicorn(no-thenable)

example/src/ScenariosScreen.tsx:18:25: Do not add `then` to an object.
const patchIdentity = () =>
`${g.__otelFirstPatch.then === Promise.prototype.then && g.__otelFirstPatch.setTimeout === g.setTimeout ? 'same' : 'changed'} refreshes=${g.__otelRefreshes ?? 0}`;

Expand Down Expand Up @@ -51,7 +51,7 @@
).finally(() => setRunning(null));
}, [running]);

// test-mode only (Task 27): each resolved forceFlush shows `flush-done-<n>`, so a wait never matches a stale one
// test-mode only: each resolved forceFlush shows `flush-done-<n>`, so a wait never matches a stale one
const [flushes, setFlushes] = useState(0);
const flush = () => startReactNativeSdk().forceFlush().then(() => setFlushes(n => n + 1));

Expand Down
2 changes: 1 addition & 1 deletion ios/Core/OtelCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ package final class OtelCore {
OtlpHttpTraceExporter(endpoint: $0, envVarHeaders: config.exportHeaders.map { ($0.key, $0.value) })
}
}
// test mode: no timed export within a device test, so only flush and background export send (Task 27)
// test mode: no timed export within a device test, so only flush and background export send
bsp = BatchSpanProcessor(spanExporter: exporter, scheduleDelay: testMode ? 120 : 5) // 5 s: upstream's default
let b = TracerProviderBuilder().with(resource: resource).add(spanProcessor: bsp)
tracerProvider = (testMode ? b.with(idGenerator: SequentialIds()) : b).build()
Expand Down
36 changes: 17 additions & 19 deletions verify/VERIFY.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ exports through `startReactNativeSdk` and the Kotlin or Swift core. One file for
the two init paths are equivalent. A scenario that only one app can run names targets (`android-bare`) instead of
platforms in `targets`.

**Fixtures by target kind (Task 23).** `harness.ts` has two chains: `test` (device targets: its auto `installed`
**Fixtures by target kind.** `harness.ts` has two chains: `test` (device targets: its auto `installed`
fixture and `target` name `device`, so every `test(…)` passes `{platforms: MOBILE}`) and `webTest` (a fresh browser
context per test; `target` is the platform, `web`). `anyTarget(title, body)` registers one body on both; e2e titles must
be unique, so the web copy is `web › <title>`.

**TestNative (R25, Task 26).** `cross-*` scenarios call `ctx.native`, the example-only Nitro HybridObject in
**TestNative (R25).** `cross-*` scenarios call `ctx.native`, the example-only Nitro HybridObject in
`example/modules/test-native/` (own `nitro.json`, podspec, `build.gradle`; autolinked through
`example/react-native.config.js`). It uses only the public `RNOtel` helpers. After editing its spec, regenerate with
`bun run codegen` in that directory (the patched root nitrogen) and commit `nitrogen/generated`.

**iOS pods (R24).** An app's Swift `AppDelegate` cannot `import ReactNativeOpenTelemetry`: the Nitro pod is built with
C++ interop and the app is not (Task 25 Step 0: `'functional' file not found` while building `NitroModules`). So
C++ interop and the app is not (`'functional' file not found` while building `NitroModules`). So
iOS ships two pods: `ReactNativeOpenTelemetryCore` (pure Swift: `ios/Core` + the public `RNOtel` in `ios/RNOtel`) and
the Nitro adapter `ReactNativeOpenTelemetry` (`ios/Adapter`), which depends on it and reaches the core's `package`
declarations through one `-package-name`. Autolinking links only the adapter, so the app's Podfile adds
`pod 'ReactNativeOpenTelemetryCore', :path => '<package dir>'`. Both linkages build: the default static libraries
(CI) and `USE_FRAMEWORKS=static` (checked locally in Task 25, not a CI job: e2e `ios-bare` 18/18 on that build).
(CI) and `USE_FRAMEWORKS=static` (checked locally, not a CI job: e2e `ios-bare` 18/18 on that build).

**`performance.timeOrigin` on Hermes (X17, Task 13).** Defined on both platforms (RN 0.88.1 release, Hermes),
**`performance.timeOrigin` on Hermes (X17).** Defined on both platforms (RN 0.88.1 release, Hermes),
checked with a one-off `console.log` of `timeOrigin`, `performance.now()` and `Date.now()` at app start:
Android `timeOrigin + now()` = `Date.now()` within 1 ms; **iOS simulator `timeOrigin + now()` was ~23.9 h behind
`Date.now()`** (the monotonic clock under `now()` stopped while the host slept; `timeOrigin` stayed at simulator boot).
Expand All @@ -87,7 +87,7 @@ an argument) can be off by that skew on iOS.

The fake collector listens on port 4318; the app reaches it at `10.0.2.2` (Android emulator) or `localhost` (iOS simulator).

## Expo app (Task 28)
## Expo app

`example-expo/`: **Expo SDK 58** (`expo` 58.0.26), **React Native 0.88.1**, React 19.3.0, `react-native-nitro-modules`
0.37.2, all pinned exactly. SDK 58 is the newest Expo SDK (npm `latest`, 2026-11-24) and bundles the same RN as the bare
Expand Down Expand Up @@ -117,7 +117,7 @@ unproven until their first CI run.
- **Not on Expo:** `native-init-failure` (`targets: ['android-bare', 'ios-bare']`): the bad URL goes to the bare app's
native init, and the Expo app has none. `fast-refresh-idempotent` runs on the bare dev builds only, locally.

## Web (Task 23)
## Web

The `web` target is the Expo app's Metro web export (`example-expo`, `expo export -p web`): its `ScenariosScreen`
through react-native-web 0.21.4 (react-dom 19.3.0). `index.js` inits first with
Expand Down Expand Up @@ -146,7 +146,7 @@ HybridObjects: no native `testMode` line, scenarios get no `native`).
(the native reload; a page reload drops the JS context, a different guarantee), `background-flush` (app
background; the browser `pagehide` flush is not covered), `fast-refresh-idempotent`, `native test mode reaches initialize`.

## Failure scenarios (Task 27)
## Failure scenarios

Each has its own e2e file (R10); the ScenariosScreen does not `forceFlush()` after `collector-down`,
`flush-after-reload` and `background-flush`, so the test decides what exports. Test-mode-only screen controls:
Expand Down Expand Up @@ -191,7 +191,7 @@ Each has its own e2e file (R10); the ScenariosScreen does not `forceFlush()` aft

If watchman reports recrawls, restart Metro: a dead watch never delivers the edit.

## Android cold start with `RNOtel.start` (Task 24, 2026-11-24)
## Android cold start with `RNOtel.start` (2026-11-24)

`adb shell am start -W -n opentelemetry.example/.MainActivity` after `am force-stop`, 6 launches each, Pixel_9
emulator (API 36, arm64), release test-mode build. `TotalTime` (ms):
Expand All @@ -203,31 +203,29 @@ emulator (API 36, arm64), release test-mode build. `TotalTime` (ms):

Emulator noise (±100 ms between runs) is larger than the difference; `RNOtel.start` builds the resource, the
batch processor and the provider, but no exporter or OkHttp client (built on the first export, on the BSP thread).
Task 29 measures properly on a device.

## Device capability check (Task 7, 2026-11-23)
## Device capability check (2026-11-23)

What Task 27 (reload, fast refresh, background flush) needs from agent-device.
What the failure scenarios (reload, fast refresh, background flush) need from agent-device.
iOS: iPhone 18 Pro simulator, iOS 27.0, Xcode 27.1, agent-device 0.21.36 (T3 device panel), RN 0.88.1 Debug build + Metro.

| Capability | iOS simulator | Android emulator (Pixel_9) |
| --- | --- | --- |
| JS reload | ✓ `agent-device metro reload` (Metro re-bundled; screen state reset). Release: native reload via TestNative (Task 27) | ✓ release: native reload via TestNative, e2e `flush-after-reload` (Task 27). `DevSettings.reload()` is a no-op in release |
| Fast refresh (dev build) | ✓ editing `ScenariosScreen.tsx` text showed on device with React state kept | ✓ e2e `fast-refresh-idempotent` on `android-dev` (Task 27) |
| Background and back | ✓ `agent-device home`, then `open opentelemetry.example`: UIKit logged the background task end and `UIApplicationWillEnterForegroundNotification`; state kept. `appstate` still says `runningForeground` after `home` (known iOS quirk, documented by e2e), so check lifecycle in the log, not `appstate` | ✓ `device.home()` in e2e `background-flush` (Task 27) |
| Read logs | ✓ `agent-device logs start/stop` captures the app's unified log, `NSLog` lines included (`RNOtel handOff …`). The e2e harness reads with `xcrun simctl spawn <udid> log show --predicate 'process == "OpenTelemetryExample" …'` | ✓ via the e2e harness: `adb logcat -d -s RNOtel:I` (tracer-bullet test green; the test was retired in Task 24, R14) |
| JS reload | ✓ `agent-device metro reload` (Metro re-bundled; screen state reset). Release: native reload via TestNative | ✓ release: native reload via TestNative, e2e `flush-after-reload`. `DevSettings.reload()` is a no-op in release |
| Fast refresh (dev build) | ✓ editing `ScenariosScreen.tsx` text showed on device with React state kept | ✓ e2e `fast-refresh-idempotent` on `android-dev` |
| Background and back | ✓ `agent-device home`, then `open opentelemetry.example`: UIKit logged the background task end and `UIApplicationWillEnterForegroundNotification`; state kept. `appstate` still says `runningForeground` after `home` (known iOS quirk, documented by e2e), so check lifecycle in the log, not `appstate` | ✓ `device.home()` in e2e `background-flush` |
| Read logs | ✓ `agent-device logs start/stop` captures the app's unified log, `NSLog` lines included (`RNOtel handOff …`). The e2e harness reads with `xcrun simctl spawn <udid> log show --predicate 'process == "OpenTelemetryExample" …'` | ✓ via the e2e harness: `adb logcat -d -s RNOtel:I` (tracer-bullet test green; the test was later retired, R14) |

**Blocker (Android, interactive only):** the T3 device panel could not open `Pixel_9`:
`Failed to allocate an emulator port for Pixel_9 … avdmanager: … Unable to locate a Java Runtime.`
The T3 host process has no `JAVA_HOME`, so `avdmanager list avd` fails. The emulator itself boots and the e2e runner
(`@e2e-dev/mobile`, agent-device 0.21.39) drives it fine. Reload / fast refresh / background on Android still need a
check before Task 27; fix the T3 host's Java (or run the check through an e2e test) and fill in the column. Task 27 filled it in through e2e tests.
(`@e2e-dev/mobile`, agent-device 0.21.39) drives it fine. The Android column was filled in through e2e tests.

## Scenarios

One file per guarantee in `verify/scenarios/`, named after it, with one exact `verify/expected/<name>.otlp.json` that
every platform compares against. It is drafted with `VERIFY_UPDATE=1` (or `VERIFY_E2E_DRAFT=1` for e2e-only scenarios,
from Android or web) and reviewed by the author. `pending` scenarios report as `todo`; the owning task flips `pending` off.
from Android or web) and reviewed by the author. `pending` scenarios report as `todo`; un-pend a scenario once it passes.

Every file uses the JS runner's resource, `service.name` only. Native test mode builds the resource from config only and
the example inits with no `serviceVersion` (R2), so native-first device runs match the same files.
Expand Down
6 changes: 3 additions & 3 deletions verify/e2e/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {web} from '@e2e-dev/web';

const bundleId = 'opentelemetry.example';
const example = '../../example';
// Expo prebuild app (JS-fallback init, Task 28): same scenarios, same android/ios expected files
// Expo prebuild app (JS-fallback init): same scenarios, same expected files
const expo = '../../example-expo';

export default {
Expand Down Expand Up @@ -49,7 +49,7 @@ export default {
appPath: process.env.E2E_IOS_EXPO_APP ?? `${expo}/ios/build/Build/Products/Release-iphonesimulator/OpenTelemetryExpo.app`,
},
},
// The Expo app's Metro web export (react-native-web), exporting with the web SDK (Task 23).
// The Expo app's Metro web export (react-native-web), exporting with the web SDK.
// The runner exports it in test mode (lib/ first: `bun run prepare`) and serves it with `expo serve`.
{
name: 'web',
Expand All @@ -66,7 +66,7 @@ export default {
},
},
},
// Dev builds (Debug + Metro), local only: fast-refresh-idempotent (Task 27). See VERIFY.md.
// Dev builds (Debug + Metro), local only: fast-refresh-idempotent. See VERIFY.md.
...(process.env.E2E_DEV === '1'
? [
{
Expand Down
6 changes: 3 additions & 3 deletions verify/e2e/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

// One collector per worker. Each chain below declares it; a target runs only one chain's tests (`platforms`).
const collector = [
async ({}, use: (c: Collector) => Promise<void>) => {

Check warning on line 40 in verify/e2e/harness.ts

View workflow job for this annotation

GitHub Actions / static-fast

eslint(no-empty-pattern)

verify/e2e/harness.ts:40:10: Empty object binding pattern
const c = await startCollector({port: COLLECTOR_PORT, artifactsDir: path.join(verifyDir, 'artifacts')});
await use(c);
await c.close();
Expand Down Expand Up @@ -86,7 +86,7 @@
);
}

/** Steps the failure scenarios (Task 27) add around the tap-and-compare. */
/** Steps the failure scenarios add around the tap-and-compare. */
export type ScenarioSteps = {
/** Replaces the cold start, e.g. to relaunch with launch arguments. */
launch?: () => Promise<void>;
Expand Down Expand Up @@ -121,8 +121,8 @@
} finally {
actual = await collector.end();
}
// every app exports through the native core (bare: native-first init, Expo: JS-fallback init), so android-* compare
// to `android` files and ios-* to `ios` (R13): one set of files proves both init paths equivalent (Task 28).
// every app exports through the native core (bare: native-first init, Expo: JS-fallback init), so one expected
// file per scenario proves both init paths equivalent (R13).
// VERIFY_E2E_DRAFT=1 writes a missing expected file and still fails (review it, then rerun)
const r = compareToExpected(name, platformOf(target), actual, {draft: process.env.VERIFY_E2E_DRAFT === '1'});
if (!r.ok) throw new Error('\n' + r.report);
Expand Down
2 changes: 1 addition & 1 deletion verify/scenarios/background-flush.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {scenario} from '../harness/scenario';

/**
* Background flush (§9.4, Task 27): run this and background the app immediately. The span arrives without
* Background flush (§9.4): run this and background the app immediately. The span arrives without
* `forceFlush()`, exactly once; no ANR on Android.
*/
export default scenario(
Expand Down
2 changes: 1 addition & 1 deletion verify/scenarios/captured-then.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {scenario} from '../harness/scenario';
/**
* Documented exception (§6.1 install order): code holding the `then` captured before the patch ran
* loses the parent and starts a new root; the patched `then` keeps it.
* The pre-patch `then` is read from the patch marker (Task 10 stores the originals there).
* The pre-patch `then` is read from the patch marker (the patch stores the originals there).
*/
export default scenario(
'captured-then',
Expand Down
2 changes: 1 addition & 1 deletion verify/scenarios/collector-down.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {scenario} from '../harness/scenario';

/**
* Collector down (§9.4 failure scenarios, Task 27): the e2e test makes the collector `refuse(503, 3)`.
* Collector down (§9.4 failure scenarios): the e2e test makes the collector `refuse(503, 3)`.
* The app does not block or crash (`scenario-done` within 2 s) and, once the collector accepts again,
* the span arrives exactly once.
*/
Expand Down
2 changes: 1 addition & 1 deletion verify/scenarios/cross-js-to-native.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {scenario} from '../harness/scenario';

/**
* A native span started from JS is a child of the active JS span (Task 26).
* A native span started from JS is a child of the active JS span.
* Steps: JS span `js.parent` active → `ctx.native.doWork(traceparent, start, end)` starts and ends native
* `native.work` with `contextFrom(traceparent)` as parent. Proof: one trace, `native.work` (a `0b…` id)
* has `js.parent` as parent.
Expand Down
Loading
Loading