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: monitor sql database #444

Merged
merged 3 commits into from
Apr 24, 2024
Merged

feat: monitor sql database #444

merged 3 commits into from
Apr 24, 2024

Conversation

achettyiitr
Copy link
Member

Description

  • Adding support for monitoring database (*sql.DB) using the DBStats provided.

Linear Ticket

  • Resolves PIPE-894

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@achettyiitr achettyiitr changed the title feat: monitor database feat: monitor sql database Apr 23, 2024
Comment on lines 22 to 26
maxOpenConnectionsStat := statsFactory.NewStat(dbIdentifier+".db.max_open_connections", stats.CountType)
openConnectionsStat := statsFactory.NewStat(dbIdentifier+".db.open_connections", stats.CountType)
inUseStat := statsFactory.NewStat(dbIdentifier+".db.in_use", stats.CountType)
idleStat := statsFactory.NewStat(dbIdentifier+".db.idle", stats.CountType)
waitCountStat := statsFactory.NewStat(dbIdentifier+".db.wait_count", stats.CountType)
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't a gauge make more sense here..?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably everything can be Gauge instead of WaitDuration?

Copy link
Member

Choose a reason for hiding this comment

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

yeah

@Sidddddarth
Copy link
Member

Suggestion: aggregate things like open_connections, in_use, idle etc. over all the different *sql.DB handles a server creates.(can use dbIdentifier=ALL)

@achettyiitr
Copy link
Member Author

achettyiitr commented Apr 24, 2024

Suggestion: aggregate things like open_connections, in_use, idle etc. over all the different *sql.DB handles a server creates.(can use dbIdentifier=ALL)

Good point. I was thinking of adding tags instead of creating different stat per identifier. It would be easy to aggregate.

sqlutil/monitor.go Outdated Show resolved Hide resolved
sqlutil/monitor.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mihir20 mihir20 left a comment

Choose a reason for hiding this comment

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

LGTM

@achettyiitr achettyiitr merged commit ae1d227 into main Apr 24, 2024
10 checks passed
@achettyiitr achettyiitr deleted the feat.monitor-db branch April 24, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants