Skip to content

Commit 5095cec

Browse files
Enable Kotlin map-like access on CustomSamplingContext. (#1192)
Use `set` method instead of `put` to let users put properties using `context["key"]` notation.
1 parent c002817 commit 5095cec

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Enhancement: Polish Performance API (#1165)
1313
* Enhancement: Set "debug" through external properties (#1186)
1414
* Enhancement: Simplify Spring integration (#1188)
15+
* Enhancement: Enable Kotlin map-like access on CustomSamplingContext (#1192)
1516
* Enhancement: Auto register custom ITransportFactory in Spring integration (#1194)
1617
* Enhancement: Improve Kotlin property access in Performance API (#1193)
1718

sentry-spring/src/main/java/io/sentry/spring/tracing/SentryTracingFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private ITransaction startTransaction(
8989
final String name = request.getMethod() + " " + request.getRequestURI();
9090

9191
final CustomSamplingContext customSamplingContext = new CustomSamplingContext();
92-
customSamplingContext.put("request", request);
92+
customSamplingContext.set("request", request);
9393

9494
if (sentryTraceHeader != null) {
9595
try {

sentry/api/sentry.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public final class io/sentry/CustomSamplingContext {
4949
public fun <init> ()V
5050
public fun get (Ljava/lang/String;)Ljava/lang/Object;
5151
public fun getData ()Ljava/util/Map;
52-
public fun put (Ljava/lang/String;Ljava/lang/Object;)V
52+
public fun set (Ljava/lang/String;Ljava/lang/Object;)V
5353
}
5454

5555
public final class io/sentry/DateUtils {

sentry/src/main/java/io/sentry/CustomSamplingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public final class CustomSamplingContext {
1414
private final @NotNull Map<String, Object> data = new HashMap<>();
1515

16-
public void put(final @NotNull String key, final @Nullable Object value) {
16+
public void set(final @NotNull String key, final @Nullable Object value) {
1717
Objects.requireNonNull(key, "key is required");
1818
this.data.put(key, value);
1919
}

0 commit comments

Comments
 (0)