Socket
Socket
Sign inDemoInstall

@google-cloud/trace-agent

Package Overview
Dependencies
Maintainers
17
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/trace-agent - npm Package Compare versions

Comparing version 2.10.0 to 2.10.1

31

build/src/plugins/plugin-http.js

@@ -33,2 +33,10 @@ "use strict";

}
/**
* Returns whether the Expect header is on the given options object.
* @param options Options for http.request.
*/
function hasExpectHeader(options) {
return !!(options.headers &&
options.headers.Expect);
}
function extractUrl(options, fallbackProtocol) {

@@ -92,2 +100,19 @@ let path;

span.addLabel(api.labels.HTTP_URL_LABEL_KEY, uri);
// If outgoing request headers contain the "Expect" header, the returned
// ClientRequest will throw an error if any new headers are added. For this
// reason, only in this scenario, we opt to clone the options object to
// inject the trace context header instead of using ClientRequest#setHeader.
// (We don't do this generally because cloning the options object is an
// expensive operation.)
let traceHeaderPreinjected = false;
if (hasExpectHeader(options)) {
traceHeaderPreinjected = true;
// "Clone" the options object -- but don't deep-clone anything except for
// headers.
options = Object.assign({}, options);
options.headers = Object.assign({}, options.headers);
// Inject the trace context header.
options.headers[api.constants.TRACE_CONTEXT_HEADER_NAME] =
span.getTraceContext();
}
const req = request(options, (res) => {

@@ -126,3 +151,2 @@ api.wrapEmitter(res);

api.wrapEmitter(req);
req.setHeader(api.constants.TRACE_CONTEXT_HEADER_NAME, span.getTraceContext());
req.on('error', error => {

@@ -133,2 +157,7 @@ span.addLabel(api.labels.ERROR_DETAILS_NAME, error.name);

});
// Inject the trace context header, but only if it wasn't already injected
// earlier.
if (!traceHeaderPreinjected) {
req.setHeader(api.constants.TRACE_CONTEXT_HEADER_NAME, span.getTraceContext());
}
return req;

@@ -135,0 +164,0 @@ };

4

package.json
{
"name": "@google-cloud/trace-agent",
"version": "2.10.0",
"version": "2.10.1",
"description": "Node.js Support for StackDriver Trace",

@@ -81,3 +81,3 @@ "main": "build/src/index.js",

"nock": "^9.1.3",
"nyc": "^11.4.1",
"nyc": "^12.0.2",
"once": "^1.4.0",

@@ -84,0 +84,0 @@ "pify": "^3.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc