Skip to content

Commit 4f7660b

Browse files
committed
when the transaction name is empty, the profiles default to "unknown"
1 parent 7e57220 commit 4f7660b

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

sentry-android-core/src/test/java/io/sentry/android/core/AndroidTransactionProfilerTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,17 @@ class AndroidTransactionProfilerTest {
360360
verify(mockExecutorService, never()).submit(any<Callable<*>>())
361361
}
362362

363+
@Test
364+
fun `profiling transaction with empty name fallbacks to unknown`() {
365+
val profiler = fixture.getSut(context)
366+
profiler.start()
367+
profiler.bindTransaction(fixture.transaction1)
368+
val profilingTraceData = profiler.onTransactionFinish(fixture.transaction1, null, fixture.options)
369+
assertNotNull(profilingTraceData)
370+
assertEquals("unknown", profilingTraceData.transactionName)
371+
assertEquals("unknown", profilingTraceData.transactions.first().name)
372+
}
373+
363374
@Test
364375
fun `profiler does not throw if traces cannot be written to disk`() {
365376
File(fixture.options.profilingTracesDirPath!!).setWritable(false)

sentry/src/main/java/io/sentry/ProfilingTraceData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public ProfilingTraceData(
144144

145145
// Transaction info
146146
this.transactions = transactions;
147-
this.transactionName = transactionName;
147+
this.transactionName = transactionName.isEmpty() ? "unknown" : transactionName;
148148
this.durationNs = durationNanos;
149149

150150
// App info

sentry/src/main/java/io/sentry/ProfilingTransactionData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public ProfilingTransactionData(
2929
@NotNull ITransaction transaction, @NotNull Long startNs, @NotNull Long startCpuMs) {
3030
this.id = transaction.getEventId().toString();
3131
this.traceId = transaction.getSpanContext().getTraceId().toString();
32-
this.name = transaction.getName();
32+
this.name = transaction.getName().isEmpty() ? "unknown" : transaction.getName();
3333
this.relativeStartNs = startNs;
3434
this.relativeStartCpuMs = startCpuMs;
3535
}

sentry/src/test/java/io/sentry/JsonSerializerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class JsonSerializerTest {
569569
mapOf(
570570
"trace_id" to "00000000000000000000000000000000",
571571
"relative_cpu_end_ms" to null,
572-
"name" to "",
572+
"name" to "unknown",
573573
"relative_start_ns" to 1,
574574
"relative_end_ns" to null,
575575
"id" to "00000000000000000000000000000000",
@@ -578,7 +578,7 @@ class JsonSerializerTest {
578578
mapOf(
579579
"trace_id" to "00000000000000000000000000000000",
580580
"relative_cpu_end_ms" to null,
581-
"name" to "",
581+
"name" to "unknown",
582582
"relative_start_ns" to 2,
583583
"relative_end_ns" to null,
584584
"id" to "00000000000000000000000000000000",

0 commit comments

Comments
 (0)