Skip to content

feat: Workspace Proxy picker show latency to each proxy #7486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Discard intercepters
  • Loading branch information
Emyrk committed May 10, 2023
commit d639a76dbb5ac6bde41c5a9d82f0753cea111d64
50 changes: 3 additions & 47 deletions site/src/contexts/ProxyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,53 +82,9 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
// Everytime we get a new proxiesResponse, update the latency check
// to each workspace proxy.
useEffect(() => {
const latencyAxios = axios.create()
latencyAxios.interceptors.request.use((config) => {
config.data = config.data || {}
config.data.startTime = new Date()
console.log("Hey kira", config, config.data)
return config
})

latencyAxios.interceptors.response.use(
// Success 200
(x) => {
// Get elapsed time (in milliseconds)
const end = new Date()
x.config.data = {
...x.config.data,
...{
endTime: end,
responseTime: end.getTime() - x.config.data.requestStartedAt,
},
}
return x
},
// Handle 4xx & 5xx responses
(x) => {
// Get elapsed time (in milliseconds)
const end = new Date()
x.config.data = x.config.data || {
...x.config.data,
...{
endTime: end,
responseTime: end.getTime() - x.config.data.requestStartedAt,
},
}
return x
},
)

// AgentLatency.tsx for colors
console.log("update workspace proxies", proxiesResp)
latencyAxios
.get<any>("/api/v2/users/authmethods")
.then((resp) => {
console.log("latency", resp)
})
.catch((err) => {
console.log("latency error", err)
})
if (!proxiesResp) {
return
}
}, [proxiesResp])

const setAndSaveProxy = (
Expand Down