diff --git a/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/arch/schema/EmbType.kt b/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/arch/schema/EmbType.kt index efc74a012e..335115e9a7 100644 --- a/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/arch/schema/EmbType.kt +++ b/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/arch/schema/EmbType.kt @@ -25,6 +25,8 @@ sealed class EmbType(type: String, subtype: String?) : TelemetryType { object NativeThreadBlockageSample : Performance("native_thread_blockage_sample") object ThermalState : Performance("thermal_state") + + object ActivityOpen : Performance("activity_open") } /** diff --git a/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilder.kt b/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilder.kt index b59f9e4f81..6e8d8060fc 100644 --- a/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilder.kt +++ b/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilder.kt @@ -85,7 +85,7 @@ class EmbraceSpanBuilder( } private fun updateKeySpan() { - if (fixedAttributes.contains(EmbType.Performance.Default)) { + if (fixedAttributes.contains(EmbType.Performance.Default) || fixedAttributes.contains(EmbType.Performance.ActivityOpen)) { if (getParentSpan() == null) { fixedAttributes.add(KeySpan) } else { diff --git a/embrace-android-core/src/test/java/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilderTest.kt b/embrace-android-core/src/test/java/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilderTest.kt index 972ddb180d..1f2189b351 100644 --- a/embrace-android-core/src/test/java/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilderTest.kt +++ b/embrace-android-core/src/test/java/io/embrace/android/embracesdk/internal/spans/EmbraceSpanBuilderTest.kt @@ -155,6 +155,31 @@ internal class EmbraceSpanBuilderTest { assertEquals("test-value", spanBuilder.getCustomAttributes()["test-key"]) } + @Test + fun `perf and activity_open spans are key spans if parent is null`() { + val perfSpanBuilder = EmbraceSpanBuilder( + tracer = tracer, + name = "test", + telemetryType = EmbType.Performance.Default, + internal = false, + private = false, + parentSpan = null, + ) + + assertTrue(perfSpanBuilder.getFixedAttributes().toSet().contains(KeySpan)) + + val activityOpenSpanBuilder = EmbraceSpanBuilder( + tracer = tracer, + name = "test", + telemetryType = EmbType.Performance.ActivityOpen, + internal = false, + private = false, + parentSpan = null, + ) + + assertTrue(activityOpenSpanBuilder.getFixedAttributes().toSet().contains(KeySpan)) + } + @Test fun `context value propagated even if it does not context a span`() { val fakeRootContext = Context.root().with(fakeContextKey, "fake-value")