Skip to content

Commit aff133e

Browse files
authored
Merge f1181ab into 5ca032d
2 parents 5ca032d + f1181ab commit aff133e

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

sentry/src/main/java/io/sentry/SentryLogEventAttributeValue.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public final class SentryLogEventAttributeValue implements JsonUnknown, JsonSeri
1515

1616
public SentryLogEventAttributeValue(final @NotNull String type, final @Nullable Object value) {
1717
this.type = type;
18-
this.value = value;
18+
if (value != null && this.type.equals("string")) {
19+
this.value = value.toString();
20+
} else {
21+
this.value = value;
22+
}
1923
}
2024

2125
public @NotNull String getType() {

sentry/src/test/java/io/sentry/protocol/SentryLogsSerializationTest.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ class SentryLogsSerializationTest {
3232
"sentry.sdk.name" to SentryLogEventAttributeValue("string", "sentry.java.spring-boot.jakarta"),
3333
"sentry.environment" to SentryLogEventAttributeValue("string", "production"),
3434
"sentry.sdk.version" to SentryLogEventAttributeValue("string", "8.11.1"),
35-
"sentry.trace.parent_span_id" to SentryLogEventAttributeValue("string", "f28b86350e534671")
35+
"sentry.trace.parent_span_id" to SentryLogEventAttributeValue("string", "f28b86350e534671"),
36+
37+
"custom.boolean" to SentryLogEventAttributeValue("boolean", true),
38+
"custom.integer" to SentryLogEventAttributeValue("integer", 10),
39+
"custom.double" to SentryLogEventAttributeValue("double", 11.toDouble()),
3640
)
3741
it.severityNumber = 10
3842
}
@@ -75,4 +79,13 @@ class SentryLogsSerializationTest {
7579
val reader = JsonObjectReader(StringReader(json))
7680
return SentryLogEvents.Deserializer().deserialize(reader, fixture.logger)
7781
}
82+
83+
companion object {
84+
data class Point(val x: Int, val y: Int) {
85+
override fun toString(): String {
86+
return "Point{x:$x,y:$y}-Hello"
87+
}
88+
}
89+
}
90+
7891
}

sentry/src/test/resources/json/sentry_logs.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@
2828
{
2929
"type": "string",
3030
"value": "f28b86350e534671"
31+
},
32+
"custom.boolean":
33+
{
34+
"type": "boolean",
35+
"value": true
36+
},
37+
"custom.integer":
38+
{
39+
"type": "integer",
40+
"value": 10
41+
},
42+
"custom.double":
43+
{
44+
"type": "double",
45+
"value": 11.0
3146
}
3247
}
3348
}

0 commit comments

Comments
 (0)