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

feat: Add logging and tracing middleware and slight reorg #10

Merged
merged 2 commits into from
May 6, 2024

Conversation

vitsalis
Copy link
Member

@vitsalis vitsalis commented May 4, 2024

Adds logging and tracing middleware to be able to track faults. The middlewares is copied from the staking API service, with the only difference that I removed the WrapWithSpan tracing method as it is not used.

Also, replaced slog with zerolog as it seemed easier to maintain with the logging middleware.

This PR also does a slight re-org of the files into directories, similar to what the staking API service does. While it should have been a separate PR, the changes were intertwined during my local development, but I can split them if you feel the PR context is too wide.

Partially resolves #9 . Did not add CORS middleware in this PR though.

"log/slog"
"github.com/babylonchain/covenant-signer/signerservice/handlers"
"github.com/babylonchain/covenant-signer/signerservice/types"
logger "github.com/rs/zerolog"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find this change a bit controversial tbh. Mainly:

  1. There is already good structured logging lib in standard lib (slog). Imo it is better to minimze amount of dependendcies.
  2. Using global object is also a bit bad, as it introduces global state.

Not a blocker for this pr as I understand this makes it consistent with staking api, but nevertheless we can re-think this at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, created #12 to track it

@vitsalis vitsalis merged commit 8685063 into main May 6, 2024
3 checks passed
@vitsalis vitsalis deleted the logging-middleware branch May 6, 2024 06:50
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.

Add middlewares
3 participants