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

fix(instrumentation-pg): ensure db.client.operation.duration metric is recorded for Promises API usage of pg #2480

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trentm
Copy link
Contributor

@trentm trentm commented Oct 11, 2024

Refs: #2380


While working on pg tests in #2464 I accidentally noticed that the duration metric added to instr-pg in #2380 didn't work if the Promises API of the pg client was used.

@trentm trentm self-assigned this Oct 11, 2024
@trentm trentm requested a review from a team as a code owner October 11, 2024 20:47
@trentm trentm requested a review from maryliag October 11, 2024 20:47
@@ -277,6 +277,7 @@ describe('pg-pool', () => {
await client.query('SELECT NOW()');
} finally {
client.release();
await newPool.end();
Copy link
Contributor Author

@trentm trentm Oct 11, 2024

Choose a reason for hiding this comment

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

reviewer note: This is an unrelated change. It fixes a few-second hang in the test file completing (presumably on a pool connection timeout).

Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.73%. Comparing base (d11efb3) to head (5a7e89a).

Files with missing lines Patch % Lines
...elemetry-instrumentation-pg/src/instrumentation.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2480      +/-   ##
==========================================
- Coverage   90.74%   90.73%   -0.02%     
==========================================
  Files         156      156              
  Lines        7723     7725       +2     
  Branches     1588     1588              
==========================================
+ Hits         7008     7009       +1     
- Misses        715      716       +1     
Files with missing lines Coverage Δ
...elemetry-instrumentation-pg/src/instrumentation.ts 89.20% <50.00%> (-0.46%) ⬇️

@trentm
Copy link
Contributor Author

trentm commented Oct 11, 2024

The codecov issue is that the recordDuration() call in the promise rejection case wasn't covered. Meh.

const metrics = resourceMetrics.scopeMetrics[0].metrics;
assert.strictEqual(
metrics[0].descriptor.name,
'db.client.operation.duration'
Copy link
Contributor

Choose a reason for hiding this comment

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

@maryliag
Copy link
Contributor

That was an awesome catch! Thanks for finding and fixing it!

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

a little nit, otherwise LGTM

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.

2 participants