Skip to content

Commit

Permalink
Merge c590094 into 7e57220
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanosiano authored Oct 3, 2024
2 parents 7e57220 + c590094 commit 17dc67a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Fixes

- fix invalid profiles when the transaction name is empty ([#3747](https://github.com/getsentry/sentry-java/pull/3747))
- Avoid stopping appStartProfiler after application creation ([#3630](https://github.com/getsentry/sentry-java/pull/3630))
- Session Replay: Correctly detect dominant color for `TextView`s with Spans ([#3682](https://github.com/getsentry/sentry-java/pull/3682))
- 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,17 @@ class AndroidTransactionProfilerTest {
verify(mockExecutorService, never()).submit(any<Callable<*>>())
}

@Test
fun `profiling transaction with empty name fallbacks to unknown`() {
val profiler = fixture.getSut(context)
profiler.start()
profiler.bindTransaction(fixture.transaction1)
val profilingTraceData = profiler.onTransactionFinish(fixture.transaction1, null, fixture.options)
assertNotNull(profilingTraceData)
assertEquals("unknown", profilingTraceData.transactionName)
assertEquals("unknown", profilingTraceData.transactions.first().name)
}

@Test
fun `profiler does not throw if traces cannot be written to disk`() {
File(fixture.options.profilingTracesDirPath!!).setWritable(false)
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/ProfilingTraceData.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public ProfilingTraceData(

// Transaction info
this.transactions = transactions;
this.transactionName = transactionName;
this.transactionName = transactionName.isEmpty() ? "unknown" : transactionName;
this.durationNs = durationNanos;

// App info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ProfilingTransactionData(
@NotNull ITransaction transaction, @NotNull Long startNs, @NotNull Long startCpuMs) {
this.id = transaction.getEventId().toString();
this.traceId = transaction.getSpanContext().getTraceId().toString();
this.name = transaction.getName();
this.name = transaction.getName().isEmpty() ? "unknown" : transaction.getName();
this.relativeStartNs = startNs;
this.relativeStartCpuMs = startCpuMs;
}
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/test/java/io/sentry/JsonSerializerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ class JsonSerializerTest {
mapOf(
"trace_id" to "00000000000000000000000000000000",
"relative_cpu_end_ms" to null,
"name" to "",
"name" to "unknown",
"relative_start_ns" to 1,
"relative_end_ns" to null,
"id" to "00000000000000000000000000000000",
Expand All @@ -578,7 +578,7 @@ class JsonSerializerTest {
mapOf(
"trace_id" to "00000000000000000000000000000000",
"relative_cpu_end_ms" to null,
"name" to "",
"name" to "unknown",
"relative_start_ns" to 2,
"relative_end_ns" to null,
"id" to "00000000000000000000000000000000",
Expand Down

0 comments on commit 17dc67a

Please sign in to comment.