From ce634d128a3652c3d73611bac4293764f7908765 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Sat, 5 Apr 2025 03:47:31 -0300 Subject: [PATCH] add videoplayback rx bytes metrics --- ...2-add-videoplayback-rx-bytes-metrics.patch | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 patches/0012-add-videoplayback-rx-bytes-metrics.patch diff --git a/patches/0012-add-videoplayback-rx-bytes-metrics.patch b/patches/0012-add-videoplayback-rx-bytes-metrics.patch new file mode 100644 index 0000000..ba68807 --- /dev/null +++ b/patches/0012-add-videoplayback-rx-bytes-metrics.patch @@ -0,0 +1,50 @@ +From 01e545dc92027614ba3a9c514fa4f2a3c1c0fa9d Mon Sep 17 00:00:00 2001 +From: Fijxu +Date: Sat, 5 Apr 2025 03:42:58 -0300 +Subject: [PATCH 12/12] add videoplayback rx bytes metrics + +--- + src/lib/helpers/metrics.ts | 5 +++++ + src/routes/videoPlaybackProxy.ts | 3 +++ + 2 files changed, 8 insertions(+) + +diff --git a/src/lib/helpers/metrics.ts b/src/lib/helpers/metrics.ts +index 5dee540..27f84c3 100644 +--- a/src/lib/helpers/metrics.ts ++++ b/src/lib/helpers/metrics.ts +@@ -63,6 +63,11 @@ export class Metrics { + 'Times a request to innertube has been retried when it gets "This helps protect our community"', + ); + ++ public videoplaybackRxBytes = this.createCounter( ++ "videoplayback_rx_bytes_count", ++ 'How many bytes have been received from google servers', ++ ); ++ + private checkStatus(videoData: IRawResponse) { + const status = videoData.playabilityStatus?.status; + +diff --git a/src/routes/videoPlaybackProxy.ts b/src/routes/videoPlaybackProxy.ts +index b6cce87..74d5324 100644 +--- a/src/routes/videoPlaybackProxy.ts ++++ b/src/routes/videoPlaybackProxy.ts +@@ -35,6 +35,7 @@ videoPlaybackProxy.get("/", async (c) => { + const urlReq = new URL(c.req.url); + const config = c.get("config"); + const queryParams = new URLSearchParams(urlReq.search); ++ const metrics = c.get("metrics"); + + if (c.req.query("enc") === "true") { + const { data: encryptedQuery } = c.req.query(); +@@ -180,6 +181,8 @@ videoPlaybackProxy.get("/", async (c) => { + } + } + ++ metrics?.videoplaybackRxBytes.inc(Number(googlevideoResponse.headers.get("content-length"))) ++ + return new Response(googlevideoResponse.body, { + status: responseStatus, + statusText: googlevideoResponse.statusText, +-- +2.49.0 +