Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sample rate to baggage as well as trace in envelope header and flatten user #2135

Merged
merged 10 commits into from
Jul 1, 2022
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

- Filter out app starts with more than 60s ([#2127](https://github.com/getsentry/sentry-java/pull/2127))

## Unreleased

### Features

- Add sample rate to baggage as well as trace in envelope header and flatten user ([#2135](https://github.com/getsentry/sentry-java/pull/2135))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge main into the branch to fix the changelog.


## 6.1.3

### Fixes
Expand Down
30 changes: 7 additions & 23 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public final class io/sentry/Baggage {
public fun setEnvironment (Ljava/lang/String;)V
public fun setPublicKey (Ljava/lang/String;)V
public fun setRelease (Ljava/lang/String;)V
public fun setSampleRate (Ljava/lang/String;)V
public fun setTraceId (Ljava/lang/String;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUserId (Ljava/lang/String;)V
Expand Down Expand Up @@ -1619,10 +1620,12 @@ public final class io/sentry/TraceContext : io/sentry/JsonSerializable, io/sentr
public fun getEnvironment ()Ljava/lang/String;
public fun getPublicKey ()Ljava/lang/String;
public fun getRelease ()Ljava/lang/String;
public fun getSampleRate ()Ljava/lang/String;
public fun getTraceId ()Lio/sentry/protocol/SentryId;
public fun getTransaction ()Ljava/lang/String;
public fun getUnknown ()Ljava/util/Map;
public fun getUser ()Lio/sentry/TraceContext$TraceContextUser;
public fun getUserId ()Ljava/lang/String;
public fun getUserSegment ()Ljava/lang/String;
public fun serialize (Lio/sentry/JsonObjectWriter;Lio/sentry/ILogger;)V
public fun setUnknown (Ljava/util/Map;)V
public fun toBaggage (Lio/sentry/ILogger;)Lio/sentry/Baggage;
Expand All @@ -1638,30 +1641,11 @@ public final class io/sentry/TraceContext$JsonKeys {
public static final field ENVIRONMENT Ljava/lang/String;
public static final field PUBLIC_KEY Ljava/lang/String;
public static final field RELEASE Ljava/lang/String;
public static final field SAMPLE_RATE Ljava/lang/String;
public static final field TRACE_ID Ljava/lang/String;
public static final field TRANSACTION Ljava/lang/String;
public static final field USER Ljava/lang/String;
public fun <init> ()V
}

public final class io/sentry/TraceContext$TraceContextUser : io/sentry/JsonSerializable, io/sentry/JsonUnknown {
public fun <init> (Lio/sentry/protocol/User;)V
public fun getId ()Ljava/lang/String;
public fun getSegment ()Ljava/lang/String;
public fun getUnknown ()Ljava/util/Map;
public fun serialize (Lio/sentry/JsonObjectWriter;Lio/sentry/ILogger;)V
public fun setUnknown (Ljava/util/Map;)V
}

public final class io/sentry/TraceContext$TraceContextUser$Deserializer : io/sentry/JsonDeserializer {
public fun <init> ()V
public fun deserialize (Lio/sentry/JsonObjectReader;Lio/sentry/ILogger;)Lio/sentry/TraceContext$TraceContextUser;
public synthetic fun deserialize (Lio/sentry/JsonObjectReader;Lio/sentry/ILogger;)Ljava/lang/Object;
}

public final class io/sentry/TraceContext$TraceContextUser$JsonKeys {
public static final field ID Ljava/lang/String;
public static final field SEGMENT Ljava/lang/String;
public static final field USER_ID Ljava/lang/String;
public static final field USER_SEGMENT Ljava/lang/String;
public fun <init> ()V
}

Expand Down
4 changes: 4 additions & 0 deletions sentry/src/main/java/io/sentry/Baggage.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public void setTransaction(final @Nullable String transaction) {
set("sentry-transaction", transaction);
}

public void setSampleRate(final @Nullable String sampleRate) {
set("sentry-samplerate", sampleRate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to make baggage and envelope header key names identical (except for the sentry- prefix in baggage keys) so that we're able to just dump the DSC data into both transport mechanisms without any mapping. (Linking to the preview here for more details)

Therefore, we should change the snake case keys to underscores (like in the example below)

Suggested change
set("sentry-samplerate", sampleRate);
set("sentry-sample_rate", sampleRate);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that also mean

  • sentry-publickey becomes sentry-public_key
  • sentry-traceid becomes sentry_trace_id
  • sentry-userid becomes sentry-user_id
  • sentry-usersegment becomes sentry-user_segment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • sentry-traceid becomes sentry_trace_id

It becomes sentry-trace_id, but that probably just was a typo ^^

Copy link
Member Author

@adinauer adinauer Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks, will update.
Yeah just a typo on the _ there.

}

public void set(final @NotNull String key, final @Nullable String value) {
this.keyValues.put(key, value);
}
Expand Down