Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

- Remove the aggregate Sentry Metrics enable flag; `Sentry.metrics()` calls now capture Metrics by default ([#5953](https://github.com/getsentry/sentry-java/pull/5953))
- Remove the aggregate Sentry Logs enable flag; manual `Sentry.logger()` calls now capture Logs by default ([#5947](https://github.com/getsentry/sentry-java/pull/5947))
- Add an explicit Logs opt-in to Spring Boot logging auto-configuration ([#5946](https://github.com/getsentry/sentry-java/pull/5946))
- Add an explicit Logs opt-in to the Android Logcat integration ([#5945](https://github.com/getsentry/sentry-java/pull/5945))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ final class ManifestMetadataReader {

static final String ENABLE_LOGCAT_LOGS = "io.sentry.logcat.logs.enabled";

static final String ENABLE_METRICS = "io.sentry.metrics.enabled";

static final String ENABLE_AUTO_TRACE_ID_GENERATION =
"io.sentry.traces.enable-auto-id-generation";

Expand Down Expand Up @@ -758,11 +756,6 @@ static void applyMetadata(
options.setEnableLogcatLogs(
readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.isEnableLogcatLogs()));

options
.getMetrics()
.setEnabled(
readBool(metadata, logger, ENABLE_METRICS, options.getMetrics().isEnabled()));

final @NotNull SentryFeedbackOptions feedbackOptions = options.getFeedbackOptions();
feedbackOptions.setNameRequired(
readBool(metadata, logger, FEEDBACK_NAME_REQUIRED, feedbackOptions.isNameRequired()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2224,44 +2224,6 @@ class ManifestMetadataReaderTest {
assertThat(fixture.options.isEnableLogcatLogs).isFalse()
}

@Test
fun `applyMetadata reads metrics enabled and keep default value if not found`() {
// Arrange
val context = fixture.getContext()

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertTrue(fixture.options.metrics.isEnabled)
}

@Test
fun `applyMetadata reads metrics enabled to options`() {
// Arrange
val bundle = bundleOf(ManifestMetadataReader.ENABLE_METRICS to false)
val context = fixture.getContext(metaData = bundle)

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertFalse(fixture.options.metrics.isEnabled)
}

@Test
fun `applyMetadata reads metrics enabled to options when set to true`() {
// Arrange
val bundle = bundleOf(ManifestMetadataReader.ENABLE_METRICS to true)
val context = fixture.getContext(metaData = bundle)

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertTrue(fixture.options.metrics.isEnabled)
}

@Test
fun `applyMetadata reads feedback name required and keep default value if not found`() {
// Arrange
Expand Down
4 changes: 0 additions & 4 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ public final class io/sentry/ExternalOptions {
public fun isEnableBackpressureHandling ()Ljava/lang/Boolean;
public fun isEnableCacheTracing ()Ljava/lang/Boolean;
public fun isEnableDatabaseTransactionTracing ()Ljava/lang/Boolean;
public fun isEnableMetrics ()Ljava/lang/Boolean;
public fun isEnablePrettySerializationOutput ()Ljava/lang/Boolean;
public fun isEnableQueueTracing ()Ljava/lang/Boolean;
public fun isEnableSpotlight ()Ljava/lang/Boolean;
Expand All @@ -610,7 +609,6 @@ public final class io/sentry/ExternalOptions {
public fun setEnableCacheTracing (Ljava/lang/Boolean;)V
public fun setEnableDatabaseTransactionTracing (Ljava/lang/Boolean;)V
public fun setEnableDeduplication (Ljava/lang/Boolean;)V
public fun setEnableMetrics (Ljava/lang/Boolean;)V
public fun setEnablePrettySerializationOutput (Ljava/lang/Boolean;)V
public fun setEnableQueueTracing (Ljava/lang/Boolean;)V
public fun setEnableSpotlight (Ljava/lang/Boolean;)V
Expand Down Expand Up @@ -4110,9 +4108,7 @@ public final class io/sentry/SentryOptions$Metrics {
public fun <init> ()V
public fun getBeforeSend ()Lio/sentry/SentryOptions$Metrics$BeforeSendMetricCallback;
public fun getMetricsBatchProcessorFactory ()Lio/sentry/metrics/IMetricsBatchProcessorFactory;
public fun isEnabled ()Z
public fun setBeforeSend (Lio/sentry/SentryOptions$Metrics$BeforeSendMetricCallback;)V
public fun setEnabled (Z)V
public fun setMetricsBatchProcessorFactory (Lio/sentry/metrics/IMetricsBatchProcessorFactory;)V
}

Expand Down
11 changes: 0 additions & 11 deletions sentry/src/main/java/io/sentry/ExternalOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public final class ExternalOptions {
private @Nullable Boolean enabled;
private @Nullable Boolean enablePrettySerializationOutput;
private @Nullable Boolean enableSpotlight;
private @Nullable Boolean enableMetrics;
private @Nullable String spotlightConnectionUrl;

private @Nullable List<String> ignoredCheckIns;
Expand Down Expand Up @@ -177,8 +176,6 @@ public final class ExternalOptions {
options.setCaptureOpenTelemetryEvents(
propertiesProvider.getBooleanProperty("capture-open-telemetry-events"));

options.setEnableMetrics(propertiesProvider.getBooleanProperty("metrics.enabled"));

for (final String ignoredExceptionType :
propertiesProvider.getList("ignored-exceptions-for-type")) {
try {
Expand Down Expand Up @@ -714,14 +711,6 @@ public void setCaptureOpenTelemetryEvents(final @Nullable Boolean captureOpenTel
return captureOpenTelemetryEvents;
}

public void setEnableMetrics(final @Nullable Boolean enableMetrics) {
this.enableMetrics = enableMetrics;
}

public @Nullable Boolean isEnableMetrics() {
return enableMetrics;
}

public @Nullable Double getProfileSessionSampleRate() {
return profileSessionSampleRate;
}
Expand Down
9 changes: 2 additions & 7 deletions sentry/src/main/java/io/sentry/SentryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.sentry.hints.TransactionEnd;
import io.sentry.logger.ILoggerBatchProcessor;
import io.sentry.metrics.IMetricsBatchProcessor;
import io.sentry.metrics.NoOpMetricsBatchProcessor;
import io.sentry.protocol.Contexts;
import io.sentry.protocol.DebugMeta;
import io.sentry.protocol.FeatureFlags;
Expand Down Expand Up @@ -60,12 +59,8 @@ public SentryClient(final @NotNull SentryOptions options) {
final RequestDetailsResolver requestDetailsResolver = new RequestDetailsResolver(options);
transport = transportFactory.create(options, requestDetailsResolver.resolve());
loggerBatchProcessor = options.getLogs().getLoggerBatchProcessorFactory().create(options, this);
if (options.getMetrics().isEnabled()) {
metricsBatchProcessor =
options.getMetrics().getMetricsBatchProcessorFactory().create(options, this);
} else {
metricsBatchProcessor = NoOpMetricsBatchProcessor.getInstance();
}
metricsBatchProcessor =
options.getMetrics().getMetricsBatchProcessorFactory().create(options, this);
}

private boolean shouldApplyScopeData(
Expand Down
25 changes: 0 additions & 25 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3834,10 +3834,6 @@ public void merge(final @NotNull ExternalOptions options) {
}
}

if (options.isEnableMetrics() != null) {
getMetrics().setEnabled(options.isEnableMetrics());
}

if (options.getProfileSessionSampleRate() != null) {
setProfileSessionSampleRate(options.getProfileSessionSampleRate());
}
Expand Down Expand Up @@ -4146,9 +4142,6 @@ public interface BeforeSendLogCallback {

public static final class Metrics {

/** Whether Sentry Metrics feature is enabled and metrics are sent to Sentry. */
private boolean enable = true;

/**
* This function is called with a metric key and tags and can return false to skip sending the
* metric
Expand All @@ -4158,24 +4151,6 @@ public static final class Metrics {
private @NotNull IMetricsBatchProcessorFactory metricsBatchProcessorFactory =
new DefaultMetricsBatchProcessorFactory();

/**
* Whether Sentry Metrics feature is enabled and metrics are sent to Sentry.
*
* @return true if Sentry Metrics should be enabled
*/
public boolean isEnabled() {
return enable;
}

/**
* Whether Sentry Metrics feature is enabled and metrics are sent to Sentry.
*
* @param enableMetrics true if Sentry Metrics should be enabled
*/
public void setEnabled(final boolean enableMetrics) {
this.enable = enableMetrics;
}

/**
* Returns the BeforeSendMetric callback
*
Expand Down
9 changes: 0 additions & 9 deletions sentry/src/main/java/io/sentry/metrics/MetricsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@ private void captureMetrics(
return;
}

if (!options.getMetrics().isEnabled()) {
options
.getLogger()
.log(
SentryLevel.WARNING,
"Sentry Metrics is disabled and this 'metrics' call is a no-op.");
return;
}

if (name == null) {
return;
}
Expand Down
19 changes: 0 additions & 19 deletions sentry/src/test/java/io/sentry/ExternalOptionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -530,25 +530,6 @@ class ExternalOptionsTest {
}
}

@Test
fun `creates options with enableMetrics set to true`() {
withPropertiesFile("metrics.enabled=true") { options ->
assertTrue(options.isEnableMetrics == true)
}
}

@Test
fun `creates options with enableMetrics set to false`() {
withPropertiesFile("metrics.enabled=false") { options ->
assertTrue(options.isEnableMetrics == false)
}
}

@Test
fun `creates options with enableMetrics set to null when not set`() {
withPropertiesFile { assertNull(it.isEnableMetrics) }
}

@Test
fun `creates options with profileSessionSampleRate set to 0_8`() {
withPropertiesFile("profile-session-sample-rate=0.8") { options ->
Expand Down
12 changes: 2 additions & 10 deletions sentry/src/test/java/io/sentry/ScopesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3300,14 +3300,6 @@ class ScopesTest {
verify(mockClient, never()).captureMetric(any(), anyOrNull(), anyOrNull())
}

@Test
fun `when metrics is not enabled, do nothing`() {
val (sut, mockClient) = getEnabledScopes { it.metrics.isEnabled = false }

sut.metrics().count("metric name")
verify(mockClient, never()).captureMetric(any(), anyOrNull(), anyOrNull())
}

@Test
fun `creating count metric works`() {
val (sut, mockClient) = getEnabledScopes()
Expand Down Expand Up @@ -4237,7 +4229,7 @@ class ScopesTest {

@Test
fun `metric event has spanId from active span`() {
val (sut, mockClient) = getEnabledScopes { it.metrics.isEnabled = true }
val (sut, mockClient) = getEnabledScopes()

val transaction =
sut.startTransaction(
Expand All @@ -4264,7 +4256,7 @@ class ScopesTest {

@Test
fun `metric event has spanId from propagation context when no active span`() {
val (sut, mockClient) = getEnabledScopes { it.metrics.isEnabled = true }
val (sut, mockClient) = getEnabledScopes()

var propagationContext: PropagationContext? = null
sut.configureScope { propagationContext = it.propagationContext }
Expand Down
7 changes: 7 additions & 0 deletions sentry/src/test/java/io/sentry/SentryClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ class SentryClientTest {
assertTrue(sut.isEnabled)
}

@Test
fun `when client is created, metrics batch processor is created`() {
val sut = fixture.getSut()

verify(fixture.metricsBatchProcessorFactory).create(fixture.sentryOptions, sut)
}

@Test
fun `when dsn is an invalid string, client throws`() {
fixture.sentryOptions.dsn = "invalid-dsn"
Expand Down
15 changes: 0 additions & 15 deletions sentry/src/test/java/io/sentry/SentryOptionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ class SentryOptionsTest {
externalOptions.isEnableSpotlight = true
externalOptions.spotlightConnectionUrl = "http://local.sentry.io:1234"
externalOptions.isGlobalHubMode = true
externalOptions.isEnableMetrics = false
externalOptions.profileSessionSampleRate = 0.8
externalOptions.profilingTracesDirPath = "/profiling-traces"
externalOptions.profileLifecycle = ProfileLifecycle.TRACE
Expand Down Expand Up @@ -642,7 +641,6 @@ class SentryOptionsTest {
assertTrue(options.isEnableSpotlight)
assertEquals("http://local.sentry.io:1234", options.spotlightConnectionUrl)
assertTrue(options.isGlobalHubMode!!)
assertFalse(options.metrics.isEnabled)
assertEquals(0.8, options.profileSessionSampleRate)
assertEquals("/profiling-traces${File.separator}${hash}", options.profilingTracesDirPath)
assertEquals(ProfileLifecycle.TRACE, options.profileLifecycle)
Expand All @@ -656,14 +654,6 @@ class SentryOptionsTest {
assertTrue(options.isEnableUncaughtExceptionHandler)
}

@Test
fun `merging options when enableMetrics is not set preserves the default value`() {
val externalOptions = ExternalOptions()
val options = SentryOptions()
options.merge(externalOptions)
assertTrue(options.metrics.isEnabled)
}

@Test
fun `merging options merges and overwrites existing tag values`() {
val externalOptions = ExternalOptions()
Expand Down Expand Up @@ -895,11 +885,6 @@ class SentryOptionsTest {
assertFalse(SentryOptions().isEnableQueueTracing)
}

@Test
fun `when options are initialized, metrics is enabled by default`() {
assertTrue(SentryOptions().metrics.isEnabled)
}

@Test
fun `when options are initialized, enableSpotlight is set to false by default`() {
assertFalse(SentryOptions().isEnableSpotlight)
Expand Down
Loading