forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deprecated telemetry (elastic#130458)
- Loading branch information
Showing
5 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/alerting/server/lib/track_deprecated_route_usage.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,32 @@ | ||
/* | ||
* 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 { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock'; | ||
import { trackDeprecatedRouteUsage } from './track_deprecated_route_usage'; | ||
|
||
describe('trackDeprecatedRouteUsage', () => { | ||
it('should call `usageCounter.incrementCounter`', () => { | ||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract(); | ||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test'); | ||
|
||
trackDeprecatedRouteUsage('test', mockUsageCounter); | ||
expect(mockUsageCounter.incrementCounter).toHaveBeenCalledWith({ | ||
counterName: `deprecatedRoute_test`, | ||
counterType: 'deprecatedApiUsage', | ||
incrementBy: 1, | ||
}); | ||
}); | ||
|
||
it('should do nothing if no usage counter is provided', () => { | ||
let err; | ||
try { | ||
trackDeprecatedRouteUsage('test', undefined); | ||
} catch (e) { | ||
err = e; | ||
} | ||
expect(err).toBeUndefined(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/alerting/server/lib/track_deprecated_route_usage.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,18 @@ | ||
/* | ||
* 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 { UsageCounter } from '@kbn/usage-collection-plugin/server'; | ||
|
||
export function trackDeprecatedRouteUsage(route: string, usageCounter?: UsageCounter) { | ||
if (usageCounter) { | ||
usageCounter.incrementCounter({ | ||
counterName: `deprecatedRoute_${route}`, | ||
counterType: 'deprecatedApiUsage', | ||
incrementBy: 1, | ||
}); | ||
} | ||
} |
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
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