Skip to content

Commit

Permalink
SLCORE-1055 Use manual options instead of options callback to improve…
Browse files Browse the repository at this point in the history
… coverage
  • Loading branch information
jblievremont committed Dec 19, 2024
1 parent 46e162d commit 3cd6bf8
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.sonarsource.sonarlint.core.commons.monitoring;

import io.sentry.Sentry;
import io.sentry.SentryOptions;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
Expand All @@ -44,32 +45,37 @@ public MonitoringService(MonitoringInitializationParams initializeParams, Dogfoo
}

public void init() {
var sentryConfiguration = getSentryConfiguration();

if (!initializeParams.isEnabled()) {
LOG.info("Monitoring is disabled by feature flag.");
return;
}
if (dogfoodEnvDetectionService.isDogfoodEnvironment()) {
LOG.info("Initializing Sentry");
Sentry.init(sentryConfiguration);
}
}

var productKey = initializeParams.getProductKey();
SentryOptions getSentryConfiguration() {
var releaseVersion = SonarLintCoreVersion.get();
var environment = "dogfood";
var productKey = initializeParams.getProductKey();
var sonarQubeForIDEVersion = initializeParams.getSonarQubeForIdeVersion();
var ideVersion = initializeParams.getIdeVersion();
var releaseVersion = SonarLintCoreVersion.get();
var platform = SystemUtils.OS_NAME;
var architecture = SystemUtils.OS_ARCH;

if (dogfoodEnvDetectionService.isDogfoodEnvironment()) {
LOG.info("Initializing Sentry");
Sentry.init(sentryOptions -> {
sentryOptions.setDsn("https://[email protected]/4508201175089152");
sentryOptions.setRelease(releaseVersion);
sentryOptions.setEnvironment(environment);
sentryOptions.setTag("productKey", productKey);
sentryOptions.setTag("sonarQubeForIDEVersion", sonarQubeForIDEVersion);
sentryOptions.setTag("ideVersion", ideVersion);
sentryOptions.setTag("platform", platform);
sentryOptions.setTag("architecture", architecture);
sentryOptions.addInAppInclude("org.sonarsource.sonarlint");
});
}
var sentryOptions = new SentryOptions();
sentryOptions.setDsn("https://[email protected]/4508201175089152");
sentryOptions.setRelease(releaseVersion);
sentryOptions.setEnvironment(environment);
sentryOptions.setTag("productKey", productKey);
sentryOptions.setTag("sonarQubeForIDEVersion", sonarQubeForIDEVersion);
sentryOptions.setTag("ideVersion", ideVersion);
sentryOptions.setTag("platform", platform);
sentryOptions.setTag("architecture", architecture);
sentryOptions.addInAppInclude("org.sonarsource.sonarlint");
return sentryOptions;
}
}

0 comments on commit 3cd6bf8

Please sign in to comment.