Repository navigation
v0 [2/7]: startReactNativeSdk on mobile and web - #26
Conversation
Mobile attaches to native, or initializes it from the JS config (§4.4), and hands spans to native through NativeHandOffProcessor. Web builds its own TracerProvider with BatchSpanProcessor and the upstream OTLP/proto exporter (R7), picked by the package's `browser` export condition. The first call's handle wins; any failure logs once and returns a no-op handle. The native module accessor no longer swallows constructor errors; start reports them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93e8e3f to
9cc5976
Compare
| return base.endsWith('/v1/traces') ? base : base + '/v1/traces'; | ||
| } | ||
|
|
||
| /** `telemetry.distro.version` on web; a unit test keeps it equal to package.json's version. */ |
There was a problem hiding this comment.
q: why can't we read package.json's version directly?
There was a problem hiding this comment.
We can, and now we do: start.web.ts imports react-native-open-telemetry/package.json (a self-reference through the package's ./package.json export). It resolves in TypeScript, Jest, the built lib/ and Metro's web export (web e2e passes). DISTRO_VERSION and its sync test are gone in d2849ec, and the release script now only keeps the iOS constant (#25). One cost: Metro bundles the whole package.json (a few KB) into the web bundle. iOS still has a hand-kept constant, because Swift has no build-time access to package.json.
| } | ||
|
|
||
| /** One endpoint meaning on every platform (§4.4). Mobile passes the base URL; native applies the same rule. */ | ||
| export function tracesUrl(url: string): string { |
There was a problem hiding this comment.
feels like we're overcomplicating it, just ask for a specific URL
There was a problem hiding this comment.
Agreed. url is now the OTLP/HTTP traces endpoint, used as given (e.g. https://collector:4318/v1/traces), on every platform: tracesUrl is removed here (d2849ec), in the Kotlin core (#22, a98a215) and in the Swift core (#23, 81ec9eb). The example apps (#24) and the spec §4.4, plan, README and MIGRATION (#25) use the full URL.
There was a problem hiding this comment.
why have any bundle size related code?
It bundled the example app with Metro on every static run against a committed baseline nobody set a budget for. Removes bundleSize.ts, its test and baseline, the static step, and CI's example install that existed only for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…istro version from package.json - No `/v1/traces` appending: `url` is the full OTLP/HTTP traces endpoint (§4.4). Native follows in the Android and iOS layers. - Web reads `telemetry.distro.version` from the package's own `package.json` (self-reference through the `./package.json` export), so there is no hand-kept version constant. - Tests: dropped the ones that only re-checked upstream or a constant (a span's default start time, the URL helper, DISTRO_VERSION against package.json); the web URL test is one case now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
startReactNativeSdk(config?)(src/sdk/):start.ts): attaches to native, or initializes it from the JS config (§4.4). Spans go to native throughNativeHandOffProcessor, and native owns the resource.start.web.ts): builds its ownTracerProviderwithBatchSpanProcessorand the upstream OTLP/proto exporter (R7). The package'sbrowserexport condition selects it.shared.ts): registers the global provider, stamps every tracer's scope and starts the probe from v0 [1/7]: context propagation — runtime patch, startup probe, Metro helper #21. The first call's handle wins (D10).noop.ts): any failure logs one error and returns a no-op handle. The SDK never throws into the app.package.json:browserexport, typed./setup.@opentelemetry/exporter-trace-otlp-protobecomes a dependency and replaces@opentelemetry/browser-sdk.jsdomis added as a dev dependency for the web unit test.exportConfig.urlis the OTLP/HTTP traces endpoint, used as given; the version fortelemetry.distro.versioncomes from the package's ownpackage.json.native/otel.tsno longer swallows HybridObject constructor errors;startreports them.testMode.tsreads plainprocess.env.OTEL_TEST_MODE, the form Babel inlines.Verified locally
bun verify static fast-js: 33 + 42 tests green (12 scenario todos until the next PR).Decisions for you (defaults applied; override with
spec:comments)TracerProviderwith the OTLP proto exporter instead of usingstartBrowserSdk. Spec §7 is rewritten, and@opentelemetry/browser-sdkis removed.Part of the v0 stack that replaces #20 for review, bottom-up: #21 context → #26 SDK → #27 JS scenarios → #22 Android → #23 iOS → #24 examples + e2e → #25 ops. Review fixes land as new commits on the layer they belong to, and the layers above are rebased. History before the split:
v0-impl/ #20. Nothing publishes: release runs only after CI onmain, and the npm environment does not exist yet.🤖 Generated with Claude Code