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 /server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts | |
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 'server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts')
-rw-r--r-- | server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts b/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts index 766cbe03b..473015e91 100644 --- a/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts +++ b/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts | |||
@@ -2,7 +2,7 @@ import { readdir } from 'fs-extra' | |||
2 | import { constants, PerformanceObserver } from 'perf_hooks' | 2 | import { constants, PerformanceObserver } from 'perf_hooks' |
3 | import * as process from 'process' | 3 | import * as process from 'process' |
4 | import { Meter, ObservableResult } from '@opentelemetry/api-metrics' | 4 | import { Meter, ObservableResult } from '@opentelemetry/api-metrics' |
5 | import { ExplicitBucketHistogramAggregation, MeterProvider } from '@opentelemetry/sdk-metrics-base' | 5 | import { ExplicitBucketHistogramAggregation } from '@opentelemetry/sdk-metrics-base' |
6 | import { View } from '@opentelemetry/sdk-metrics-base/build/src/view/View' | 6 | import { View } from '@opentelemetry/sdk-metrics-base/build/src/view/View' |
7 | import { logger } from '@server/helpers/logger' | 7 | import { logger } from '@server/helpers/logger' |
8 | 8 | ||
@@ -12,7 +12,16 @@ import { logger } from '@server/helpers/logger' | |||
12 | 12 | ||
13 | export class NodeJSObserversBuilder { | 13 | export class NodeJSObserversBuilder { |
14 | 14 | ||
15 | constructor (private readonly meter: Meter, private readonly meterProvider: MeterProvider) { | 15 | constructor (private readonly meter: Meter) { |
16 | } | ||
17 | |||
18 | static getViews () { | ||
19 | return [ | ||
20 | new View({ | ||
21 | aggregation: new ExplicitBucketHistogramAggregation([ 0.001, 0.01, 0.1, 1, 2, 5 ]), | ||
22 | instrumentName: 'nodejs_gc_duration_seconds' | ||
23 | }) | ||
24 | ] | ||
16 | } | 25 | } |
17 | 26 | ||
18 | buildObservers () { | 27 | buildObservers () { |
@@ -91,11 +100,6 @@ export class NodeJSObserversBuilder { | |||
91 | [constants.NODE_PERFORMANCE_GC_WEAKCB]: 'weakcb' | 100 | [constants.NODE_PERFORMANCE_GC_WEAKCB]: 'weakcb' |
92 | } | 101 | } |
93 | 102 | ||
94 | this.meterProvider.addView( | ||
95 | new View({ aggregation: new ExplicitBucketHistogramAggregation([ 0.001, 0.01, 0.1, 1, 2, 5 ]) }), | ||
96 | { instrument: { name: 'nodejs_gc_duration_seconds' } } | ||
97 | ) | ||
98 | |||
99 | const histogram = this.meter.createHistogram('nodejs_gc_duration_seconds', { | 103 | const histogram = this.meter.createHistogram('nodejs_gc_duration_seconds', { |
100 | description: 'Garbage collection duration by kind, one of major, minor, incremental or weakcb' | 104 | description: 'Garbage collection duration by kind, one of major, minor, incremental or weakcb' |
101 | }) | 105 | }) |