Merge pull request #3617 from zalando-incubator/refresh-location-logging

`refreshAllLocations` uses a child logger with meta. Refs #3602
This commit is contained in:
Patrik Oldsberg
2020-12-08 19:11:18 +01:00
committed by GitHub
2 changed files with 19 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
refreshAllLocations uses a child logger of the HigherOrderOperation with a meta `component` : `catalog-all-locations-refresh`
@@ -116,28 +116,34 @@ export class HigherOrderOperations implements HigherOrderOperation {
*/
async refreshAllLocations(): Promise<void> {
const startTimestamp = process.hrtime();
this.logger.info('Beginning locations refresh');
const logger = this.logger.child({
component: 'catalog-all-locations-refresh',
});
logger.info('Locations Refresh: Beginning locations refresh');
const locations = await this.locationsCatalog.locations();
this.logger.info(`Visiting ${locations.length} locations`);
logger.info(`Locations Refresh: Visiting ${locations.length} locations`);
for (const { data: location } of locations) {
this.logger.info(
`Refreshing location ${location.type}:${location.target}`,
logger.info(
`Locations Refresh: Refreshing location ${location.type}:${location.target}`,
);
try {
await this.refreshSingleLocation(location);
await this.locationsCatalog.logUpdateSuccess(location.id, undefined);
} catch (e) {
this.logger.warn(
`Failed to refresh location ${location.type}:${location.target}, ${e.stack}`,
logger.warn(
`Locations Refresh: Failed to refresh location ${location.type}:${location.target}, ${e.stack}`,
);
await this.locationsCatalog.logUpdateFailure(location.id, e);
}
}
this.logger.info(
`Completed locations refresh in ${durationText(startTimestamp)}`,
logger.info(
`Locations Refresh: Completed locations refresh in ${durationText(
startTimestamp,
)}`,
);
}