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

Improve logging in ledger API server [DPP-231] #8676

Merged
merged 18 commits into from
Feb 15, 2021

Conversation

kamil-da
Copy link
Contributor

@kamil-da kamil-da commented Jan 28, 2021

Motivation
Troubleshooting is made unnecessarily hard by lack of adequate logging. Every client request should be logged at the info level as it enters and leaves the system.

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

@kamil-da
Copy link
Contributor Author

@mziolekda Could you review changes and point out which information worth logging I haven't included in this draft?

@kamil-da kamil-da force-pushed the kamil-da/improve-logging-in-api-server branch from eec2e6f to ccdb108 Compare February 1, 2021 19:59
@kamil-da kamil-da marked this pull request as ready for review February 1, 2021 19:59
@kamil-da kamil-da requested a review from a user February 1, 2021 19:59
@kamil-da kamil-da requested a review from mziolekda February 1, 2021 20:00
Copy link
Contributor

@stefanobaghino-da stefanobaghino-da left a comment

Choose a reason for hiding this comment

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

Thanks, it basically looks ok, I've added a few notes here and there.

Copy link
Contributor

@stefanobaghino-da stefanobaghino-da left a comment

Choose a reason for hiding this comment

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

LGTM (but maybe wait for someone from your team to approve as well, if you think that makes sense)

@kamil-da kamil-da force-pushed the kamil-da/improve-logging-in-api-server branch from 638ca92 to a22c0c6 Compare February 2, 2021 14:11
@stefanobaghino-da
Copy link
Contributor

Judging from @mziolekda's most recent comments it appears that many of the keys that are being inserted in this PR were actually already there. It would probably be best to have a second look at this.

@kamil-da kamil-da force-pushed the kamil-da/improve-logging-in-api-server branch from 9f9242a to 4e072ab Compare February 10, 2021 10:59
): Map[String, String] =
Map(
logging.commandId(commandId),
"statusCode" -> statusCode.map(_.toString).getOrElse(""),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"statusCode" -> statusCode.map(_.toString).getOrElse(""),
"statusCode" -> statusCode.mkString,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it's not possible with our current Scala compiler settings. Specifically, compilation will fail with:

error: [wartremover:Option2Iterable] Implicit conversion from Option to Iterable is disabled - use Option#toList instead

I could use statusCode.toList.mkString but it looks a bit strange to create a list only for mkString. What do you think?

Copy link
Contributor

@mziolekda mziolekda left a comment

Choose a reason for hiding this comment

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

It looks ok now, thanks

@kamil-da kamil-da force-pushed the kamil-da/improve-logging-in-api-server branch from b91d438 to 869ef17 Compare February 15, 2021 09:34
@kamil-da kamil-da merged commit 926fb59 into main Feb 15, 2021
@kamil-da kamil-da deleted the kamil-da/improve-logging-in-api-server branch February 15, 2021 10:45
@@ -110,7 +110,7 @@ private[apiserver] final class ApiSubmissionService private (

override def submit(request: SubmitRequest): Future[Unit] =
withEnrichedLoggingContext(logging.commands(request.commands)) { implicit loggingContext =>
logger.debug("Submitting transaction")
logger.info("Submitting transaction")
Copy link
Contributor

Choose a reason for hiding this comment

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

@kamil-da , don't you feel logging every submission at info level might turn out to be a bit verbose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@oliverse-da Thank you for the comment.
Actually I think it may be more reasonable to lower the level to debug.
This change was explicitly requested by @mziolekda , so his input might be valuable here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants