Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/instrumentation-http

Package Overview
Dependencies
Maintainers
4
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-http - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

16

build/src/http.js

@@ -190,3 +190,3 @@ "use strict";

}
this.tracer.bind(response);
api_1.context.bind(response);
this._logger.debug('outgoingRequest on response()');

@@ -240,3 +240,7 @@ response.on('end', () => {

if (utils.isIgnored(pathname, instrumentation._getConfig().ignoreIncomingPaths, (e) => instrumentation._logger.error('caught ignoreIncomingPaths error: ', e))) {
return original.apply(this, [event, ...args]);
return api_1.context.with(api_1.suppressInstrumentation(api_1.context.active()), () => {
api_1.context.bind(request);
api_1.context.bind(response);
return original.apply(this, [event, ...args]);
});
}

@@ -253,3 +257,3 @@ const headers = request.headers;

const span = instrumentation._startHttpSpan(`${component.toLocaleUpperCase()} ${method}`, spanOptions);
return instrumentation.tracer.withSpan(span, () => {
return api_1.context.with(api_1.setSpan(api_1.context.active(), span), () => {
api_1.context.bind(request);

@@ -329,3 +333,3 @@ api_1.context.bind(response);

}
api_1.propagation.inject(api_1.setActiveSpan(api_1.context.active(), span), optionsParsed.headers);
api_1.propagation.inject(api_1.setSpan(api_1.context.active(), span), optionsParsed.headers);
const request = instrumentation_1.safeExecuteInTheMiddle(() => original.apply(this, [optionsParsed, ...args]), error => {

@@ -339,3 +343,3 @@ if (error) {

instrumentation._logger.debug('%s instrumentation outgoingRequest', component);
instrumentation.tracer.bind(request);
api_1.context.bind(request);
return instrumentation._traceClientRequest(component, request, optionsParsed, span);

@@ -353,3 +357,3 @@ };

let span;
const currentSpan = this.tracer.getCurrentSpan();
const currentSpan = api_1.getSpan(api_1.context.active());
if (requireParent === true && currentSpan === undefined) {

@@ -356,0 +360,0 @@ // TODO: Refactor this when a solution is found in

@@ -44,2 +44,15 @@ /// <reference types="node" />

/**
* Adds attributes for request content-length and content-encoding HTTP headers
* @param { IncomingMessage } Request object whose headers will be analyzed
* @param { Attributes } Attributes object to be modified
*/
export declare const setRequestContentLengthAttribute: (request: IncomingMessage, attributes: Attributes) => void;
/**
* Adds attributes for response content-length and content-encoding HTTP headers
* @param { IncomingMessage } Response object whose headers will be analyzed
* @param { Attributes } Attributes object to be modified
*/
export declare const setResponseContentLengthAttribute: (response: IncomingMessage, attributes: Attributes) => void;
export declare const isCompressed: (headers: OutgoingHttpHeaders | IncomingHttpHeaders) => boolean;
/**
* Makes sure options is an url object

@@ -46,0 +59,0 @@ * return an object with default value and parsed options

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIncomingRequestAttributesOnResponse = exports.getIncomingRequestAttributes = exports.getOutgoingRequestAttributesOnResponse = exports.getAttributesFromHttpKind = exports.getOutgoingRequestAttributes = exports.isValidOptionsType = exports.getRequestInfo = exports.setSpanWithError = exports.isIgnored = exports.satisfiesPattern = exports.hasExpectHeader = exports.parseResponseStatus = exports.getAbsoluteUrl = void 0;
exports.getIncomingRequestAttributesOnResponse = exports.getIncomingRequestAttributes = exports.getOutgoingRequestAttributesOnResponse = exports.getAttributesFromHttpKind = exports.getOutgoingRequestAttributes = exports.isValidOptionsType = exports.getRequestInfo = exports.isCompressed = exports.setResponseContentLengthAttribute = exports.setRequestContentLengthAttribute = exports.setSpanWithError = exports.isIgnored = exports.satisfiesPattern = exports.hasExpectHeader = exports.parseResponseStatus = exports.getAbsoluteUrl = void 0;
/*

@@ -141,2 +141,47 @@ * Copyright The OpenTelemetry Authors

/**
* Adds attributes for request content-length and content-encoding HTTP headers
* @param { IncomingMessage } Request object whose headers will be analyzed
* @param { Attributes } Attributes object to be modified
*/
exports.setRequestContentLengthAttribute = (request, attributes) => {
const length = getContentLength(request.headers);
if (length === null)
return;
if (exports.isCompressed(request.headers)) {
attributes[semantic_conventions_1.HttpAttribute.HTTP_REQUEST_CONTENT_LENGTH] = length;
}
else {
attributes[semantic_conventions_1.HttpAttribute.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED] = length;
}
};
/**
* Adds attributes for response content-length and content-encoding HTTP headers
* @param { IncomingMessage } Response object whose headers will be analyzed
* @param { Attributes } Attributes object to be modified
*/
exports.setResponseContentLengthAttribute = (response, attributes) => {
const length = getContentLength(response.headers);
if (length === null)
return;
if (exports.isCompressed(response.headers)) {
attributes[semantic_conventions_1.HttpAttribute.HTTP_RESPONSE_CONTENT_LENGTH] = length;
}
else {
attributes[semantic_conventions_1.HttpAttribute.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED] = length;
}
};
function getContentLength(headers) {
const contentLengthHeader = headers['content-length'];
if (contentLengthHeader === undefined)
return null;
const contentLength = parseInt(contentLengthHeader, 10);
if (isNaN(contentLength))
return null;
return contentLength;
}
exports.isCompressed = (headers) => {
const encoding = headers['content-encoding'];
return !!encoding && encoding !== 'identity';
};
/**
* Makes sure options is an url object

@@ -265,2 +310,3 @@ * return an object with default value and parsed options

};
exports.setResponseContentLengthAttribute(response, attributes);
if (statusCode) {

@@ -308,2 +354,3 @@ attributes[semantic_conventions_1.HttpAttribute.HTTP_STATUS_CODE] = statusCode;

}
exports.setRequestContentLengthAttribute(request, attributes);
const httpKindAttributes = exports.getAttributesFromHttpKind(httpVersion);

@@ -310,0 +357,0 @@ return Object.assign(attributes, httpKindAttributes);

@@ -1,2 +0,2 @@

export declare const VERSION = "0.14.0";
export declare const VERSION = "0.15.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.14.0';
exports.VERSION = '0.15.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/instrumentation-http",
"version": "0.14.0",
"version": "0.15.0",
"description": "OpenTelemetry http/https automatic instrumentation package.",

@@ -9,13 +9,11 @@ "main": "build/src/index.js",

"scripts": {
"compile": "tsc --build",
"clean": "tsc --build --clean",
"test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts",
"tdd": "npm run test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"precompile": "tsc --version",
"version:update": "node ../../scripts/version-update.js",
"compile": "npm run version:update && tsc -p .",
"prepare": "npm run compile",
"watch": "tsc -w"
"version": "node ../../scripts/version-update.js",
"watch": "tsc --build --watch"
},

@@ -47,14 +45,14 @@ "keywords": [

"devDependencies": {
"@opentelemetry/context-async-hooks": "^0.14.0",
"@opentelemetry/context-base": "^0.14.0",
"@opentelemetry/node": "^0.14.0",
"@opentelemetry/tracing": "^0.14.0",
"@opentelemetry/context-async-hooks": "^0.15.0",
"@opentelemetry/context-base": "^0.15.0",
"@opentelemetry/node": "^0.15.0",
"@opentelemetry/tracing": "^0.15.0",
"@types/got": "9.6.11",
"@types/mocha": "8.2.0",
"@types/node": "14.14.12",
"@types/node": "14.14.20",
"@types/request-promise-native": "1.0.17",
"@types/semver": "7.3.4",
"@types/sinon": "9.0.9",
"@types/sinon": "9.0.10",
"@types/superagent": "4.1.10",
"axios": "0.21.0",
"axios": "0.21.1",
"codecov": "3.8.1",

@@ -69,3 +67,3 @@ "got": "9.6.0",

"rimraf": "3.0.2",
"sinon": "9.2.2",
"sinon": "9.2.3",
"superagent": "6.1.0",

@@ -77,9 +75,9 @@ "ts-mocha": "8.0.0",

"dependencies": {
"@opentelemetry/api": "^0.14.0",
"@opentelemetry/core": "^0.14.0",
"@opentelemetry/instrumentation": "^0.14.0",
"@opentelemetry/semantic-conventions": "^0.14.0",
"@opentelemetry/api": "^0.15.0",
"@opentelemetry/core": "^0.15.0",
"@opentelemetry/instrumentation": "^0.15.0",
"@opentelemetry/semantic-conventions": "^0.15.0",
"semver": "^7.1.3"
},
"gitHead": "27a8d4530c56257c191468b073669909bf8892a1"
"gitHead": "960b868f5b7686eabbf49190071b8463551e5d8f"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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