Skip to content

Commit fe70d60

Browse files
authored
Merge ffb15c2 into 5ca032d
2 parents 5ca032d + ffb15c2 commit fe70d60

File tree

9 files changed

+230
-56
lines changed

9 files changed

+230
-56
lines changed

sentry/api/sentry.api

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,34 @@ public final class io/sentry/SentryAppStartProfilingOptions$JsonKeys {
26582658
public fun <init> ()V
26592659
}
26602660

2661+
public final class io/sentry/SentryAttribute {
2662+
public static fun booleanAttribute (Ljava/lang/String;Ljava/lang/Boolean;)Lio/sentry/SentryAttribute;
2663+
public static fun doubleAttribute (Ljava/lang/String;Ljava/lang/Double;)Lio/sentry/SentryAttribute;
2664+
public fun getName ()Ljava/lang/String;
2665+
public fun getType ()Lio/sentry/SentryAttributeType;
2666+
public fun getValue ()Ljava/lang/Object;
2667+
public static fun integerAttribute (Ljava/lang/String;Ljava/lang/Integer;)Lio/sentry/SentryAttribute;
2668+
public static fun named (Ljava/lang/String;Ljava/lang/Object;)Lio/sentry/SentryAttribute;
2669+
public static fun stringAttribute (Ljava/lang/String;Ljava/lang/String;)Lio/sentry/SentryAttribute;
2670+
}
2671+
2672+
public final class io/sentry/SentryAttributeType : java/lang/Enum {
2673+
public static final field BOOLEAN Lio/sentry/SentryAttributeType;
2674+
public static final field DOUBLE Lio/sentry/SentryAttributeType;
2675+
public static final field INTEGER Lio/sentry/SentryAttributeType;
2676+
public static final field STRING Lio/sentry/SentryAttributeType;
2677+
public fun apiName ()Ljava/lang/String;
2678+
public static fun valueOf (Ljava/lang/String;)Lio/sentry/SentryAttributeType;
2679+
public static fun values ()[Lio/sentry/SentryAttributeType;
2680+
}
2681+
2682+
public final class io/sentry/SentryAttributes {
2683+
public fun add (Lio/sentry/SentryAttribute;)V
2684+
public static fun fromMap (Ljava/util/Map;)Lio/sentry/SentryAttributes;
2685+
public fun getAttributes ()Ljava/util/List;
2686+
public static fun of ([Lio/sentry/SentryAttribute;)Lio/sentry/SentryAttributes;
2687+
}
2688+
26612689
public final class io/sentry/SentryAutoDateProvider : io/sentry/SentryDateProvider {
26622690
public fun <init> ()V
26632691
public fun now ()Lio/sentry/SentryDate;
@@ -3077,6 +3105,7 @@ public final class io/sentry/SentryLogEvent$JsonKeys {
30773105
}
30783106

30793107
public final class io/sentry/SentryLogEventAttributeValue : io/sentry/JsonSerializable, io/sentry/JsonUnknown {
3108+
public fun <init> (Lio/sentry/SentryAttributeType;Ljava/lang/Object;)V
30803109
public fun <init> (Ljava/lang/String;Ljava/lang/Object;)V
30813110
public fun getType ()Ljava/lang/String;
30823111
public fun getUnknown ()Ljava/util/Map;
@@ -4711,9 +4740,8 @@ public abstract interface class io/sentry/logger/ILoggerApi {
47114740
public abstract fun fatal (Ljava/lang/String;[Ljava/lang/Object;)V
47124741
public abstract fun info (Ljava/lang/String;[Ljava/lang/Object;)V
47134742
public abstract fun log (Lio/sentry/SentryLogLevel;Lio/sentry/SentryDate;Ljava/lang/String;[Ljava/lang/Object;)V
4743+
public abstract fun log (Lio/sentry/SentryLogLevel;Lio/sentry/logger/LogParams;Ljava/lang/String;[Ljava/lang/Object;)V
47144744
public abstract fun log (Lio/sentry/SentryLogLevel;Ljava/lang/String;[Ljava/lang/Object;)V
4715-
public abstract fun log (Ljava/util/Map;Lio/sentry/SentryLogLevel;Lio/sentry/SentryDate;Ljava/lang/String;[Ljava/lang/Object;)V
4716-
public abstract fun log (Ljava/util/Map;Lio/sentry/SentryLogLevel;Ljava/lang/String;[Ljava/lang/Object;)V
47174745
public abstract fun trace (Ljava/lang/String;[Ljava/lang/Object;)V
47184746
public abstract fun warn (Ljava/lang/String;[Ljava/lang/Object;)V
47194747
}
@@ -4723,16 +4751,25 @@ public abstract interface class io/sentry/logger/ILoggerBatchProcessor {
47234751
public abstract fun close (Z)V
47244752
}
47254753

4754+
public final class io/sentry/logger/LogParams {
4755+
public fun <init> ()V
4756+
public static fun create (Lio/sentry/SentryAttributes;)Lio/sentry/logger/LogParams;
4757+
public static fun create (Lio/sentry/SentryDate;Lio/sentry/SentryAttributes;)Lio/sentry/logger/LogParams;
4758+
public fun getAttributes ()Lio/sentry/SentryAttributes;
4759+
public fun getTimestamp ()Lio/sentry/SentryDate;
4760+
public fun setAttributes (Lio/sentry/SentryAttributes;)V
4761+
public fun setTimestamp (Lio/sentry/SentryDate;)V
4762+
}
4763+
47264764
public final class io/sentry/logger/LoggerApi : io/sentry/logger/ILoggerApi {
47274765
public fun <init> (Lio/sentry/Scopes;)V
47284766
public fun debug (Ljava/lang/String;[Ljava/lang/Object;)V
47294767
public fun error (Ljava/lang/String;[Ljava/lang/Object;)V
47304768
public fun fatal (Ljava/lang/String;[Ljava/lang/Object;)V
47314769
public fun info (Ljava/lang/String;[Ljava/lang/Object;)V
47324770
public fun log (Lio/sentry/SentryLogLevel;Lio/sentry/SentryDate;Ljava/lang/String;[Ljava/lang/Object;)V
4771+
public fun log (Lio/sentry/SentryLogLevel;Lio/sentry/logger/LogParams;Ljava/lang/String;[Ljava/lang/Object;)V
47334772
public fun log (Lio/sentry/SentryLogLevel;Ljava/lang/String;[Ljava/lang/Object;)V
4734-
public fun log (Ljava/util/Map;Lio/sentry/SentryLogLevel;Lio/sentry/SentryDate;Ljava/lang/String;[Ljava/lang/Object;)V
4735-
public fun log (Ljava/util/Map;Lio/sentry/SentryLogLevel;Ljava/lang/String;[Ljava/lang/Object;)V
47364773
public fun trace (Ljava/lang/String;[Ljava/lang/Object;)V
47374774
public fun warn (Ljava/lang/String;[Ljava/lang/Object;)V
47384775
}
@@ -4752,9 +4789,8 @@ public final class io/sentry/logger/NoOpLoggerApi : io/sentry/logger/ILoggerApi
47524789
public static fun getInstance ()Lio/sentry/logger/NoOpLoggerApi;
47534790
public fun info (Ljava/lang/String;[Ljava/lang/Object;)V
47544791
public fun log (Lio/sentry/SentryLogLevel;Lio/sentry/SentryDate;Ljava/lang/String;[Ljava/lang/Object;)V
4792+
public fun log (Lio/sentry/SentryLogLevel;Lio/sentry/logger/LogParams;Ljava/lang/String;[Ljava/lang/Object;)V
47554793
public fun log (Lio/sentry/SentryLogLevel;Ljava/lang/String;[Ljava/lang/Object;)V
4756-
public fun log (Ljava/util/Map;Lio/sentry/SentryLogLevel;Lio/sentry/SentryDate;Ljava/lang/String;[Ljava/lang/Object;)V
4757-
public fun log (Ljava/util/Map;Lio/sentry/SentryLogLevel;Ljava/lang/String;[Ljava/lang/Object;)V
47584794
public fun trace (Ljava/lang/String;[Ljava/lang/Object;)V
47594795
public fun warn (Ljava/lang/String;[Ljava/lang/Object;)V
47604796
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package io.sentry;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
import org.jetbrains.annotations.Nullable;
5+
6+
public final class SentryAttribute {
7+
8+
private final @NotNull String name;
9+
private final @Nullable SentryAttributeType type;
10+
private final @Nullable Object value;
11+
12+
private SentryAttribute(
13+
final @NotNull String name,
14+
final @Nullable SentryAttributeType type,
15+
final @Nullable Object value) {
16+
this.name = name;
17+
this.type = type;
18+
this.value = value;
19+
}
20+
21+
public @NotNull String getName() {
22+
return name;
23+
}
24+
25+
public @Nullable SentryAttributeType getType() {
26+
return type;
27+
}
28+
29+
public @Nullable Object getValue() {
30+
return value;
31+
}
32+
33+
public static @NotNull SentryAttribute named(
34+
final @NotNull String name, final @Nullable Object value) {
35+
return new SentryAttribute(name, null, value);
36+
}
37+
38+
public static @NotNull SentryAttribute booleanAttribute(
39+
final @NotNull String name, final @Nullable Boolean value) {
40+
return new SentryAttribute(name, SentryAttributeType.BOOLEAN, value);
41+
}
42+
43+
public static @NotNull SentryAttribute integerAttribute(
44+
final @NotNull String name, final @Nullable Integer value) {
45+
return new SentryAttribute(name, SentryAttributeType.INTEGER, value);
46+
}
47+
48+
public static @NotNull SentryAttribute doubleAttribute(
49+
final @NotNull String name, final @Nullable Double value) {
50+
return new SentryAttribute(name, SentryAttributeType.DOUBLE, value);
51+
}
52+
53+
public static @NotNull SentryAttribute stringAttribute(
54+
final @NotNull String name, final @Nullable String value) {
55+
return new SentryAttribute(name, SentryAttributeType.STRING, value);
56+
}
57+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.sentry;
2+
3+
import java.util.Locale;
4+
import org.jetbrains.annotations.NotNull;
5+
6+
public enum SentryAttributeType {
7+
STRING,
8+
BOOLEAN,
9+
INTEGER,
10+
DOUBLE;
11+
12+
public @NotNull String apiName() {
13+
return name().toLowerCase(Locale.ROOT);
14+
}
15+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package io.sentry;
2+
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.List;
6+
import java.util.Map;
7+
import org.jetbrains.annotations.NotNull;
8+
import org.jetbrains.annotations.Nullable;
9+
10+
public final class SentryAttributes {
11+
12+
private final @NotNull List<SentryAttribute> attributes;
13+
14+
private SentryAttributes(final @NotNull List<SentryAttribute> attributes) {
15+
this.attributes = attributes;
16+
}
17+
18+
public void add(final @Nullable SentryAttribute attribute) {
19+
if (attribute == null) {
20+
return;
21+
}
22+
attributes.add(attribute);
23+
}
24+
25+
public @NotNull List<SentryAttribute> getAttributes() {
26+
return attributes;
27+
}
28+
29+
public static @NotNull SentryAttributes of(SentryAttribute... attributes) {
30+
return new SentryAttributes(Arrays.asList(attributes));
31+
}
32+
33+
public static @NotNull SentryAttributes fromMap(final @Nullable Map<String, Object> attributes) {
34+
if (attributes == null) {
35+
return new SentryAttributes(new ArrayList<>());
36+
}
37+
SentryAttributes sentryAttributes = new SentryAttributes(new ArrayList<>(attributes.size()));
38+
for (Map.Entry<String, Object> attribute : attributes.entrySet()) {
39+
sentryAttributes.add(SentryAttribute.named(attribute.getKey(), attribute.getValue()));
40+
}
41+
42+
return sentryAttributes;
43+
}
44+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public SentryLogEventAttributeValue(final @NotNull String type, final @Nullable
1818
this.value = value;
1919
}
2020

21+
public SentryLogEventAttributeValue(
22+
final @NotNull SentryAttributeType type, final @Nullable Object value) {
23+
this.type = type.apiName();
24+
this.value = value;
25+
}
26+
2127
public @NotNull String getType() {
2228
return type;
2329
}

sentry/src/main/java/io/sentry/logger/ILoggerApi.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.sentry.SentryDate;
44
import io.sentry.SentryLogLevel;
5-
import java.util.Map;
65
import org.jetbrains.annotations.ApiStatus;
76
import org.jetbrains.annotations.NotNull;
87
import org.jetbrains.annotations.Nullable;
@@ -31,15 +30,8 @@ void log(
3130
@Nullable Object... args);
3231

3332
void log(
34-
@Nullable Map<String, Object> attributes,
3533
@NotNull SentryLogLevel level,
36-
@Nullable String message,
37-
@Nullable Object... args);
38-
39-
void log(
40-
@Nullable Map<String, Object> attributes,
41-
@NotNull SentryLogLevel level,
42-
@Nullable SentryDate timestamp,
34+
@NotNull LogParams params,
4335
@Nullable String message,
4436
@Nullable Object... args);
4537
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package io.sentry.logger;
2+
3+
import io.sentry.SentryAttributes;
4+
import io.sentry.SentryDate;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
7+
8+
public final class LogParams {
9+
10+
private @Nullable SentryDate timestamp;
11+
private @Nullable SentryAttributes attributes;
12+
13+
public @Nullable SentryDate getTimestamp() {
14+
return timestamp;
15+
}
16+
17+
public void setTimestamp(final @Nullable SentryDate timestamp) {
18+
this.timestamp = timestamp;
19+
}
20+
21+
public @Nullable SentryAttributes getAttributes() {
22+
return attributes;
23+
}
24+
25+
public void setAttributes(final @Nullable SentryAttributes attributes) {
26+
this.attributes = attributes;
27+
}
28+
29+
public static @NotNull LogParams create(
30+
final @Nullable SentryDate timestamp, final @Nullable SentryAttributes attributes) {
31+
final @NotNull LogParams params = new LogParams();
32+
33+
params.setTimestamp(timestamp);
34+
params.setAttributes(attributes);
35+
36+
return params;
37+
}
38+
39+
public static @NotNull LogParams create(final @Nullable SentryAttributes attributes) {
40+
return create(null, attributes);
41+
}
42+
}

0 commit comments

Comments
 (0)