Skip to content
Draft
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 @@ -144,6 +144,8 @@ final class ManifestMetadataReader {

static final String ENABLE_LOGS = "io.sentry.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 @@ -614,6 +616,11 @@ static void applyMetadata(
.getLogs()
.setEnabled(readBool(metadata, logger, ENABLE_LOGS, options.getLogs().isEnabled()));

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 @@ -1711,6 +1711,44 @@ class ManifestMetadataReaderTest {
assertTrue(fixture.options.logs.isEnabled)
}

@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
Loading