Merged
Conversation
fe73f62 to
d0bdc6b
Compare
ee85b5d to
b994921
Compare
b994921 to
3805e36
Compare
dsiganos
reviewed
Feb 2, 2024
dsiganos
previously approved these changes
Feb 6, 2024
nano/node/transport/channel.cpp
Outdated
| node.logger.trace (nano::log::type::channel_sent, nano::to_log_detail (message_a.type ()), | ||
| nano::log::arg{ "message", message_a }, | ||
| nano::log::arg{ "channel", *this }, | ||
| nano::log::arg{ "dropped", false }); |
Contributor
There was a problem hiding this comment.
To achieve more compression of data, we could remove the dropped field when it is set to false.
So, a missing dropped would mean that the message was not dropped.
Contributor
Author
There was a problem hiding this comment.
Some tools that automatically detect data format (eg. Apache Drill, but likely others too) might have problems with format that is inconsistent. I believe in case of Drill it infers schema from first ~60k entries. Looking at this now, this function flow should be refactored, so that it has a single point at which data is logged.
dsiganos
reviewed
Feb 6, 2024
dsiganos
approved these changes
Feb 7, 2024
Closed
This file contains hidden or 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
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.
The goal of this PR is to introduce a framework for tracing events in the node. This is meant to be used for debugging and profiling purposes, eg. by visualizing the flow of votes through the network or analyzing the delay between receiving a block and confirming it.
This is accomplished by introducing a
nano::object_streamclass that can be used to serialize objects. It is meant to be a relatively thin wrapper around the underlying stream, that ensures the output format is structured and consistent. It avoids allocations and unnecessary run-time dispatching by using a compile-time visitor pattern.This interface also allows to switch between different output formats and automatically handles some common functionality, like providing
operator<<,to_string()andto_json(). If in the future a better serialization library is found, it should be possible to easily replace the underlying implementation without changing the interface.Usage
To use tracing, it must be enabled at compile time by passing
-DNANO_TRACING=ONflag to CMake. By default, it is disabled for release builds and enabled for debug builds.After that, tracing can be enabled by setting the logging verbosity level to
trace. (NANO_LOG=trace)Since the amount of logs when setting logging level to
traceis very large, it is recommended to usetracelevel only for specific components. This can be done by settingNANO_LOG_LEVELSenvironment variable to a comma-separated list of components to trace. For example, to trace onlyactive_transactionsandvote_processor, setNANO_LOG_LEVELS="active_transactions=trace,vote_processor=trace". Alternatively this can also be done by modifying theconfig-log.tomlfile.Tracing Formats
It is possible to specify format of tracing output at runtime. This is done by setting
NANO_TRACE_FORMATenvironment variable to one of the following:standardorjson.Standard
Standard tracing format is enabled by default. It is a simple
key: { value }format with indentation that should be easy to read.Sample output:
JSON
JSON tracing format is meant to be parsed by external tools. There is no indentation or newlines, so each log output line can be treated as a separate event, which simplifies parsing.
Sample output: