All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m16s
50 lines
1.8 KiB
Diff
50 lines
1.8 KiB
Diff
From 598119b75a5bd7c913c657d789b00a2506df64e9 Mon Sep 17 00:00:00 2001
|
|
From: Fijxu <fijxu@nadeko.net>
|
|
Date: Sat, 5 Apr 2025 03:42:58 -0300
|
|
Subject: [PATCH 12/13] 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 0f707d9..c141c02 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();
|
|
@@ -182,6 +183,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
|
|
|