aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/metrics.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/metrics.ts')
-rw-r--r--server/controllers/api/metrics.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/server/controllers/api/metrics.ts b/server/controllers/api/metrics.ts
new file mode 100644
index 000000000..578b023a1
--- /dev/null
+++ b/server/controllers/api/metrics.ts
@@ -0,0 +1,27 @@
1import express from 'express'
2import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics'
3import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models'
4import { addPlaybackMetricValidator, asyncMiddleware } from '../../middlewares'
5
6const metricsRouter = express.Router()
7
8metricsRouter.post('/playback',
9 asyncMiddleware(addPlaybackMetricValidator),
10 addPlaybackMetric
11)
12
13// ---------------------------------------------------------------------------
14
15export {
16 metricsRouter
17}
18
19// ---------------------------------------------------------------------------
20
21function addPlaybackMetric (req: express.Request, res: express.Response) {
22 const body: PlaybackMetricCreate = req.body
23
24 OpenTelemetryMetrics.Instance.observePlaybackMetric(res.locals.onlyImmutableVideo, body)
25
26 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
27}