Skip to content

Commit 1914d83

Browse files
committed
update
1 parent 5ca032d commit 1914d83

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-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 && 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: 13 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+
"custom.boolean" to SentryLogEventAttributeValue("boolean", true),
37+
"custom.double" to SentryLogEventAttributeValue("double", 11.12.toDouble()),
38+
"custom.point" to SentryLogEventAttributeValue("string", Point(20, 30)),
39+
"custom.integer" to SentryLogEventAttributeValue("integer", 10)
3640
)
3741
it.severityNumber = 10
3842
}
@@ -75,4 +79,12 @@ 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+
}
7890
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@
2828
{
2929
"type": "string",
3030
"value": "f28b86350e534671"
31+
},
32+
"custom.boolean":
33+
{
34+
"type": "boolean",
35+
"value": true
36+
},
37+
"custom.double": {
38+
"type": "double",
39+
"value": 11.12
40+
},
41+
"custom.point": {
42+
"type": "string",
43+
"value": "Point{x:20,y:30}-Hello"
44+
},
45+
"custom.integer":
46+
{
47+
"type": "integer",
48+
"value": 10
3149
}
3250
}
3351
}

0 commit comments

Comments
 (0)