Skip to content

Commit 27829cb

Browse files
committed
wip
1 parent 5ca032d commit 27829cb

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-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: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ 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()),
40+
"custom.null" to SentryLogEventAttributeValue("string", null),
41+
"custom.object" to SentryLogEventAttributeValue("string", Point(30, 40)),
3642
)
3743
it.severityNumber = 10
3844
}
@@ -75,4 +81,13 @@ class SentryLogsSerializationTest {
7581
val reader = JsonObjectReader(StringReader(json))
7682
return SentryLogEvents.Deserializer().deserialize(reader, fixture.logger)
7783
}
84+
85+
companion object {
86+
data class Point(val x: Int, val y: Int) {
87+
override fun toString(): String {
88+
return "Point{x:$x,y:$y}-Hello"
89+
}
90+
}
91+
}
92+
7893
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@
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
46+
},
47+
"custom.null":
48+
{
49+
"type": "string",
50+
"value": null
51+
},
52+
"custom.object":
53+
{
54+
"type": "string",
55+
"value": "Point{x:30,y:40}-Hello"
3156
}
3257
}
3358
}

0 commit comments

Comments
 (0)