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

contrib/jackc/pgx.v5: publish pgxpool stats to statsd client #2692

Merged
merged 10 commits into from
Jul 10, 2024

Conversation

bengentree
Copy link
Contributor

Fixes #2680

What does this PR do?

Adds a new option to contrib/jackc/pgx.v5 to enable polling and submission of pgxpool stats as metrics to Datadog
Ref: https://pkg.go.dev/github.com/jackc/pgx/v5/pgxpool#Stat

Motivation

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@bengentree bengentree requested review from a team as code owners May 11, 2024 16:33
contrib/jackc/pgx.v5/metrics.go Outdated Show resolved Hide resolved
contrib/jackc/pgx.v5/metrics.go Outdated Show resolved Hide resolved
contrib/jackc/pgx.v5/option.go Outdated Show resolved Hide resolved
if err != nil {
return nil, err
}
if tracer.cfg.poolStats {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if tracer.cfg.poolStats {
if tracer.cfg.poolStats && tracer.cfg.statsdClient != nil {

If we failed to generate a statsd client, we don't want to attempt to submit metrics on it.
See this PR for more context/motivation: #2682

if pool == nil {
log.Debug("No traced pool connection found; cannot pull pool stats.")
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove lines 38 - 41 as they essentially duplicate the err != nil check done by the caller, NewPoolWithConfig (Note: We also removed a similar check in the database/sql DB Stats feature in more recent versions , PR)

@bengentree bengentree requested a review from mtoffl01 May 15, 2024 14:37
Copy link
Contributor

This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale Stuck for more than 1 month label Jun 21, 2024
@darccio
Copy link
Member

darccio commented Jul 10, 2024

@rarguelloF @zarirhamza This looks good. Can you review it, please?

@rarguelloF rarguelloF removed the stale Stuck for more than 1 month label Jul 10, 2024
@darccio darccio enabled auto-merge (squash) July 10, 2024 10:18
@darccio darccio merged commit 6f26c4c into DataDog:main Jul 10, 2024
101 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.

Stats for contrib/jackc/pgxpool
4 participants