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

feat: add golang runtime metrics, process metrics and std lib db metrics #1197

Merged
merged 3 commits into from Oct 31, 2023

Conversation

sysvm
Copy link
Collaborator

@sysvm sysvm commented Oct 23, 2023

Description

Add golang runtime metrics, process metrics and std lib db metrics to improve availability.

Rationale

Improve availability and speed to debug problems.

Example

curl http://localhost:24367/metrics

process metrics:
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 7.31
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 8192
......

golang metrics:
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 7
......

db metrics:
# HELP go_sql_idle_connections The number of idle connections.
# TYPE go_sql_idle_connections gauge
go_sql_idle_connections{db_name="spdb"} 3
# HELP go_sql_in_use_connections The number of connections currently in use.
# TYPE go_sql_in_use_connections gauge
go_sql_in_use_connections{db_name="spdb"} 0
......

Changes

Notable changes:

  • N/A

@sysvm sysvm changed the base branch from master to develop October 23, 2023 02:26
@sysvm sysvm changed the title Feat golangmetrics feat: add golang runtime and std lib db metrics Oct 23, 2023
@sysvm sysvm changed the title feat: add golang runtime and std lib db metrics feat: add golang runtime metrics, process metrics and std lib db metrics Oct 23, 2023
@sysvm sysvm added the r4r Ready for review label Oct 23, 2023
@@ -256,6 +256,13 @@ func DefaultGfSpDBOption(app *GfSpBaseApp, cfg *gfspconfig.GfSpConfig) error {
return
}
app.gfSpDB = db
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we place app.gfSpDB = db at the end of the function because db may be modified by RegisterStdDBStats?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

db is not modified by RegisterStdDBStats, this function is just used to get some db metrics.

// golang runtime and process metrics
collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(collectors.GoRuntimeMetricsRule{
Matcher: regexp.MustCompile("/.*")})),
collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}),
Copy link
Collaborator

@will-2012 will-2012 Oct 30, 2023

Choose a reason for hiding this comment

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

Keep consistent with the above, define a variable.

Copy link
Collaborator Author

@sysvm sysvm Oct 31, 2023

Choose a reason for hiding this comment

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

fixed

@sysvm sysvm merged commit 870e4be into develop Oct 31, 2023
11 checks passed
@sysvm sysvm deleted the feat-golangmetrics branch October 31, 2023 02:56
constwz pushed a commit that referenced this pull request Oct 31, 2023
…ics (#1197)

* feat: add golang runtime metrics, process metrics and std lib db metrics

* fix: define golang runtime and process metrics as variables

---------

Co-authored-by: VM <arimas@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r4r Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants