aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-05 15:43:21 +0200
committerChocobozzz <me@florianbigard.com>2022-07-06 15:13:55 +0200
commit630d0a1bf5897fff203cb07e426223f55dcc882d (patch)
tree5e6fa9d26f3f21178a538bd1ac38fa0a3f4f228c /server.ts
parent15b43b214eb37b05aa65aa8ef61fd0e6aa0b62d2 (diff)
downloadPeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.tar.gz
PeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.tar.zst
PeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.zip
Introduce experimental telemetry
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)