Skip to content

Commit 4afc962

Browse files
committed
Fix PR feedback
1 parent 01ea1c4 commit 4afc962

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ export type TelemetryLocalStats = ReturnType<typeof handleLocalStats>;
6262

6363
/**
6464
* Get statistics for all products joined by Elasticsearch cluster.
65-
* @param {Array} cluster uuids
66-
* @param {Object} config contains the new esClient already scoped contains usageCollection, callCluster, esClient, start, end
65+
* @param {Array} cluster uuids array of cluster uuid's
66+
* @param {Object} config contains the usageCollection, callCluster (deprecated), the esClient and Saved Objects client scoped to the request or the internal repository, and the kibana request
6767
* @param {Object} StatsCollectionContext contains logger and version (string)
6868
*/
6969
export const getLocalStats: StatsGetter<{}, TelemetryLocalStats> = async (
70-
clustersDetails, // array of cluster uuid's
71-
config, // contains the new esClient already scoped contains usageCollection, callCluster, esClient, start, end and the saved objects client scoped to the request or the internal repository
72-
context // StatsCollectionContext contains logger and version (string)
70+
clustersDetails,
71+
config,
72+
context
7373
) => {
7474
const { callCluster, usageCollection, esClient, soClient, kibanaRequest } = config;
7575

src/plugins/usage_collection/server/collector/collector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export type CollectorFetchContext<WithKibanaRequest extends boolean | undefined
7676
* The KibanaRequest that can be used to scope the requests:
7777
* It is provided only when your custom clients need to be scoped. If not available, you should use the Internal Client.
7878
* More information about when scoping is needed: {@link CollectorFetchContext}
79-
* @remark You should only use this if you implement your collector to deal with both scenarios: when provided and, especially, when not because it's the actual situation when the telemetry payload is sent to the remote service.
79+
* @remark You should only use this if you implement your collector to deal with both scenarios: when provided and, especially, when not provided. When telemetry payload is sent to the remote service the `kibanaRequest` will not be provided.
8080
*/
8181
kibanaRequest?: KibanaRequest;
8282
}

x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_usage_collector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { fetchClusters } from '../../lib/alerts/fetch_clusters';
1818
export function getMonitoringUsageCollector(
1919
usageCollection: UsageCollectionSetup,
2020
config: MonitoringConfig,
21-
esClient: ILegacyClusterClient
21+
legacyEsClient: ILegacyClusterClient
2222
) {
2323
return usageCollection.makeUsageCollector<MonitoringUsage, unknown, true>({
2424
type: 'monitoring',
@@ -102,8 +102,8 @@ export function getMonitoringUsageCollector(
102102
},
103103
fetch: async ({ kibanaRequest }) => {
104104
const callCluster = kibanaRequest
105-
? esClient.asScoped(kibanaRequest).callAsCurrentUser
106-
: esClient.callAsInternalUser;
105+
? legacyEsClient.asScoped(kibanaRequest).callAsCurrentUser
106+
: legacyEsClient.callAsInternalUser;
107107
const usageClusters: MonitoringClusterStackProductUsage[] = [];
108108
const availableCcs = config.ui.ccs.enabled ? await fetchAvailableCcs(callCluster) : [];
109109
const elasticsearchIndex = getCcsIndexPattern(INDEX_PATTERN_ELASTICSEARCH, availableCcs);

x-pack/plugins/monitoring/server/kibana_monitoring/collectors/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ export { KibanaSettingsCollector } from './get_settings_collector';
1515
export function registerCollectors(
1616
usageCollection: UsageCollectionSetup,
1717
config: MonitoringConfig,
18-
esClient: ILegacyClusterClient
18+
legacyEsClient: ILegacyClusterClient
1919
) {
2020
usageCollection.registerCollector(getSettingsCollector(usageCollection, config));
21-
usageCollection.registerCollector(getMonitoringUsageCollector(usageCollection, config, esClient));
21+
usageCollection.registerCollector(
22+
getMonitoringUsageCollector(usageCollection, config, legacyEsClient)
23+
);
2224
}

0 commit comments

Comments
 (0)