Skip to content
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

SLLS-283 Use monitoring facility from core backend #426

Merged
merged 1 commit into from
Dec 24, 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: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<properties>
<jdk.min.version>17</jdk.min.version>
<sonarlint.core.version>10.12.1.79852</sonarlint.core.version>
<sonarlint.core.version>10.13.0.79879</sonarlint.core.version>
<!-- Version used by Xodus -->
<kotlin.version>1.6.10</kotlin.version>
<!-- analyzers used for tests -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@

public class BackendServiceFacade {

public static final String MONITORING_DISABLED_PROPERTY_KEY = "sonarlint.monitoring.disabled";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is set in the SLLS tests and will also be set in the SLVSCODE tests 🙈

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reverse the name, it will make everything much easier to follow. i.e. MONITORING_ENABLED_PROPERTY_KEY = "sonarlint.monitoring.enabled"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm half-and-half on this one.

I agree that it would make it somewhat easier to follow, but it would also be less consistent with the property that governs telemetry (and the default behavior is to have monitoring enabled, hence the property to disable it).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I always spend a couple of extra brain cells on computing the actual value of telemetry enabled/disabled because of that :D

OK, we can leave it as is I guess, for the sake of consistency 😢 😄


private static final int DEFAULT_INIT_TIMEOUT_SECONDS = 60;

private final int initTimeoutSeconds;
Expand Down Expand Up @@ -155,6 +157,7 @@ private void initOnce(Map<String, ServerConnectionSettings> connections) {

private InitializeParams toInitParams(BackendInitParams initParams) {
var telemetryEnabled = telemetry != null && telemetry.enabled();
var monitoringEnabled = shouldEnableMonitoring();
var clientNodeJsPath = StringUtils.isEmpty(initParams.getClientNodePath()) ? null : Path.of(initParams.getClientNodePath());
var eslintBridgeServerBundlePath = StringUtils.isEmpty(initParams.getEslintBridgeServerPath()) ? null : Path.of(initParams.getEslintBridgeServerPath());
var languageSpecificRequirements = getLanguageSpecificRequirements(clientNodeJsPath, eslintBridgeServerBundlePath);
Expand All @@ -168,7 +171,7 @@ private InitializeParams toInitParams(BackendInitParams initParams) {
getHttpConfiguration(),
getSonarCloudAlternativeEnvironment(),
new FeatureFlagsDto(true, true, true,
true, initParams.isEnableSecurityHotspots(), true, true, true, telemetryEnabled, true),
true, initParams.isEnableSecurityHotspots(), true, true, true, telemetryEnabled, true, monitoringEnabled),
initParams.getStorageRoot(),
Path.of(initParams.getSonarlintUserHome()),
initParams.getEmbeddedPluginPaths(),
Expand All @@ -187,6 +190,14 @@ private InitializeParams toInitParams(BackendInitParams initParams) {
);
}

private boolean shouldEnableMonitoring() {
var monitoringDisabledByProperty = "true".equals(System.getProperty(MONITORING_DISABLED_PROPERTY_KEY));
if (monitoringDisabledByProperty) {
lsLogOutput.debug("Monitoring is disabled by system property");
}
return !monitoringDisabledByProperty;
}

@NotNull
private LanguageSpecificRequirements getLanguageSpecificRequirements(@Nullable Path clientNodeJsPath, @Nullable Path eslintBridgeSeverPath) {
return new LanguageSpecificRequirements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public abstract class AbstractLanguageServerMediumTests {
@BeforeAll
static void startServer() throws Exception {
System.setProperty(SonarLintTelemetry.DISABLE_PROPERTY_KEY, "true");
System.setProperty("sonarlint.monitoring.disabled", "true");
SettingsManager.setSonarLintUserHomeOverride(makeStaticTempDir());
serverSocket = new ServerSocket(0);
var port = serverSocket.getLocalPort();
Expand Down
Loading