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

[Telemetry] Apply shared logging module #420

Merged
merged 25 commits into from
Feb 4, 2023
Merged

[Telemetry] Apply shared logging module #420

merged 25 commits into from
Feb 4, 2023

Conversation

Gustavobelfort
Copy link
Contributor

@Gustavobelfort Gustavobelfort commented Dec 28, 2022

Description

This:

  • Replaces all the log calls with the logging module
  • Initializes a new instance of the logging module object in all of the modules and submodules that relied on logging calls
  • Updates the reflex configuration to output cleaner logs
  • BugFixes in the logging module to make it work properly

Issue

Fixes #288

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other

List of changes

  • Replaces all the log calls with the logging module
  • Initializes a new instance of the logging module object in all of the modules and submodules that relied on logging calls
  • Updates the reflex configuration to output cleaner logs
  • BugFixes in the logging module to make it work properly

Testing

  • make develop_test
  • LocalNet w/ all of the steps outlined in the README

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested my changes using the available tooling
  • I have updated the corresponding CHANGELOG

If Applicable Checklist

  • I have updated the corresponding README(s); local and/or global
  • I have added tests that prove my fix is effective or that my feature works
  • I have added, or updated, mermaid.js diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@Gustavobelfort Gustavobelfort self-assigned this Dec 28, 2022
@Gustavobelfort Gustavobelfort added telemetry everything related to collection telemetry tooling tooling to support development, testing et al labels Dec 28, 2022
Copy link
Member

@okdas okdas left a comment

Choose a reason for hiding this comment

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

@Gustavobelfort great work! Thank you!

Do you think we could add more dimensions to the log lines, like I included in a couple of comments? This would allow to index/parse/query these fields easily, e.g. we could get logs related to one particular height or step. It just makes sense to make use of structured logging.

consensus/helpers.go Outdated Show resolved Hide resolved
consensus/helpers.go Outdated Show resolved Hide resolved
logger/module.go Outdated Show resolved Hide resolved
@Gustavobelfort Gustavobelfort linked an issue Jan 3, 2023 that may be closed by this pull request
9 tasks
@Gustavobelfort Gustavobelfort changed the title [WIP][Telemetry] Apply shared logging module [Telemetry] Apply shared logging module Jan 4, 2023
@Gustavobelfort Gustavobelfort marked this pull request as ready for review January 4, 2023 16:34
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

This is some REALLY high-quality work 🔥 💯 🔥

@Gustavobelfort Sorry for how long it took me to review this but this LFG

  1. I left a few comments & a few questions throughout the doc
  2. Since it took me so long to review this, you'll need to handle some merge conflicts with main.
  3. We'll need to update the documentation (general and how to use this). I'm totally okay with doing this in a followup so we can just merge this into main sooner.

As a starting point for the documentation (again, can be done in a followup), I've aggregated these notes while reviewing:

* When logging error with `err`: `logger.Global.Logger.Error().Err(err).Msg(msg)`
* When logging error without `err`: `logger.Global.Logger.Error().Msg(msg)`
* When logging a fatal error: `logger.Global.Fatal().Err(err).Msg(msg)`
* When do we have to do `logger.Create(runtimeMgr)`?
* `—decoration` flag
* If in a module, use `m.logger`
* Levels
    * `.logger.Info()`
    * `.logger.Debug()`
* Fields
    * `.logger.Level().Fields()
* Parameters
    * Configured parameters (applied everywhere)
    * Fields parameter that (a map)
    * Type specific parameters (`.Str`, `.Int`, etc…)

app/client/cli/debug.go Outdated Show resolved Hide resolved
app/client/cli/debug.go Outdated Show resolved Hide resolved
app/client/cli/debug.go Outdated Show resolved Hide resolved
app/client/cli/utils.go Outdated Show resolved Hide resolved
consensus/debugging.go Outdated Show resolved Hide resolved
rpc/server.go Show resolved Hide resolved
rpc/module.go Show resolved Hide resolved
logger/module.go Show resolved Hide resolved
logger/module.go Outdated Show resolved Hide resolved
logger/module.go Outdated Show resolved Hide resolved
@Olshansk
Copy link
Member

@Gustavobelfort Saw that you pushed a lot of changes. Lmk if this is ready for another look

@Gustavobelfort
Copy link
Contributor Author

@Gustavobelfort Saw that you pushed a lot of changes. Lmk if this is ready for another look

Yes it is !

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

@Gustavobelfort Few things:

  1. I apologize for some repetitive comments you may find (I didn't go back to delete repetitive things)
  2. Do you plan to add documentation in this ticket or a follow-up?
  3. Please create the tickets for the follow-up items
  4. Minor comments & NITS left throughout
  5. The biggest issue with the PR is that LocalNet doesn't work:
Screen.Recording.2023-01-20.at.6.22.37.PM.mov

persistence/context.go Show resolved Hide resolved
consensus/block.go Show resolved Hide resolved
consensus/helpers.go Show resolved Hide resolved
consensus/helpers.go Show resolved Hide resolved
consensus/hotstuff_handler.go Show resolved Hide resolved
logger/module.go Outdated Show resolved Hide resolved
logger/module.go Outdated Show resolved Hide resolved
logger/module.go Show resolved Hide resolved
shared/modules/doc/README.md Show resolved Hide resolved
utility/block.go Show resolved Hide resolved
telemetry/prometheus_module.go Outdated Show resolved Hide resolved
shared/modules/doc/README.md Outdated Show resolved Hide resolved
consensus/module.go Outdated Show resolved Hide resolved
@@ -194,6 +195,8 @@ func (m *consensusModule) Start() error {
consensusTelemetry.CONSENSUS_BLOCKCHAIN_HEIGHT_COUNTER_DESCRIPTION,
)

m.logger = logger.Global.CreateLoggerForModule(m.GetModuleName())
Copy link
Member

Choose a reason for hiding this comment

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

In the README, you specified that we should create this in Start, but here we are creating it in Create.

I realize it doesn't matter but just want to be consistent and set a good pattern to follow for other devs.

Can you pick up and update everywhere?

Copy link
Member

Choose a reason for hiding this comment

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

@Olshansk from what I see you've left a comment in Start().

image

And I've checked other places CreateLoggerForModule is called - they are also under Start().

consensus/hotstuff_leader.go Show resolved Hide resolved
@@ -1,6 +1,7 @@
package logger
Copy link
Member

@Olshansk Olshansk Jan 31, 2023

Choose a reason for hiding this comment

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

Can you add a README under logger/docs/README.md?

I think a good outline (as a starting point) could be:

## 1. Configuration

* Mention ` —decoration` flag

## 2. Log Types

### 2.1 Levels

* When logging error with `err`: `logger.Global.Logger.Error().Err(err).Msg(msg)`
* When logging error without `err`: `logger.Global.Logger.Error().Msg(msg)`
* When logging a fatal error: `logger.Global.Fatal().Err(err).Msg(msg)`

### 2.2. Fields

* Fields
    * `.logger.Level().Fields()
* Parameters
    * Configured parameters (applied everywhere)
    * Fields parameter that (a map)
    * Type specific parameters (`.Str`, `.Int`, etc…)


## 3. Global Logging

## 4. Module Logging

* If in a module, use `m.logger`

### 4.1 Logger Initialisation

*  When do we have to do `logger.Create(runtimeMgr)`?
* Show what we should do in start method


## 5. Accessing Logs

Go to localhost:XXX

### 5.1. Grafana

#### 5.2. Example Queries

Copy link
Member

Choose a reason for hiding this comment

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

Wow, thank you for starting that README!

Copy link
Member

Choose a reason for hiding this comment

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

Done, please beware I am not currently able to provide example queries.


#### 5.2. Example Queries

We will populate this section with useful queries as we go.
Copy link
Member

Choose a reason for hiding this comment

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

With LocalNet and this branch not merged I can't build queries. We can populate this part later.

@okdas okdas requested a review from Olshansk February 4, 2023 01:39
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

@okdas Reviewed your changes and pushed it over the finish.

Let's squash & merge it in and prepare the demo next week with some example queries!

@okdas okdas merged commit 834ee23 into main Feb 4, 2023
@okdas okdas deleted the feat/implement-logging branch February 4, 2023 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
telemetry everything related to collection telemetry tooling tooling to support development, testing et al
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Telemetry] Apply shared logging module
3 participants