aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server.ts')
-rw-r--r--server.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/server.ts b/server.ts
index 559327f16..73b7441f9 100644
--- a/server.ts
+++ b/server.ts
@@ -1,4 +1,7 @@
1// ----------- Node modules ----------- 1// ----------- Node modules -----------
2import { registerOpentelemetryTracing } from './server/lib/opentelemetry/tracing'
3registerOpentelemetryTracing()
4
2import express from 'express' 5import express from 'express'
3import morgan, { token } from 'morgan' 6import morgan, { token } from 'morgan'
4import cors from 'cors' 7import cors from 'cors'
@@ -47,6 +50,12 @@ checkConfig()
47// Trust our proxy (IP forwarding...) 50// Trust our proxy (IP forwarding...)
48app.set('trust proxy', CONFIG.TRUST_PROXY) 51app.set('trust proxy', CONFIG.TRUST_PROXY)
49 52
53app.use((_req, res, next) => {
54 res.locals.requestStart = Date.now()
55
56 return next()
57})
58
50// Security middleware 59// Security middleware
51import { baseCSP } from './server/middlewares/csp' 60import { baseCSP } from './server/middlewares/csp'
52 61
@@ -126,6 +135,7 @@ import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache
126import { ServerConfigManager } from '@server/lib/server-config-manager' 135import { ServerConfigManager } from '@server/lib/server-config-manager'
127import { VideoViewsManager } from '@server/lib/views/video-views-manager' 136import { VideoViewsManager } from '@server/lib/views/video-views-manager'
128import { isTestInstance } from './server/helpers/core-utils' 137import { isTestInstance } from './server/helpers/core-utils'
138import { 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
195app.use(advertiseDoNotTrack) 205app.use(advertiseDoNotTrack)
196 206
207// ----------- Open Telemetry -----------
208
209OpenTelemetryMetrics.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)