FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Metrics implementation by r4f4ss · Pull Request #210 · optimism-java/shisui · GitHub

Metrics implementation - #210

Merged
GrapeBaBa merged 4 commits into
optimism-java:portalfrom
r4f4ss:metrics_final
Oct 29, 2024
Merged

Metrics implementation#210
GrapeBaBa merged 4 commits into
optimism-java:portalfrom
r4f4ss:metrics_final

Conversation

r4f4ss commented Oct 28, 2024

Copy link
Copy Markdown

Implementation/fix of the following metrics:

portal/<NETWORK>/radius_ratio
portal/<NETWORK>/entry_count
portal/<NETWORK>/content_storage
portal/<NETWORK>/total_storage

Comment thread portalnetwork/beacon/storage.go Outdated
Comment thread portalnetwork/beacon/storage.go Outdated
r4f4ss requested a review from GrapeBaBa October 28, 2024 21:08

Copy link
Copy Markdown

I think we can abstract a Metrics interface and add an implementation called NoMetrics, where all methods are empty.

When metrics are not needed, we can use an instance of NoMetrics, so we don't have to check metrics.Enable every time.

count, _ := res.RowsAffected()
count, err := res.RowsAffected()
p.log.Trace("delete items", "count", count)
if metrics.Enabled && err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The condition probably be err == nil

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, thanks, fixed locally, I will commit soon

r4f4ss commented Oct 29, 2024
edited
Loading

Copy link
Copy Markdown
Author

I think we can abstract a Metrics interface and add an implementation called NoMetrics, where all methods are empty.

When metrics are not needed, we can use an instance of NoMetrics, so we don't have to check metrics.Enable every time.

Definitely will make the code more clear, but I am not sure if a function call to the interface is computationally cheapper than an if verification. As alternative, what about replace the duplicate code:

if metrics.Enabled {
	portalStorageMetrics.EntriesCount.Dec(count)
}

in a function that verify:

func verifyDec(metric){
    if metrics.Enabled {
	    metric.Dec(count)
    }
}

and it is more clear in the code to call simple:

verifyDec(metric)

EDIT: Nevermind, It is the worst solution, uses an function call and an if comparison, higher computationally cost

Copy link
Copy Markdown
Member

I think we can abstract a Metrics interface and add an implementation called NoMetrics, where all methods are empty.
When metrics are not needed, we can use an instance of NoMetrics, so we don't have to check metrics.Enable every time.

Definitely will make the code more clear, but I am not sure if a function call to the interface is computationally cheapper than an if verification. As alternative, what about replace the duplicate code:

if metrics.Enabled {
	portalStorageMetrics.EntriesCount.Dec(count)
}

in a function that verify:

func verifyDec(metric){
    if metrics.Enabled {
	    metric.Dec(count)
    }
}

and it is more clear in the code to call simple:

verifyDec(metric)

EDIT: Nevermind, It is the worst solution, uses an function call and an if comparison, higher computationally cost

Just follow the geth style is OK.

Copy link
Copy Markdown

By the way, the code of storage is according from the early version of the trin. Now, the trin has update the storage code, maybe we can check there code to decide if we should do some update.

GrapeBaBa merged commit 9c4f3b2 into optimism-java:portal Oct 29, 2024
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL