Skip to content

Commit 17dc67a

Browse files
authored
Merge c590094 into 7e57220
2 parents 7e57220 + c590094 commit 17dc67a

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
### Fixes
1111

12+
- fix invalid profiles when the transaction name is empty ([#3747](https://github.com/getsentry/sentry-java/pull/3747))
1213
- Avoid stopping appStartProfiler after application creation ([#3630](https://github.com/getsentry/sentry-java/pull/3630))
1314
- Session Replay: Correctly detect dominant color for `TextView`s with Spans ([#3682](https://github.com/getsentry/sentry-java/pull/3682))
1415
- Session Replay: Add options to selectively redact/ignore views from being captured. The following options are available: ([#3689](https://github.com/getsentry/sentry-java/pull/3689))

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

+11
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

+1-1
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

+1-1
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

+2-2
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)