Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove templating from INFO/WARN/ERROR log messages #33448

Open
rarkins opened this issue Jan 7, 2025 · 0 comments
Open

Remove templating from INFO/WARN/ERROR log messages #33448

rarkins opened this issue Jan 7, 2025 · 0 comments
Assignees
Labels
priority-2-high Bugs impacting wide number of users or very important features type:refactor Refactoring or improving of existing code

Comments

@rarkins
Copy link
Collaborator

rarkins commented Jan 7, 2025

Describe the proposed change(s).

It is common for Renovate admins to use metrics on INFO and above level messages. When such messages use string templating, it means you can't easily "group"/count them in backends. Instead, we should use log metadata for variable data instead, and keep fixed message strings.

Here is an example of some of the types of changes needed:

diff --git a/lib/modules/datasource/hex/index.ts b/lib/modules/datasource/hex/index.ts
index ebf03fbfb..f6246381e 100644
--- a/lib/modules/datasource/hex/index.ts
+++ b/lib/modules/datasource/hex/index.ts
@@ -55,7 +55,7 @@ export class HexDatasource extends Datasource {
     const { val: result, err } = await this.http
       .getJsonSafe(hexUrl, HexRelease)
       .onError((err) => {
-        logger.warn({ datasource: 'hex', packageName, err }, `Error fetching ${hexUrl}`); // prettier-ignore
+        logger.warn({ datasource: 'hex', url: hexUrl, packageName, err }, 'Error fetching datasource url'); // prettier-ignore
       })
       .unwrap();
 
diff --git a/lib/modules/manager/pip-compile/extract.ts b/lib/modules/manager/pip-compile/extract.ts
index 1ef63fc65..60c4a90ee 100644
--- a/lib/modules/manager/pip-compile/extract.ts
+++ b/lib/modules/manager/pip-compile/extract.ts
@@ -66,7 +66,10 @@ export async function extractAllPackageFiles(
       compileArgs = extractHeaderCommand(fileContent, fileMatch);
       compileDir = inferCommandExecDir(fileMatch, compileArgs.outputFile);
     } catch (error) {
-      logger.warn({ fileMatch }, `pip-compile: ${error.message}`);
+      logger.warn(
+        { fileMatch, errorMessage: error.message },
+        'pip-compile error',
+      );
       continue;
     }
     lockFileArgs.set(fileMatch, compileArgs);
diff --git a/lib/workers/repository/update/pr/index.ts b/lib/workers/repository/update/pr/index.ts
index edc851770..074eb4d15 100644
--- a/lib/workers/repository/update/pr/index.ts
+++ b/lib/workers/repository/update/pr/index.ts
@@ -573,7 +573,7 @@ export async function ensurePr(
       logger.debug('Passing error up');
       throw err;
     }
-    logger.error({ err }, 'Failed to ensure PR: ' + prTitle);
+    logger.error({ err, prTitle }, 'Failed to ensure PR');
   }
   if (existingPr) {
     return { type: 'with-pr', pr: existingPr };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-2-high Bugs impacting wide number of users or very important features type:refactor Refactoring or improving of existing code
Projects
None yet
Development

No branches or pull requests

2 participants