Add ability to disable http duration OTEL metrics

This commit is contained in:
Chocobozzz
2023-02-27 13:53:54 +01:00
parent 5b94394a1a
commit 8d1f78044c
8 changed files with 44 additions and 5 deletions

View File

@@ -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 ])
})
})

View File

@@ -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()
})