From a1c48fe68ba0bbbfa417dfd227913e592ed10d45 Mon Sep 17 00:00:00 2001 From: Ahmad Bamieh <ahmadbamieh@gmail.com> Date: Sat, 11 Sep 2021 15:20:13 +0300 Subject: [PATCH] update documentation --- src/core/server/metrics/collectors/types.ts | 2 +- .../event_loop_delays_monitor.mocks.ts | 2 +- .../event_loop_delays_monitor.ts | 21 +----------- .../server/metrics/event_loop_delays/index.ts | 1 - src/core/server/metrics/index.ts | 2 +- src/core/server/metrics/types.ts | 34 +++++++++++++++++++ src/core/server/server.api.md | 2 -- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/core/server/metrics/collectors/types.ts b/src/core/server/metrics/collectors/types.ts index 9306dbb1dd9c..1f1a48bae754 100644 --- a/src/core/server/metrics/collectors/types.ts +++ b/src/core/server/metrics/collectors/types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { IntervalHistogram } from '../event_loop_delays'; +import type { IntervalHistogram } from '../types'; /** Base interface for all metrics gatherers */ export interface MetricsCollector<T> { diff --git a/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.mocks.ts b/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.mocks.ts index 66daf8fce3f5..9069078fffec 100644 --- a/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.mocks.ts +++ b/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.mocks.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ import moment from 'moment'; -import type { IntervalHistogram } from 'kibana/server'; import type { EventLoopDelaysMonitor } from './event_loop_delays_monitor'; +import type { IntervalHistogram } from '../types'; function createMockHistogram(overwrites: Partial<IntervalHistogram> = {}): IntervalHistogram { const now = moment(); diff --git a/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.ts b/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.ts index 12063aa88550..3dff847f83c9 100644 --- a/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.ts +++ b/src/core/server/metrics/event_loop_delays/event_loop_delays_monitor.ts @@ -8,26 +8,7 @@ import type { EventLoopDelayMonitor } from 'perf_hooks'; import { monitorEventLoopDelay } from 'perf_hooks'; - -/** - * an IntervalHistogram object that samples and reports the event loop delay over time. - * The delays will be reported in nanoseconds. - */ -export interface IntervalHistogram { - fromTimestamp: string; - lastUpdatedAt: string; - min: number; - max: number; - mean: number; - exceeds: number; - stddev: number; - percentiles: { - 50: number; - 75: number; - 95: number; - 99: number; - }; -} +import type { IntervalHistogram } from '../types'; export class EventLoopDelaysMonitor { private readonly loopMonitor: EventLoopDelayMonitor; diff --git a/src/core/server/metrics/event_loop_delays/index.ts b/src/core/server/metrics/event_loop_delays/index.ts index 50d2e35e388e..bc9cda18d443 100644 --- a/src/core/server/metrics/event_loop_delays/index.ts +++ b/src/core/server/metrics/event_loop_delays/index.ts @@ -7,4 +7,3 @@ */ export { EventLoopDelaysMonitor } from './event_loop_delays_monitor'; -export type { IntervalHistogram } from './event_loop_delays_monitor'; diff --git a/src/core/server/metrics/index.ts b/src/core/server/metrics/index.ts index 63e475a25918..797a0ae8c3f0 100644 --- a/src/core/server/metrics/index.ts +++ b/src/core/server/metrics/index.ts @@ -12,10 +12,10 @@ export type { MetricsServiceSetup, MetricsServiceStart, OpsMetrics, + IntervalHistogram, } from './types'; export type { OpsProcessMetrics, OpsServerMetrics, OpsOsMetrics } from './collectors'; export { MetricsService } from './metrics_service'; export { opsConfig } from './ops_config'; export type { OpsConfigType } from './ops_config'; export { EventLoopDelaysMonitor } from './event_loop_delays'; -export type { IntervalHistogram } from './event_loop_delays'; diff --git a/src/core/server/metrics/types.ts b/src/core/server/metrics/types.ts index 8beeae2ff7ad..c6a846cf91b6 100644 --- a/src/core/server/metrics/types.ts +++ b/src/core/server/metrics/types.ts @@ -67,3 +67,37 @@ export interface OpsMetrics { /** number of current concurrent connections to the server */ concurrent_connections: OpsServerMetrics['concurrent_connections']; } + +/** + * an IntervalHistogram object that samples and reports the event loop delay over time. + * The delays will be reported in nanoseconds. + * + * @public + */ +export interface IntervalHistogram { + // The first timestamp the interval timer kicked in for collecting data points. + fromTimestamp: string; + // Last timestamp the interval timer kicked in for collecting data points. + lastUpdatedAt: string; + // The minimum recorded event loop delay. + min: number; + // The maximum recorded event loop delay. + max: number; + // The mean of the recorded event loop delays. + mean: number; + // The number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold. + exceeds: number; + // The standard deviation of the recorded event loop delays. + stddev: number; + // An object detailing the accumulated percentile distribution. + percentiles: { + // 50th percentile of delays of the collected data points. + 50: number; + // 75th percentile of delays of the collected data points. + 75: number; + // 95th percentile of delays of the collected data points. + 95: number; + // 99th percentile of delays of the collected data points. + 99: number; + }; +} diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 476777e43684..ea2b9dde949b 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -1181,8 +1181,6 @@ export interface IKibanaSocket { }): Promise<void>; } -// Warning: (ae-missing-release-tag) "IntervalHistogram" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public export interface IntervalHistogram { // (undocumented)