diff --git a/docs/development/core/server/kibana-plugin-core-server.deprecationsservicesetup.md b/docs/development/core/server/kibana-plugin-core-server.deprecationsservicesetup.md index 00e5da4a9a9f9..2bc7f6cba594d 100644 --- a/docs/development/core/server/kibana-plugin-core-server.deprecationsservicesetup.md +++ b/docs/development/core/server/kibana-plugin-core-server.deprecationsservicesetup.md @@ -25,10 +25,9 @@ import { i18n } from '@kbn/i18n'; async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecationsContext): Promise { const deprecations: DeprecationsDetails[] = []; - - // Example of an api correctiveAction const count = await getFooCount(savedObjectsClient); if (count > 0) { + // Example of a manual correctiveAction deprecations.push({ title: i18n.translate('xpack.foo.deprecations.title', { defaultMessage: `Foo's are deprecated` @@ -42,12 +41,12 @@ async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecations level: 'warning', correctiveActions: { manualSteps: [ - i18n.translate('xpack.foo.deprecations.manualStepOneMessage', { - defaultMessage: 'Navigate to the Kibana Dashboard and click "Create dashboard".', - }), - i18n.translate('xpack.foo.deprecations.manualStepTwoMessage', { - defaultMessage: 'Select Foo from the "New Visualization" window.', - }), + i18n.translate('xpack.foo.deprecations.manualStepOneMessage', { + defaultMessage: 'Navigate to the Kibana Dashboard and click "Create dashboard".', + }), + i18n.translate('xpack.foo.deprecations.manualStepTwoMessage', { + defaultMessage: 'Select Foo from the "New Visualization" window.', + }), ], api: { path: '/internal/security/users/test_dashboard_user', @@ -68,7 +67,6 @@ async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecations }, }); } - return deprecations; } diff --git a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md index 3a9efc0eacdb6..ae9df8b406be6 100644 --- a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md +++ b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md @@ -4,7 +4,7 @@ ## EventLoopDelaysMonitor.(constructor) -Constructs a new instance of the `EventLoopDelaysMonitor` class +Creating a new instance from EventLoopDelaysMonitor will automatically start tracking event loop delays. Signature: diff --git a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.collect.md b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.collect.md index 6277f59067239..0e07497baf887 100644 --- a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.collect.md +++ b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.collect.md @@ -4,6 +4,8 @@ ## EventLoopDelaysMonitor.collect() method +Collect gathers event loop delays metrics from nodejs perf\_hooks.monitorEventLoopDelay the histogram calculations start from the last time `reset` was called or this EventLoopDelaysMonitor instance was created. + Signature: ```typescript @@ -13,3 +15,5 @@ collect(): IntervalHistogram; `IntervalHistogram` +{IntervalHistogram} + diff --git a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.md b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.md index 15d02ecd5f25d..21bbd8b48840c 100644 --- a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.md +++ b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.md @@ -14,13 +14,13 @@ export declare class EventLoopDelaysMonitor | Constructor | Modifiers | Description | | --- | --- | --- | -| [(constructor)()](./kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md) | | Constructs a new instance of the EventLoopDelaysMonitor class | +| [(constructor)()](./kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md) | | Creating a new instance from EventLoopDelaysMonitor will automatically start tracking event loop delays. | ## Methods | Method | Modifiers | Description | | --- | --- | --- | -| [collect()](./kibana-plugin-core-server.eventloopdelaysmonitor.collect.md) | | | -| [reset()](./kibana-plugin-core-server.eventloopdelaysmonitor.reset.md) | | | -| [stop()](./kibana-plugin-core-server.eventloopdelaysmonitor.stop.md) | | | +| [collect()](./kibana-plugin-core-server.eventloopdelaysmonitor.collect.md) | | Collect gathers event loop delays metrics from nodejs perf\_hooks.monitorEventLoopDelay the histogram calculations start from the last time reset was called or this EventLoopDelaysMonitor instance was created. | +| [reset()](./kibana-plugin-core-server.eventloopdelaysmonitor.reset.md) | | Resets the collected histogram data. | +| [stop()](./kibana-plugin-core-server.eventloopdelaysmonitor.stop.md) | | Disables updating the interval timer for collecting new data points. | diff --git a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.reset.md b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.reset.md index c593d0341bbed..fdba7a79ebda0 100644 --- a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.reset.md +++ b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.reset.md @@ -4,6 +4,8 @@ ## EventLoopDelaysMonitor.reset() method +Resets the collected histogram data. + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.stop.md b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.stop.md index 86e76d0c6fba4..25b61434b0061 100644 --- a/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.stop.md +++ b/docs/development/core/server/kibana-plugin-core-server.eventloopdelaysmonitor.stop.md @@ -4,6 +4,8 @@ ## EventLoopDelaysMonitor.stop() method +Disables updating the interval timer for collecting new data points. + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-core-server.intervalhistogram.md b/docs/development/core/server/kibana-plugin-core-server.intervalhistogram.md index 20f71420a0d88..d7fb889dce322 100644 --- a/docs/development/core/server/kibana-plugin-core-server.intervalhistogram.md +++ b/docs/development/core/server/kibana-plugin-core-server.intervalhistogram.md @@ -4,6 +4,8 @@ ## IntervalHistogram interface +an IntervalHistogram object that samples and reports the event loop delay over time. The delays will be reported in nanoseconds. + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md index a702c5fe7b97b..66c0299669dc4 100644 --- a/docs/development/core/server/kibana-plugin-core-server.md +++ b/docs/development/core/server/kibana-plugin-core-server.md @@ -98,7 +98,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [IExternalUrlPolicy](./kibana-plugin-core-server.iexternalurlpolicy.md) | A policy describing whether access to an external destination is allowed. | | [IKibanaResponse](./kibana-plugin-core-server.ikibanaresponse.md) | A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-core-server.requesthandler.md) execution | | [IKibanaSocket](./kibana-plugin-core-server.ikibanasocket.md) | A tiny abstraction for TCP socket. | -| [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) | | +| [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) | an IntervalHistogram object that samples and reports the event loop delay over time. The delays will be reported in nanoseconds. | | [IRenderOptions](./kibana-plugin-core-server.irenderoptions.md) | | | [IRouter](./kibana-plugin-core-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-core-server.routeconfig.md) and [RequestHandler](./kibana-plugin-core-server.requesthandler.md) for more information about arguments to route registrations. | | [ISavedObjectsPointInTimeFinder](./kibana-plugin-core-server.isavedobjectspointintimefinder.md) | | diff --git a/docs/development/core/server/kibana-plugin-core-server.opsprocessmetrics.md b/docs/development/core/server/kibana-plugin-core-server.opsprocessmetrics.md index fdaaf594232fd..198b668afca60 100644 --- a/docs/development/core/server/kibana-plugin-core-server.opsprocessmetrics.md +++ b/docs/development/core/server/kibana-plugin-core-server.opsprocessmetrics.md @@ -19,7 +19,6 @@ export interface OpsProcessMetrics | [event\_loop\_delay\_histogram](./kibana-plugin-core-server.opsprocessmetrics.event_loop_delay_histogram.md) | IntervalHistogram | node event loop delay histogram since last collection | | [event\_loop\_delay](./kibana-plugin-core-server.opsprocessmetrics.event_loop_delay.md) | number | mean event loop delay since last collection | | [memory](./kibana-plugin-core-server.opsprocessmetrics.memory.md) | {
heap: {
total_in_bytes: number;
used_in_bytes: number;
size_limit: number;
};
resident_set_size_in_bytes: number;
} | process memory usage | -| [name](./kibana-plugin-core-server.opsprocessmetrics.name.md) | 'coordinator' | 'server_worker' | name of process (example: 'coordinator' \| 'server\_worker' \| 'task\_worker' \| 'reporting\_worker') | | [pid](./kibana-plugin-core-server.opsprocessmetrics.pid.md) | number | pid of the kibana process | | [uptime\_in\_millis](./kibana-plugin-core-server.opsprocessmetrics.uptime_in_millis.md) | number | uptime of the kibana process | diff --git a/docs/development/core/server/kibana-plugin-core-server.opsprocessmetrics.name.md b/docs/development/core/server/kibana-plugin-core-server.opsprocessmetrics.name.md deleted file mode 100644 index 72f98fb7e717d..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.opsprocessmetrics.name.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [OpsProcessMetrics](./kibana-plugin-core-server.opsprocessmetrics.md) > [name](./kibana-plugin-core-server.opsprocessmetrics.name.md) - -## OpsProcessMetrics.name property - -name of process (example: 'coordinator' \| 'server\_worker' \| 'task\_worker' \| 'reporting\_worker') - -Signature: - -```typescript -name: 'coordinator' | 'server_worker'; -``` diff --git a/src/core/public/core_app/status/lib/load_status.test.ts b/src/core/public/core_app/status/lib/load_status.test.ts index 7411cab5892ac..73c697c3d55aa 100644 --- a/src/core/public/core_app/status/lib/load_status.test.ts +++ b/src/core/public/core_app/status/lib/load_status.test.ts @@ -62,7 +62,6 @@ const mockedResponse: StatusResponse = { }, }, process: { - name: 'server_worker' as const, pid: 1, memory: { heap: { @@ -78,7 +77,6 @@ const mockedResponse: StatusResponse = { }, processes: [ { - name: 'server_worker' as const, pid: 1, memory: { heap: { diff --git a/src/core/server/deprecations/deprecations_service.ts b/src/core/server/deprecations/deprecations_service.ts index b8a134fbf8cd2..bc981c21ba975 100644 --- a/src/core/server/deprecations/deprecations_service.ts +++ b/src/core/server/deprecations/deprecations_service.ts @@ -39,7 +39,6 @@ import { SavedObjectsClientContract } from '../saved_objects/types'; * const deprecations: DeprecationsDetails[] = []; * const count = await getFooCount(savedObjectsClient); * if (count > 0) { - * // Example of a manual correctiveAction * deprecations.push({ * title: i18n.translate('xpack.foo.deprecations.title', { * defaultMessage: `Foo's are deprecated` diff --git a/src/core/server/metrics/collectors/process.mocks.ts b/src/core/server/metrics/collectors/process.mocks.ts index e9c002f320fb5..8ee43394b9251 100644 --- a/src/core/server/metrics/collectors/process.mocks.ts +++ b/src/core/server/metrics/collectors/process.mocks.ts @@ -12,7 +12,6 @@ export function createMockOpsProcessMetrics(): OpsProcessMetrics { const histogram = mocked.createHistogram(); return { - name: 'server_worker' as const, memory: { heap: { total_in_bytes: 1, used_in_bytes: 1, size_limit: 1 }, resident_set_size_in_bytes: 1, diff --git a/src/core/server/metrics/collectors/process.ts b/src/core/server/metrics/collectors/process.ts index 8205de65a6b78..3acfda3e165ee 100644 --- a/src/core/server/metrics/collectors/process.ts +++ b/src/core/server/metrics/collectors/process.ts @@ -12,7 +12,12 @@ import { EventLoopDelaysMonitor } from '../event_loop_delays'; export class ProcessMetricsCollector implements MetricsCollector { static getMainThreadMetrics(processes: OpsProcessMetrics[]): undefined | OpsProcessMetrics { - return processes.find(({ name }) => name === 'server_worker'); + /** + * Currently Kibana does not support multi-processes. + * Once we have multiple processes we can add a `name` field + * and filter on `name === 'server_worker'` to get the main thread. + */ + return processes[0]; } private readonly eventLoopDelayMonitor = new EventLoopDelaysMonitor(); @@ -23,7 +28,6 @@ export class ProcessMetricsCollector implements MetricsCollector { export interface OpsProcessMetrics { /** pid of the kibana process */ pid: number; - /** name of process (example: 'coordinator' | 'server_worker' | 'task_worker' | 'reporting_worker') */ - name: 'coordinator' | 'server_worker'; /** process memory usage */ memory: { /** heap memory usage */ 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 cf8f9e780e48f..12063aa885501 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 @@ -9,6 +9,10 @@ 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; @@ -29,13 +33,22 @@ export class EventLoopDelaysMonitor { private readonly loopMonitor: EventLoopDelayMonitor; private fromTimestamp: Date; + /** + * Creating a new instance from EventLoopDelaysMonitor will + * automatically start tracking event loop delays. + */ constructor() { const monitor = monitorEventLoopDelay(); monitor.enable(); this.fromTimestamp = new Date(); this.loopMonitor = monitor; } - + /** + * Collect gathers event loop delays metrics from nodejs perf_hooks.monitorEventLoopDelay + * the histogram calculations start from the last time `reset` was called or this + * EventLoopDelaysMonitor instance was created. + * @returns {IntervalHistogram} + */ public collect(): IntervalHistogram { const lastUpdated = new Date(); this.loopMonitor.disable(); @@ -61,11 +74,17 @@ export class EventLoopDelaysMonitor { return collectedData; } + /** + * Resets the collected histogram data. + */ public reset() { this.loopMonitor.reset(); this.fromTimestamp = new Date(); } + /** + * Disables updating the interval timer for collecting new data points. + */ public stop() { this.loopMonitor.disable(); } diff --git a/src/core/server/metrics/metrics_service.ts b/src/core/server/metrics/metrics_service.ts index 8a0d6f17b4464..78e4dd98f93d6 100644 --- a/src/core/server/metrics/metrics_service.ts +++ b/src/core/server/metrics/metrics_service.ts @@ -16,7 +16,6 @@ import { InternalMetricsServiceSetup, InternalMetricsServiceStart, OpsMetrics } import { OpsMetricsCollector } from './ops_metrics_collector'; import { opsConfig, OpsConfigType } from './ops_config'; import { getEcsOpsMetricsLog } from './logging'; -import { InternalEnvironmentServiceSetup } from '../environment'; interface MetricsServiceSetupDeps { http: InternalHttpServiceSetup; diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 5fca11e7856c5..476777e43684b 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -943,11 +943,8 @@ export interface ErrorHttpResponseOptions { // @public (undocumented) export class EventLoopDelaysMonitor { constructor(); - // (undocumented) collect(): IntervalHistogram; - // (undocumented) reset(): void; - // (undocumented) stop(): void; } @@ -1186,7 +1183,7 @@ export interface IKibanaSocket { // Warning: (ae-missing-release-tag) "IntervalHistogram" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // -// @public (undocumented) +// @public export interface IntervalHistogram { // (undocumented) exceeds: number; @@ -1548,7 +1545,6 @@ export interface OpsProcessMetrics { }; resident_set_size_in_bytes: number; }; - name: 'coordinator' | 'server_worker'; pid: number; uptime_in_millis: number; } diff --git a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/rollups/integration_tests/daily_rollups.test.ts b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/rollups/integration_tests/daily_rollups.test.ts index 499227d796f1e..64668a5f23de1 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/rollups/integration_tests/daily_rollups.test.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/rollups/integration_tests/daily_rollups.test.ts @@ -29,14 +29,17 @@ const { startES } = createTestServers({ const eventLoopDelaysMonitor = metricsServiceMock.createEventLoopDelaysMonitor(); function createRawObject(date: moment.MomentInput) { const pid = Math.round(Math.random() * 10000); + const instanceUuid = 'mock_instance'; + return { type: SAVED_OBJECTS_DAILY_TYPE, - id: serializeSavedObjectId({ pid, date }), + id: serializeSavedObjectId({ pid, date, instanceUuid }), attributes: { ...eventLoopDelaysMonitor.collect(), fromTimestamp: moment(date).startOf('day').toISOString(), lastUpdatedAt: moment(date).toISOString(), processId: pid, + instanceUuid, }, }; } diff --git a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.test.ts b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.test.ts index ee610d918d61c..ddae0ff302829 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.test.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.test.ts @@ -16,8 +16,8 @@ import type { SavedObjectsFindResponse } from '../../../../../core/server/'; describe('serializeSavedObjectId', () => { it('returns serialized id', () => { - const id = serializeSavedObjectId({ date: 1623233091278, pid: 123 }); - expect(id).toBe('123::09062021'); + const id = serializeSavedObjectId({ instanceUuid: 'mock_uuid', date: 1623233091278, pid: 123 }); + expect(id).toBe('mock_uuid::123::09062021'); }); }); @@ -33,13 +33,14 @@ describe('storeHistogram', () => { it('stores histogram data in a savedObject', async () => { const mockHistogram = eventLoopDelaysMonitor.collect(); - await storeHistogram(mockHistogram, mockInternalRepository); + const instanceUuid = 'mock_uuid'; + await storeHistogram(mockHistogram, mockInternalRepository, instanceUuid); const pid = process.pid; - const id = serializeSavedObjectId({ date: mockNow, pid }); + const id = serializeSavedObjectId({ date: mockNow, pid, instanceUuid }); expect(mockInternalRepository.create).toBeCalledWith( 'event_loop_delays_daily', - { ...mockHistogram, processId: pid }, + { ...mockHistogram, processId: pid, instanceUuid }, { id, overwrite: true } ); }); diff --git a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.ts b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.ts index b66451d1fb764..57a9bb3b739c0 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/saved_objects.ts @@ -17,6 +17,7 @@ export const SAVED_OBJECTS_DAILY_TYPE = 'event_loop_delays_daily'; export interface EventLoopDelaysDaily extends SavedObjectAttributes, IntervalHistogram { processId: number; + instanceUuid: string; } export function registerSavedObjectTypes(registerType: SavedObjectsServiceSetup['registerType']) { @@ -34,10 +35,18 @@ export function registerSavedObjectTypes(registerType: SavedObjectsServiceSetup[ }); } -export function serializeSavedObjectId({ date, pid }: { date: moment.MomentInput; pid: number }) { +export function serializeSavedObjectId({ + date, + pid, + instanceUuid, +}: { + date: moment.MomentInput; + pid: number; + instanceUuid: string; +}) { const formattedDate = moment(date).format('DDMMYYYY'); - return `${pid}::${formattedDate}`; + return `${instanceUuid}::${pid}::${formattedDate}`; } export async function deleteHistogramSavedObjects( @@ -58,14 +67,15 @@ export async function deleteHistogramSavedObjects( export async function storeHistogram( histogram: IntervalHistogram, - internalRepository: ISavedObjectsRepository + internalRepository: ISavedObjectsRepository, + instanceUuid: string ) { const pid = process.pid; - const id = serializeSavedObjectId({ date: histogram.lastUpdatedAt, pid }); + const id = serializeSavedObjectId({ date: histogram.lastUpdatedAt, pid, instanceUuid }); return await internalRepository.create( SAVED_OBJECTS_DAILY_TYPE, - { ...histogram, processId: pid }, + { ...histogram, processId: pid, instanceUuid }, { id, overwrite: true } ); } diff --git a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.test.ts b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.test.ts index ea8309cff31e7..92549b926eafc 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.test.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.test.ts @@ -14,6 +14,8 @@ describe('startTrackingEventLoopDelaysUsage', () => { const eventLoopDelaysMonitor = metricsServiceMock.createEventLoopDelaysMonitor(); const mockInternalRepository = savedObjectsRepositoryMock.create(); const stopMonitoringEventLoop$ = new Subject(); + const instanceUuid = 'mock_uuid'; + beforeAll(() => jest.useFakeTimers('modern')); beforeEach(() => jest.clearAllMocks()); afterEach(() => stopMonitoringEventLoop$.next()); @@ -22,6 +24,7 @@ describe('startTrackingEventLoopDelaysUsage', () => { const collectionStartDelay = 1000; startTrackingEventLoopDelaysUsage( mockInternalRepository, + instanceUuid, stopMonitoringEventLoop$, eventLoopDelaysMonitor, { @@ -39,6 +42,7 @@ describe('startTrackingEventLoopDelaysUsage', () => { const collectionInterval = 1000; startTrackingEventLoopDelaysUsage( mockInternalRepository, + instanceUuid, stopMonitoringEventLoop$, eventLoopDelaysMonitor, { @@ -60,8 +64,10 @@ describe('startTrackingEventLoopDelaysUsage', () => { const collectionStartDelay = 0; const collectionInterval = 1000; const histogramReset = 5000; + startTrackingEventLoopDelaysUsage( mockInternalRepository, + instanceUuid, stopMonitoringEventLoop$, eventLoopDelaysMonitor, { @@ -81,6 +87,7 @@ describe('startTrackingEventLoopDelaysUsage', () => { it('stops monitoring event loop delays once stopMonitoringEventLoop$.next is called', () => { startTrackingEventLoopDelaysUsage( mockInternalRepository, + instanceUuid, stopMonitoringEventLoop$, eventLoopDelaysMonitor ); diff --git a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts index d5006c801bddd..facdb549d0df7 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts @@ -24,6 +24,7 @@ import { storeHistogram } from './saved_objects'; */ export function startTrackingEventLoopDelaysUsage( internalRepository: ISavedObjectsRepository, + instanceUuid: string, stopMonitoringEventLoop$: Observable, eventLoopDelaysMonitor: EventLoopDelaysMonitor, configs: { @@ -51,6 +52,6 @@ export function startTrackingEventLoopDelaysUsage( if (shouldReset) { eventLoopDelaysMonitor.reset(); } - await storeHistogram(histogram, internalRepository); + await storeHistogram(histogram, internalRepository, instanceUuid); }); } diff --git a/src/plugins/kibana_usage_collection/server/collectors/ops_stats/__snapshots__/ops_stats_collector.test.ts.snap b/src/plugins/kibana_usage_collection/server/collectors/ops_stats/__snapshots__/ops_stats_collector.test.ts.snap index 69176fef2f4a5..f962eca858199 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/ops_stats/__snapshots__/ops_stats_collector.test.ts.snap +++ b/src/plugins/kibana_usage_collection/server/collectors/ops_stats/__snapshots__/ops_stats_collector.test.ts.snap @@ -29,7 +29,6 @@ Object { }, "resident_set_size_in_bytes": 1, }, - "name": "server_worker", "uptime_in_millis": 1, }, "processes": Array [ @@ -44,7 +43,6 @@ Object { }, "resident_set_size_in_bytes": 1, }, - "name": "server_worker", "uptime_in_millis": 1, }, ], diff --git a/src/plugins/kibana_usage_collection/server/plugin.ts b/src/plugins/kibana_usage_collection/server/plugin.ts index 2363dd8671ae9..07a70dfd56fb4 100644 --- a/src/plugins/kibana_usage_collection/server/plugin.ts +++ b/src/plugins/kibana_usage_collection/server/plugin.ts @@ -56,6 +56,7 @@ type SavedObjectsRegisterType = SavedObjectsServiceSetup['registerType']; export class KibanaUsageCollectionPlugin implements Plugin { private readonly logger: Logger; private readonly legacyConfig$: Observable; + private readonly instanceUuid: string; private savedObjectsClient?: ISavedObjectsRepository; private uiSettingsClient?: IUiSettingsClient; private metric$: Subject; @@ -68,6 +69,7 @@ export class KibanaUsageCollectionPlugin implements Plugin { this.legacyConfig$ = initializerContext.config.legacy.globalConfig$; this.metric$ = new Subject(); this.pluginStop$ = new Subject(); + this.instanceUuid = initializerContext.env.instanceUuid; } public setup(coreSetup: CoreSetup, { usageCollection }: KibanaUsageCollectionPluginsDepsSetup) { @@ -95,6 +97,7 @@ export class KibanaUsageCollectionPlugin implements Plugin { this.coreUsageData = core.coreUsageData; startTrackingEventLoopDelaysUsage( this.savedObjectsClient, + this.instanceUuid, this.pluginStop$.asObservable(), new EventLoopDelaysMonitor() );