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
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ class SentryAutoConfigurationTest {
"sentry.cron.default-timezone=America/New_York",
"sentry.cron.default-failure-issue-threshold=40",
"sentry.cron.default-recovery-threshold=50",
"sentry.experimental.logs.enabled=true",
"sentry.experimental.logs.sample-rate=0.4"
"sentry.experimental.logs.enabled=true"
).run {
val options = it.getBean(SentryProperties::class.java)
assertThat(options.readTimeoutMillis).isEqualTo(10)
Expand Down Expand Up @@ -235,7 +234,6 @@ class SentryAutoConfigurationTest {
assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L)
assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L)
assertThat(options.experimental.logs.isEnabled).isEqualTo(true)
assertThat(options.experimental.logs.sampleRate).isEqualTo(0.4)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ class SentryAutoConfigurationTest {
"sentry.cron.default-timezone=America/New_York",
"sentry.cron.default-failure-issue-threshold=40",
"sentry.cron.default-recovery-threshold=50",
"sentry.experimental.logs.enabled=true",
"sentry.experimental.logs.sample-rate=0.4"
"sentry.experimental.logs.enabled=true"
).run {
val options = it.getBean(SentryProperties::class.java)
assertThat(options.readTimeoutMillis).isEqualTo(10)
Expand Down Expand Up @@ -234,7 +233,6 @@ class SentryAutoConfigurationTest {
assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L)
assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L)
assertThat(options.experimental.logs.isEnabled).isEqualTo(true)
assertThat(options.experimental.logs.sampleRate).isEqualTo(0.4)
}
}

Expand Down
4 changes: 0 additions & 4 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ public final class io/sentry/ExternalOptions {
public fun getIgnoredTransactions ()Ljava/util/List;
public fun getInAppExcludes ()Ljava/util/List;
public fun getInAppIncludes ()Ljava/util/List;
public fun getLogsSampleRate ()Ljava/lang/Double;
public fun getMaxRequestBodySize ()Lio/sentry/SentryOptions$RequestSize;
public fun getPrintUncaughtStackTrace ()Ljava/lang/Boolean;
public fun getProfilesSampleRate ()Ljava/lang/Double;
Expand Down Expand Up @@ -535,7 +534,6 @@ public final class io/sentry/ExternalOptions {
public fun setIgnoredCheckIns (Ljava/util/List;)V
public fun setIgnoredErrors (Ljava/util/List;)V
public fun setIgnoredTransactions (Ljava/util/List;)V
public fun setLogsSampleRate (Ljava/lang/Double;)V
public fun setMaxRequestBodySize (Lio/sentry/SentryOptions$RequestSize;)V
public fun setPrintUncaughtStackTrace (Ljava/lang/Boolean;)V
public fun setProfilesSampleRate (Ljava/lang/Double;)V
Expand Down Expand Up @@ -3457,11 +3455,9 @@ public final class io/sentry/SentryOptions$Cron {
public final class io/sentry/SentryOptions$Logs {
public fun <init> ()V
public fun getBeforeSend ()Lio/sentry/SentryOptions$Logs$BeforeSendLogCallback;
public fun getSampleRate ()Ljava/lang/Double;
public fun isEnabled ()Z
public fun setBeforeSend (Lio/sentry/SentryOptions$Logs$BeforeSendLogCallback;)V
public fun setEnabled (Z)V
public fun setSampleRate (Ljava/lang/Double;)V
}

public abstract interface class io/sentry/SentryOptions$Logs$BeforeSendLogCallback {
Expand Down
13 changes: 0 additions & 13 deletions sentry/src/main/java/io/sentry/ExternalOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public final class ExternalOptions {
private @Nullable Boolean enableDeduplication;
private @Nullable Double tracesSampleRate;
private @Nullable Double profilesSampleRate;
private @Nullable Double logsSampleRate;
private @Nullable SentryOptions.RequestSize maxRequestBodySize;
private final @NotNull Map<String, @NotNull String> tags = new ConcurrentHashMap<>();
private @Nullable SentryOptions.Proxy proxy;
Expand Down Expand Up @@ -153,8 +152,6 @@ public final class ExternalOptions {
propertiesProvider.getBooleanProperty("capture-open-telemetry-events"));

options.setEnableLogs(propertiesProvider.getBooleanProperty("experimental.logs.enabled"));
options.setLogsSampleRate(
propertiesProvider.getDoubleProperty("experimental.logs.sample-rate"));

for (final String ignoredExceptionType :
propertiesProvider.getList("ignored-exceptions-for-type")) {
Expand Down Expand Up @@ -534,14 +531,4 @@ public void setEnableLogs(final @Nullable Boolean enableLogs) {
public @Nullable Boolean isEnableLogs() {
return enableLogs;
}

@ApiStatus.Experimental
public @Nullable Double getLogsSampleRate() {
return logsSampleRate;
}

@ApiStatus.Experimental
public void setLogsSampleRate(final @Nullable Double logsSampleRate) {
this.logsSampleRate = logsSampleRate;
}
}
37 changes: 0 additions & 37 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3205,10 +3205,6 @@ public void merge(final @NotNull ExternalOptions options) {
if (options.isEnableLogs() != null) {
getExperimental().getLogs().setEnabled(options.isEnableLogs());
}

if (options.getLogsSampleRate() != null) {
getExperimental().getLogs().setSampleRate(options.getLogsSampleRate());
}
}

private @NotNull SdkVersion createSdkVersion() {
Expand Down Expand Up @@ -3369,13 +3365,6 @@ public static final class Logs {
/** Whether Sentry Logs feature is enabled and Sentry.logger() usages are sent to Sentry. */
@ApiStatus.Experimental private boolean enable = false;

/**
* Configures the sample rate as a percentage of log items to be sent in the range of 0.0 to
* 1.0. if 1.0 is set it means that 100% of items are sent. If set to 0.1 only 10% of items will
* be sent. Items are picked randomly. Default is 1.0
*/
@ApiStatus.Experimental private @Nullable Double sampleRate = 1.0;

/**
* This function is called with an SDK specific log event object and can return a modified event
* object or nothing to skip reporting the log item
Expand Down Expand Up @@ -3422,32 +3411,6 @@ public void setBeforeSend(@Nullable BeforeSendLogCallback beforeSendLog) {
this.beforeSend = beforeSendLog;
}

/**
* Returns the logs sample rate Default is null (disabled)
*
* @return the logs sample rate
*/
@ApiStatus.Experimental
public @Nullable Double getSampleRate() {
return sampleRate;
}

/**
* Sets the logsSampleRate Can be anything between 0.0 and 1.0 (default) or null to disable it.
*
* @param logsSampleRate the sample rate for log events
*/
@ApiStatus.Experimental
public void setSampleRate(Double logsSampleRate) {
if (!SampleRateUtils.isValidSampleRate(logsSampleRate)) {
throw new IllegalArgumentException(
"The value "
+ logsSampleRate
+ " is not valid. Use null to disable or values >= 0.0 and <= 1.0.");
}
this.sampleRate = logsSampleRate;
}

/** The BeforeSendLog callback */
public interface BeforeSendLogCallback {

Expand Down
24 changes: 0 additions & 24 deletions sentry/src/main/java/io/sentry/logger/LoggerApi.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.sentry.logger;

import io.sentry.DataCategory;
import io.sentry.Hint;
import io.sentry.ISpan;
import io.sentry.PropagationContext;
Expand All @@ -12,11 +11,8 @@
import io.sentry.SentryLogLevel;
import io.sentry.SentryOptions;
import io.sentry.SpanId;
import io.sentry.clientreport.DiscardReason;
import io.sentry.protocol.SdkVersion;
import io.sentry.protocol.SentryId;
import io.sentry.util.Random;
import io.sentry.util.SentryRandom;
import java.util.HashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -107,16 +103,6 @@ private void captureLog(
return;
}

if (!sampleLog(options)) {
options
.getLogger()
.log(SentryLevel.DEBUG, "Log Event was dropped due to sampling decision.");
options
.getClientReportRecorder()
.recordLostEvent(DiscardReason.SAMPLE_RATE, DataCategory.LogItem);
return;
}

final @NotNull SentryDate timestampToUse =
timestamp == null ? options.getDateProvider().now() : timestamp;
final @NotNull String messageToUse = args == null ? message : String.format(message, args);
Expand All @@ -137,16 +123,6 @@ private void captureLog(
}
}

private boolean sampleLog(final @NotNull SentryOptions options) {
final @Nullable Random random =
options.getExperimental().getLogs().getSampleRate() == null ? null : SentryRandom.current();
if (options.getExperimental().getLogs().getSampleRate() != null && random != null) {
final double sampling = options.getExperimental().getLogs().getSampleRate();
return !(sampling < random.nextDouble()); // bad luck
}
return false;
}

private @NotNull HashMap<String, SentryLogEventAttributeValue> createAttributes(
final @NotNull String message, final @NotNull SpanId spanId, final @Nullable Object... args) {
final @NotNull HashMap<String, SentryLogEventAttributeValue> attributes = new HashMap<>();
Expand Down
7 changes: 0 additions & 7 deletions sentry/src/test/java/io/sentry/ExternalOptionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,6 @@ class ExternalOptionsTest {
}
}

@Test
fun `creates options with logsSampleRate using external properties`() {
withPropertiesFile("experimental.logs.sample-rate=0.2") {
assertEquals(0.2, it.logsSampleRate)
}
}

private fun withPropertiesFile(textLines: List<String> = emptyList(), logger: ILogger = mock(), fn: (ExternalOptions) -> Unit) {
// create a sentry.properties file in temporary folder
val temporaryFolder = TemporaryFolder()
Expand Down
2 changes: 0 additions & 2 deletions sentry/src/test/java/io/sentry/SentryOptionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ class SentryOptionsTest {
externalOptions.spotlightConnectionUrl = "http://local.sentry.io:1234"
externalOptions.isGlobalHubMode = true
externalOptions.isEnableLogs = true
externalOptions.logsSampleRate = 0.6

val options = SentryOptions()

Expand Down Expand Up @@ -461,7 +460,6 @@ class SentryOptionsTest {
assertEquals("http://local.sentry.io:1234", options.spotlightConnectionUrl)
assertTrue(options.isGlobalHubMode!!)
assertTrue(options.experimental.logs.isEnabled!!)
assertEquals(0.6, options.experimental.logs.sampleRate)
}

@Test
Expand Down
Loading