Skip to content

Commit ae66f73

Browse files
authored
Merge branch 'main' into markushi/feat/anr-profiling
2 parents a62b5e8 + a416a65 commit ae66f73

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
## Unreleased
44

5-
### Features
5+
### Improvements
66

7+
- Do not send manual log origin ([#4897](https://github.com/getsentry/sentry-java/pull/4897))
78
- Add ANR profiling integration ([#4899](https://github.com/getsentry/sentry-java/pull/4899))
89
- Captures main thread profile when ANR is detected
910
- Identifies culprit code causing application hangs
1011
- Profiles are attached to ANR error events for better diagnostics
1112
- Enable via `options.setEnableAnrProfiling(true)` or Android manifest: `<meta-data android:name="io.sentry.anr.enable-profiling" android:value="true" />`
1213

14+
1315
## 8.26.0
1416

1517
### Features

sentry/src/main/java/io/sentry/logger/LoggerApi.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ private void captureLog(
163163
final @NotNull SpanId spanId,
164164
final @Nullable Object... args) {
165165
final @NotNull HashMap<String, SentryLogEventAttributeValue> attributes = new HashMap<>();
166-
attributes.put(
167-
"sentry.origin",
168-
new SentryLogEventAttributeValue(SentryAttributeType.STRING, params.getOrigin()));
166+
final @NotNull String origin = params.getOrigin();
167+
if (!"manual".equalsIgnoreCase(origin)) {
168+
attributes.put(
169+
"sentry.origin", new SentryLogEventAttributeValue(SentryAttributeType.STRING, origin));
170+
}
169171

170172
final @Nullable SentryAttributes incomingAttributes = params.getAttributes();
171173

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,43 @@ class ScopesTest {
25852585
)
25862586
}
25872587

2588+
@Test
2589+
fun `log with manual origin does not have origin attribute`() {
2590+
val (sut, mockClient) = getEnabledScopes { it.logs.isEnabled = true }
2591+
2592+
sut.logger().log(SentryLogLevel.WARN, "log message")
2593+
2594+
verify(mockClient)
2595+
.captureLog(
2596+
check {
2597+
assertEquals("log message", it.body)
2598+
assertNull(it.attributes!!.get("sentry.origin"))
2599+
},
2600+
anyOrNull(),
2601+
)
2602+
}
2603+
2604+
@Test
2605+
fun `log with non manual origin does have origin attribute`() {
2606+
val (sut, mockClient) = getEnabledScopes { it.logs.isEnabled = true }
2607+
2608+
sut
2609+
.logger()
2610+
.log(SentryLogLevel.WARN, SentryLogParameters().also { it.origin = "other" }, "log message")
2611+
2612+
verify(mockClient)
2613+
.captureLog(
2614+
check {
2615+
assertEquals("log message", it.body)
2616+
assertEquals(
2617+
"other",
2618+
(it.attributes!!.get("sentry.origin") as? SentryLogEventAttributeValue)?.value,
2619+
)
2620+
},
2621+
anyOrNull(),
2622+
)
2623+
}
2624+
25882625
@Test
25892626
fun `creating log with format string works`() {
25902627
val (sut, mockClient) =

0 commit comments

Comments
 (0)