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

[TECH] Récupérer les correlations IDs dans le logger.js (PIX-12823) #9425

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

dlahaye
Copy link
Contributor

@dlahaye dlahaye commented Jul 2, 2024

👷‍♀️👷‍♂️ Ceci est une reprise de la PR Remplacer les usages de Logger par les méthodes avec correlations IDs

🦄 Problème

Ajout d'infos dans les logs. Les correlationIDs (request-id & user-id) ne sont pas loggués partout pour l'instant.
Le but est de pouvoir prévenir automatiquement chaque équipe en cas d'erreur, en fonction d'un label @team qu'il faudra ajouter sur chaque route.

🤖 Proposition

Dans le fichier logger.js, utiliser loggerInfoWithCorrelationId lors de l'appel de logger.info, et loggerErrorWithCorrelationId lors de l'appel de logger.error.

Le logger.js expose alors ses loggerInfoWithCorrelationId et loggerErrorWithCorrelationId afin de permettre à monitoring-tools de les utiliser sans nécessiter de grosses refacto

🌈 Remarques

Pour l'instant logger.warn & logger.trace & logger.fatal & logger.debug ne sont pas gérées.

💯 Pour tester

@pix-bot-github
Copy link

Une fois les applications déployées, elles seront accessibles via les liens suivants :

Les variables d'environnement seront accessibles via les liens suivants :

@dlahaye dlahaye changed the title Pix 12823 add correlation id to logs v2 [TECH] Récupérer les correlations IDs dans le logger.js (PIX-12823) Jul 2, 2024
@dlahaye dlahaye added the cross-team Toutes les équipes de dev label Jul 2, 2024
@dlahaye dlahaye force-pushed the pix-12823-add-correlation-id-to-logs-v2 branch from 703409c to f913844 Compare July 4, 2024 07:42
@dlahaye dlahaye force-pushed the pix-12823-add-correlation-id-to-logs-v2 branch from f913844 to 9ec29d1 Compare July 4, 2024 08:04
*/
const logErrorWithCorrelationIds = _logWithCorrelationIds(internalLogger.error);

/** @param {object} data
Copy link
Contributor Author

@dlahaye dlahaye Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @param {object} data
/** @param {object|string} data

Et idem pour la jsDoc du logError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

au passage est-ce qu'on en profiterait pas pour proposer une jsDoc aussi exhaustive pour le logInfo que ce qui a été fait pour le logError ?

Comment on lines 97 to 98
error: _logWithCorrelationIds(internalLogger.error),
info: _logWithCorrelationIds(internalLogger.info),
Copy link
Contributor Author

@dlahaye dlahaye Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suite aux remontées d'erreur de la CI:

/home/circleci/pix/api/node_modules/pino/lib/tools.js:59
      if (typeof this[msgPrefixSym] === 'string' && msg !== undefined && msg !== null) {

Je pense qu'il faudrait plutôt faire comme ça

Suggested change
error: _logWithCorrelationIds(internalLogger.error),
info: _logWithCorrelationIds(internalLogger.info),
error: _logWithCorrelationIds(internalLogger.error.bind(internalLogger)),
info: _logWithCorrelationIds(internalLogger.info.bind(internalLogger)),

Ou un truc du genre 😅

@aurelie-crouillebois aurelie-crouillebois force-pushed the pix-12823-add-correlation-id-to-logs-v2 branch from c201409 to 457be8c Compare July 5, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-team Toutes les équipes de dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants