diff options
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1,4 +1,7 @@ | |||
1 | // ----------- Node modules ----------- | 1 | // ----------- Node modules ----------- |
2 | import { registerOpentelemetryTracing } from './server/lib/opentelemetry/tracing' | ||
3 | registerOpentelemetryTracing() | ||
4 | |||
2 | import express from 'express' | 5 | import express from 'express' |
3 | import morgan, { token } from 'morgan' | 6 | import morgan, { token } from 'morgan' |
4 | import cors from 'cors' | 7 | import cors from 'cors' |
@@ -47,6 +50,12 @@ checkConfig() | |||
47 | // Trust our proxy (IP forwarding...) | 50 | // Trust our proxy (IP forwarding...) |
48 | app.set('trust proxy', CONFIG.TRUST_PROXY) | 51 | app.set('trust proxy', CONFIG.TRUST_PROXY) |
49 | 52 | ||
53 | app.use((_req, res, next) => { | ||
54 | res.locals.requestStart = Date.now() | ||
55 | |||
56 | return next() | ||
57 | }) | ||
58 | |||
50 | // Security middleware | 59 | // Security middleware |
51 | import { baseCSP } from './server/middlewares/csp' | 60 | import { baseCSP } from './server/middlewares/csp' |
52 | 61 | ||
@@ -126,6 +135,7 @@ import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache | |||
126 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 135 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
127 | import { VideoViewsManager } from '@server/lib/views/video-views-manager' | 136 | import { VideoViewsManager } from '@server/lib/views/video-views-manager' |
128 | import { isTestInstance } from './server/helpers/core-utils' | 137 | import { isTestInstance } from './server/helpers/core-utils' |
138 | import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' | ||
129 | 139 | ||
130 | // ----------- Command line ----------- | 140 | // ----------- Command line ----------- |
131 | 141 | ||
@@ -194,6 +204,10 @@ app.use(cookieParser()) | |||
194 | // W3C DNT Tracking Status | 204 | // W3C DNT Tracking Status |
195 | app.use(advertiseDoNotTrack) | 205 | app.use(advertiseDoNotTrack) |
196 | 206 | ||
207 | // ----------- Open Telemetry ----------- | ||
208 | |||
209 | OpenTelemetryMetrics.Instance.init(app) | ||
210 | |||
197 | // ----------- Views, routes and static files ----------- | 211 | // ----------- Views, routes and static files ----------- |
198 | 212 | ||
199 | // API | 213 | // API |
@@ -297,6 +311,7 @@ async function startApplication () { | |||
297 | RemoveDanglingResumableUploadsScheduler.Instance.enable() | 311 | RemoveDanglingResumableUploadsScheduler.Instance.enable() |
298 | VideoViewsBufferScheduler.Instance.enable() | 312 | VideoViewsBufferScheduler.Instance.enable() |
299 | GeoIPUpdateScheduler.Instance.enable() | 313 | GeoIPUpdateScheduler.Instance.enable() |
314 | OpenTelemetryMetrics.Instance.registerMetrics() | ||
300 | 315 | ||
301 | Redis.Instance.init() | 316 | Redis.Instance.init() |
302 | PeerTubeSocket.Instance.init(server) | 317 | PeerTubeSocket.Instance.init(server) |