Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@
### Behavioural Changes

- (Android) The JNI layer for sentry-native has now been moved from sentry-java to sentry-native ([#3189](https://github.com/getsentry/sentry-java/pull/3189))
- This now includes prefab support for sentry-native, allowing you to link and access the sentry-native API within your native app code
- Checkout the `sentry-samples/sentry-samples-android` example on how to configure CMake and consume `sentry.h`
- This now includes prefab support for sentry-native, allowing you to link and access the sentry-native API within your native app code
- Checkout the `sentry-samples/sentry-samples-android` example on how to configure CMake and consume `sentry.h`

### Features

- Our `sentry-opentelemetry-agent` has been completely reworked and now plays nicely with the rest of the Java SDK
- You may also want to give this new agent a try even if you haven't used OpenTelemetry (with Sentry) before. It offers support for [many more libraries and frameworks](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/supported-libraries.md), improving on our trace propagation, `Scopes` (used to be `Hub`) propagation as well as performance instrumentation (i.e. more spans).
- If you are using a framework we did not support before and currently resort to manual instrumentation, please give the agent a try. See [here for a list of supported libraries, frameworks and application servers](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/supported-libraries.md).
- NOTE: Not all features have been implemented yet for the OpenTelemetry agent. Features of note that are not working yet:
- Metrics
- Measurements
- `forceFinish` on transaction
- `scheduleFinish` on transaction
- see [#3436](https://github.com/getsentry/sentry-java/issues/3436) for a more up-to-date list of features we have (not) implemented
- Please see "Installing `sentry-opentelemetry-agent`" for more details on how to set up the agent.
- What's new about the Agent
- When the OpenTelemetry Agent is used, Sentry API creates OpenTelemetry spans under the hood, handing back a wrapper object which bridges the gap between traditional Sentry API and OpenTelemetry. We might be replacing some of the Sentry performance API in the future.
- This is achieved by configuring the SDK to use `OtelSpanFactory` instead of `DefaultSpanFactory` which is done automatically by the auto init of the Java Agent.
- OpenTelemetry spans are now only turned into Sentry spans when they are finished so they can be sent to the Sentry server.
- Now registers an OpenTelemetry `Sampler` which uses Sentry sampling configuration
- Other Performance integrations automatically stop creating spans to avoid duplicate spans
- The Sentry SDK now makes use of OpenTelemetry `Context` for storing Sentry `Scopes` (which is similar to what used to be called `Hub`) and thus relies on OpenTelemetry for `Context` propagation.
- Classes used for the previous version of our OpenTelemetry support have been deprecated but can still be used manually. We're not planning to keep the old agent around in favor of less complexity in the SDK.
- You may also want to give this new agent a try even if you haven't used OpenTelemetry (with Sentry) before. It offers support for [many more libraries and frameworks](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/supported-libraries.md), improving on our trace propagation, `Scopes` (used to be `Hub`) propagation as well as performance instrumentation (i.e. more spans).
- If you are using a framework we did not support before and currently resort to manual instrumentation, please give the agent a try. See [here for a list of supported libraries, frameworks and application servers](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/supported-libraries.md).
- NOTE: Not all features have been implemented yet for the OpenTelemetry agent. Features of note that are not working yet:
- Metrics
- Measurements
- `forceFinish` on transaction
- `scheduleFinish` on transaction
- see [#3436](https://github.com/getsentry/sentry-java/issues/3436) for a more up-to-date list of features we have (not) implemented
- Please see "Installing `sentry-opentelemetry-agent`" for more details on how to set up the agent.
- What's new about the Agent
- When the OpenTelemetry Agent is used, Sentry API creates OpenTelemetry spans under the hood, handing back a wrapper object which bridges the gap between traditional Sentry API and OpenTelemetry. We might be replacing some of the Sentry performance API in the future.
- This is achieved by configuring the SDK to use `OtelSpanFactory` instead of `DefaultSpanFactory` which is done automatically by the auto init of the Java Agent.
- OpenTelemetry spans are now only turned into Sentry spans when they are finished so they can be sent to the Sentry server.
- Now registers an OpenTelemetry `Sampler` which uses Sentry sampling configuration
- Other Performance integrations automatically stop creating spans to avoid duplicate spans
- The Sentry SDK now makes use of OpenTelemetry `Context` for storing Sentry `Scopes` (which is similar to what used to be called `Hub`) and thus relies on OpenTelemetry for `Context` propagation.
- Classes used for the previous version of our OpenTelemetry support have been deprecated but can still be used manually. We're not planning to keep the old agent around in favor of less complexity in the SDK.
- Add `ignoredSpanOrigins` option for ignoring spans coming from certain integrations
- We pre-configure this to ignore Performance instrumentation for Spring and other integrations when using our OpenTelemetry Agent to avoid duplicate spans
- We pre-configure this to ignore Performance instrumentation for Spring and other integrations when using our OpenTelemetry Agent to avoid duplicate spans
- Add data fetching environment hint to breadcrumb for GraphQL (#3413) ([#3431](https://github.com/getsentry/sentry-java/pull/3431))

### Fixes
Expand All @@ -60,9 +60,9 @@ If you've been using the previous version of `sentry-opentelemetry-agent`, simpl

#### New to the agent
If you've not been using OpenTelemetry before, you can add `sentry-opentelemetry-agent` to your setup by downloading the latest release and using it when starting up your application
- `SENTRY_PROPERTIES_FILE=sentry.properties java -javaagent:sentry-opentelemetry-agent-x.x.x.jar -jar your-application.jar`
- Please use `sentry.properties` or environment variables to configure the SDK as the agent is now in charge of initializing the SDK and options coming from things like logging integrations or our Spring Boot integration will not take effect.
- You may find the [docs page](https://docs.sentry.io/platforms/java/tracing/instrumentation/opentelemetry/#using-sentry-opentelemetry-agent-with-auto-initialization) useful. While we haven't updated it yet to reflect the changes described here, the section about using the agent with auto init should still be valid.
- `SENTRY_PROPERTIES_FILE=sentry.properties java -javaagent:sentry-opentelemetry-agent-x.x.x.jar -jar your-application.jar`
- Please use `sentry.properties` or environment variables to configure the SDK as the agent is now in charge of initializing the SDK and options coming from things like logging integrations or our Spring Boot integration will not take effect.
- You may find the [docs page](https://docs.sentry.io/platforms/java/tracing/instrumentation/opentelemetry/#using-sentry-opentelemetry-agent-with-auto-initialization) useful. While we haven't updated it yet to reflect the changes described here, the section about using the agent with auto init should still be valid.

If you want to skip auto initialization of the SDK performed by the agent, please follow the steps above and set the environment variable `SENTRY_AUTO_INIT` to `false` then add the following to your `Sentry.init`:

Expand All @@ -87,8 +87,8 @@ Sentry.OptionsConfiguration<SentryOptions> optionsConfiguration() {
### Dependencies

- Bump Native SDK from v0.7.0 to v0.7.5 ([#3441](https://github.com/getsentry/sentry-java/pull/3189))
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#075)
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.0...0.7.5)
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#075)
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.0...0.7.5)

## 8.0.0-alpha.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static SentryId captureEnvelope(
deleteCurrentSessionFile(
options,
// should be sync if going to crash or already not a main thread
!maybeStartNewSession || !hub.getOptions().getMainThreadChecker().isMainThread());
!maybeStartNewSession || !scopes.getOptions().getMainThreadChecker().isMainThread());
if (maybeStartNewSession) {
scopes.startSession();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static synchronized void init(
Sentry.init(
OptionsContainer.create(SentryAndroidOptions.class),
options -> {
final LoadClass classLoader = new LoadClass();
final io.sentry.util.LoadClass classLoader = new io.sentry.util.LoadClass();
final boolean isTimberUpstreamAvailable =
classLoader.isClassAvailable(TIMBER_CLASS_NAME, options);
final boolean isFragmentUpstreamAvailable =
Expand All @@ -104,7 +104,7 @@ public static synchronized void init(
&& classLoader.isClassAvailable(SENTRY_TIMBER_INTEGRATION_CLASS_NAME, options));

final BuildInfoProvider buildInfoProvider = new BuildInfoProvider(logger);
final LoadClass loadClass = new LoadClass();
final io.sentry.util.LoadClass loadClass = new io.sentry.util.LoadClass();
final ActivityFramesTracker activityFramesTracker =
new ActivityFramesTracker(loadClass, options);

Expand Down Expand Up @@ -154,7 +154,7 @@ public static synchronized void init(
// so only start a session if it's not already started
// This e.g. happens on React Native, or e.g. on deferred SDK init
final AtomicBoolean sessionStarted = new AtomicBoolean(false);
hub.configureScope(
scopes.configureScope(
scope -> {
final @Nullable Session currentSession = scope.getSession();
if (currentSession != null && currentSession.getStarted() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class SentryAndroidTest {
@Test
fun `init does not start a session if one is already running`() {
val client = mock<ISentryClient>()
whenever(client.isEnabled).thenReturn(true)

initSentryWithForegroundImportance(true, { options ->
options.addIntegration { hub, _ ->
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal class SentryOkHttpEvent(private val scopes: IScopes, private val reques
callRootSpan?.setData("url", url)
callRootSpan?.setData("host", host)
callRootSpan?.setData("path", encodedPath)
callRootSpan?.setData(SpanDataConvention.HTTP_METHOD_KEY, method.toUpperCase(Locale.ROOT))
callRootSpan?.setData(SpanDataConvention.HTTP_METHOD_KEY, method.uppercase(Locale.ROOT))
}

/**
Expand Down
8 changes: 8 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public final class io/sentry/CombinedScopeView : io/sentry/IScope {
public fun clear ()V
public fun clearAttachments ()V
public fun clearBreadcrumbs ()V
public fun clearSession ()V
public fun clearTransaction ()V
public fun clone ()Lio/sentry/IScope;
public synthetic fun clone ()Ljava/lang/Object;
Expand Down Expand Up @@ -326,6 +327,7 @@ public final class io/sentry/DataCategory : java/lang/Enum {
public static final field Profile Lio/sentry/DataCategory;
public static final field Security Lio/sentry/DataCategory;
public static final field Session Lio/sentry/DataCategory;
public static final field Span Lio/sentry/DataCategory;
public static final field Transaction Lio/sentry/DataCategory;
public static final field Unknown Lio/sentry/DataCategory;
public static final field UserReport Lio/sentry/DataCategory;
Expand Down Expand Up @@ -738,6 +740,7 @@ public abstract interface class io/sentry/IScope {
public abstract fun clear ()V
public abstract fun clearAttachments ()V
public abstract fun clearBreadcrumbs ()V
public abstract fun clearSession ()V
public abstract fun clearTransaction ()V
public abstract fun clone ()Lio/sentry/IScope;
public abstract fun endSession ()Lio/sentry/Session;
Expand Down Expand Up @@ -1412,6 +1415,7 @@ public final class io/sentry/NoOpScope : io/sentry/IScope {
public fun clear ()V
public fun clearAttachments ()V
public fun clearBreadcrumbs ()V
public fun clearSession ()V
public fun clearTransaction ()V
public fun clone ()Lio/sentry/IScope;
public synthetic fun clone ()Ljava/lang/Object;
Expand Down Expand Up @@ -1884,6 +1888,7 @@ public final class io/sentry/Scope : io/sentry/IScope {
public fun clear ()V
public fun clearAttachments ()V
public fun clearBreadcrumbs ()V
public fun clearSession ()V
public fun clearTransaction ()V
public fun clone ()Lio/sentry/IScope;
public synthetic fun clone ()Ljava/lang/Object;
Expand Down Expand Up @@ -3632,6 +3637,7 @@ public final class io/sentry/clientreport/ClientReportRecorder : io/sentry/clien
public fun recordLostEnvelope (Lio/sentry/clientreport/DiscardReason;Lio/sentry/SentryEnvelope;)V
public fun recordLostEnvelopeItem (Lio/sentry/clientreport/DiscardReason;Lio/sentry/SentryEnvelopeItem;)V
public fun recordLostEvent (Lio/sentry/clientreport/DiscardReason;Lio/sentry/DataCategory;)V
public fun recordLostEvent (Lio/sentry/clientreport/DiscardReason;Lio/sentry/DataCategory;J)V
}

public final class io/sentry/clientreport/DiscardReason : java/lang/Enum {
Expand Down Expand Up @@ -3677,6 +3683,7 @@ public abstract interface class io/sentry/clientreport/IClientReportRecorder {
public abstract fun recordLostEnvelope (Lio/sentry/clientreport/DiscardReason;Lio/sentry/SentryEnvelope;)V
public abstract fun recordLostEnvelopeItem (Lio/sentry/clientreport/DiscardReason;Lio/sentry/SentryEnvelopeItem;)V
public abstract fun recordLostEvent (Lio/sentry/clientreport/DiscardReason;Lio/sentry/DataCategory;)V
public abstract fun recordLostEvent (Lio/sentry/clientreport/DiscardReason;Lio/sentry/DataCategory;J)V
}

public abstract interface class io/sentry/clientreport/IClientReportStorage {
Expand All @@ -3690,6 +3697,7 @@ public final class io/sentry/clientreport/NoOpClientReportRecorder : io/sentry/c
public fun recordLostEnvelope (Lio/sentry/clientreport/DiscardReason;Lio/sentry/SentryEnvelope;)V
public fun recordLostEnvelopeItem (Lio/sentry/clientreport/DiscardReason;Lio/sentry/SentryEnvelopeItem;)V
public fun recordLostEvent (Lio/sentry/clientreport/DiscardReason;Lio/sentry/DataCategory;)V
public fun recordLostEvent (Lio/sentry/clientreport/DiscardReason;Lio/sentry/DataCategory;J)V
}

public abstract interface class io/sentry/config/PropertiesProvider {
Expand Down
5 changes: 5 additions & 0 deletions sentry/src/main/java/io/sentry/CombinedScopeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ public void withTransaction(Scope.@NotNull IWithTransaction callback) {
return globalScope.getSession();
}

@Override
public void clearSession() {
getDefaultWriteScope().clearSession();
}

@Override
public void setPropagationContext(@NotNull PropagationContext propagationContext) {
getDefaultWriteScope().setPropagationContext(propagationContext);
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/Scopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ public void flush(long timeoutMillis) {
getOptions()
.getClientReportRecorder()
.recordLostEvent(DiscardReason.BACKPRESSURE, DataCategory.Transaction);
options
getOptions()
.getClientReportRecorder()
.recordLostEvent(
DiscardReason.BACKPRESSURE,
Expand All @@ -785,7 +785,7 @@ public void flush(long timeoutMillis) {
getOptions()
.getClientReportRecorder()
.recordLostEvent(DiscardReason.SAMPLE_RATE, DataCategory.Transaction);
options
getOptions()
.getClientReportRecorder()
.recordLostEvent(
DiscardReason.SAMPLE_RATE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ class UncaughtExceptionHandlerIntegrationTest {
}

val integration1 = UncaughtExceptionHandlerIntegration(handler)
integration1.register(fixture.hub, fixture.options)
integration1.register(fixture.scopes, fixture.options)

val integration2 = UncaughtExceptionHandlerIntegration(handler)
integration2.register(fixture.hub, fixture.options)
integration2.register(fixture.scopes, fixture.options)

assertEquals(currentDefaultHandler, integration2)
integration2.close()
Expand All @@ -334,10 +334,10 @@ class UncaughtExceptionHandlerIntegrationTest {
}

val integration1 = UncaughtExceptionHandlerIntegration(handler)
integration1.register(fixture.hub, fixture.options)
integration1.register(fixture.scopes, fixture.options)

val integration2 = UncaughtExceptionHandlerIntegration(handler)
integration2.register(fixture.hub, fixture.options)
integration2.register(fixture.scopes, fixture.options)

assertEquals(currentDefaultHandler, integration2)
integration2.close()
Expand Down
Loading