Skip to content

Commit

Permalink
added safety checks on LSP telemetry emissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Borges committed Nov 26, 2024
1 parent 71f3248 commit 0ae7fa1
Showing 1 changed file with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,56 @@ public static void setManifestStartPoint(final Instant start) {
}

public static void emitSetupGetManifest(final Result result, final RecordLspSetupArgs args) {
args.setDuration(Duration.between(manifestStartPoint, Instant.now()).toMillis());
if (result == null || args == null) {
return;
}
if (manifestStartPoint != null) {
args.setDuration(Duration.between(manifestStartPoint, Instant.now()).toMillis());
}
emitSetupMetric(result, args, LanguageServerSetupStage.GET_MANIFEST);
if (result == Result.FAILED && args.getManifestLocation() == ManifestLocation.UNKNOWN) {
emitSetupAll(Result.FAILED, args);
}
}

public static void emitSetupGetServer(final Result result, final RecordLspSetupArgs args) {
if (result == null || args == null) {
return;
}
emitSetupMetric(result, args, LanguageServerSetupStage.GET_SERVER);
if (result == Result.FAILED && args.getLocation() == LanguageServerLocation.UNKNOWN) {
emitSetupAll(Result.FAILED, args);
}
}

public static void emitSetupValidate(final Result result, final RecordLspSetupArgs args) {
if (result == null || args == null) {
return;
}
emitSetupMetric(result, args, LanguageServerSetupStage.VALIDATE);
if (result == Result.FAILED && args.getLocation() != LanguageServerLocation.OVERRIDE) {
emitSetupAll(Result.FAILED, args);
}
}
public static void emitSetupInitialize(final Result result, final RecordLspSetupArgs args) {
args.setDuration(Duration.between(initStartPoint, Instant.now()).toMillis());
if (result == null || args == null) {
return;
}
if (initStartPoint != null) {
args.setDuration(Duration.between(initStartPoint, Instant.now()).toMillis());
}
emitSetupMetric(result, args, LanguageServerSetupStage.INITIALIZE);

//final step completing makes call to complete full process
emitSetupAll(result, args);
}
public static void emitSetupAll(final Result result, final RecordLspSetupArgs args) {
args.setDuration(Duration.between(allStartPoint, Instant.now()).toMillis());
if (result == null || args == null) {
return;
}
if (allStartPoint != null) {
args.setDuration(Duration.between(allStartPoint, Instant.now()).toMillis());
}
emitSetupMetric(result, args, LanguageServerSetupStage.ALL);
}

Expand Down

0 comments on commit 0ae7fa1

Please sign in to comment.