diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-12 16:41:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-16 10:33:27 +0200 |
commit | fd3c2e87051f5029cdec39d877b576a62f48e219 (patch) | |
tree | a3c657f178702a3363af680ed8ffb7cd038243b8 /shared | |
parent | 0e6cd1c00f71554fe7375a96db693a6983951ba6 (diff) | |
download | PeerTube-fd3c2e87051f5029cdec39d877b576a62f48e219.tar.gz PeerTube-fd3c2e87051f5029cdec39d877b576a62f48e219.tar.zst PeerTube-fd3c2e87051f5029cdec39d877b576a62f48e219.zip |
Add playback metric endpoint sent to OTEL
Diffstat (limited to 'shared')
-rw-r--r-- | shared/models/index.ts | 1 | ||||
-rw-r--r-- | shared/models/metrics/index.ts | 1 | ||||
-rw-r--r-- | shared/models/metrics/playback-metric-create.model.ts | 19 | ||||
-rw-r--r-- | shared/server-commands/server/index.ts | 1 | ||||
-rw-r--r-- | shared/server-commands/server/metrics-command.ts | 18 | ||||
-rw-r--r-- | shared/server-commands/server/server.ts | 3 |
6 files changed, 43 insertions, 0 deletions
diff --git a/shared/models/index.ts b/shared/models/index.ts index 78723d830..439e9c8e1 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -6,6 +6,7 @@ export * from './custom-markup' | |||
6 | export * from './feeds' | 6 | export * from './feeds' |
7 | export * from './http' | 7 | export * from './http' |
8 | export * from './joinpeertube' | 8 | export * from './joinpeertube' |
9 | export * from './metrics' | ||
9 | export * from './moderation' | 10 | export * from './moderation' |
10 | export * from './overviews' | 11 | export * from './overviews' |
11 | export * from './plugins' | 12 | export * from './plugins' |
diff --git a/shared/models/metrics/index.ts b/shared/models/metrics/index.ts new file mode 100644 index 000000000..24194cce3 --- /dev/null +++ b/shared/models/metrics/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './playback-metric-create.model' | |||
diff --git a/shared/models/metrics/playback-metric-create.model.ts b/shared/models/metrics/playback-metric-create.model.ts new file mode 100644 index 000000000..d669ab690 --- /dev/null +++ b/shared/models/metrics/playback-metric-create.model.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import { VideoResolution } from '../videos' | ||
2 | |||
3 | export interface PlaybackMetricCreate { | ||
4 | playerMode: 'p2p-media-loader' | 'webtorrent' | ||
5 | |||
6 | resolution?: VideoResolution | ||
7 | fps?: number | ||
8 | |||
9 | resolutionChanges: number | ||
10 | |||
11 | errors: number | ||
12 | |||
13 | downloadedBytesP2P: number | ||
14 | downloadedBytesHTTP: number | ||
15 | |||
16 | uploadedBytesP2P: number | ||
17 | |||
18 | videoId: number | string | ||
19 | } | ||
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' | |||
5 | export * from './follows' | 5 | export * from './follows' |
6 | export * from './jobs' | 6 | export * from './jobs' |
7 | export * from './jobs-command' | 7 | export * from './jobs-command' |
8 | export * from './metrics-command' | ||
8 | export * from './object-storage-command' | 9 | export * from './object-storage-command' |
9 | export * from './plugins-command' | 10 | export * from './plugins-command' |
10 | export * from './redundancy-command' | 11 | 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 @@ | |||
1 | import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' | ||
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
3 | |||
4 | export class MetricsCommand extends AbstractCommand { | ||
5 | |||
6 | addPlaybackMetric (options: OverrideCommandOptions & { metrics: PlaybackMetricCreate }) { | ||
7 | const path = '/api/v1/metrics/playback' | ||
8 | |||
9 | return this.postBodyRequest({ | ||
10 | ...options, | ||
11 | |||
12 | path, | ||
13 | fields: options.metrics, | ||
14 | implicitToken: false, | ||
15 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
16 | }) | ||
17 | } | ||
18 | } | ||
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' | |||
37 | import { DebugCommand } from './debug-command' | 37 | import { DebugCommand } from './debug-command' |
38 | import { FollowsCommand } from './follows-command' | 38 | import { FollowsCommand } from './follows-command' |
39 | import { JobsCommand } from './jobs-command' | 39 | import { JobsCommand } from './jobs-command' |
40 | import { MetricsCommand } from './metrics-command' | ||
40 | import { ObjectStorageCommand } from './object-storage-command' | 41 | import { ObjectStorageCommand } from './object-storage-command' |
41 | import { PluginsCommand } from './plugins-command' | 42 | import { PluginsCommand } from './plugins-command' |
42 | import { RedundancyCommand } from './redundancy-command' | 43 | import { RedundancyCommand } from './redundancy-command' |
@@ -104,6 +105,7 @@ export class PeerTubeServer { | |||
104 | debug?: DebugCommand | 105 | debug?: DebugCommand |
105 | follows?: FollowsCommand | 106 | follows?: FollowsCommand |
106 | jobs?: JobsCommand | 107 | jobs?: JobsCommand |
108 | metrics?: MetricsCommand | ||
107 | plugins?: PluginsCommand | 109 | plugins?: PluginsCommand |
108 | redundancy?: RedundancyCommand | 110 | redundancy?: RedundancyCommand |
109 | stats?: StatsCommand | 111 | stats?: StatsCommand |
@@ -377,6 +379,7 @@ export class PeerTubeServer { | |||
377 | this.debug = new DebugCommand(this) | 379 | this.debug = new DebugCommand(this) |
378 | this.follows = new FollowsCommand(this) | 380 | this.follows = new FollowsCommand(this) |
379 | this.jobs = new JobsCommand(this) | 381 | this.jobs = new JobsCommand(this) |
382 | this.metrics = new MetricsCommand(this) | ||
380 | this.plugins = new PluginsCommand(this) | 383 | this.plugins = new PluginsCommand(this) |
381 | this.redundancy = new RedundancyCommand(this) | 384 | this.redundancy = new RedundancyCommand(this) |
382 | this.stats = new StatsCommand(this) | 385 | this.stats = new StatsCommand(this) |