perf(http): load the GCP pubsub push plugin lazily#9178
Conversation
Overall package sizeSelf size: 6.44 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 32db337 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-01 16:42:22 Comparing candidate commit 32db337 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2254 metrics, 32 unstable metrics.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9178 +/- ##
==========================================
- Coverage 93.74% 93.73% -0.01%
==========================================
Files 895 895
Lines 51399 51396 -3
Branches 11980 11980
==========================================
- Hits 48182 48178 -4
- Misses 3217 3218 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The http plugin requires datadog-plugin-google-cloud-pubsub's pubsub-push-subscription module at the top of its own file, so every process that instruments http pulls in that plugin graph even though it is only used on GCP Cloud Run (K_SERVICE set and DD_TRACE_GCP_PUBSUB_PUSH_ENABLED not opted out). Moving the require inside the existing gate keeps the module — and its transitive graph — out of the startup path for every other deployment. Drive-by fix: * Drop the try/catch around the require: the pubsub plugin ships with the tracer, so this require cannot fail independently of the tracer's own load.
71b92f1 to
32db337
Compare
but there is no try catch now, is there? |
|
@juan-fernandez outdated description :) |
The http plugin requires datadog-plugin-google-cloud-pubsub's pubsub-push-subscription module at the top of its own file, so every process that instruments http pulls in that plugin graph even though it is only used on GCP Cloud Run (K_SERVICE set and DD_TRACE_GCP_PUBSUB_PUSH_ENABLED not opted out). Moving the require inside the existing gate keeps the module — and its transitive graph — out of the startup path for every other deployment. Drive-by fix: * Drop the try/catch around the require: the pubsub plugin ships with the tracer, so this require cannot fail independently of the tracer's own load.
The http plugin requires datadog-plugin-google-cloud-pubsub's pubsub-push-subscription module at the top of its own file, so every process that instruments http pulls in that plugin graph even though it is only used on GCP Cloud Run (K_SERVICE set and DD_TRACE_GCP_PUBSUB_PUSH_ENABLED not opted out). Moving the require inside the existing gate keeps the module — and its transitive graph — out of the startup path for every other deployment. Drive-by fix: * Drop the try/catch around the require: the pubsub plugin ships with the tracer, so this require cannot fail independently of the tracer's own load.
The http plugin requires datadog-plugin-google-cloud-pubsub's pubsub-push-subscription module at the top of its own file, so every process that instruments http pulls in that plugin graph even though it is only used on GCP Cloud Run (K_SERVICE set and DD_TRACE_GCP_PUBSUB_PUSH_ENABLED not opted out). Moving the require inside the existing gate keeps the module — and its transitive graph — out of the startup path for every other deployment. Drive-by fix: * Drop the try/catch around the require: the pubsub plugin ships with the tracer, so this require cannot fail independently of the tracer's own load.
Summary
The http plugin required
datadog-plugin-google-cloud-pubsub'spubsub-push-subscriptionmodule at the top ofpackages/datadog-plugin-http/src/index.js. Because http is instrumented in almost every service, that pulled the pubsub plugin graph into the startup path of every process — even though the plugin is only used on GCP Cloud Run (K_SERVICEset andDD_TRACE_GCP_PUBSUB_PUSH_ENABLEDnot opted out).Moving the
requireinside the existingenableGCPPubSubPushSubscription()gate keeps the module and its transitive graph out of startup for every non-GCP-Cloud-Run deployment.Test plan
packages/datadog-plugin-http/test/index.spec.js— new: asserts the pubsub module is absent fromrequire.cacheafter readingHttpPlugin.pluginswith the GCP push gate off (fails on the eager-require shape), and that it loads first when the gate is on.catchlog isistanbul ignored.httpplugin CI job (PLUGINS: http, globstest/**/*.spec.js).