Skip to content

fix: Publish request finish on close or finish, but only once for a r… #2625

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

Merged
merged 3 commits into from
Dec 22, 2022

Conversation

astuyve
Copy link
Collaborator

@astuyve astuyve commented Dec 19, 2022

…equest. Use weakset to ensure idempotency.

What does this PR do?

Closes DataDog/serverless-plugin-datadog#324

Motivation

Popular serverless-specific libraries which implement express don't emit close events, however they do emit finish.
This behavior was changed here, and we do not want to revert this as close also represents the end of a request, and there are cases where it's correct to emit close but not finish (eg: client disconnects midway through receiving a response).

This change introduces a weakset to track whether we've received close or finish for a given request, and only emit on the first occurrence.

Plugin Checklist

Additional Notes

@astuyve astuyve requested a review from a team as a code owner December 19, 2022 18:59
@codecov
Copy link

codecov bot commented Dec 19, 2022

Codecov Report

Merging #2625 (0f96242) into master (c92bd5a) will decrease coverage by 0.12%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2625      +/-   ##
==========================================
- Coverage   89.00%   88.88%   -0.13%     
==========================================
  Files         298      288      -10     
  Lines       10381    10135     -246     
  Branches       33       33              
==========================================
- Hits         9240     9008     -232     
+ Misses       1141     1127      -14     
Impacted Files Coverage Δ
...ckages/datadog-instrumentations/src/http/server.js 93.93% <100.00%> (+0.39%) ⬆️
packages/datadog-instrumentations/src/rhea.js
packages/datadog-plugin-amqp10/src/index.js
packages/datadog-plugin-amqp10/src/consumer.js
packages/datadog-instrumentations/src/amqp10.js
packages/datadog-plugin-rhea/src/consumer.js
packages/datadog-instrumentations/src/promise.js
packages/datadog-plugin-rhea/src/index.js
packages/datadog-plugin-rhea/src/producer.js
packages/datadog-plugin-amqp10/src/util.js
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pr-commenter
Copy link

pr-commenter bot commented Dec 19, 2022

Benchmarks

Comparing candidate commit 0f96242 in PR branch aj/fix-http-close-error with baseline commit c92bd5a in branch master.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 965 cases.

@Qard Qard merged commit 095a694 into master Dec 22, 2022
@Qard Qard deleted the aj/fix-http-close-error branch December 22, 2022 20:30
Qard pushed a commit that referenced this pull request Dec 22, 2022
#2625)

* fix: Publish request finish on close or finish, but only once for a request. Use weakset to ensure idempotency.

* feat: Store response, not request, in finishedSet

* feat: lint
Qard pushed a commit that referenced this pull request Dec 22, 2022
#2625)

* fix: Publish request finish on close or finish, but only once for a request. Use weakset to ensure idempotency.

* feat: Store response, not request, in finishedSet

* feat: lint
Qard pushed a commit that referenced this pull request Dec 23, 2022
#2625)

* fix: Publish request finish on close or finish, but only once for a request. Use weakset to ensure idempotency.

* feat: Store response, not request, in finishedSet

* feat: lint
juan-fernandez pushed a commit that referenced this pull request Jan 3, 2023
#2625)

* fix: Publish request finish on close or finish, but only once for a request. Use weakset to ensure idempotency.

* feat: Store response, not request, in finishedSet

* feat: lint
juan-fernandez pushed a commit that referenced this pull request Jan 4, 2023
#2625)

* fix: Publish request finish on close or finish, but only once for a request. Use weakset to ensure idempotency.

* feat: Store response, not request, in finishedSet

* feat: lint
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.

express.request and pg.query APM missing after node 16 upgrade.
4 participants