Skip to content

Commit 878313f

Browse files
committed
Add perf tracing for Salsa
1 parent 0c7bd47 commit 878313f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/languageserverinstance.jl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,29 @@ mutable struct LanguageServerInstance
7878
_extra_tracked_files::Vector{URI}
7979

8080
function LanguageServerInstance(@nospecialize(pipe_in), @nospecialize(pipe_out), env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true, symbolcache_upstream = nothing, julia_exe::Union{NamedTuple{(:path,:version),Tuple{String,VersionNumber}},Nothing}=nothing)
81+
endpoint = JSONRPC.JSONRPCEndpoint(pipe_in, pipe_out, err_handler)
82+
jw = JuliaWorkspace()
83+
if hasfield(typeof(jw.runtime), :performance_tracing_callback)
84+
jw.runtime.performance_tracing_callback = (name, start_time, duration) -> begin
85+
if g_operationId[] != ""
86+
JSONRPC.send(
87+
endpoint,
88+
telemetry_event_notification_type,
89+
Dict(
90+
"command" => "request_metric",
91+
"operationId" => string(uuid4()),
92+
"operationParentId" => g_operationId[],
93+
"name" => name,
94+
"duration" => duration,
95+
"time" => string(Dates.unix2datetime(start_time), "Z")
96+
)
97+
)
98+
end
99+
end
100+
end
101+
81102
new(
82-
JSONRPC.JSONRPCEndpoint(pipe_in, pipe_out, err_handler),
103+
endpoint,
83104
Set{String}(),
84105
Dict{URI,Document}(),
85106
env_path,
@@ -110,7 +131,7 @@ mutable struct LanguageServerInstance
110131
missing,
111132
nothing,
112133
false,
113-
JuliaWorkspace(),
134+
jw,
114135
Dict{URI,Int}(),
115136
Dict{URI,JuliaWorkspaces.TextFile}(),
116137
URI[]

0 commit comments

Comments
 (0)