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

metrics: Add memory usage statistics to Prometheus #9465

Merged
merged 19 commits into from
Feb 27, 2024
Merged

Conversation

shohamc1
Copy link
Member

@shohamc1 shohamc1 commented Feb 19, 2024

Prometheus preview

image

diagnostics/mem.go Outdated Show resolved Hide resolved
defer ticker.Stop()

for {
dbg.GetMemUsage()
Copy link
Member

Choose a reason for hiding this comment

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

suggest to be explicit when swallowing an err:

_, _ := dbg.GetMemUsages() // err ignored since this is best effort background information logging

or

_, err := dbg.GetMemUsage()
if err != nil {
    logger.Trace("...")
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

From one side: “it maybe does stop the world”, from another: do stop the world in “only 1” goroutine with predictable timer maybe better than from many goroutines.

so, i would say: yes, and remove all other usages. With 1min timer.

diagnostics/mem.go Outdated Show resolved Hide resolved
diagnostics/mem.go Outdated Show resolved Hide resolved
@AskAlexSharov
Copy link
Collaborator

seems this PR is related to https://github.com/ledgerwatch/erigon/pull/9482/files

)

func SetupMemAccess(metricsMux *http.ServeMux) {
metricsMux.HandleFunc("/mem", func(w http.ResponseWriter, r *http.Request) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

a bit unclear why need separated http endpoint for memory metrics. we already have /debug/metrics/prometheus (enabling by flag --metrics)

Copy link
Member

Choose a reason for hiding this comment

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

I may want to use it to show it in diagnostics

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dvovk i see. but how it answers the question: "why not use existing /debug/metrics/prometheus ? (enabling by flag --metrics)"

Copy link
Contributor

@mh0lt mh0lt Feb 27, 2024

Choose a reason for hiding this comment

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

Diagnostics are enabled by the metrics flag, however metrics doesn't use the prometheus protocol for gathering data and works using individual requests for specific diagnostics rather than scraping all. Hence it uses additional endpoints for the data its needs.

Having said that it should hit the same data point.

eth/backend.go Outdated Show resolved Hide resolved
eth/backend.go Outdated Show resolved Hide resolved
diagnostics/setup.go Outdated Show resolved Hide resolved
@shohamc1 shohamc1 marked this pull request as ready for review February 26, 2024 07:37
@shohamc1 shohamc1 requested a review from mh0lt February 26, 2024 07:38
@shohamc1 shohamc1 merged commit bff5c69 into devel Feb 27, 2024
7 checks passed
@shohamc1 shohamc1 deleted the shohamc1/mem-stats branch February 27, 2024 14:05
mriccobene pushed a commit to mriccobene/erigon that referenced this pull request Mar 13, 2024
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.

5 participants