diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-05 15:43:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-06 15:13:55 +0200 |
commit | 630d0a1bf5897fff203cb07e426223f55dcc882d (patch) | |
tree | 5e6fa9d26f3f21178a538bd1ac38fa0a3f4f228c /server.ts | |
parent | 15b43b214eb37b05aa65aa8ef61fd0e6aa0b62d2 (diff) | |
download | PeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.tar.gz PeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.tar.zst PeerTube-630d0a1bf5897fff203cb07e426223f55dcc882d.zip |
Introduce experimental telemetry
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) |