Skip to content

Commit

Permalink
Fix PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Nov 17, 2020
1 parent 01ea1c4 commit 4afc962
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ export type TelemetryLocalStats = ReturnType<typeof handleLocalStats>;

/**
* Get statistics for all products joined by Elasticsearch cluster.
* @param {Array} cluster uuids
* @param {Object} config contains the new esClient already scoped contains usageCollection, callCluster, esClient, start, end
* @param {Array} cluster uuids array of cluster uuid's
* @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
* @param {Object} StatsCollectionContext contains logger and version (string)
*/
export const getLocalStats: StatsGetter<{}, TelemetryLocalStats> = async (
clustersDetails, // array of cluster uuid's
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
context // StatsCollectionContext contains logger and version (string)
clustersDetails,
config,
context
) => {
const { callCluster, usageCollection, esClient, soClient, kibanaRequest } = config;

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/usage_collection/server/collector/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export type CollectorFetchContext<WithKibanaRequest extends boolean | undefined
* The KibanaRequest that can be used to scope the requests:
* It is provided only when your custom clients need to be scoped. If not available, you should use the Internal Client.
* More information about when scoping is needed: {@link CollectorFetchContext}
* @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.
* @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.
*/
kibanaRequest?: KibanaRequest;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { fetchClusters } from '../../lib/alerts/fetch_clusters';
export function getMonitoringUsageCollector(
usageCollection: UsageCollectionSetup,
config: MonitoringConfig,
esClient: ILegacyClusterClient
legacyEsClient: ILegacyClusterClient
) {
return usageCollection.makeUsageCollector<MonitoringUsage, unknown, true>({
type: 'monitoring',
Expand Down Expand Up @@ -102,8 +102,8 @@ export function getMonitoringUsageCollector(
},
fetch: async ({ kibanaRequest }) => {
const callCluster = kibanaRequest
? esClient.asScoped(kibanaRequest).callAsCurrentUser
: esClient.callAsInternalUser;
? legacyEsClient.asScoped(kibanaRequest).callAsCurrentUser
: legacyEsClient.callAsInternalUser;
const usageClusters: MonitoringClusterStackProductUsage[] = [];
const availableCcs = config.ui.ccs.enabled ? await fetchAvailableCcs(callCluster) : [];
const elasticsearchIndex = getCcsIndexPattern(INDEX_PATTERN_ELASTICSEARCH, availableCcs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export { KibanaSettingsCollector } from './get_settings_collector';
export function registerCollectors(
usageCollection: UsageCollectionSetup,
config: MonitoringConfig,
esClient: ILegacyClusterClient
legacyEsClient: ILegacyClusterClient
) {
usageCollection.registerCollector(getSettingsCollector(usageCollection, config));
usageCollection.registerCollector(getMonitoringUsageCollector(usageCollection, config, esClient));
usageCollection.registerCollector(
getMonitoringUsageCollector(usageCollection, config, legacyEsClient)
);
}

0 comments on commit 4afc962

Please sign in to comment.