Skip to content

Commit

Permalink
Add emb.type for spans that track activity opening
Browse files Browse the repository at this point in the history
  • Loading branch information
bidetofevil committed Sep 12, 2024
1 parent efe09f5 commit dff3659
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit dff3659

Please sign in to comment.