-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SLCORE-1055 Use manual options instead of options callback to improve…
… coverage
- Loading branch information
1 parent
46e162d
commit 3cd6bf8
Showing
1 changed file
with
22 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
} | ||
} |