diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c099f92..311b289 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,26 +46,6 @@ jobs: path: verify/artifacts/ if-no-files-found: ignore - fast-swift: - runs-on: macos-15 - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '16.4' - - uses: oven-sh/setup-bun@v2 - with: - bun-version: 1.2.19 - - run: bun install --frozen-lockfile - - run: bun verify fast-swift # no-op until Package.swift exists (Task 18) - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: verify-artifacts-fast-swift - path: verify/artifacts/ - if-no-files-found: ignore - # Release builds with the JS bundle embedded (no Metro), test mode on. # Native outputs are cached on native inputs only, so a JS-only change re-bundles but reuses the native build. e2e-android-bare: @@ -200,7 +180,7 @@ jobs: if-no-files-found: ignore budget: - needs: [static-fast, fast-swift, e2e-android-bare, e2e-ios-bare] # every other job; extend when jobs are added + needs: [static-fast, e2e-android-bare, e2e-ios-bare] # every other job; extend when jobs are added if: always() runs-on: ubuntu-latest timeout-minutes: 5 diff --git a/android/build.gradle b/android/build.gradle index ede1486..0ce563d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -18,6 +18,8 @@ def getExtOrIntegerDefault(name) { // Test mode is a build flag, never API: -PotelTestMode=true (or otelTestMode=true in the app's gradle.properties). def otelTestMode = (findProperty("otelTestMode") ?: "false").toString() == "true" +// telemetry.distro.version = the npm package version +def otelDistroVersion = new groovy.json.JsonSlurper().parse(file("../package.json")).version android { namespace "com.margelo.nitro.callstack.otel" @@ -29,6 +31,9 @@ android { minSdkVersion getExtOrIntegerDefault("minSdkVersion") targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") buildConfigField "boolean", "OTEL_TEST_MODE", otelTestMode.toString() + buildConfigField "String", "OTEL_DISTRO_VERSION", "\"${otelDistroVersion}\"" + // apps that minify (Expo's release default) need these + consumerProguardFiles "consumer-rules.pro" externalNativeBuild { cmake { @@ -95,8 +100,12 @@ repositories { dependencies { implementation "com.facebook.react:react-android" implementation project(":react-native-nitro-modules") + // ProcessLifecycleOwner: background flush on ON_STOP (same version React Native already resolves) + implementation "androidx.lifecycle:lifecycle-process:2.6.2" - implementation platform("io.opentelemetry:opentelemetry-bom:1.68.0") + // RNOtel's public signatures expose Tracer, Span and Context: the API is part of ours + api platform("io.opentelemetry:opentelemetry-bom:1.68.0") + api "io.opentelemetry:opentelemetry-api" implementation "io.opentelemetry:opentelemetry-sdk" // The OkHttp sender runs on React Native's own OkHttp (every okhttp3 member the 1.68 sender uses exists in 4.9.2); // excluding it keeps otel-java from pulling the app up to OkHttp 5. diff --git a/android/consumer-rules.pro b/android/consumer-rules.pro new file mode 100644 index 0000000..6f1650f --- /dev/null +++ b/android/consumer-rules.pro @@ -0,0 +1,11 @@ +# Guarded by the minified Expo release e2e (Task 28): 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.** +-dontwarn com.google.errorprone.annotations.** +-dontwarn io.opentelemetry.api.incubator.** +-dontwarn io.opentelemetry.sdk.autoconfigure.spi.** + +# otel-java's ResourceMarshaler reaches Resource/ResourceBuilder entity methods by reflection (EntityUtil) on every +# export; renamed or merged, the export throws and nothing is sent. +-keep class io.opentelemetry.sdk.resources.** { *; } diff --git a/android/gradle.properties b/android/gradle.properties index dc55b22..c315c79 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ ReactNativeOpenTelemetry_kotlinVersion=2.1.21 -ReactNativeOpenTelemetry_minSdkVersion=24 +ReactNativeOpenTelemetry_minSdkVersion=26 ReactNativeOpenTelemetry_targetSdkVersion=36 ReactNativeOpenTelemetry_compileSdkVersion=36 ReactNativeOpenTelemetry_ndkVersion=27.1.12297006 diff --git a/android/src/main/java/com/callstack/otel/RNOtel.kt b/android/src/main/java/com/callstack/otel/RNOtel.kt new file mode 100644 index 0000000..eb047d9 --- /dev/null +++ b/android/src/main/java/com/callstack/otel/RNOtel.kt @@ -0,0 +1,77 @@ +package com.callstack.otel + +import android.app.Application +import android.content.Context +import android.os.Build +import android.os.Handler +import android.os.Looper +import android.util.Log +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.ProcessLifecycleOwner +import com.callstack.otel.core.CoreConfig +import com.callstack.otel.core.InitResult +import com.callstack.otel.core.OtelCore +import com.margelo.nitro.callstack.otel.BuildConfig +import io.opentelemetry.api.OpenTelemetry +import io.opentelemetry.api.trace.Span +import io.opentelemetry.api.trace.Tracer +import io.opentelemetry.context.Context as OtelContext +import java.io.File +import java.util.concurrent.atomic.AtomicBoolean + +/** Public native API (spec §4.3/§4.4). Test mode comes from the build (`-PotelTestMode=true`), never from here. */ +object RNOtel { + private const val TAG = "RNOtel" + private val observing = AtomicBoolean() + + /** Native-first init from `Application.onCreate`. No-op outside the main process; never throws. */ + @JvmStatic + fun start(context: Context, block: RNOtelConfig.() -> Unit) { + try { + val app = context.applicationContext + if (processName() != app.packageName) return + val r = initialize(RNOtelConfig().apply(block).toCore()) + // alreadyInitialized: a repeat call; a sticky failure was logged by the first one + if (r.error != null && !r.alreadyInitialized) Log.e(TAG, "init failed; telemetry is off: ${r.error}") + } catch (e: Exception) { + Log.e(TAG, "init failed; telemetry is off", e) + } + } + + /** One path for native-first and JS-fallback init. The exporter (OkHttp) is built on first export, on the BSP thread. */ + internal fun initialize(config: CoreConfig?): InitResult { + val r = OtelCore.initialize(config, BuildConfig.OTEL_TEST_MODE, BuildConfig.OTEL_DISTRO_VERSION) + if (OtelCore.instance != null && observing.compareAndSet(false, true)) { + Handler(Looper.getMainLooper()).post { + ProcessLifecycleOwner.get().lifecycle.addObserver(object : DefaultLifecycleObserver { + // forceFlush only signals the BSP worker: asynchronous, never join() on the main thread + override fun onStop(owner: LifecycleOwner) { + OtelCore.instance?.tracerProvider?.forceFlush() + } + }) + } + } + return r + } + + /** A tracer on the native provider; a no-op tracer before (or without) a successful init. */ + @JvmStatic + @JvmOverloads + fun tracer(name: String, version: String? = null): Tracer { + val provider = OtelCore.instance?.tracerProvider ?: OpenTelemetry.noop().tracerProvider + return provider.tracerBuilder(name).apply { version?.let(::setInstrumentationVersion) }.build() + } + + /** W3C traceparent -> explicit, non-remote parent context; invalid input -> root. */ + @JvmStatic + fun contextFrom(traceparent: String): OtelContext = com.callstack.otel.core.contextFrom(traceparent) + + @JvmStatic + fun traceparentOf(span: Span): String = com.callstack.otel.core.traceparentOf(span) + + // Application.getProcessName() is API 28+; minSdk is 26. + private fun processName(): String = + if (Build.VERSION.SDK_INT >= 28) Application.getProcessName() + else File("/proc/self/cmdline").readText().substringBefore('\u0000').trim() +} diff --git a/android/src/main/java/com/callstack/otel/RNOtelConfig.kt b/android/src/main/java/com/callstack/otel/RNOtelConfig.kt new file mode 100644 index 0000000..ee450d8 --- /dev/null +++ b/android/src/main/java/com/callstack/otel/RNOtelConfig.kt @@ -0,0 +1,30 @@ +package com.callstack.otel + +import com.callstack.otel.core.CoreConfig +import io.opentelemetry.api.common.Attributes + +/** Native-first config (spec §4.4): `RNOtel.start(this) { serviceName = …; export { url = … } }`. */ +class RNOtelConfig { + var serviceName: String = "" + var serviceVersion: String? = null + var resourceAttributes: Map = emptyMap() + private var export = Export() + + class Export { + /** The OTLP/HTTP traces endpoint (e.g. `https://collector:4318/v1/traces`), used as given. */ + var url: String = "" + var headers: Map = emptyMap() + } + + fun export(block: Export.() -> Unit) { + export = Export().apply(block) + } + + internal fun toCore() = CoreConfig( + serviceName = serviceName, + serviceVersion = serviceVersion, + resourceAttributes = Attributes.builder().apply { resourceAttributes.forEach { (k, v) -> put(k, v) } }.build(), + exportUrl = export.url, + exportHeaders = export.headers, + ) +} diff --git a/android/src/main/java/com/callstack/otel/core/Attributes.kt b/android/src/main/java/com/callstack/otel/core/Attributes.kt new file mode 100644 index 0000000..a697da2 --- /dev/null +++ b/android/src/main/java/com/callstack/otel/core/Attributes.kt @@ -0,0 +1,31 @@ +package com.callstack.otel.core + +import com.margelo.nitro.callstack.otel.AttrValue +import com.margelo.nitro.callstack.otel.SeamAttribute +import io.opentelemetry.api.common.AttributeKey +import io.opentelemetry.api.common.Attributes + +// Number.isInteger(v): whole and finite (-0 included). Long.MAX_VALUE as Double is 2^63, hence the exclusive bound. +private fun isLong(v: Double) = v == Math.rint(v) && v >= -9.223372036854775807E18 && v < 9.223372036854775807E18 + +/** JS numbers become `long` iff Number.isInteger (and they fit), else `double`; the same rule on JS, Kotlin, Swift. */ +fun attributesOf(list: Array): Attributes { + val b = Attributes.builder() + for (a in list) { + val k = a.key + when (val v = a.value) { + is AttrValue.Fifth -> b.put(k, v.value) + is AttrValue.First -> b.put(k, v.value) + is AttrValue.Sixth -> if (isLong(v.value)) b.put(k, v.value.toLong()) else b.put(k, v.value) + is AttrValue.Third -> b.put(AttributeKey.stringArrayKey(k), v.value.toList()) + is AttrValue.Second -> b.put(AttributeKey.booleanArrayKey(k), v.value.toList()) + is AttrValue.Fourth -> + if (v.value.all(::isLong)) b.put(AttributeKey.longArrayKey(k), v.value.map { it.toLong() }) + else b.put(AttributeKey.doubleArrayKey(k), v.value.toList()) + } + } + return b.build() +} + +/** An `HrTime` `[seconds, nanos]` as epoch nanos. Never throws on the JS thread: missing elements read as 0. */ +fun epochNanos(t: DoubleArray): Long = t.getOrElse(0) { 0.0 }.toLong() * 1_000_000_000L + t.getOrElse(1) { 0.0 }.toLong() diff --git a/android/src/main/java/com/callstack/otel/core/CoreConfig.kt b/android/src/main/java/com/callstack/otel/core/CoreConfig.kt new file mode 100644 index 0000000..e665768 --- /dev/null +++ b/android/src/main/java/com/callstack/otel/core/CoreConfig.kt @@ -0,0 +1,15 @@ +package com.callstack.otel.core + +import io.opentelemetry.api.common.Attributes + +data class CoreConfig( + val serviceName: String, + val serviceVersion: String? = null, + val resourceAttributes: Attributes = Attributes.empty(), + /** The OTLP/HTTP traces endpoint, used as given. */ + val exportUrl: String, + val exportHeaders: Map = emptyMap(), +) + +/** Mirrors the seam's `SeamInitResult`. */ +data class InitResult(val alreadyInitialized: Boolean, val testMode: Boolean, val error: String? = null) diff --git a/android/src/main/java/com/callstack/otel/core/Endpoint.kt b/android/src/main/java/com/callstack/otel/core/Endpoint.kt new file mode 100644 index 0000000..78d190f --- /dev/null +++ b/android/src/main/java/com/callstack/otel/core/Endpoint.kt @@ -0,0 +1,14 @@ +package com.callstack.otel.core + +import java.net.URI + +/** Eager check (D8), no exporter built: http(s) scheme and a host. Returns an error message or null. */ +internal fun validateExportUrl(url: String): String? { + val u = try { URI(url) } catch (e: Exception) { return "invalid exportUrl: ${e.message}" } + // URI.host is null for a host it rejects as a hostname, like `otel_collector`, which iOS and web accept + val host = u.host ?: u.rawAuthority?.substringAfterLast('@')?.substringBefore(':') + if (u.scheme?.lowercase() !in setOf("http", "https") || host.isNullOrEmpty()) { + return "invalid exportUrl \"$url\": expected http(s)://host[:port]" + } + return null +} diff --git a/android/src/main/java/com/callstack/otel/core/JsSpanData.kt b/android/src/main/java/com/callstack/otel/core/JsSpanData.kt new file mode 100644 index 0000000..ca466c2 --- /dev/null +++ b/android/src/main/java/com/callstack/otel/core/JsSpanData.kt @@ -0,0 +1,83 @@ +package com.callstack.otel.core + +import com.margelo.nitro.callstack.otel.SeamSpan +import com.margelo.nitro.callstack.otel.SeamSpanContext +import io.opentelemetry.api.trace.SpanContext +import io.opentelemetry.api.trace.SpanKind +import io.opentelemetry.api.trace.StatusCode +import io.opentelemetry.api.trace.TraceFlags +import io.opentelemetry.api.trace.TraceState +import io.opentelemetry.api.common.AttributeKey +import io.opentelemetry.sdk.common.InstrumentationLibraryInfo +import io.opentelemetry.sdk.common.InstrumentationScopeInfo +import io.opentelemetry.sdk.resources.Resource +import io.opentelemetry.sdk.trace.ReadableSpan +import io.opentelemetry.sdk.trace.data.EventData +import io.opentelemetry.sdk.trace.data.LinkData +import io.opentelemetry.sdk.trace.data.SpanData +import io.opentelemetry.sdk.trace.data.StatusData + +private fun traceState(s: String?): TraceState { + if (s.isNullOrEmpty()) return TraceState.getDefault() + val b = TraceState.builder() + // the builder puts each new entry first, so add the W3C list back to front + for (kv in s.split(',').asReversed()) { + val i = kv.indexOf('=') + if (i > 0) b.put(kv.substring(0, i).trim(), kv.substring(i + 1).trim()) + } + return b.build() +} + +private fun contextOf(c: SeamSpanContext): SpanContext = + SpanContext.create(c.traceId, c.spanId, TraceFlags.fromByte(c.traceFlags.toInt().toByte()), traceState(c.traceState)) + +/** + * A finished JS span handed over the seam: the frozen [ReadableSpan] the native BatchSpanProcessor queues, and the + * [SpanData] it exports. Everything but the span context is computed lazily, on first access from the export thread. + */ +class JsSpanData(private val span: SeamSpan, private val resource: Resource) : ReadableSpan, SpanData { + private val context by lazy { contextOf(span.context) } + private val parent by lazy { + span.parentSpanId?.let { SpanContext.create(span.context.traceId, it, context.traceFlags, context.traceState) } + ?: SpanContext.getInvalid() + } + // API SpanKind and Java SpanKind share their order (INTERNAL, SERVER, CLIENT, PRODUCER, CONSUMER); OTLP's +1 is the exporter's job. + private val spanKind by lazy { SpanKind.values().getOrElse(span.kind.toInt()) { SpanKind.INTERNAL } } + private val attrs by lazy { attributesOf(span.attributes) } + private val eventList by lazy { span.events.map { EventData.create(epochNanos(it.time), it.name, attributesOf(it.attributes)) } } + private val linkList by lazy { span.links.map { LinkData.create(contextOf(it.context), attributesOf(it.attributes)) } } + private val statusData by lazy { + StatusData.create(StatusCode.values().getOrElse(span.status.code.toInt()) { StatusCode.UNSET }, span.status.message.orEmpty()) + } + private val scope by lazy { + InstrumentationScopeInfo.builder(span.scope.name) + .apply { span.scope.version?.let(::setVersion); span.scope.schemaUrl?.let(::setSchemaUrl) } + .setAttributes(attributesOf(span.scope.attributes)) + .build() + } + + override fun getName() = span.name + override fun getKind() = spanKind + override fun getSpanContext() = context + override fun getParentSpanContext() = parent + override fun getStatus() = statusData + override fun getStartEpochNanos() = epochNanos(span.start) + override fun getEndEpochNanos() = epochNanos(span.end) + override fun getAttributes() = attrs + override fun getEvents() = eventList + override fun getLinks() = linkList + override fun hasEnded() = true + override fun getTotalRecordedEvents() = span.events.size + override fun getTotalRecordedLinks() = span.links.size + override fun getTotalAttributeCount() = span.attributes.size + override fun getInstrumentationScopeInfo() = scope + @Deprecated("otel-java deprecated API; still abstract on both interfaces") + override fun getInstrumentationLibraryInfo(): InstrumentationLibraryInfo = + @Suppress("DEPRECATION") InstrumentationLibraryInfo.create(scope.name, scope.version, scope.schemaUrl) + override fun getResource() = resource + + // ReadableSpan: frozen, nothing to mutate + override fun toSpanData(): SpanData = this + override fun getLatencyNanos() = endEpochNanos - startEpochNanos + override fun getAttribute(key: AttributeKey): T? = attrs.get(key) +} diff --git a/android/src/main/java/com/callstack/otel/core/OtelCore.kt b/android/src/main/java/com/callstack/otel/core/OtelCore.kt new file mode 100644 index 0000000..b04ae7e --- /dev/null +++ b/android/src/main/java/com/callstack/otel/core/OtelCore.kt @@ -0,0 +1,97 @@ +package com.callstack.otel.core + +import com.margelo.nitro.callstack.otel.SeamSpan +import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter +import io.opentelemetry.sdk.common.CompletableResultCode +import io.opentelemetry.sdk.trace.data.SpanData +import io.opentelemetry.sdk.trace.export.SpanExporter +import io.opentelemetry.sdk.resources.Resource +import io.opentelemetry.sdk.trace.IdGenerator +import io.opentelemetry.sdk.trace.SdkTracerProvider +import io.opentelemetry.sdk.trace.export.BatchSpanProcessor +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicLong + +/** Test mode: `0b…` IDs, the native counterpart of JS `sequentialIds('0a')`. */ +private class SequentialIds : IdGenerator { + private val t = AtomicLong() + private val s = AtomicLong() + override fun generateTraceId() = "0b" + t.incrementAndGet().toString().padStart(30, '0') + override fun generateSpanId() = "0b" + s.incrementAndGet().toString().padStart(14, '0') +} + +const val DISTRO_NAME = "react-native-open-telemetry" + +/** Built on first export (the export thread), so init on the main thread never constructs an HTTP client. */ +private class LazyExporter(private val build: () -> SpanExporter) : SpanExporter { + private val d by lazy(build) + override fun export(spans: Collection) = d.export(spans) + override fun flush(): CompletableResultCode = d.flush() + override fun shutdown(): CompletableResultCode = d.shutdown() +} + +class OtelCore(config: CoreConfig, testMode: Boolean = false, distroVersion: String = "unknown") { + /** The one resource of the app; in test mode built from config only (no `telemetry.*`). */ + val resource: Resource = (if (testMode) Resource.empty() else Resource.getDefault()).merge( + Resource.create( + config.resourceAttributes.toBuilder() + .put("service.name", config.serviceName) + .apply { config.serviceVersion?.let { put("service.version", it) } } + .apply { + if (!testMode) { + put("telemetry.distro.name", DISTRO_NAME) + put("telemetry.distro.version", distroVersion) + } + } + .build(), + ), + ) + + private val bsp = BatchSpanProcessor.builder( + LazyExporter { + 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) + ).apply { if (testMode) setScheduleDelay(120, TimeUnit.SECONDS) }.build() + + /** The native TracerProvider; JS spans join its batch processor. */ + val tracerProvider: SdkTracerProvider = SdkTracerProvider.builder() + .setResource(resource) + .addSpanProcessor(bsp) + .apply { if (testMode) setIdGenerator(SequentialIds()) } + .build() + + /** JS-thread work: wrap and enqueue only; SpanData is built on the export thread. */ + fun handOff(spans: Array) { + for (s in spans) bsp.onEnd(JsSpanData(s, resource)) + } + + fun flush(timeoutMs: Long): Boolean = tracerProvider.forceFlush().join(timeoutMs, TimeUnit.MILLISECONDS).isSuccess + + companion object { + private var state: InitResult? = null + @Volatile var instance: OtelCore? = null + private set + + /** + * Idempotent. The first result sticks, a failed one too (R16): later calls never retry. A call without config + * before any init is an error but is not remembered, so the real init can still follow. + */ + @Synchronized fun initialize(config: CoreConfig?, testMode: Boolean = false, distroVersion: String = "unknown"): InitResult { + state?.let { return it.copy(alreadyInitialized = true) } + if (config == null) return InitResult(false, testMode, "not initialized: no config") + val err = validateExportUrl(config.exportUrl) + val result = InitResult(false, testMode, err) + if (err == null) { + try { instance = OtelCore(config, testMode, distroVersion) } catch (e: Exception) { + return InitResult(false, testMode, "init failed: ${e.message}").also { state = it } + } + } + state = result + return result + } + + @Synchronized internal fun resetForTest() { state = null; instance = null } + } +} diff --git a/android/src/main/java/com/callstack/otel/core/Parenting.kt b/android/src/main/java/com/callstack/otel/core/Parenting.kt new file mode 100644 index 0000000..5a975d0 --- /dev/null +++ b/android/src/main/java/com/callstack/otel/core/Parenting.kt @@ -0,0 +1,24 @@ +package com.callstack.otel.core + +import io.opentelemetry.api.trace.Span +import io.opentelemetry.api.trace.SpanContext +import io.opentelemetry.api.trace.TraceFlags +import io.opentelemetry.api.trace.TraceState +import io.opentelemetry.context.Context + +private val TRACEPARENT = Regex("^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$") + +/** + * W3C traceparent -> Context holding a NON-remote parent (spec §4.3). + * Not W3CTraceContextPropagator.extract: that yields isRemote=true. + * Invalid input (incl. all-zero ids) -> Context.root(); never throws. + */ +fun contextFrom(traceparent: String): Context { + val m = TRACEPARENT.matchEntire(traceparent) ?: return Context.root() + val (traceId, spanId, flags) = m.destructured + val sc = SpanContext.create(traceId, spanId, TraceFlags.fromHex(flags, 0), TraceState.getDefault()) + return if (sc.isValid) Context.root().with(Span.wrap(sc)) else Context.root() +} + +fun traceparentOf(span: Span): String = + span.spanContext.let { "00-${it.traceId}-${it.spanId}-${it.traceFlags.asHex()}" } diff --git a/android/src/main/java/com/margelo/nitro/callstack/otel/HybridOtel.kt b/android/src/main/java/com/margelo/nitro/callstack/otel/HybridOtel.kt index 9aff250..b85088d 100644 --- a/android/src/main/java/com/margelo/nitro/callstack/otel/HybridOtel.kt +++ b/android/src/main/java/com/margelo/nitro/callstack/otel/HybridOtel.kt @@ -1,29 +1,43 @@ package com.margelo.nitro.callstack.otel -import android.util.Log import androidx.annotation.Keep +import com.callstack.otel.RNOtel +import com.callstack.otel.core.CoreConfig +import com.callstack.otel.core.OtelCore +import com.callstack.otel.core.attributesOf import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.Promise -import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers -/** Tracer-bullet stub (Task 7): proves the seam and the otel-java link; the real adapter is Task 24. */ +/** The seam: the core reads Nitro's structs directly. */ // Constructed from JNI by name (ReactNativeOpenTelemetryOnLoad.cpp): keep it through R8. @DoNotStrip @Keep class HybridOtel : HybridOtelSpec() { override fun initialize(config: SeamConfig?): SeamInitResult { - // Touch otel-java + its OkHttp sender so a broken dependency fails here, not in Task 24. - OtlpHttpSpanExporter.builder().build().shutdown() - return SeamInitResult(alreadyInitialized = false, testMode = BuildConfig.OTEL_TEST_MODE, error = null) + val r = RNOtel.initialize(config?.let { + CoreConfig( + serviceName = it.serviceName, + serviceVersion = it.serviceVersion, + resourceAttributes = attributesOf(it.resourceAttributes), + exportUrl = it.exportUrl, + exportHeaders = it.exportHeaders.mapNotNull { h -> h.value.asFifthOrNull()?.let { v -> h.key to v } }.toMap(), + ) + }) + return SeamInitResult(r.alreadyInitialized, r.testMode, r.error) } + /** JS thread: enqueue only; SpanData is built on the export thread. */ override fun handOff(spans: Array) { - Log.i( - "RNOtel", - "RNOtel handOff spans=${spans.size} attrs=${spans.sumOf { it.attributes.size }} " + - "events=${spans.sumOf { it.events.size }} links=${spans.sumOf { it.links.size }}", - ) + OtelCore.instance?.handOff(spans) } - override fun flush(timeoutMs: Double): Promise = Promise.resolved(Unit) + // Off the JS and main threads (the join blocks, so on IO); resolves even when native never initialized. + override fun flush(timeoutMs: Double): Promise = Promise.async(io) { + OtelCore.instance?.flush(timeoutMs.toLong()) + Unit + } + + private val io = CoroutineScope(Dispatchers.IO) } diff --git a/example/src/ScenariosScreen.tsx b/example/src/ScenariosScreen.tsx index a578e86..a3cae79 100644 --- a/example/src/ScenariosScreen.tsx +++ b/example/src/ScenariosScreen.tsx @@ -5,11 +5,8 @@ import {SimpleSpanProcessor, TracerProvider} from '@opentelemetry/sdk-trace'; import {OTLPTraceExporter} from '@opentelemetry/exporter-trace-otlp-proto'; import {getOtel} from '../../src/native/otel'; import {sequentialIds} from '../../src/internal/testMode'; -import type {SeamSpan} from '../../src/native/Otel.nitro'; import {at} from '../../verify/harness/scenario'; -import {decodeFixture} from '../../verify/harness/fixtureJson'; import {allScenarios} from '../../verify/scenarios'; -import richSpan from '../../verify/fixtures/rich-span.handoff.json'; /** Must match COLLECTOR_PORT in verify/e2e/harness.ts. */ const COLLECTOR_PORT = 4318; @@ -55,12 +52,6 @@ export function ScenariosScreen() { setRunning(name); }; - const handOff = () => { - const {spans} = decodeFixture(JSON.stringify(richSpan)) as {spans: SeamSpan[]}; - getOtel()!.handOff(spans); - setStatus('handoff'); - }; - return ( {testMode} @@ -69,12 +60,7 @@ export function ScenariosScreen() { {s.name} ))} - {/* hidden: driven by verify/e2e/tracer-bullet.e2e.ts */} - - tracer bullet - {status === 'done' && done} - {status === 'handoff' && handed off} {status.startsWith('error') && {status}} ); @@ -83,6 +69,4 @@ export function ScenariosScreen() { const styles = StyleSheet.create({ container: {padding: 24, paddingTop: 80, gap: 8}, button: {padding: 12, backgroundColor: '#ddd'}, - // tappable for the e2e runner, invisible to people - hidden: {opacity: 0.02, padding: 12}, }); diff --git a/verify/e2e/tracer-bullet.e2e.ts b/verify/e2e/tracer-bullet.e2e.ts deleted file mode 100644 index fb266e8..0000000 --- a/verify/e2e/tracer-bullet.e2e.ts +++ /dev/null @@ -1,35 +0,0 @@ -import fs from 'node:fs'; -import path from 'node:path'; -import {expect} from 'e2e'; -import {clearDeviceLog, deviceLog, platformOf, test} from './harness'; -import {decodeFixture} from '../harness/fixtureJson'; - -type Span = {attributes: unknown[]; events: unknown[]; links: unknown[]}; -const {spans} = decodeFixture( - fs.readFileSync(path.join(import.meta.dirname, '..', 'fixtures', 'rich-span.handoff.json'), 'utf8'), -) as {spans: Span[]}; -const sum = (f: (s: Span) => number) => spans.reduce((n, s) => n + f(s), 0); -const line = - `RNOtel handOff spans=${spans.length} attrs=${sum(s => s.attributes.length)} ` + - `events=${sum(s => s.events.length)} links=${sum(s => s.links.length)}`; - -test('handOff crosses the Nitro seam', async ({app, screen, device, target}) => { - const platform = platformOf(target); - const {deviceId} = device.unstable_raw; - await app.open(); - const since = clearDeviceLog(platform, deviceId); - await screen.getByTestId('tracer-bullet-handoff').tap(); - await expect(screen.getByTestId('tracer-bullet-done')).toBeVisible({timeout: 10_000}); - // the log line can land a moment after the tap returns - let seen: string[] = []; - for (let i = 0; i < 20 && !seen.length; i++) { - seen = deviceLog(platform, deviceId, 'RNOtel handOff', since); - if (!seen.length) await new Promise(r => setTimeout(r, 500)); - } - expect(seen.at(-1) ?? '(no RNOtel handOff line in the device log)').toContain(line); -}); - -test('native test mode reaches initialize', async ({app, screen}) => { - await app.open(); - await expect(screen.getByTestId('native-test-mode')).toHaveText('native testMode=true'); -}); diff --git a/verify/expected/async-generator.android.otlp.json b/verify/expected/async-generator.android.otlp.json new file mode 100644 index 0000000..cbf84fd --- /dev/null +++ b/verify/expected/async-generator.android.otlp.json @@ -0,0 +1,79 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "root", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000060000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "gen.0", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000003", + "parentSpanId": "0a00000000000001", + "name": "loop.0", + "kind": 1, + "startTimeUnixNano": "1767225600000020000", + "endTimeUnixNano": "1767225600000021000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000004", + "parentSpanId": "0a00000000000001", + "name": "gen.1", + "kind": 1, + "startTimeUnixNano": "1767225600000030000", + "endTimeUnixNano": "1767225600000031000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000005", + "parentSpanId": "0a00000000000001", + "name": "loop.1", + "kind": 1, + "startTimeUnixNano": "1767225600000040000", + "endTimeUnixNano": "1767225600000041000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/background-flush.android.otlp.json b/verify/expected/background-flush.android.otlp.json new file mode 100644 index 0000000..75f8271 --- /dev/null +++ b/verify/expected/background-flush.android.otlp.json @@ -0,0 +1,35 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "before_background", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000010000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/batching-shared-queue.android.otlp.json b/verify/expected/batching-shared-queue.android.otlp.json new file mode 100644 index 0000000..0b41dc0 --- /dev/null +++ b/verify/expected/batching-shared-queue.android.otlp.json @@ -0,0 +1,67 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "h1", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000001000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000002", + "name": "h2", + "kind": 1, + "startTimeUnixNano": "1767225600000002000", + "endTimeUnixNano": "1767225600000003000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000003", + "parentSpanId": "0a00000000000001", + "name": "h1.work", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000004", + "parentSpanId": "0a00000000000001", + "name": "h2.work", + "kind": 1, + "startTimeUnixNano": "1767225600000020000", + "endTimeUnixNano": "1767225600000021000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/captured-then.android.otlp.json b/verify/expected/captured-then.android.otlp.json new file mode 100644 index 0000000..b57eb7e --- /dev/null +++ b/verify/expected/captured-then.android.otlp.json @@ -0,0 +1,56 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "parent", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000030000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "kept", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000003", + "name": "lost", + "kind": 1, + "startTimeUnixNano": "1767225600000020000", + "endTimeUnixNano": "1767225600000021000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/collector-down.android.otlp.json b/verify/expected/collector-down.android.otlp.json new file mode 100644 index 0000000..367c32e --- /dev/null +++ b/verify/expected/collector-down.android.otlp.json @@ -0,0 +1,35 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "work", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000010000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/concurrent-interleaved.android.otlp.json b/verify/expected/concurrent-interleaved.android.otlp.json new file mode 100644 index 0000000..3428488 --- /dev/null +++ b/verify/expected/concurrent-interleaved.android.otlp.json @@ -0,0 +1,99 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "a", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000030000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000002", + "name": "b", + "kind": 1, + "startTimeUnixNano": "1767225600000001000", + "endTimeUnixNano": "1767225600000031000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000003", + "parentSpanId": "0a00000000000001", + "name": "a.1", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000004", + "parentSpanId": "0a00000000000002", + "name": "b.1", + "kind": 1, + "startTimeUnixNano": "1767225600000011000", + "endTimeUnixNano": "1767225600000012000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000005", + "parentSpanId": "0a00000000000001", + "name": "a.2", + "kind": 1, + "startTimeUnixNano": "1767225600000020000", + "endTimeUnixNano": "1767225600000021000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000006", + "parentSpanId": "0a00000000000002", + "name": "b.2", + "kind": 1, + "startTimeUnixNano": "1767225600000021000", + "endTimeUnixNano": "1767225600000022000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000003", + "spanId": "0a00000000000007", + "name": "after.all", + "kind": 1, + "startTimeUnixNano": "1767225600000040000", + "endTimeUnixNano": "1767225600000041000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/cross-js-to-native.android.otlp.json b/verify/expected/cross-js-to-native.android.otlp.json new file mode 100644 index 0000000..184d55b --- /dev/null +++ b/verify/expected/cross-js-to-native.android.otlp.json @@ -0,0 +1,53 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "js.parent", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000300000", + "status": {}, + "flags": 257 + } + ] + }, + { + "scope": { + "name": "test-native" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0b00000000000001", + "parentSpanId": "0a00000000000001", + "name": "native.work", + "kind": 1, + "startTimeUnixNano": "1767225600000100000", + "endTimeUnixNano": "1767225600000200000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/cross-native-to-js.android.otlp.json b/verify/expected/cross-native-to-js.android.otlp.json new file mode 100644 index 0000000..fe18d38 --- /dev/null +++ b/verify/expected/cross-native-to-js.android.otlp.json @@ -0,0 +1,53 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "test-native" + }, + "spans": [ + { + "traceId": "0b000000000000000000000000000001", + "spanId": "0b00000000000001", + "name": "native.work", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000100000", + "status": {}, + "flags": 257 + } + ] + }, + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0b000000000000000000000000000001", + "spanId": "0a00000000000001", + "parentSpanId": "0b00000000000001", + "name": "js.after_native", + "kind": 1, + "startTimeUnixNano": "1767225600000200000", + "endTimeUnixNano": "1767225600000300000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/error-in-callback.android.otlp.json b/verify/expected/error-in-callback.android.otlp.json new file mode 100644 index 0000000..22eccaa --- /dev/null +++ b/verify/expected/error-in-callback.android.otlp.json @@ -0,0 +1,67 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "parent", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000040000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "throws", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000003", + "name": "root.next", + "kind": 1, + "startTimeUnixNano": "1767225600000030000", + "endTimeUnixNano": "1767225600000031000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000004", + "parentSpanId": "0a00000000000001", + "name": "caught", + "kind": 1, + "startTimeUnixNano": "1767225600000020000", + "endTimeUnixNano": "1767225600000021000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/event-emitter-listener.android.otlp.json b/verify/expected/event-emitter-listener.android.otlp.json new file mode 100644 index 0000000..71f62e7 --- /dev/null +++ b/verify/expected/event-emitter-listener.android.otlp.json @@ -0,0 +1,46 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "emit", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000020000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "listener", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/export-headers.android.otlp.json b/verify/expected/export-headers.android.otlp.json new file mode 100644 index 0000000..09465b2 --- /dev/null +++ b/verify/expected/export-headers.android.otlp.json @@ -0,0 +1,35 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "headers", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000010000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/flush-after-reload.android.otlp.json b/verify/expected/flush-after-reload.android.otlp.json new file mode 100644 index 0000000..2c9cf5f --- /dev/null +++ b/verify/expected/flush-after-reload.android.otlp.json @@ -0,0 +1,35 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "before_reload", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000010000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/handoff-basic.android.otlp.json b/verify/expected/handoff-basic.android.otlp.json new file mode 100644 index 0000000..6876639 --- /dev/null +++ b/verify/expected/handoff-basic.android.otlp.json @@ -0,0 +1,43 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "root", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000100000", + "attributes": [ + { + "key": "app.step", + "value": { + "stringValue": "one" + } + } + ], + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/interval-new-root.android.otlp.json b/verify/expected/interval-new-root.android.otlp.json new file mode 100644 index 0000000..3923a1e --- /dev/null +++ b/verify/expected/interval-new-root.android.otlp.json @@ -0,0 +1,66 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "tap", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000400000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000002", + "name": "tick", + "kind": 1, + "startTimeUnixNano": "1767225600000100000", + "endTimeUnixNano": "1767225600000101000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000003", + "spanId": "0a00000000000003", + "name": "tick", + "kind": 1, + "startTimeUnixNano": "1767225600000200000", + "endTimeUnixNano": "1767225600000201000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000004", + "parentSpanId": "0a00000000000001", + "name": "load", + "kind": 1, + "startTimeUnixNano": "1767225600000300000", + "endTimeUnixNano": "1767225600000301000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/native-init-failure.android.otlp.json b/verify/expected/native-init-failure.android.otlp.json new file mode 100644 index 0000000..0efd939 --- /dev/null +++ b/verify/expected/native-init-failure.android.otlp.json @@ -0,0 +1,3 @@ +{ + "resourceSpans": [] +} diff --git a/verify/expected/nest-after-await.android.otlp.json b/verify/expected/nest-after-await.android.otlp.json new file mode 100644 index 0000000..611ade2 --- /dev/null +++ b/verify/expected/nest-after-await.android.otlp.json @@ -0,0 +1,46 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "parent", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000030000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "child", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000020000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/nest-promise-all-race.android.otlp.json b/verify/expected/nest-promise-all-race.android.otlp.json new file mode 100644 index 0000000..57ceef3 --- /dev/null +++ b/verify/expected/nest-promise-all-race.android.otlp.json @@ -0,0 +1,90 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "root", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000060000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "all.a", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000003", + "parentSpanId": "0a00000000000001", + "name": "all.b", + "kind": 1, + "startTimeUnixNano": "1767225600000020000", + "endTimeUnixNano": "1767225600000021000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000004", + "parentSpanId": "0a00000000000001", + "name": "race.a", + "kind": 1, + "startTimeUnixNano": "1767225600000030000", + "endTimeUnixNano": "1767225600000031000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000005", + "parentSpanId": "0a00000000000001", + "name": "race.b", + "kind": 1, + "startTimeUnixNano": "1767225600000040000", + "endTimeUnixNano": "1767225600000041000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000006", + "parentSpanId": "0a00000000000001", + "name": "after", + "kind": 1, + "startTimeUnixNano": "1767225600000050000", + "endTimeUnixNano": "1767225600000051000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/nest-raf.android.otlp.json b/verify/expected/nest-raf.android.otlp.json new file mode 100644 index 0000000..947dddf --- /dev/null +++ b/verify/expected/nest-raf.android.otlp.json @@ -0,0 +1,46 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "root", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000020000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "frame", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/nest-timers-microtasks.android.otlp.json b/verify/expected/nest-timers-microtasks.android.otlp.json new file mode 100644 index 0000000..c730379 --- /dev/null +++ b/verify/expected/nest-timers-microtasks.android.otlp.json @@ -0,0 +1,90 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "root", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000050000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "timeout", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000003", + "parentSpanId": "0a00000000000001", + "name": "immediate", + "kind": 1, + "startTimeUnixNano": "1767225600000020000", + "endTimeUnixNano": "1767225600000021000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000004", + "parentSpanId": "0a00000000000001", + "name": "microtask", + "kind": 1, + "startTimeUnixNano": "1767225600000030000", + "endTimeUnixNano": "1767225600000031000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000005", + "parentSpanId": "0a00000000000001", + "name": "timeout.microtask", + "kind": 1, + "startTimeUnixNano": "1767225600000040000", + "endTimeUnixNano": "1767225600000041000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000006", + "parentSpanId": "0a00000000000001", + "name": "after.end", + "kind": 1, + "startTimeUnixNano": "1767225600000060000", + "endTimeUnixNano": "1767225600000061000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/never-settling-promise.android.otlp.json b/verify/expected/never-settling-promise.android.otlp.json new file mode 100644 index 0000000..a71e213 --- /dev/null +++ b/verify/expected/never-settling-promise.android.otlp.json @@ -0,0 +1,66 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "parent", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000020000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "child", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000003", + "name": "later.await", + "kind": 1, + "startTimeUnixNano": "1767225600000030000", + "endTimeUnixNano": "1767225600000031000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000003", + "spanId": "0a00000000000004", + "name": "later.timeout", + "kind": 1, + "startTimeUnixNano": "1767225600000040000", + "endTimeUnixNano": "1767225600000041000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/odd-attributes.android.otlp.json b/verify/expected/odd-attributes.android.otlp.json new file mode 100644 index 0000000..b82c28d --- /dev/null +++ b/verify/expected/odd-attributes.android.otlp.json @@ -0,0 +1,67 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "odd", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000010000", + "attributes": [ + { + "key": "big", + "value": { + "intValue": "9007199254740994" + } + }, + { + "key": "empty", + "value": { + "arrayValue": {} + } + }, + { + "key": "inf", + "value": { + "doubleValue": "Infinity" + } + }, + { + "key": "nan", + "value": { + "doubleValue": "NaN" + } + }, + { + "key": "negZero", + "value": { + "intValue": "0" + } + } + ], + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/expected/rich-span.android.otlp.json b/verify/expected/rich-span.android.otlp.json new file mode 100644 index 0000000..7f3f8c4 --- /dev/null +++ b/verify/expected/rich-span.android.otlp.json @@ -0,0 +1,191 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify.rich", + "version": "1.2.3", + "attributes": [ + { + "key": "scope.key", + "value": { + "stringValue": "scope-value" + } + } + ] + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "rich", + "kind": 3, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000100000", + "attributes": [ + { + "key": "bool", + "value": { + "boolValue": true + } + }, + { + "key": "bools", + "value": { + "arrayValue": { + "values": [ + { + "boolValue": true + }, + { + "boolValue": false + } + ] + } + } + }, + { + "key": "double", + "value": { + "doubleValue": 1.5 + } + }, + { + "key": "doubles", + "value": { + "arrayValue": { + "values": [ + { + "doubleValue": 1.5 + }, + { + "doubleValue": 2.5 + } + ] + } + } + }, + { + "key": "int", + "value": { + "intValue": "42" + } + }, + { + "key": "ints", + "value": { + "arrayValue": { + "values": [ + { + "intValue": "1" + }, + { + "intValue": "2" + }, + { + "intValue": "3" + } + ] + } + } + }, + { + "key": "str", + "value": { + "stringValue": "zażółć 🚀" + } + }, + { + "key": "strs", + "value": { + "arrayValue": { + "values": [ + { + "stringValue": "a" + }, + { + "stringValue": "b" + } + ] + } + } + } + ], + "events": [ + { + "timeUnixNano": "1767225600000010000", + "name": "first", + "attributes": [ + { + "key": "event.key", + "value": { + "stringValue": "e1" + } + }, + { + "key": "event.n", + "value": { + "intValue": "1" + } + } + ] + }, + { + "timeUnixNano": "1767225600000020000", + "name": "second", + "attributes": [ + { + "key": "event.ok", + "value": { + "boolValue": true + } + } + ] + } + ], + "links": [ + { + "traceId": "0f111111111111111111111111111111", + "spanId": "0f22222222222222", + "traceState": "k=v", + "attributes": [ + { + "key": "link.key", + "value": { + "stringValue": "link-value" + } + }, + { + "key": "link.n", + "value": { + "intValue": "7" + } + } + ], + "flags": 257 + } + ], + "status": { + "message": "boom", + "code": 2 + }, + "flags": 257 + } + ], + "schemaUrl": "https://opentelemetry.io/schemas/1.40.0" + } + ] + } + ] +} diff --git a/verify/expected/root-no-leak.android.otlp.json b/verify/expected/root-no-leak.android.otlp.json new file mode 100644 index 0000000..b72d020 --- /dev/null +++ b/verify/expected/root-no-leak.android.otlp.json @@ -0,0 +1,76 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "service.name", + "value": { + "stringValue": "verify" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "verify" + }, + "spans": [ + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000001", + "name": "scoped", + "kind": 1, + "startTimeUnixNano": "1767225600000000000", + "endTimeUnixNano": "1767225600000020000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000001", + "spanId": "0a00000000000002", + "parentSpanId": "0a00000000000001", + "name": "scoped.child", + "kind": 1, + "startTimeUnixNano": "1767225600000010000", + "endTimeUnixNano": "1767225600000011000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000002", + "spanId": "0a00000000000003", + "name": "after.sync", + "kind": 1, + "startTimeUnixNano": "1767225600000030000", + "endTimeUnixNano": "1767225600000031000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000003", + "spanId": "0a00000000000004", + "name": "after.await", + "kind": 1, + "startTimeUnixNano": "1767225600000040000", + "endTimeUnixNano": "1767225600000041000", + "status": {}, + "flags": 257 + }, + { + "traceId": "0a000000000000000000000000000004", + "spanId": "0a00000000000005", + "name": "after.timeout", + "kind": 1, + "startTimeUnixNano": "1767225600000050000", + "endTimeUnixNano": "1767225600000051000", + "status": {}, + "flags": 257 + } + ] + } + ] + } + ] +} diff --git a/verify/fixtures/async-generator.handoff.json b/verify/fixtures/async-generator.handoff.json deleted file mode 100644 index 3fac4bb..0000000 --- a/verify/fixtures/async-generator.handoff.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "gen.0", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "loop.0", - "kind": 0, - "start": [ - 1767225600, - 20000 - ], - "end": [ - 1767225600, - 21000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "gen.1", - "kind": 0, - "start": [ - 1767225600, - 30000 - ], - "end": [ - 1767225600, - 31000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000005", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "loop.1", - "kind": 0, - "start": [ - 1767225600, - 40000 - ], - "end": [ - 1767225600, - 41000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "root", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 60000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/batching-shared-queue.handoff.json b/verify/fixtures/batching-shared-queue.handoff.json deleted file mode 100644 index 774d444..0000000 --- a/verify/fixtures/batching-shared-queue.handoff.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "h1", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 1000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "name": "h2", - "kind": 0, - "start": [ - 1767225600, - 2000 - ], - "end": [ - 1767225600, - 3000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "h1.work", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "h2.work", - "kind": 0, - "start": [ - 1767225600, - 20000 - ], - "end": [ - 1767225600, - 21000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/captured-then.handoff.json b/verify/fixtures/captured-then.handoff.json deleted file mode 100644 index 925e406..0000000 --- a/verify/fixtures/captured-then.handoff.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "kept", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "name": "lost", - "kind": 0, - "start": [ - 1767225600, - 20000 - ], - "end": [ - 1767225600, - 21000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "parent", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 30000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/concurrent-interleaved.handoff.json b/verify/fixtures/concurrent-interleaved.handoff.json deleted file mode 100644 index 2585051..0000000 --- a/verify/fixtures/concurrent-interleaved.handoff.json +++ /dev/null @@ -1,203 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "a.1", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000002", - "name": "b.1", - "kind": 0, - "start": [ - 1767225600, - 11000 - ], - "end": [ - 1767225600, - 12000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000005", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "a.2", - "kind": 0, - "start": [ - 1767225600, - 20000 - ], - "end": [ - 1767225600, - 21000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "a", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 30000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000006", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000002", - "name": "b.2", - "kind": 0, - "start": [ - 1767225600, - 21000 - ], - "end": [ - 1767225600, - 22000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "name": "b", - "kind": 0, - "start": [ - 1767225600, - 1000 - ], - "end": [ - 1767225600, - 31000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000003", - "spanId": "0a00000000000007", - "traceFlags": 1 - }, - "name": "after.all", - "kind": 0, - "start": [ - 1767225600, - 40000 - ], - "end": [ - 1767225600, - 41000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/error-in-callback.handoff.json b/verify/fixtures/error-in-callback.handoff.json deleted file mode 100644 index d082b48..0000000 --- a/verify/fixtures/error-in-callback.handoff.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "throws", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "name": "root.next", - "kind": 0, - "start": [ - 1767225600, - 30000 - ], - "end": [ - 1767225600, - 31000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "caught", - "kind": 0, - "start": [ - 1767225600, - 20000 - ], - "end": [ - 1767225600, - 21000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "parent", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 40000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/export-headers.handoff.json b/verify/fixtures/export-headers.handoff.json deleted file mode 100644 index d6e97a5..0000000 --- a/verify/fixtures/export-headers.handoff.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [ - { - "key": "x-api-key", - "value": "test" - } - ] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "headers", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 10000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/handoff-basic.handoff.json b/verify/fixtures/handoff-basic.handoff.json deleted file mode 100644 index 28df8f9..0000000 --- a/verify/fixtures/handoff-basic.handoff.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "root", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 100000 - ], - "attributes": [ - { - "key": "app.step", - "value": "one" - } - ], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/interval-new-root.handoff.json b/verify/fixtures/interval-new-root.handoff.json deleted file mode 100644 index a245d81..0000000 --- a/verify/fixtures/interval-new-root.handoff.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "name": "tick", - "kind": 0, - "start": [ - 1767225600, - 100000 - ], - "end": [ - 1767225600, - 101000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000003", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "name": "tick", - "kind": 0, - "start": [ - 1767225600, - 200000 - ], - "end": [ - 1767225600, - 201000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "load", - "kind": 0, - "start": [ - 1767225600, - 300000 - ], - "end": [ - 1767225600, - 301000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "tap", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 400000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/nest-after-await.handoff.json b/verify/fixtures/nest-after-await.handoff.json deleted file mode 100644 index 3ffc349..0000000 --- a/verify/fixtures/nest-after-await.handoff.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "child", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 20000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "parent", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 30000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/nest-promise-all-race.handoff.json b/verify/fixtures/nest-promise-all-race.handoff.json deleted file mode 100644 index 0b97d5f..0000000 --- a/verify/fixtures/nest-promise-all-race.handoff.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "all.a", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "all.b", - "kind": 0, - "start": [ - 1767225600, - 20000 - ], - "end": [ - 1767225600, - 21000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "race.a", - "kind": 0, - "start": [ - 1767225600, - 30000 - ], - "end": [ - 1767225600, - 31000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000005", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "race.b", - "kind": 0, - "start": [ - 1767225600, - 40000 - ], - "end": [ - 1767225600, - 41000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000006", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "after", - "kind": 0, - "start": [ - 1767225600, - 50000 - ], - "end": [ - 1767225600, - 51000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "root", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 60000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/nest-timers-microtasks.handoff.json b/verify/fixtures/nest-timers-microtasks.handoff.json deleted file mode 100644 index 1beda0c..0000000 --- a/verify/fixtures/nest-timers-microtasks.handoff.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "timeout", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "immediate", - "kind": 0, - "start": [ - 1767225600, - 20000 - ], - "end": [ - 1767225600, - 21000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "microtask", - "kind": 0, - "start": [ - 1767225600, - 30000 - ], - "end": [ - 1767225600, - 31000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000005", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "timeout.microtask", - "kind": 0, - "start": [ - 1767225600, - 40000 - ], - "end": [ - 1767225600, - 41000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "root", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 50000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000006", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "after.end", - "kind": 0, - "start": [ - 1767225600, - 60000 - ], - "end": [ - 1767225600, - 61000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/never-settling-promise.handoff.json b/verify/fixtures/never-settling-promise.handoff.json deleted file mode 100644 index 463e62d..0000000 --- a/verify/fixtures/never-settling-promise.handoff.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "child", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "parent", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 20000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "name": "later.await", - "kind": 0, - "start": [ - 1767225600, - 30000 - ], - "end": [ - 1767225600, - 31000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000003", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "name": "later.timeout", - "kind": 0, - "start": [ - 1767225600, - 40000 - ], - "end": [ - 1767225600, - 41000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/odd-attributes.handoff.json b/verify/fixtures/odd-attributes.handoff.json deleted file mode 100644 index bb85702..0000000 --- a/verify/fixtures/odd-attributes.handoff.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "odd", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 10000 - ], - "attributes": [ - { - "key": "nan", - "value": { - "$num": "NaN" - } - }, - { - "key": "inf", - "value": { - "$num": "Infinity" - } - }, - { - "key": "negZero", - "value": { - "$num": "-0" - } - }, - { - "key": "big", - "value": 9007199254740994 - }, - { - "key": "empty", - "value": [] - } - ], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/fixtures/rich-span.handoff.json b/verify/fixtures/rich-span.handoff.json deleted file mode 100644 index 034d94a..0000000 --- a/verify/fixtures/rich-span.handoff.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "rich", - "kind": 2, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 100000 - ], - "attributes": [ - { - "key": "str", - "value": "zażółć 🚀" - }, - { - "key": "int", - "value": 42 - }, - { - "key": "double", - "value": 1.5 - }, - { - "key": "bool", - "value": true - }, - { - "key": "strs", - "value": [ - "a", - "b" - ] - }, - { - "key": "ints", - "value": [ - 1, - 2, - 3 - ] - }, - { - "key": "doubles", - "value": [ - 1.5, - 2.5 - ] - }, - { - "key": "bools", - "value": [ - true, - false - ] - } - ], - "events": [ - { - "name": "first", - "time": [ - 1767225600, - 10000 - ], - "attributes": [ - { - "key": "event.key", - "value": "e1" - }, - { - "key": "event.n", - "value": 1 - } - ] - }, - { - "name": "second", - "time": [ - 1767225600, - 20000 - ], - "attributes": [ - { - "key": "event.ok", - "value": true - } - ] - } - ], - "links": [ - { - "context": { - "traceId": "0f111111111111111111111111111111", - "spanId": "0f22222222222222", - "traceFlags": 1, - "traceState": "k=v" - }, - "attributes": [ - { - "key": "link.key", - "value": "link-value" - }, - { - "key": "link.n", - "value": 7 - } - ] - } - ], - "status": { - "code": 2, - "message": "boom" - }, - "scope": { - "name": "verify.rich", - "version": "1.2.3", - "schemaUrl": "https://opentelemetry.io/schemas/1.40.0", - "attributes": [ - { - "key": "scope.key", - "value": "scope-value" - } - ] - } - } - ] -} diff --git a/verify/fixtures/root-no-leak.handoff.json b/verify/fixtures/root-no-leak.handoff.json deleted file mode 100644 index 8821bb2..0000000 --- a/verify/fixtures/root-no-leak.handoff.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "config": { - "serviceName": "verify", - "resourceAttributes": [], - "exportUrl": "", - "exportHeaders": [] - }, - "spans": [ - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000002", - "traceFlags": 1 - }, - "parentSpanId": "0a00000000000001", - "name": "scoped.child", - "kind": 0, - "start": [ - 1767225600, - 10000 - ], - "end": [ - 1767225600, - 11000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000001", - "spanId": "0a00000000000001", - "traceFlags": 1 - }, - "name": "scoped", - "kind": 0, - "start": [ - 1767225600, - 0 - ], - "end": [ - 1767225600, - 20000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000002", - "spanId": "0a00000000000003", - "traceFlags": 1 - }, - "name": "after.sync", - "kind": 0, - "start": [ - 1767225600, - 30000 - ], - "end": [ - 1767225600, - 31000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000003", - "spanId": "0a00000000000004", - "traceFlags": 1 - }, - "name": "after.await", - "kind": 0, - "start": [ - 1767225600, - 40000 - ], - "end": [ - 1767225600, - 41000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - }, - { - "context": { - "traceId": "0a000000000000000000000000000004", - "spanId": "0a00000000000005", - "traceFlags": 1 - }, - "name": "after.timeout", - "kind": 0, - "start": [ - 1767225600, - 50000 - ], - "end": [ - 1767225600, - 51000 - ], - "attributes": [], - "events": [], - "links": [], - "status": { - "code": 0 - }, - "scope": { - "name": "verify", - "attributes": [] - } - } - ] -} diff --git a/verify/harness/__tests__/fixtureJson.test.ts b/verify/harness/__tests__/fixtureJson.test.ts deleted file mode 100644 index 54b143e..0000000 --- a/verify/harness/__tests__/fixtureJson.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {decodeFixture, encodeFixture} from '../fixtureJson'; - -test('fixture round trip keeps NaN, Infinity and -0', () => { - const v = {a: [NaN, Infinity, -Infinity, -0, 0, 1.5], b: {c: -0}, s: 'x'}; - const json = encodeFixture(v); - expect(JSON.parse(json).a[0]).toEqual({$num: 'NaN'}); - expect(JSON.parse(json).a[3]).toEqual({$num: '-0'}); - const d = decodeFixture(json) as any; - expect(d.a[0]).toBeNaN(); - expect(d.a[1]).toBe(Infinity); - expect(d.a[2]).toBe(-Infinity); - expect(Object.is(d.a[3], -0)).toBe(true); - expect(Object.is(d.a[4], 0)).toBe(true); - expect(Object.is(d.b.c, -0)).toBe(true); - expect(d.s).toBe('x'); -}); diff --git a/verify/harness/fixtureJson.ts b/verify/harness/fixtureJson.ts deleted file mode 100644 index a9773d1..0000000 --- a/verify/harness/fixtureJson.ts +++ /dev/null @@ -1,23 +0,0 @@ -const NUMS = ['NaN', 'Infinity', '-Infinity', '-0'] as const; - -/** JSON with NaN, Infinity, -Infinity and -0 as {"$num": ""}. */ -export const encodeFixture = (value: unknown): string => - JSON.stringify( - value, - (_k, v) => - typeof v !== 'number' - ? v - : Object.is(v, -0) - ? {$num: '-0'} - : Number.isFinite(v) - ? v - : {$num: String(v)}, - 2, - ); - -export const decodeFixture = (json: string): unknown => - JSON.parse(json, (_k, v) => - v && typeof v === 'object' && Object.keys(v).length === 1 && NUMS.includes(v.$num) - ? Number(v.$num) - : v, - ); diff --git a/verify/harness/scenario.ts b/verify/harness/scenario.ts index 7b0ce82..ef921a7 100644 --- a/verify/harness/scenario.ts +++ b/verify/harness/scenario.ts @@ -15,11 +15,8 @@ export type ScenarioCtx = { /** Only on devices (the example app); e2e-only scenarios use it. */ native?: TestNative; }; -/** - * `jest`: Jest records the hand-off fixture and compares the JS output to `.js.otlp.json`. - * `seam`: Jest records only the hand-off fixture, for scenarios whose JS output would be upstream's alone. - */ -export type Runner = 'jest' | 'seam' | 'e2e'; +/** `jest`: Jest compares the JS output to `.js.otlp.json`. `e2e`: the example apps on devices and web. */ +export type Runner = 'jest' | 'e2e'; /** A platform, or one e2e target (`android-bare`, `ios-expo`, …) for what only one app can run. */ export type Target = 'android' | 'ios' | 'web' | `${'android' | 'ios'}-${'bare' | 'expo'}`; export type Scenario = { diff --git a/verify/jest/fixtures.test.ts b/verify/jest/handoff.test.ts similarity index 62% rename from verify/jest/fixtures.test.ts rename to verify/jest/handoff.test.ts index fe20b74..d22febc 100644 --- a/verify/jest/fixtures.test.ts +++ b/verify/jest/handoff.test.ts @@ -1,26 +1,10 @@ -import fs from 'fs'; -import path from 'path'; import {SamplingDecision} from '@opentelemetry/sdk-trace'; import {resourceFromAttributes} from '@opentelemetry/resources'; import {TracerProvider} from '@opentelemetry/sdk-trace'; -import {decodeFixture, encodeFixture} from '../harness/fixtureJson'; import {at} from '../harness/scenario'; import {sequentialIds} from '../../src/internal/testMode'; import {NativeHandOffProcessor} from '../../src/handoff/NativeHandOffProcessor'; import type {Otel, SeamSpan} from '../../src/native/Otel.nitro'; -import {allScenarios} from '../scenarios'; -import {pendingScenarios} from '../harness/compare'; - -const CONFIG = { - serviceName: 'verify', - resourceAttributes: [], - exportUrl: '', - exportHeaders: [], -}; -// R11: per-scenario config; export-headers proves the headers reach the collector (fast-jvm asserts headers.json) -const configFor = (name: string) => - name === 'export-headers' ? {...CONFIG, exportHeaders: [{key: 'x-api-key', value: 'test'}]} : CONFIG; -const dir = path.join(process.env.VERIFY_DIR ?? path.join(__dirname, '..'), 'fixtures'); function setup() { const calls: SeamSpan[][] = []; @@ -81,24 +65,3 @@ describe('NativeHandOffProcessor', () => { expect(() => { t.startSpan('a').end(); t.startSpan('b').end(); }).not.toThrow(); }); }); - -// R6: every active Jest scenario has a seam fixture -for (const s of allScenarios().filter(x => !x.pending && (x.runners.includes('jest') || x.runners.includes('seam')))) { - const name = s.name; - // a pending body is not its final version yet: keep the reviewed fixture until the owning task un-pends it - if (pendingScenarios.has(name)) { - test.todo(`${name} fixture matches hand-off payloads`); - continue; - } - test(`${name} fixture matches hand-off payloads`, async () => { - const {calls, provider} = setup(); - await s.run({tracer: provider.getTracer('verify'), getTracer: (n, v, o) => provider.getTracer(n, v, o), at}); - const actual = calls.flat(); - const file = path.join(dir, `${name}.handoff.json`); - if (process.env.VERIFY_UPDATE === '1') { - fs.mkdirSync(dir, {recursive: true}); - fs.writeFileSync(file, encodeFixture({config: configFor(name), spans: actual}) + '\n'); - } - expect(decodeFixture(fs.readFileSync(file, 'utf8'))).toStrictEqual({config: configFor(name), spans: actual}); - }); -} diff --git a/verify/jest/jest.scenarios.config.js b/verify/jest/jest.scenarios.config.js index ad092a7..7758500 100644 --- a/verify/jest/jest.scenarios.config.js +++ b/verify/jest/jest.scenarios.config.js @@ -5,5 +5,5 @@ module.exports = { testEnvironment: 'node', transform: {'\\.[jt]sx?$': ['babel-jest', {presets: ['@react-native/babel-preset']}]}, setupFiles: ['/src/setup.ts'], - testMatch: ['/verify/jest/scenarios.test.ts', '/verify/jest/fixtures.test.ts'], + testMatch: ['/verify/jest/scenarios.test.ts', '/verify/jest/handoff.test.ts'], }; diff --git a/verify/scenarios/export-headers.ts b/verify/scenarios/export-headers.ts index bb4c5b1..f2da091 100644 --- a/verify/scenarios/export-headers.ts +++ b/verify/scenarios/export-headers.ts @@ -2,12 +2,12 @@ import {scenario} from '../harness/scenario'; /** * Configured export headers are sent on every export request: the collector's `.headers.json` for this - * scenario contains `x-api-key: test`. Its seam fixture carries a per-scenario config `exportHeaders: [{key: 'x-api-key', value: 'test'}]`; fast-jvm asserts `headers.json`. + * scenario contains `x-api-key: test` (every example app's init sets it; verify/e2e/export-headers.e2e.ts asserts it). */ export default scenario( 'export-headers', async ({tracer, at}) => { tracer.startSpan('headers', {startTime: at(0)}).end(at(10)); }, - {runners: ['seam', 'e2e'], targets: ['android', 'ios', 'web']}, // every example app's init sends x-api-key: test + {runners: ['e2e'], targets: ['android', 'ios', 'web']}, ); diff --git a/verify/scenarios/handoff-basic.ts b/verify/scenarios/handoff-basic.ts index c92538a..a5ca9c2 100644 --- a/verify/scenarios/handoff-basic.ts +++ b/verify/scenarios/handoff-basic.ts @@ -3,4 +3,4 @@ import {scenario} from '../harness/scenario'; export default scenario('handoff-basic', async ({tracer, at}) => { const root = tracer.startSpan('root', {startTime: at(0), attributes: {'app.step': 'one'}}); root.end(at(100)); -}, {runners: ['seam', 'e2e']}); +}, {runners: ['e2e']}); diff --git a/verify/scenarios/odd-attributes.ts b/verify/scenarios/odd-attributes.ts index 2ea5d32..9f9b993 100644 --- a/verify/scenarios/odd-attributes.ts +++ b/verify/scenarios/odd-attributes.ts @@ -7,4 +7,4 @@ export default scenario('odd-attributes', async ({tracer, at}) => { attributes: {nan: NaN, inf: Infinity, negZero: -0, big: 2 ** 53 + 2, empty: []}, }) .end(at(10)); -}, {runners: ['seam', 'e2e']}); +}, {runners: ['e2e']}); diff --git a/verify/stages/fast-swift.ts b/verify/stages/fast-swift.ts deleted file mode 100644 index 44c5fc9..0000000 --- a/verify/stages/fast-swift.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {existsSync} from 'node:fs'; -import type {Stage} from '../run'; - -const stage: Stage = { - name: 'fast-swift', - order: 30, - e2e: false, - run({sh}) { - if (process.platform !== 'darwin') return void console.log('skipped: not macOS'); - if (!existsSync('Package.swift')) return void console.log('skipped: no Package.swift'); - sh(['swift', 'test']); - }, -}; - -export default stage;