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/database/sql: Submit DBStats as Datadog metrics #2543

Merged
merged 46 commits into from Feb 27, 2024

Conversation

mtoffl01
Copy link
Contributor

@mtoffl01 mtoffl01 commented Feb 7, 2024

What does this PR do?

Publicly, this PR exposes a contrib/database/sql option to enable polling and submission of DBStats as metrics to Datadog
Ref: https://pkg.go.dev/database/sql#DBStats
This PR also lays the groundwork on the tracer package for submitting statsd payloads from other contrib integrations in the future, if desired

Motivation

Customer requests
#2303

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.

For Datadog employees:

  • If this PR touches code that handles credentials of any kind, such as Datadog API keys, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

@mtoffl01 mtoffl01 requested a review from a team as a code owner February 7, 2024 16:47
@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Feb 7, 2024
contrib/database/sql/option.go Outdated Show resolved Hide resolved
contrib/database/sql/sql.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics.go Outdated Show resolved Hide resolved
contrib/database/sql/sql.go Outdated Show resolved Hide resolved
@pr-commenter
Copy link

pr-commenter bot commented Feb 7, 2024

Benchmarks

Benchmark execution time: 2024-02-27 18:57:47

Comparing candidate commit 9523300 in PR branch mtoff/sql_metrics with baseline commit b855917 in branch main.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 39 metrics, 1 unstable metrics.

scenario:BenchmarkPartialFlushing/Disabled-24

  • 🟩 avgHeapInUse(Mb) [-6.609MB; -1.303MB] or [-10.273%; -2.025%]

@mtoffl01 mtoffl01 marked this pull request as draft February 7, 2024 17:54
…nd tracer to share stats from former to latter
internal/globalconfig/globalconfig.go Outdated Show resolved Hide resolved
internal/statsd.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
internal/statsd.go Outdated Show resolved Hide resolved
Copy link
Contributor

@katiehockman katiehockman left a comment

Choose a reason for hiding this comment

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

Overall this looks like a sound approach! I'll read over the design doc when you send it, and that'll probably help clarify things too. Nice work! 🥳

contrib/database/sql/sql.go Outdated Show resolved Hide resolved
contrib/database/sql/sql.go Outdated Show resolved Hide resolved
contrib/database/sql/option.go Show resolved Hide resolved
ddtrace/tracer/option.go Show resolved Hide resolved
internal/statsd.go Outdated Show resolved Hide resolved
internal/statsd.go Show resolved Hide resolved
internal/statsd.go Outdated Show resolved Hide resolved
Co-authored-by: Katie Hockman <katie@hockman.dev>
internal/statsd.go Outdated Show resolved Hide resolved
internal/statsd_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/metrics_test.go Outdated Show resolved Hide resolved
internal/globalconfig/globalconfig_test.go Outdated Show resolved Hide resolved
contrib/database/sql/option.go Outdated Show resolved Hide resolved
Copy link
Contributor

@katiehockman katiehockman left a comment

Choose a reason for hiding this comment

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

Just a few small comments, but otherwise looks good! We should be good to merge after this.

contrib/database/sql/sql_test.go Outdated Show resolved Hide resolved
internal/globalconfig/globalconfig_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/option.go Show resolved Hide resolved
contrib/database/sql/sql_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@katiehockman katiehockman left a comment

Choose a reason for hiding this comment

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

Since these are just test-related comments, I'll go ahead and approve and we can merge after those are addressed 😄

@katiehockman katiehockman enabled auto-merge (squash) February 27, 2024 15:10
@katiehockman katiehockman merged commit 8a989a5 into main Feb 27, 2024
155 of 157 checks passed
@katiehockman katiehockman deleted the mtoff/sql_metrics branch February 27, 2024 19:20
MaxIdleClosed = tracerPrefix + "sql.db.connections.closed.max_idle_conns"
MaxIdleTimeClosed = tracerPrefix + "sql.db.connections.closed.max_idle_time"
MaxLifetimeClosed = tracerPrefix + "sql.db.connections.closed.max_lifetime"
)
Copy link
Member

Choose a reason for hiding this comment

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

NIT: Should these be public? (if not, we could still make them private before the next release starts on Monday, cc @dianashevchenko )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there's no need for these to be public, that was just an oversight!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants