-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps][Alerting] Provide scaling metrics for Kibana Alerting (#…
…143586) * Adding scaling metrics * Adding utilization tests * Changing the key name * Updating to use new api * Updating task created counter * Fixing tests * Fixing tests * Adding telemetry * Changing telemetry field * Updating telemetry schema * Fixing failing test * Fixed typos * Update x-pack/plugins/task_manager/server/routes/background_task_utilization.test.ts Co-authored-by: Ying Mao <[email protected]> * Addressing pr feedback * Updating to use configurable interval * Updating metrics to be counts Co-authored-by: Ying Mao <[email protected]>
- Loading branch information
Showing
20 changed files
with
1,728 additions
and
13 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/task_manager/server/lib/adhoc_task_counter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { AdHocTaskCounter } from './adhoc_task_counter'; | ||
|
||
describe('AdHocTaskCounter', () => { | ||
const counter = new AdHocTaskCounter(); | ||
|
||
afterAll(() => { | ||
counter.reset(); | ||
}); | ||
|
||
it('increments counter', async () => { | ||
counter.increment(10); | ||
await expect(counter.count).toEqual(10); | ||
}); | ||
|
||
it('resets counter', async () => { | ||
counter.increment(10); | ||
counter.reset(); | ||
await expect(counter.count).toEqual(0); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/task_manager/server/lib/adhoc_task_counter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
/** | ||
* Keeps track of how many tasks have been created. | ||
* | ||
* @export | ||
* @class AdHocTaskCounter | ||
* | ||
*/ | ||
export class AdHocTaskCounter { | ||
/** | ||
* Gets the number of created tasks. | ||
*/ | ||
public get count() { | ||
return this._count; | ||
} | ||
|
||
private _count: number; | ||
|
||
constructor() { | ||
this._count = 0; | ||
} | ||
|
||
public increment(by: number = 1) { | ||
this._count += by; | ||
} | ||
|
||
public reset() { | ||
this._count = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.