-
Notifications
You must be signed in to change notification settings - Fork 268
feat: tracing for structured, context-aware logs #499
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
Merged
+282
−227
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
de-sh
added a commit
that referenced
this pull request
Nov 14, 2022
carlocorradini
pushed a commit
to carlocorradini/rumqtt
that referenced
this pull request
Aug 3, 2023
* feat: use tracing crate instead of log * tracing subscriber in progress * added client_idx as span field and use FILTER env var * manually create spans * initial POC for reloading filter * feat: dynamically reloading filter for logs * feat: filter the log with rumqttd as target by default * feat: consume span and removed unnecessary fields * return text instead of json if logs filter reloaded * feat: removed count in run span and created span for server * feat: tracing * feat: pretty logs * feat: use instrument combinator for attaching span to futures * feat: stop logging run * fix: merge issues * fix: clippy warning * feat: removed unnecessary client_id from log Co-authored-by: Devdutt Shenoi <devdutt@bytebeam.io>
carlocorradini
pushed a commit
to carlocorradini/rumqtt
that referenced
this pull request
Aug 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In asynchronous code, we can't rely on order of printed logs to determine the logical flow of execution. Static context like file, module or function in which the event was recorded in, isn't much useful for understanding runtime behavior of a program.
To solve this, we can use tracing crate, which can trace the logical contexts and how the flow of execution is moves between them. We also have fields with key-value pair to add more structure to logs. (ref)
We use tracing-subscriber to pretty print those logs. It is also used to dynamically filter the logs based on their level, spans, fields, etc.