Skip to content

Commit 4051bdc

Browse files
authored
feat: Add support for vars attribute in SentryStackFrame (#4686)
1 parent 78f7c1a commit 4051bdc

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
- NOTE: Our `sentry-opentelemetry-agentless-spring` is not working yet for Spring Boot 4. Please use `sentry-opentelemetry-agent` until OpenTelemetry has support for Spring Boot 4.
1313
- Replace `UUIDGenerator` implementation with Apache licensed code ([#4662](https://github.com/getsentry/sentry-java/pull/4662))
1414
- Replace `Random` implementation with MIT licensed code ([#4664](https://github.com/getsentry/sentry-java/pull/4664))
15+
- Add support for `vars` attribute in `SentryStackFrame` ([#4686](https://github.com/getsentry/sentry-java/pull/4686))
16+
- **Breaking change**: The type of the `vars` attribute has been changed from `Map<String, String>` to `Map<String, Object>`.
1517

1618
## 8.20.0
1719

sentry/api/sentry.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5933,6 +5933,7 @@ public final class io/sentry/protocol/SentryStackFrame$JsonKeys {
59335933
public static final field RAW_FUNCTION Ljava/lang/String;
59345934
public static final field SYMBOL Ljava/lang/String;
59355935
public static final field SYMBOL_ADDR Ljava/lang/String;
5936+
public static final field VARS Ljava/lang/String;
59365937
public fun <init> ()V
59375938
}
59385939

sentry/src/main/java/io/sentry/protocol/SentryStackFrame.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public final class SentryStackFrame implements JsonUnknown, JsonSerializable {
2929
private @Nullable List<String> postContext;
3030

3131
/** Mapping of local variables and expression names that were available in this frame. */
32-
private @Nullable Map<String, String> vars;
32+
private @Nullable Map<String, Object> vars;
3333

3434
private @Nullable List<Integer> framesOmitted;
3535

@@ -170,11 +170,11 @@ public void setPostContext(final @Nullable List<String> postContext) {
170170
this.postContext = postContext;
171171
}
172172

173-
public @Nullable Map<String, String> getVars() {
173+
public @Nullable Map<String, Object> getVars() {
174174
return vars;
175175
}
176176

177-
public void setVars(final @Nullable Map<String, String> vars) {
177+
public void setVars(final @Nullable Map<String, Object> vars) {
178178
this.vars = vars;
179179
}
180180

@@ -366,6 +366,7 @@ public static final class JsonKeys {
366366
public static final String LOCK = "lock";
367367
public static final String PRE_CONTEXT = "pre_context";
368368
public static final String POST_CONTEXT = "post_context";
369+
public static final String VARS = "vars";
369370
}
370371

371372
@Override
@@ -432,6 +433,9 @@ public void serialize(final @NotNull ObjectWriter writer, final @NotNull ILogger
432433
if (postContext != null && !postContext.isEmpty()) {
433434
writer.name(JsonKeys.POST_CONTEXT).value(logger, postContext);
434435
}
436+
if (vars != null && !vars.isEmpty()) {
437+
writer.name(JsonKeys.VARS).value(logger, vars);
438+
}
435439
if (unknown != null) {
436440
for (String key : unknown.keySet()) {
437441
Object value = unknown.get(key);
@@ -513,6 +517,9 @@ public static final class Deserializer implements JsonDeserializer<SentryStackFr
513517
case JsonKeys.POST_CONTEXT:
514518
sentryStackFrame.postContext = (List<String>) reader.nextObjectOrNull();
515519
break;
520+
case JsonKeys.VARS:
521+
sentryStackFrame.vars = (Map<String, Object>) reader.nextObjectOrNull();
522+
break;
516523
default:
517524
if (unknown == null) {
518525
unknown = new ConcurrentHashMap<>();

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ class SentryStackFrameSerializationTest {
5454
"0a959b53-6bdf-45d1-93ca-936281d7897a",
5555
"4e6085a3-1e44-4aa2-b3d9-9b79dca970ed",
5656
)
57+
vars =
58+
mapOf<String, Any?>(
59+
"int_var" to 42,
60+
"array_var" to listOf<Any?>(true, 17, "7a3750d1-9177-4ee2-8016-3ba02fa90291"),
61+
"string_var" to "325ad70e-1a8b-4d2d-ba92-182ee49448b7",
62+
"object_var" to
63+
mapOf<String, Any?>(
64+
"int_prop" to 53,
65+
"string_prop" to "93db3ec5-b1ec-4e95-b6d0-b9633c9e03cd",
66+
"bool_prop" to false,
67+
),
68+
"bool_var" to false,
69+
)
5770
}
5871
}
5972

sentry/src/test/resources/json/sentry_stack_frame.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,20 @@
3131
"2153c99d-2f17-45f1-a173-69e08cc6a219",
3232
"0a959b53-6bdf-45d1-93ca-936281d7897a",
3333
"4e6085a3-1e44-4aa2-b3d9-9b79dca970ed"
34-
]
34+
],
35+
"vars": {
36+
"int_var": 42,
37+
"array_var": [
38+
true,
39+
17,
40+
"7a3750d1-9177-4ee2-8016-3ba02fa90291"
41+
],
42+
"string_var": "325ad70e-1a8b-4d2d-ba92-182ee49448b7",
43+
"object_var": {
44+
"int_prop": 53,
45+
"string_prop": "93db3ec5-b1ec-4e95-b6d0-b9633c9e03cd",
46+
"bool_prop": false
47+
},
48+
"bool_var": false
49+
}
3550
}

0 commit comments

Comments
 (0)