mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Wrap Snapshot Telemetry generation in an APM transaction (#180846)
This commit is contained in:
parent
057da1e09d
commit
591bbff92e
1 changed files with 19 additions and 1 deletions
|
@ -21,6 +21,7 @@ import type {
|
|||
} from '@kbn/core/server';
|
||||
|
||||
import { firstValueFrom, ReplaySubject } from 'rxjs';
|
||||
import apm from 'elastic-apm-node';
|
||||
import type {
|
||||
TelemetryCollectionManagerPluginSetup,
|
||||
TelemetryCollectionManagerPluginStart,
|
||||
|
@ -259,7 +260,16 @@ export class TelemetryCollectionManagerPlugin
|
|||
config: EncryptedStatsGetterConfig
|
||||
): Promise<Array<{ clusterUuid: string; stats: string }>>;
|
||||
private async getStats(config: StatsGetterConfig) {
|
||||
const retrieveSnapshotTelemetryTransaction = apm.startTransaction(
|
||||
'Retrieve Snapshot Telemetry',
|
||||
'telemetry'
|
||||
);
|
||||
retrieveSnapshotTelemetryTransaction.addLabels({
|
||||
unencrypted: config.unencrypted,
|
||||
refresh: config.refreshCache,
|
||||
});
|
||||
if (!this.usageCollection) {
|
||||
retrieveSnapshotTelemetryTransaction.end('skipped');
|
||||
return [];
|
||||
}
|
||||
const collection = this.collectionStrategy;
|
||||
|
@ -268,10 +278,12 @@ export class TelemetryCollectionManagerPlugin
|
|||
const statsCollectionConfig = this.getStatsCollectionConfig(config, this.usageCollection);
|
||||
if (statsCollectionConfig) {
|
||||
try {
|
||||
retrieveSnapshotTelemetryTransaction.startSpan('Fetch usage');
|
||||
const usageData = await this.getUsageForCollection(collection, statsCollectionConfig);
|
||||
this.logger.debug(`Received Usage using ${collection.title} collection.`);
|
||||
|
||||
return await Promise.all(
|
||||
retrieveSnapshotTelemetryTransaction.startSpan('Prepare response');
|
||||
const results = await Promise.all(
|
||||
usageData.map(async (clusterStats) => {
|
||||
const { cluster_uuid: clusterUuid } = clusterStats.cluster_stats as Record<
|
||||
string,
|
||||
|
@ -288,14 +300,20 @@ export class TelemetryCollectionManagerPlugin
|
|||
};
|
||||
})
|
||||
);
|
||||
retrieveSnapshotTelemetryTransaction.end('success');
|
||||
return results;
|
||||
} catch (err) {
|
||||
this.logger.debug(
|
||||
`Failed to collect any usage with registered collection ${collection.title}.`
|
||||
);
|
||||
retrieveSnapshotTelemetryTransaction.end('error');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
retrieveSnapshotTelemetryTransaction.end('skipped');
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue