2121import io .sentry .util .Platform ;
2222import io .sentry .util .TracingUtils ;
2323import java .util .HashMap ;
24- import java .util .Map ;
2524import org .jetbrains .annotations .NotNull ;
2625import org .jetbrains .annotations .Nullable ;
2726
@@ -164,14 +163,6 @@ private void captureLog(
164163 final @ NotNull String message ,
165164 final @ Nullable Object ... args ) {
166165 final @ NotNull HashMap <String , SentryLogEventAttributeValue > attributes = new HashMap <>();
167-
168- final @ NotNull Map <String , SentryAttribute > scopeAttributes =
169- scopes .getCombinedScopeView ().getAttributes ();
170- for (SentryAttribute scopeAttribute : scopeAttributes .values ()) {
171- attributes .put (
172- scopeAttribute .getName (), SentryLogEventAttributeValue .fromAttribute (scopeAttribute ));
173- }
174-
175166 final @ NotNull String origin = params .getOrigin ();
176167 if (!"manual" .equalsIgnoreCase (origin )) {
177168 attributes .put (
@@ -182,14 +173,17 @@ private void captureLog(
182173
183174 if (incomingAttributes != null ) {
184175 for (SentryAttribute attribute : incomingAttributes .getAttributes ().values ()) {
185- attributes .put (attribute .getName (), SentryLogEventAttributeValue .fromAttribute (attribute ));
176+ final @ Nullable Object value = attribute .getValue ();
177+ final @ NotNull SentryAttributeType type =
178+ attribute .getType () == null ? getType (value ) : attribute .getType ();
179+ attributes .put (attribute .getName (), new SentryLogEventAttributeValue (type , value ));
186180 }
187181 }
188182
189183 if (args != null ) {
190184 int i = 0 ;
191185 for (Object arg : args ) {
192- final @ NotNull SentryAttributeType type = SentryAttributeType . inferFrom (arg );
186+ final @ NotNull SentryAttributeType type = getType (arg );
193187 attributes .put (
194188 "sentry.message.parameter." + i , new SentryLogEventAttributeValue (type , arg ));
195189 i ++;
@@ -298,4 +292,17 @@ private void setUser(final @NotNull HashMap<String, SentryLogEventAttributeValue
298292 }
299293 }
300294 }
295+
296+ private @ NotNull SentryAttributeType getType (final @ Nullable Object arg ) {
297+ if (arg instanceof Boolean ) {
298+ return SentryAttributeType .BOOLEAN ;
299+ }
300+ if (arg instanceof Integer ) {
301+ return SentryAttributeType .INTEGER ;
302+ }
303+ if (arg instanceof Number ) {
304+ return SentryAttributeType .DOUBLE ;
305+ }
306+ return SentryAttributeType .STRING ;
307+ }
301308}
0 commit comments