File tree Expand file tree Collapse file tree 3 files changed +48
-3
lines changed
main/java/io/sentry/logger Expand file tree Collapse file tree 3 files changed +48
-3
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ ### Improvements
6+
7+ - Do not send manual log origin ([#4897](https://github.com/getsentry/sentry-java/pull/4897))
8+
39## 8.26.0
410
511### Features
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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) =
You can’t perform that action at this time.
0 commit comments