Socket
Socket
Sign inDemoInstall

@opencensus/instrumentation-http

Package Overview
Dependencies
Maintainers
7
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencensus/instrumentation-http - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

8

build/src/http.d.ts

@@ -18,3 +18,4 @@ /**

import { BasePlugin, Func, SpanKind, TagMap } from '@opencensus/core';
import { ClientRequest, IncomingMessage, request } from 'http';
import { ClientRequest, IncomingMessage, request, RequestOptions } from 'http';
import * as url from 'url';
import { IgnoreMatcher } from './types';

@@ -80,4 +81,9 @@ export declare type HttpGetCallback = (res: IncomingMessage) => void;

static recordStats(kind: SpanKind, tags: TagMap, ms: number): void;
/**
* Returns whether the Expect header is on the given options object.
* @param options Options for http.request.
*/
hasExpectHeader(options: RequestOptions | url.URL): boolean;
}
declare const plugin: HttpPlugin;
export { plugin };

@@ -31,2 +31,3 @@ "use strict";

};
const TAG_VALUE_MAX_LENGTH = 255;
/** Http instrumentation plugin for Opencensus */

@@ -178,3 +179,6 @@ class HttpPlugin extends core_1.BasePlugin {

rootSpan.addAttribute(HttpPlugin.ATTRIBUTE_HTTP_ROUTE, requestUrl.path || '');
tags.set(stats.HTTP_SERVER_ROUTE, { value: requestUrl.path || '' }, UNLIMITED_PROPAGATION_MD);
tags.set(stats.HTTP_SERVER_ROUTE, {
value: (requestUrl.path ||
'').substring(0, TAG_VALUE_MAX_LENGTH)
}, UNLIMITED_PROPAGATION_MD);
}

@@ -256,3 +260,3 @@ if (userAgent) {

plugin.logger.debug('outgoingRequest starting a child span');
const span = plugin.tracer.startChildSpan(traceOptions.name, traceOptions.kind);
const span = plugin.tracer.startChildSpan({ name: traceOptions.name, kind: traceOptions.kind });
return (plugin.getMakeRequestTraceFunction(request, options, plugin))(span);

@@ -279,3 +283,12 @@ }

setHeader(name, value) {
request.setHeader(name, value);
// If outgoing request headers contain the "Expect" header, the
// returned ClientRequest will throw an error if any new headers are
// added. We need to set the header directly in the headers object
// which has been cloned earlier.
if (plugin.hasExpectHeader(options) && options.headers) {
options.headers[name] = value;
}
else {
request.setHeader(name, value);
}
}

@@ -285,2 +298,10 @@ };

if (propagation) {
// If outgoing request headers contain the "Expect" header, the returned
// ClientRequest will throw an error if any new headers are added.
// So we need to clone the options object to be able to inject new
// header.
if (plugin.hasExpectHeader(options)) {
options = Object.assign({}, options);
options.headers = Object.assign({}, options.headers);
}
propagation.inject(setter, span.spanContext);

@@ -389,2 +410,10 @@ }

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

@@ -391,0 +420,0 @@ /**

8

package.json
{
"name": "@opencensus/instrumentation-http",
"version": "0.0.11",
"version": "0.0.12",
"description": "Opencensus http automatic instrumentation package.",

@@ -59,5 +59,5 @@ "main": "build/src/index.js",

"gts": "^0.9.0",
"mocha": "^6.0.0",
"mocha": "^6.1.0",
"nock": "^10.0.0",
"nyc": "^13.0.0",
"nyc": "^14.0.0",
"rimraf": "^2.6.2",

@@ -69,3 +69,3 @@ "ts-mocha": "^6.0.0",

"dependencies": {
"@opencensus/core": "^0.0.11",
"@opencensus/core": "^0.0.12",
"semver": "^6.0.0",

@@ -72,0 +72,0 @@ "shimmer": "^1.2.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