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

Logging improvement #13

Merged
merged 4 commits into from
Jan 3, 2024
Merged

Logging improvement #13

merged 4 commits into from
Jan 3, 2024

Conversation

Jason-Zhangxin-Chen
Copy link
Collaborator

To close #10, this PR contains:

  1. logging improvements in oracle server and plugins.
  2. better error handling in plugins.

config/config.go Outdated
@@ -24,23 +24,30 @@ var (
)

const Version = "v0.1.5"
const UsageOracleKey = "Set the oracle server key file path."
const UsagePluginConf = "Set the plugins' configuration file path."
Copy link
Contributor

Choose a reason for hiding this comment

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

type plugins' ==> plugin's

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

type plugins' ==> plugin's

Resolved in bd07764

@@ -391,7 +392,7 @@ func (os *OracleServer) reportWithCommitment(newRound uint64, lastRoundData *typ
return err
}

os.logger.Info("oracle client left fund", "balance", balance.String())
os.logger.Info("oracle server account left fund", "address", os.key.Address, "balance", balance.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

"left fund" can be removed from the log. Or say remaining balance. there is a balance field getting printed sperately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"left fund" can be removed from the log. Or say remaining balance. there is a balance field getting printed sperately.

Resolved in bd07764

@@ -407,7 +408,7 @@ func (os *OracleServer) reportWithoutCommitment(lastRoundData *types.RoundData)
os.logger.Error("do report", "error", err.Error())
return err
}
os.logger.Info("report without commitment", "TX hash", tx.Hash(), "Nonce", tx.Nonce())
os.logger.Info("reported last round data and without current round commitment", "TX hash", tx.Hash(), "Nonce", tx.Nonce())
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be info, Or Debug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should this be info, Or Debug?

It could be info, because this is the last report of an oracle node who is no longer in the committee due to the epoch rotation.

@@ -472,7 +473,7 @@ func (os *OracleServer) buildRoundData(round uint64) (*types.RoundData, error) {
for _, s := range os.protocolSymbols {
p, err := os.aggregatePrice(s, int64(os.curSampleTS))
if err != nil {
os.logger.Error("aggregatePrice", "error", err.Error(), "symbol", s)
os.logger.Warn("aggregatePrice", "error", err.Error(), "symbol", s)
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a warning. Maybe we should not say error in the message itself. 'price aggregation failed due to "err.Error()"'. Also it should only be warning if there is something to fix/actionable item from end-user point of view. Else this can be a debug

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If this is a warning. Maybe we should not say error in the message itself. 'price aggregation failed due to "err.Error()"'. Also it should only be warning if there is something to fix/actionable item from end-user point of view. Else this can be a debug

Resolved in bd07764

@@ -691,18 +687,17 @@ func (os *OracleServer) tryLoadingNewPlugin(f fs.FileInfo, plugConf types.Plugin
return
}

os.logger.Info("** Replacing legacy plugin with new one: ", f.Name(), f.Mode().String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we use ** in the log? Is it to put more emphasis on this specific log statement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do we use ** in the log? Is it to put more emphasis on this specific log statement?

Yes, it put more emphasis on the testing phase, since this feature is stable, I will remove the stars.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do we use ** in the log? Is it to put more emphasis on this specific log statement?

Resolved in bd07764

return err
}

if len(report.BadSymbols) != 0 {
pw.logger.Warn("find bad symbols: ", report.BadSymbols)
if len(report.UnRecognizeSymbols) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think the correct word would be unrecognizable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think the correct word would be unrecognizable

Resolved in bd07764

pluginWrapper := pWrapper.NewPluginWrapper(os.loggingLevel, f.Name(), os.pluginDIR, os)
if err := pluginWrapper.Initialize(); err != nil {
os.logger.Error("** Cannot initialize plugin", "name", f.Name(), "error", err.Error())
os.logger.Error("Cannot initialize plugin", "name", f.Name(), "error", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the first Capital letter is not consistent with other logs and also not the preferred logging style in most golang projects. logging is usually the lowercase. Consistent casing is useful while filtering logs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the first Capital letter is not consistent with other logs and also not the preferred logging style in most golang projects. logging is usually the lowercase. Consistent casing is useful while filtering logs

Resolved in bd07764

@@ -714,11 +709,11 @@ func (os *OracleServer) ApplyPluginConf(name string, plugConf types.PluginConfig
// set the plugin configuration via system env, thus the plugin can load it on startup.
conf, err := json.Marshal(plugConf)
if err != nil {
os.logger.Error("** Cannot marshal plugin's configuration", "error", err.Error())
os.logger.Error("Cannot marshal plugin's configuration", "error", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, other places too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same here, other places too

Resolved in bd07764

@@ -35,12 +34,12 @@ type BIClient struct {
func NewBIClient(conf *types.PluginConfig) *BIClient {
client := common.NewClient(conf.Key, time.Second*time.Duration(conf.Timeout), conf.Endpoint)
if client == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

In what cases, is this possible?

Copy link
Collaborator Author

@Jason-Zhangxin-Chen Jason-Zhangxin-Chen Dec 21, 2023

Choose a reason for hiding this comment

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

In what cases, is this possible?

I doubled checked, it is not possible.
Resolved in bd07764

@Jason-Zhangxin-Chen Jason-Zhangxin-Chen merged commit 90e8d2e into master Jan 3, 2024
4 checks passed
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.

Logging improvements
2 participants