aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/metrics.ts
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2023-03-14 08:50:44 +0100
committerGitHub <noreply@github.com>2023-03-14 08:50:44 +0100
commite72ace5a506904a67290e347e962ddf930d2b9f9 (patch)
tree08af8cb7b20e9911c4962910024ba2ba70645d92 /server/controllers/api/metrics.ts
parent2b02a9b98cfc93a01b52ad6cb893e3d089fec472 (diff)
downloadPeerTube-e72ace5a506904a67290e347e962ddf930d2b9f9.tar.gz
PeerTube-e72ace5a506904a67290e347e962ddf930d2b9f9.tar.zst
PeerTube-e72ace5a506904a67290e347e962ddf930d2b9f9.zip
Handle redis disconnection gracefully (#5599)
* feat(server/api/contact): handle redis disconnection * feat(server/api/metrics): handle metrics disabled
Diffstat (limited to 'server/controllers/api/metrics.ts')
-rw-r--r--server/controllers/api/metrics.ts5
1 files changed, 5 insertions, 0 deletions
diff --git a/server/controllers/api/metrics.ts b/server/controllers/api/metrics.ts
index 578b023a1..f66173875 100644
--- a/server/controllers/api/metrics.ts
+++ b/server/controllers/api/metrics.ts
@@ -2,6 +2,7 @@ import express from 'express'
2import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' 2import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics'
3import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' 3import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models'
4import { addPlaybackMetricValidator, asyncMiddleware } from '../../middlewares' 4import { addPlaybackMetricValidator, asyncMiddleware } from '../../middlewares'
5import { CONFIG } from '@server/initializers/config'
5 6
6const metricsRouter = express.Router() 7const metricsRouter = express.Router()
7 8
@@ -19,6 +20,10 @@ export {
19// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
20 21
21function addPlaybackMetric (req: express.Request, res: express.Response) { 22function addPlaybackMetric (req: express.Request, res: express.Response) {
23 if (!CONFIG.OPEN_TELEMETRY.METRICS.ENABLED) {
24 return res.sendStatus(HttpStatusCode.FORBIDDEN_403)
25 }
26
22 const body: PlaybackMetricCreate = req.body 27 const body: PlaybackMetricCreate = req.body
23 28
24 OpenTelemetryMetrics.Instance.observePlaybackMetric(res.locals.onlyImmutableVideo, body) 29 OpenTelemetryMetrics.Instance.observePlaybackMetric(res.locals.onlyImmutableVideo, body)