Skip to content

Standardize Error Logging to Include Request IDs in All Log Components #3710

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

Open
quiet-node opened this issue Apr 17, 2025 · 0 comments
Open
Labels
enhancement New feature or request Team Promoted Issues to be triaged and discussed by committers, maintainers, to be worked on the following sprint

Comments

@quiet-node
Copy link
Contributor

Problem

The current error logging pattern in the codebase often separates error objects from their contextual messages. When errors are passed as the first parameter to logger.error() methods (as shown below), the error details and stack traces appear on separate lines in logging dashboards without request IDs:

this.logger.error(
  new Error(error.message),
  `${requestIdPrefix} Error encountered while communicating with the mirror node server: method=${method}, path=${path}, status=${effectiveStatusCode}`
);

This separation makes debugging challenging as:

  1. Error details and stack traces don't contain request IDs
  2. When filtering logs by request ID, error details are not included in search results
  3. Correlation between errors and their context becomes difficult in high-volume environments

Proposed Solution - TBD

Standardize error logging throughout the codebase to consistently include request IDs in all log components by either

  1. Modifying error logging to use a pattern that incorporates request IDs in both the error context and message:

    // Preferred approach - error message includes request ID
    this.logger.error(
      `${requestIdPrefix} Error encountered while communicating with the mirror node server: method=${method}, path=${path}, status=${effectiveStatusCode}, error=${error.message}`,
      error
    );
  2. Ensure request ID is included in the error message:

    const enrichedError = new Error(`${requestIdPrefix} ${error.message}`);
    enrichedError.stack = error.stack;
    this.logger.error(
      enrichedError,
      `${requestIdPrefix} Additional context: method=${method}`
    );
@quiet-node quiet-node added enhancement New feature or request Team Promoted Issues to be triaged and discussed by committers, maintainers, to be worked on the following sprint labels Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Team Promoted Issues to be triaged and discussed by committers, maintainers, to be worked on the following sprint
Projects
None yet
Development

No branches or pull requests

1 participant