]>
Commit | Line | Data |
---|---|---|
fd3c2e87 C |
1 | import express from 'express' |
2 | import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' | |
3 | import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' | |
4 | import { addPlaybackMetricValidator, asyncMiddleware } from '../../middlewares' | |
5 | ||
6 | const metricsRouter = express.Router() | |
7 | ||
8 | metricsRouter.post('/playback', | |
9 | asyncMiddleware(addPlaybackMetricValidator), | |
10 | addPlaybackMetric | |
11 | ) | |
12 | ||
13 | // --------------------------------------------------------------------------- | |
14 | ||
15 | export { | |
16 | metricsRouter | |
17 | } | |
18 | ||
19 | // --------------------------------------------------------------------------- | |
20 | ||
21 | function 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 | } |