From c1a4addda3006202cd4b704e126b9cb2b72932ec Mon Sep 17 00:00:00 2001 From: Patrick Jungermann Date: Tue, 8 Nov 2022 09:18:56 +0100 Subject: [PATCH] feat(catalog): add location to processing error logs Signed-off-by: Patrick Jungermann --- .changeset/cuddly-coats-try.md | 7 +++++++ .../src/processing/DefaultCatalogProcessingEngine.ts | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .changeset/cuddly-coats-try.md diff --git a/.changeset/cuddly-coats-try.md b/.changeset/cuddly-coats-try.md new file mode 100644 index 0000000000..3b8bb654b2 --- /dev/null +++ b/.changeset/cuddly-coats-try.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Improve processing error logging. + +Adds `location` and `owner` to the logging meta if they are available. diff --git a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts index 2cc0e2dc40..bef2878099 100644 --- a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts +++ b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts @@ -14,7 +14,11 @@ * limitations under the License. */ -import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; +import { + ANNOTATION_LOCATION, + Entity, + stringifyEntityRef, +} from '@backstage/catalog-model'; import { assertError, serializeError, stringifyError } from '@backstage/errors'; import { Hash } from 'crypto'; import stableStringify from 'fast-json-stable-stringify'; @@ -116,11 +120,12 @@ export class DefaultCatalogProcessingEngine implements CatalogProcessingEngine { }); } + const location = + unprocessedEntity?.metadata?.annotations?.[ANNOTATION_LOCATION]; for (const error of result.errors) { - // TODO(freben): Try to extract the location out of the unprocessed - // entity and add as meta to the log lines this.logger.warn(error.message, { entity: entityRef, + location, }); } const errorsString = JSON.stringify(