Skip to content

Remove metrics #3774

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

Merged
merged 15 commits into from
Oct 9, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Breaking Changes

- Throw IllegalArgumentException when calling Sentry.init on Android ([#3596](https://github.com/getsentry/sentry-java/pull/3596))
- Metrics have been removed from the SDK ([#3774](https://github.com/getsentry/sentry-java/pull/3774))
- Metrics will return but we don't know in what exact form yet
- Change OkHttp sub-spans to span attributes ([#3556](https://github.com/getsentry/sentry-java/pull/3556))
- This will reduce the number of spans created by the SDK
- `options.experimental.sessionReplay.errorSampleRate` was renamed to `options.experimental.sessionReplay.onErrorSampleRate` ([#3637](https://github.com/getsentry/sentry-java/pull/3637))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ final class ManifestMetadataReader {

static final String ENABLE_SCOPE_PERSISTENCE = "io.sentry.enable-scope-persistence";

static final String ENABLE_METRICS = "io.sentry.enable-metrics";

static final String REPLAYS_SESSION_SAMPLE_RATE = "io.sentry.session-replay.session-sample-rate";

static final String REPLAYS_ERROR_SAMPLE_RATE = "io.sentry.session-replay.on-error-sample-rate";
Expand Down Expand Up @@ -398,9 +396,6 @@ static void applyMetadata(
readBool(
metadata, logger, ENABLE_SCOPE_PERSISTENCE, options.isEnableScopePersistence()));

options.setEnableMetrics(
readBool(metadata, logger, ENABLE_METRICS, options.isEnableMetrics()));

if (options.getExperimental().getSessionReplay().getSessionSampleRate() == null) {
final Double sessionSampleRate =
readDouble(metadata, logger, REPLAYS_SESSION_SAMPLE_RATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ private static SentrySpan timeSpanToSentrySpan(
APP_METRICS_ORIGIN,
new ConcurrentHashMap<>(),
new ConcurrentHashMap<>(),
null,
defaultSpanData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1397,31 +1397,6 @@ class ManifestMetadataReaderTest {
assertTrue(fixture.options.isEnableScopePersistence)
}

@Test
fun `applyMetadata reads enableMetrics flag to options`() {
// 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.isEnableMetrics)
}

@Test
fun `applyMetadata reads enableMetrics flag to options and keeps default if not found`() {
// Arrange
val context = fixture.getContext()

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

// Assert
assertFalse(fixture.options.isEnableMetrics)
}

@Test
fun `applyMetadata reads replays onErrorSampleRate from metadata`() {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
).also {
AppStartMetrics.getInstance().onActivityCreated(mock(), mock())
Expand Down Expand Up @@ -597,7 +596,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)

Expand All @@ -613,7 +611,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)
tr.spans.add(ttid)
Expand All @@ -633,7 +630,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)

Expand All @@ -650,7 +646,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)

Expand All @@ -667,7 +662,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
mutableMapOf<String, Any>(
"tag" to "value"
)
Expand Down Expand Up @@ -719,7 +713,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)

Expand Down Expand Up @@ -755,7 +748,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)

Expand All @@ -771,7 +763,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)
tr.spans.add(ttid)
Expand All @@ -790,7 +781,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
null
)

Expand All @@ -807,7 +797,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
mutableMapOf<String, Any>(
"thread.name" to "main"
)
Expand All @@ -826,7 +815,6 @@ class PerformanceAndroidEventProcessorTest {
null,
emptyMap(),
emptyMap(),
null,
mutableMapOf<String, Any>(
"thread.name" to "background"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.sentry.CheckIn
import io.sentry.Hint
import io.sentry.IMetricsAggregator
import io.sentry.IScope
import io.sentry.ISentryClient
import io.sentry.ProfilingTraceData
Expand Down Expand Up @@ -184,9 +183,5 @@ class SessionTrackingIntegrationTest {
override fun getRateLimiter(): RateLimiter? {
TODO("Not yet implemented")
}

override fun getMetricsAggregator(): IMetricsAggregator {
TODO("Not yet implemented")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public final class io/sentry/opentelemetry/OtelSpanWrapper : io/sentry/ISpan {
public fun getData (Ljava/lang/String;)Ljava/lang/Object;
public fun getDescription ()Ljava/lang/String;
public fun getFinishDate ()Lio/sentry/SentryDate;
public fun getLocalMetricsAggregator ()Lio/sentry/metrics/LocalMetricsAggregator;
public fun getMeasurements ()Ljava/util/Map;
public fun getOperation ()Ljava/lang/String;
public fun getSamplingDecision ()Lio/sentry/TracesSamplingDecision;
Expand Down Expand Up @@ -89,7 +88,6 @@ public final class io/sentry/opentelemetry/OtelTransactionSpanForwarder : io/sen
public fun getEventId ()Lio/sentry/protocol/SentryId;
public fun getFinishDate ()Lio/sentry/SentryDate;
public fun getLatestActiveSpan ()Lio/sentry/ISpan;
public fun getLocalMetricsAggregator ()Lio/sentry/metrics/LocalMetricsAggregator;
public fun getName ()Ljava/lang/String;
public fun getOperation ()Ljava/lang/String;
public fun getSamplingDecision ()Lio/sentry/TracesSamplingDecision;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
import io.sentry.SpanStatus;
import io.sentry.TraceContext;
import io.sentry.TracesSamplingDecision;
import io.sentry.metrics.LocalMetricsAggregator;
import io.sentry.protocol.Contexts;
import io.sentry.protocol.MeasurementValue;
import io.sentry.protocol.SentryId;
import io.sentry.protocol.TransactionNameSource;
import io.sentry.util.AutoClosableReentrantLock;
import io.sentry.util.LazyEvaluator;
import io.sentry.util.Objects;
import java.lang.ref.WeakReference;
import java.util.ArrayDeque;
Expand Down Expand Up @@ -70,10 +68,6 @@ public final class OtelSpanWrapper implements ISpan {
private final @NotNull Map<String, Object> data = new ConcurrentHashMap<>();
private final @NotNull Map<String, MeasurementValue> measurements = new ConcurrentHashMap<>();

@SuppressWarnings("Convert2MethodRef") // older AGP versions do not support method references
private final @NotNull LazyEvaluator<LocalMetricsAggregator> metricsAggregator =
new LazyEvaluator<>(() -> new LocalMetricsAggregator());

/** A throwable thrown during the execution of the span. */
private @Nullable Throwable throwable;

Expand Down Expand Up @@ -402,11 +396,6 @@ public boolean isNoOp() {
return false;
}

@Override
public @Nullable LocalMetricsAggregator getLocalMetricsAggregator() {
return metricsAggregator.getValue();
}

@Override
public void setContext(@NotNull String key, @NotNull Object context) {
contexts.put(key, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.sentry.SpanStatus;
import io.sentry.TraceContext;
import io.sentry.TracesSamplingDecision;
import io.sentry.metrics.LocalMetricsAggregator;
import io.sentry.protocol.Contexts;
import io.sentry.protocol.SentryId;
import io.sentry.protocol.TransactionNameSource;
Expand Down Expand Up @@ -208,11 +207,6 @@ public boolean isNoOp() {
return rootSpan.isNoOp();
}

@Override
public @Nullable LocalMetricsAggregator getLocalMetricsAggregator() {
return rootSpan.getLocalMetricsAggregator();
}

@Override
public @NotNull TransactionNameSource getTransactionNameSource() {
final @Nullable TransactionNameSource nameSource = rootSpan.getTransactionNameSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
<activity android:name=".FrameDataForSpansActivity"
android:exported="false"/>

<activity android:name=".MetricsActivity"
android:exported="false"/>

<!-- NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard-->
<meta-data android:name="io.sentry.dsn" android:value="https://[email protected]/5428559" />

Expand Down Expand Up @@ -163,8 +160,6 @@

<meta-data android:name="io.sentry.performance-v2.enable" android:value="true" />

<meta-data android:name="io.sentry.enable-metrics" android:value="true" />

<meta-data android:name="io.sentry.session-replay.session-sample-rate" android:value="1.0" />
<meta-data android:name="io.sentry.session-replay.redact-all-text" android:value="false" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,6 @@ public void run() {
binding.openFrameDataForSpans.setOnClickListener(
view -> startActivity(new Intent(this, FrameDataForSpansActivity.class)));

binding.openMetrics.setOnClickListener(
view -> startActivity(new Intent(this, MetricsActivity.class)));

setContentView(binding.getRoot());
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.app.Application;
import android.os.StrictMode;
import io.sentry.Sentry;

/** Apps. main Application. */
public class MyApplication extends Application {
Expand All @@ -25,8 +24,6 @@ public void onCreate() {
// });
// */
// });

Sentry.metrics().increment("app.start.cold");
}

private void strictMode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@
android:layout_height="wrap_content"
android:text="@string/open_frame_data_for_spans"/>

<Button
android:id="@+id/open_metrics"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/open_metrics"/>
</LinearLayout>

</ScrollView>
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@ Person create(Person person) {
span.setMeasurement("create_count", createCount);
}

Sentry.metrics()
.timing(
"person.insert",
() -> {
jdbcTemplate.update(
"insert into person (firstName, lastName) values (?, ?)",
person.getFirstName(),
person.getLastName());
});
jdbcTemplate.update(
"insert into person (firstName, lastName) values (?, ?)",
person.getFirstName(),
person.getLastName());

return person;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ sentry.debug=true
sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enable-metrics=true
sentry.enablePrettySerializationOutput=false
in-app-includes="io.sentry.samples"

Expand Down
Loading
Loading