|
1 | 1 | use crate::{
|
2 |
| - metrics::{DURATION_WS, LIVE_WS}, |
3 |
| - parse_channel, parse_crate_type, parse_edition, parse_mode, |
| 2 | + metrics, parse_channel, parse_crate_type, parse_edition, parse_mode, |
4 | 3 | sandbox::{self, Sandbox},
|
5 | 4 | Error, ExecutionSnafu, Result, SandboxCreationSnafu, WebSocketTaskPanicSnafu,
|
6 | 5 | };
|
@@ -120,10 +119,18 @@ impl From<sandbox::ExecuteResponse> for ExecuteResponse {
|
120 | 119 | }
|
121 | 120 | }
|
122 | 121 |
|
123 |
| -pub async fn handle(mut socket: WebSocket) { |
124 |
| - LIVE_WS.inc(); |
| 122 | +pub async fn handle(socket: WebSocket) { |
| 123 | + metrics::LIVE_WS.inc(); |
125 | 124 | let start = Instant::now();
|
126 | 125 |
|
| 126 | + handle_core(socket).await; |
| 127 | + |
| 128 | + metrics::LIVE_WS.dec(); |
| 129 | + let elapsed = start.elapsed(); |
| 130 | + metrics::DURATION_WS.observe(elapsed.as_secs_f64()); |
| 131 | +} |
| 132 | + |
| 133 | +async fn handle_core(mut socket: WebSocket) { |
127 | 134 | if !connect_handshake(&mut socket).await {
|
128 | 135 | return;
|
129 | 136 | }
|
@@ -187,10 +194,6 @@ pub async fn handle(mut socket: WebSocket) {
|
187 | 194 |
|
188 | 195 | drop((tx, rx, socket));
|
189 | 196 | tasks.shutdown().await;
|
190 |
| - |
191 |
| - LIVE_WS.dec(); |
192 |
| - let elapsed = start.elapsed(); |
193 |
| - DURATION_WS.observe(elapsed.as_secs_f64()); |
194 | 197 | }
|
195 | 198 |
|
196 | 199 | async fn connect_handshake(socket: &mut WebSocket) -> bool {
|
|
0 commit comments