Skip to content

Commit 0ab63b2

Browse files
committed
Put request measurement behind a flag
1 parent de5c766 commit 0ab63b2

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

src/languageserverinstance.jl

+34-29
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,29 @@ mutable struct LanguageServerInstance
7777
# folder. Primarily for projects and manifests outside of the workspace.
7878
_extra_tracked_files::Vector{URI}
7979

80+
_send_request_metrics::Bool
81+
8082
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)
8183
endpoint = JSONRPC.JSONRPCEndpoint(pipe_in, pipe_out, err_handler)
8284
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[] != "" && endpoint.status === :running
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
85+
# if hasfield(typeof(jw.runtime), :performance_tracing_callback)
86+
# jw.runtime.performance_tracing_callback = (name, start_time, duration) -> begin
87+
# if g_operationId[] != "" && endpoint.status === :running
88+
# JSONRPC.send(
89+
# endpoint,
90+
# telemetry_event_notification_type,
91+
# Dict(
92+
# "command" => "request_metric",
93+
# "operationId" => string(uuid4()),
94+
# "operationParentId" => g_operationId[],
95+
# "name" => name,
96+
# "duration" => duration,
97+
# "time" => string(Dates.unix2datetime(start_time), "Z")
98+
# )
99+
# )
100+
# end
101+
# end
102+
# end
101103

102104
new(
103105
endpoint,
@@ -134,7 +136,8 @@ mutable struct LanguageServerInstance
134136
jw,
135137
Dict{URI,Int}(),
136138
Dict{URI,JuliaWorkspaces.TextFile}(),
137-
URI[]
139+
URI[],
140+
false
138141
)
139142
end
140143
end
@@ -442,16 +445,18 @@ function Base.run(server::LanguageServerInstance; timings = [])
442445
toc = time_ns()
443446
duration = (toc - tic) / 1e+6
444447

445-
JSONRPC.send(
446-
server.jr_endpoint,
447-
telemetry_event_notification_type,
448-
Dict(
449-
"command" => "request_metric",
450-
"operationId" => g_operationId[],
451-
"name" => msg["method"],
452-
"time" => start_time,
453-
"duration" => duration)
454-
)
448+
if server._send_request_metrics
449+
JSONRPC.send(
450+
server.jr_endpoint,
451+
telemetry_event_notification_type,
452+
Dict(
453+
"command" => "request_metric",
454+
"operationId" => g_operationId[],
455+
"name" => msg["method"],
456+
"time" => start_time,
457+
"duration" => duration)
458+
)
459+
end
455460
elseif message.type == :symservmsg
456461
@debug "Received new data from Julia Symbol Server."
457462

0 commit comments

Comments
 (0)