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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bengentree
Copy link

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 and others added 2 commits May 14, 2024 15:15
Co-authored-by: Mikayla Toffler <46911781+mtoffl01@users.noreply.github.com>
@bengentree bengentree requested a review from mtoffl01 May 15, 2024 14:37
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
2 participants