Comments (2)
Here is a patch which adds agent
option to Libhoney.
diff --git a/node_modules/libhoney/dist/libhoney.cjs.js b/node_modules/libhoney/dist/libhoney.cjs.js
index 9249824..9a4bb0b 100644
--- a/node_modules/libhoney/dist/libhoney.cjs.js
+++ b/node_modules/libhoney/dist/libhoney.cjs.js
@@ -443,6 +443,7 @@ class Transmission {
this._userAgentAddition = options.userAgentAddition || "";
this._proxy = options.proxy;
+ this._agent = options.agent;
// Included for testing; to stub out randomness and verify that an event
// was dropped.
@@ -565,6 +566,11 @@ class Transmission {
userAgent = `${LIBHONEY_VERSION} ${trimmedAddition} ${NODE_VERSION}`;
}
+ let agent = typeof this._agent === "function" ? this._agent() : this._agent;
+ if (agent) {
+ req.agent(agent);
+ }
+
let start = Date.now();
req
.set("X-Honeycomb-Team", batch.writeKey)
Usage:
new Libhoney({ ..., agent: new https.Agent({ keepAlive: true, maxSockets: 10 })});
Works very well, dropped the rate of new HTTPS connections dramatically for us.
from libhoney-js.
Hi @dko-slapdash - thanks for the creating the issue and proposing a solution.
I generally like what you've suggested. I'm a little wary of allowing a user to provide their own custom agent as it they could accidentally use the wrong implementation (http vs https) for their destination URL. However, I think good documentation here would help.
An alternative solution would be to expose discrete options for keepalive and maxsockets and we create the agent, but then we'd need to pick a default maxsockets if one isn't set which could also be tricky.
Please could you create a PR with your suggestion, and we can iterate from there. Thanks 👍
from libhoney-js.
Related Issues (20)
- v2.2.2 does not include the compiled code, and crashes the process when required HOT 1
- Add support for use in conjunction with the AWS extension HOT 1
- Drop support for Node 8
- No-yarn engine requirement breaks use as dependency HOT 5
- Retry once on send timeout
- Update for E&S
- Example app is checked in CI HOT 1
- Add type declaration file
- Add TypeScript to project
- Type declaration file is checked in CI
- Date range picker issues HOT 1
- Drop support for node versions that are no longer security supported.
- Add node version to the user-agent header
- sec: critical vulnerability in transitive dep vm2 (via superagent-proxy) HOT 2
- dependencies upgrade of module superagent due to a public vulnerability HOT 2
- 'User-Agent' header console error in Browser (detect if in browser and avoid setting UA) HOT 1
- Queued responses aren't garbage collected, leaking memory HOT 4
- When transmission is set to console, allow the writekey to be undefined / empty string
- Typescript types? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libhoney-js.