Add ability to disable http duration OTEL metrics
This commit is contained in:
parent
5b94394a1a
commit
8d1f78044c
|
@ -222,6 +222,10 @@ open_telemetry:
|
|||
metrics:
|
||||
enabled: false
|
||||
|
||||
http_request_duration:
|
||||
# You can disable HTTP request duration metric that can have a high tag cardinality
|
||||
enabled: true
|
||||
|
||||
# Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics
|
||||
prometheus_exporter:
|
||||
hostname: '127.0.0.1'
|
||||
|
|
|
@ -220,6 +220,10 @@ open_telemetry:
|
|||
metrics:
|
||||
enabled: false
|
||||
|
||||
http_request_duration:
|
||||
# You can disable HTTP request duration metric that can have a high tag cardinality
|
||||
enabled: true
|
||||
|
||||
# Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics
|
||||
prometheus_exporter:
|
||||
hostname: '127.0.0.1'
|
||||
|
|
|
@ -23,6 +23,7 @@ function checkMissedConfig () {
|
|||
'log.log_ping_requests', 'log.log_tracker_unknown_infohash', 'log.prettify_sql', 'log.accept_client_log',
|
||||
'open_telemetry.metrics.enabled', 'open_telemetry.metrics.prometheus_exporter.hostname',
|
||||
'open_telemetry.metrics.prometheus_exporter.port', 'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint',
|
||||
'open_telemetry.metrics.http_request_duration.enabled',
|
||||
'user.video_quota', 'user.video_quota_daily',
|
||||
'video_channels.max_per_user',
|
||||
'csp.enabled', 'csp.report_only', 'csp.report_uri',
|
||||
|
|
|
@ -195,6 +195,10 @@ const CONFIG = {
|
|||
METRICS: {
|
||||
ENABLED: config.get<boolean>('open_telemetry.metrics.enabled'),
|
||||
|
||||
HTTP_REQUEST_DURATION: {
|
||||
ENABLED: config.get<boolean>('open_telemetry.metrics.http_request_duration.enabled')
|
||||
},
|
||||
|
||||
PROMETHEUS_EXPORTER: {
|
||||
HOSTNAME: config.get<string>('open_telemetry.metrics.prometheus_exporter.hostname'),
|
||||
PORT: config.get<number>('open_telemetry.metrics.prometheus_exporter.port')
|
||||
|
|
|
@ -62,7 +62,9 @@ class OpenTelemetryMetrics {
|
|||
|
||||
this.meter = metrics.getMeter('default')
|
||||
|
||||
this.buildRequestObserver()
|
||||
if (CONFIG.OPEN_TELEMETRY.METRICS.HTTP_REQUEST_DURATION.ENABLED === true) {
|
||||
this.buildRequestObserver()
|
||||
}
|
||||
|
||||
this.playbackMetrics = new PlaybackMetrics(this.meter)
|
||||
this.playbackMetrics.buildCounters()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||
import { MockSmtpServer } from '@server/tests/shared'
|
||||
import { HttpStatusCode, UserRole } from '@shared/models'
|
||||
import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
|
||||
|
||||
|
@ -112,8 +111,6 @@ describe('Test users API validators', function () {
|
|||
})
|
||||
|
||||
after(async function () {
|
||||
MockSmtpServer.Instance.kill()
|
||||
|
||||
await cleanupTests([ server ])
|
||||
})
|
||||
})
|
||||
|
|
|
@ -29,6 +29,8 @@ describe('Open Telemetry', function () {
|
|||
})
|
||||
|
||||
it('Should enable open telemetry metrics', async function () {
|
||||
this.timeout(120000)
|
||||
|
||||
server = await createSingleServer(1, {
|
||||
open_telemetry: {
|
||||
metrics: {
|
||||
|
@ -37,8 +39,12 @@ describe('Open Telemetry', function () {
|
|||
}
|
||||
})
|
||||
|
||||
// Simulate a HTTP request
|
||||
await server.videos.list()
|
||||
|
||||
const res = await makeRawRequest({ url: metricsUrl, expectedStatus: HttpStatusCode.OK_200 })
|
||||
expect(res.text).to.contain('peertube_job_queue_total{')
|
||||
expect(res.text).to.contain('http_request_duration_ms_bucket{')
|
||||
})
|
||||
|
||||
it('Should have playback metrics', async function () {
|
||||
|
@ -64,6 +70,27 @@ describe('Open Telemetry', function () {
|
|||
expect(res.text).to.contain('peertube_playback_http_downloaded_bytes_total{')
|
||||
})
|
||||
|
||||
it('Should disable http request duration metrics', async function () {
|
||||
await server.kill()
|
||||
|
||||
server = await createSingleServer(1, {
|
||||
open_telemetry: {
|
||||
metrics: {
|
||||
enabled: true,
|
||||
http_request_duration: {
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Simulate a HTTP request
|
||||
await server.videos.list()
|
||||
|
||||
const res = await makeRawRequest({ url: metricsUrl, expectedStatus: HttpStatusCode.OK_200 })
|
||||
expect(res.text).to.not.contain('http_request_duration_ms_bucket{')
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
await server.kill()
|
||||
})
|
||||
|
|
|
@ -43,7 +43,7 @@ class MockSmtpServer {
|
|||
kill () {
|
||||
if (!this.maildev) return
|
||||
|
||||
this.maildev.shutdown()
|
||||
this.maildev.close()
|
||||
|
||||
this.maildev = null
|
||||
MockSmtpServer.instance = null
|
||||
|
|
Loading…
Reference in New Issue