Skip to content

Commit 7e0a8f0

Browse files
Michael Thomasfacebook-github-bot
Michael Thomas
authored andcommitted
Log diagnostics
Summary: For tracking error lifetimes in the IDE we need to know when it was first observed - this will almost always be as a diagnostic. This diff adds logging for diagnostics in open files. Reviewed By: CatherineGasnier Differential Revision: D71121584 fbshipit-source-id: 1be4c1142e463b6abc456110feff44fb1d0fb428
1 parent 897ecfa commit 7e0a8f0

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

hphp/hack/src/client/clientLsp.ml

+6
Original file line numberDiff line numberDiff line change
@@ -3450,6 +3450,12 @@ let publish_and_report_after_recomputing_live_squiggles
34503450
uris
34513451
in
34523452
let params = ide_diagnostics_to_lsp_diagnostics file_path diagnostics in
3453+
let _ =
3454+
(* Log diagnostics so we can track error lifetime *)
3455+
Option.iter
3456+
(Telemetry.of_json_opt (Lsp_fmt.print_diagnostics params))
3457+
~f:HackEventLogger.Diagnostics.log
3458+
in
34533459
let notification = PublishDiagnosticsNotification params in
34543460
notify_jsonrpc ~powered_by:Serverless_ide notification;
34553461
report_recheck_telemetry ~trigger ~ref_unblocked_time uri (Ok diagnostics);

hphp/hack/src/utils/core/telemetry.ml

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ type key_value_pair = string * Hh_json.json [@@deriving show]
1313
(** This list is in reverse order (i.e. most recent first) *)
1414
type t = key_value_pair list [@@deriving show]
1515

16+
let of_json_opt = function
17+
| Hh_json.JSON_Object kvs -> Some kvs
18+
| _ -> None
19+
1620
(* Ignore - we only use the generated `pp_key_value_pair` in deriving `show` for t *)
1721
let _ = show_key_value_pair
1822

hphp/hack/src/utils/core/telemetry.mli

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ val to_string : ?pretty:bool -> t -> string
1414

1515
val to_json : t -> Hh_json.json
1616

17+
val of_json_opt : Hh_json.json -> t option
18+
1719
(** `diff ~all current ~prev` is for when `current` and `prev` have the same structure.
1820
It produces a hybrid telemetry object where, element by element, if they're the same
1921
then we only see the current element, but if they're different then we see both.

0 commit comments

Comments
 (0)