From fd3c2e87051f5029cdec39d877b576a62f48e219 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Aug 2022 16:41:29 +0200 Subject: Add playback metric endpoint sent to OTEL --- shared/server-commands/server/index.ts | 1 + shared/server-commands/server/metrics-command.ts | 18 ++++++++++++++++++ shared/server-commands/server/server.ts | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 shared/server-commands/server/metrics-command.ts (limited to 'shared/server-commands') diff --git a/shared/server-commands/server/index.ts b/shared/server-commands/server/index.ts index 0a4b21fc4..9a2fbf8d3 100644 --- a/shared/server-commands/server/index.ts +++ b/shared/server-commands/server/index.ts @@ -5,6 +5,7 @@ export * from './follows-command' export * from './follows' export * from './jobs' export * from './jobs-command' +export * from './metrics-command' export * from './object-storage-command' export * from './plugins-command' export * from './redundancy-command' diff --git a/shared/server-commands/server/metrics-command.ts b/shared/server-commands/server/metrics-command.ts new file mode 100644 index 000000000..d22b4833d --- /dev/null +++ b/shared/server-commands/server/metrics-command.ts @@ -0,0 +1,18 @@ +import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' +import { AbstractCommand, OverrideCommandOptions } from '../shared' + +export class MetricsCommand extends AbstractCommand { + + addPlaybackMetric (options: OverrideCommandOptions & { metrics: PlaybackMetricCreate }) { + const path = '/api/v1/metrics/playback' + + return this.postBodyRequest({ + ...options, + + path, + fields: options.metrics, + implicitToken: false, + defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 + }) + } +} diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index c05d16ad2..2b4c9c9f8 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts @@ -37,6 +37,7 @@ import { ContactFormCommand } from './contact-form-command' import { DebugCommand } from './debug-command' import { FollowsCommand } from './follows-command' import { JobsCommand } from './jobs-command' +import { MetricsCommand } from './metrics-command' import { ObjectStorageCommand } from './object-storage-command' import { PluginsCommand } from './plugins-command' import { RedundancyCommand } from './redundancy-command' @@ -104,6 +105,7 @@ export class PeerTubeServer { debug?: DebugCommand follows?: FollowsCommand jobs?: JobsCommand + metrics?: MetricsCommand plugins?: PluginsCommand redundancy?: RedundancyCommand stats?: StatsCommand @@ -377,6 +379,7 @@ export class PeerTubeServer { this.debug = new DebugCommand(this) this.follows = new FollowsCommand(this) this.jobs = new JobsCommand(this) + this.metrics = new MetricsCommand(this) this.plugins = new PluginsCommand(this) this.redundancy = new RedundancyCommand(this) this.stats = new StatsCommand(this) -- cgit v1.2.3