2121import io .sentry .util .Platform ;
2222import io .sentry .util .TracingUtils ;
2323import java .util .HashMap ;
24+ import java .util .Map ;
2425import org .jetbrains .annotations .NotNull ;
2526import org .jetbrains .annotations .Nullable ;
2627
@@ -163,6 +164,14 @@ private void captureLog(
163164 final @ NotNull String message ,
164165 final @ Nullable Object ... args ) {
165166 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+
166175 final @ NotNull String origin = params .getOrigin ();
167176 if (!"manual" .equalsIgnoreCase (origin )) {
168177 attributes .put (
@@ -173,17 +182,14 @@ private void captureLog(
173182
174183 if (incomingAttributes != null ) {
175184 for (SentryAttribute attribute : incomingAttributes .getAttributes ().values ()) {
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 ));
185+ attributes .put (attribute .getName (), SentryLogEventAttributeValue .fromAttribute (attribute ));
180186 }
181187 }
182188
183189 if (args != null ) {
184190 int i = 0 ;
185191 for (Object arg : args ) {
186- final @ NotNull SentryAttributeType type = getType (arg );
192+ final @ NotNull SentryAttributeType type = SentryAttributeType . inferFrom (arg );
187193 attributes .put (
188194 "sentry.message.parameter." + i , new SentryLogEventAttributeValue (type , arg ));
189195 i ++;
@@ -292,17 +298,4 @@ private void setUser(final @NotNull HashMap<String, SentryLogEventAttributeValue
292298 }
293299 }
294300 }
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- }
308301}
0 commit comments