feat: response size and duration metrics
This commit is contained in:
@@ -52,10 +52,16 @@ export function createRESTNetworkRequestStream(
|
|||||||
): Observable<HoppRESTResponse> {
|
): Observable<HoppRESTResponse> {
|
||||||
const response = new BehaviorSubject<HoppRESTResponse>({ type: "loading" })
|
const response = new BehaviorSubject<HoppRESTResponse>({ type: "loading" })
|
||||||
|
|
||||||
|
const timeStart = Date.now()
|
||||||
|
|
||||||
runAppropriateStrategy({
|
runAppropriateStrategy({
|
||||||
url: req.effectiveFinalURL,
|
url: req.effectiveFinalURL,
|
||||||
}).then((res: any) => {
|
}).then((res: any) => {
|
||||||
console.log(res)
|
const timeEnd = Date.now()
|
||||||
|
|
||||||
|
const contentLength = res.headers["content-length"]
|
||||||
|
? parseInt(res.headers["content-length"])
|
||||||
|
: (res.data as ArrayBuffer).byteLength
|
||||||
|
|
||||||
const resObj: HoppRESTResponse = {
|
const resObj: HoppRESTResponse = {
|
||||||
type: "success",
|
type: "success",
|
||||||
@@ -66,9 +72,8 @@ export function createRESTNetworkRequestStream(
|
|||||||
value: res.headers[x],
|
value: res.headers[x],
|
||||||
})),
|
})),
|
||||||
meta: {
|
meta: {
|
||||||
// TODO: Implement
|
responseSize: contentLength,
|
||||||
responseSize: 0,
|
responseDuration: timeEnd - timeStart,
|
||||||
responseDuration: 0,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
response.next(resObj)
|
response.next(resObj)
|
||||||
|
|||||||
Reference in New Issue
Block a user