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

@opentelemetry/instrumentation-http

Package Overview
Dependencies
Maintainers
3
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.51.1 to 0.52.0

3

build/src/http.d.ts

@@ -9,3 +9,3 @@ /// <reference types="node" />

*/
export declare class HttpInstrumentation extends InstrumentationBase {
export declare class HttpInstrumentation extends InstrumentationBase<HttpInstrumentationConfig> {
/** keep track on spans not ended */

@@ -18,3 +18,2 @@ private readonly _spanNotEnded;

protected _updateMetricInstruments(): void;
private _getConfig;
setConfig(config?: HttpInstrumentationConfig): void;

@@ -21,0 +20,0 @@ init(): [

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

class HttpInstrumentation extends instrumentation_1.InstrumentationBase {
constructor(config) {
constructor(config = {}) {
super('@opentelemetry/instrumentation-http', version_1.VERSION, config);

@@ -52,6 +52,3 @@ /** keep track on spans not ended */

}
_getConfig() {
return this._config;
}
setConfig(config) {
setConfig(config = {}) {
super.setConfig(config);

@@ -65,13 +62,4 @@ this._headerCapture = this._createHeaderCapture();

return new instrumentation_1.InstrumentationNodeModuleDefinition('http', ['*'], (moduleExports) => {
if ((0, instrumentation_1.isWrapped)(moduleExports.request)) {
this._unwrap(moduleExports, 'request');
}
this._wrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction('http'));
if ((0, instrumentation_1.isWrapped)(moduleExports.get)) {
this._unwrap(moduleExports, 'get');
}
this._wrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(moduleExports.request));
if ((0, instrumentation_1.isWrapped)(moduleExports.Server.prototype.emit)) {
this._unwrap(moduleExports.Server.prototype, 'emit');
}
this._wrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction('http'));

@@ -89,13 +77,4 @@ return moduleExports;

return new instrumentation_1.InstrumentationNodeModuleDefinition('https', ['*'], (moduleExports) => {
if ((0, instrumentation_1.isWrapped)(moduleExports.request)) {
this._unwrap(moduleExports, 'request');
}
this._wrap(moduleExports, 'request', this._getPatchHttpsOutgoingRequestFunction('https'));
if ((0, instrumentation_1.isWrapped)(moduleExports.get)) {
this._unwrap(moduleExports, 'get');
}
this._wrap(moduleExports, 'get', this._getPatchHttpsOutgoingGetFunction(moduleExports.request));
if ((0, instrumentation_1.isWrapped)(moduleExports.Server.prototype.emit)) {
this._unwrap(moduleExports.Server.prototype, 'emit');
}
this._wrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction('https'));

@@ -190,3 +169,3 @@ return moduleExports;

_traceClientRequest(request, span, startTime, metricAttributes) {
if (this._getConfig().requestHook) {
if (this.getConfig().requestHook) {
this._callRequestHook(span, request);

@@ -211,3 +190,3 @@ }

metricAttributes = Object.assign(metricAttributes, utils.getOutgoingRequestMetricAttributesOnResponse(responseAttributes));
if (this._getConfig().responseHook) {
if (this.getConfig().responseHook) {
this._callResponseHook(span, response);

@@ -234,4 +213,4 @@ }

span.setStatus(status);
if (this._getConfig().applyCustomAttributesOnSpan) {
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this._getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true);
if (this.getConfig().applyCustomAttributesOnSpan) {
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this.getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true);
}

@@ -293,4 +272,4 @@ this._closeHttpSpan(span, api_1.SpanKind.CLIENT, startTime, metricAttributes);

instrumentation._diag.debug(`${component} instrumentation incomingRequest`);
if (utils.isIgnored(pathname, instrumentation._getConfig().ignoreIncomingPaths, (e) => instrumentation._diag.error('caught ignoreIncomingPaths error: ', e)) ||
(0, instrumentation_1.safeExecuteInTheMiddle)(() => { var _a, _b; return (_b = (_a = instrumentation._getConfig()).ignoreIncomingRequestHook) === null || _b === void 0 ? void 0 : _b.call(_a, request); }, (e) => {
if (utils.isIgnored(pathname, instrumentation.getConfig().ignoreIncomingPaths, (e) => instrumentation._diag.error('caught ignoreIncomingPaths error: ', e)) ||
(0, instrumentation_1.safeExecuteInTheMiddle)(() => { var _a, _b; return (_b = (_a = instrumentation.getConfig()).ignoreIncomingRequestHook) === null || _b === void 0 ? void 0 : _b.call(_a, request); }, (e) => {
if (e != null) {

@@ -309,4 +288,4 @@ instrumentation._diag.error('caught ignoreIncomingRequestHook error: ', e);

component: component,
serverName: instrumentation._getConfig().serverName,
hookAttributes: instrumentation._callStartSpanHook(request, instrumentation._getConfig().startIncomingSpanHook),
serverName: instrumentation.getConfig().serverName,
hookAttributes: instrumentation._callStartSpanHook(request, instrumentation.getConfig().startIncomingSpanHook),
});

@@ -328,6 +307,6 @@ const spanOptions = {

api_1.context.bind(api_1.context.active(), response);
if (instrumentation._getConfig().requestHook) {
if (instrumentation.getConfig().requestHook) {
instrumentation._callRequestHook(span, request);
}
if (instrumentation._getConfig().responseHook) {
if (instrumentation.getConfig().responseHook) {
instrumentation._callResponseHook(span, response);

@@ -379,7 +358,7 @@ }

}
if (utils.isIgnored(origin + pathname, instrumentation._getConfig().ignoreOutgoingUrls, (e) => instrumentation._diag.error('caught ignoreOutgoingUrls error: ', e)) ||
if (utils.isIgnored(origin + pathname, instrumentation.getConfig().ignoreOutgoingUrls, (e) => instrumentation._diag.error('caught ignoreOutgoingUrls error: ', e)) ||
(0, instrumentation_1.safeExecuteInTheMiddle)(() => {
var _a, _b;
return (_b = (_a = instrumentation
._getConfig()).ignoreOutgoingRequestHook) === null || _b === void 0 ? void 0 : _b.call(_a, optionsParsed);
.getConfig()).ignoreOutgoingRequestHook) === null || _b === void 0 ? void 0 : _b.call(_a, optionsParsed);
}, (e) => {

@@ -397,3 +376,3 @@ if (e != null) {

hostname,
hookAttributes: instrumentation._callStartSpanHook(optionsParsed, instrumentation._getConfig().startOutgoingSpanHook),
hookAttributes: instrumentation._callStartSpanHook(optionsParsed, instrumentation.getConfig().startOutgoingSpanHook),
});

@@ -451,4 +430,4 @@ const startTime = (0, core_1.hrTime)();

}
if (this._getConfig().applyCustomAttributesOnSpan) {
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this._getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true);
if (this.getConfig().applyCustomAttributesOnSpan) {
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this.getConfig().applyCustomAttributesOnSpan(span, request, response), () => { }, true);
}

@@ -467,4 +446,4 @@ this._closeHttpSpan(span, api_1.SpanKind.SERVER, startTime, metricAttributes);

const requireParent = options.kind === api_1.SpanKind.CLIENT
? this._getConfig().requireParentforOutgoingSpans
: this._getConfig().requireParentforIncomingSpans;
? this.getConfig().requireParentforOutgoingSpans
: this.getConfig().requireParentforIncomingSpans;
let span;

@@ -500,6 +479,6 @@ const currentSpan = api_1.trace.getSpan(ctx);

_callResponseHook(span, response) {
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this._getConfig().responseHook(span, response), () => { }, true);
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this.getConfig().responseHook(span, response), () => { }, true);
}
_callRequestHook(span, request) {
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this._getConfig().requestHook(span, request), () => { }, true);
(0, instrumentation_1.safeExecuteInTheMiddle)(() => this.getConfig().requestHook(span, request), () => { }, true);
}

@@ -513,3 +492,3 @@ _callStartSpanHook(request, hookFunc) {

var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
const config = this._getConfig();
const config = this.getConfig();
return {

@@ -516,0 +495,0 @@ client: {

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

export declare const VERSION = "0.51.1";
export declare const VERSION = "0.52.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.51.1';
exports.VERSION = '0.52.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/instrumentation-http",
"version": "0.51.1",
"description": "OpenTelemetry http/https automatic instrumentation package.",
"version": "0.52.0",
"description": "OpenTelemetry instrumentation for `node:http` and `node:https` http client and server modules",
"main": "build/src/index.js",

@@ -21,3 +21,4 @@ "types": "build/src/index.d.ts",

"prewatch": "node ../../../scripts/version-update.js",
"peer-api-check": "node ../../../scripts/peer-api-check.js"
"peer-api-check": "node ../../../scripts/peer-api-check.js",
"align-api-deps": "node ../../../scripts/align-api-deps.js"
},

@@ -49,13 +50,13 @@ "keywords": [

"devDependencies": {
"@opentelemetry/api": "1.8.0",
"@opentelemetry/context-async-hooks": "1.24.1",
"@opentelemetry/sdk-metrics": "1.24.1",
"@opentelemetry/sdk-trace-base": "1.24.1",
"@opentelemetry/sdk-trace-node": "1.24.1",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/context-async-hooks": "1.25.0",
"@opentelemetry/sdk-metrics": "1.25.0",
"@opentelemetry/sdk-trace-base": "1.25.0",
"@opentelemetry/sdk-trace-node": "1.25.0",
"@types/mocha": "10.0.6",
"@types/node": "18.6.5",
"@types/request-promise-native": "1.0.21",
"@types/semver": "7.5.6",
"@types/sinon": "10.0.20",
"@types/superagent": "4.1.24",
"@types/semver": "7.5.8",
"@types/sinon": "17.0.3",
"@types/superagent": "8.1.7",
"axios": "1.6.0",

@@ -71,3 +72,3 @@ "codecov": "3.8.3",

"sinon": "15.1.2",
"superagent": "8.0.9",
"superagent": "9.0.2",
"ts-mocha": "10.0.0",

@@ -80,5 +81,5 @@ "typescript": "4.4.4"

"dependencies": {
"@opentelemetry/core": "1.24.1",
"@opentelemetry/instrumentation": "0.51.1",
"@opentelemetry/semantic-conventions": "1.24.1",
"@opentelemetry/core": "1.25.0",
"@opentelemetry/instrumentation": "0.52.0",
"@opentelemetry/semantic-conventions": "1.25.0",
"semver": "^7.5.2"

@@ -88,3 +89,3 @@ },

"sideEffects": false,
"gitHead": "41c2626fe0ed03e2e83bd79ee43c9bdf0ffd80d8"
"gitHead": "c4d3351b6b3f5593c8d7cbfec97b45cea9fe1511"
}

@@ -19,2 +19,6 @@ # OpenTelemetry HTTP and HTTPS Instrumentation for Node.js

## Supported Versions
- Nodejs `>=14`
## Usage

@@ -78,28 +82,28 @@

| Attribute | Short Description | Notes |
| ------------------------------------------- | ------------------------------------------------------------------------------ | --------------------------------------------------------- |
| `ip_tcp` | Transport protocol used | Key: `NETTRANSPORTVALUES_IP_TCP` |
| `ip_udp` | Transport protocol used | Key: `NETTRANSPORTVALUES_IP_UDP` |
| `http.client_ip` | The IP address of the original client behind all proxies, if known | Key: `SEMATTRS_HTTP_CLIENT_IP` |
| `http.flavor` | Kind of HTTP protocol used | Key: `SEMATTRS_HTTP_FLAVOR` |
| `http.host` | The value of the HTTP host header | Key: `SEMATTRS_HTTP_HOST` |
| `http.method` | HTTP request method | Key: `SEMATTRS_HTTP_METHOD` |
| `http.request_content_length` | The size of the request payload body in bytes | Key: `SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH` |
| `http.request_content_length_uncompressed` | The size of the uncompressed request payload body after transport decoding | Key: `SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED` |
| `http.response_content_length` | The size of the response payload body in bytes | Key: `SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH` |
| `http.response_content_length_uncompressed` | The size of the uncompressed response payload body after transport decoding | Key: `SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED` |
| `http.route` | The matched route (path template). | Key: `SEMATTRS_HTTP_ROUTE` |
| `http.scheme` | The URI scheme identifying the used protocol | Key: `SEMATTRS_HTTP_SCHEME` |
| `http.server_name` | The primary server name of the matched virtual host | Key: `SEMATTRS_HTTP_SERVER_NAME` |
| `http.status_code` | HTTP response status code | Key: `SEMATTRS_HTTP_STATUS_CODE` |
| `http.target` | The full request target as passed in a HTTP request line or equivalent | Key: `SEMATTRS_HTTP_TARGET` |
| `http.url` | Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]` | Key: `SEMATTRS_HTTP_URL` |
| `http.user_agent` | Value of the HTTP User-Agent header sent by the client | Key: `SEMATTRS_HTTP_USER_AGENT` |
| `net.host.ip` | Like net.peer.ip but for the host IP. Useful in case of a multi-IP host | Key: `SEMATTRS_NET_HOST_IP` |
| `net.host.name` | Local hostname or similar | Key: `SEMATTRS_NET_HOST_NAME` |
| `net.host.port` | Like net.peer.port but for the host port | Key: `SEMATTRS_NET_HOST_PORT` |
| `net.peer.ip.` | Remote address of the peer (dotted decimal for IPv4 or RFC5952 for IPv6) | Key: `SEMATTRS_NET_PEER_IP` |
| `net.peer.name` | Remote hostname or similar | Key: `SEMATTRS_NET_PEER_NAME` |
| `net.peer.port` | Remote port number | Key: `SEMATTRS_NET_PEER_PORT` |
| `net.transport` | Transport protocol used | Key: `SEMATTRS_NET_TRANSPORT` |
| Attribute | Short Description |
| ------------------------------------------- | ------------------------------------------------------------------------------ |
| `ip_tcp` | Transport protocol used |
| `ip_udp` | Transport protocol used |
| `http.client_ip` | The IP address of the original client behind all proxies, if known |
| `http.flavor` | Kind of HTTP protocol used |
| `http.host` | The value of the HTTP host header |
| `http.method` | HTTP request method |
| `http.request_content_length` | The size of the request payload body in bytes |
| `http.request_content_length_uncompressed` | The size of the uncompressed request payload body after transport decoding |
| `http.response_content_length` | The size of the response payload body in bytes |
| `http.response_content_length_uncompressed` | The size of the uncompressed response payload body after transport decoding |
| `http.route` | The matched route (path template). |
| `http.scheme` | The URI scheme identifying the used protocol |
| `http.server_name` | The primary server name of the matched virtual host |
| `http.status_code` | HTTP response status code |
| `http.target` | The full request target as passed in a HTTP request line or equivalent |
| `http.url` | Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]` |
| `http.user_agent` | Value of the HTTP User-Agent header sent by the client |
| `net.host.ip` | Like net.peer.ip but for the host IP. Useful in case of a multi-IP host |
| `net.host.name` | Local hostname or similar |
| `net.host.port` | Like net.peer.port but for the host port |
| `net.peer.ip.` | Remote address of the peer (dotted decimal for IPv4 or RFC5952 for IPv6) |
| `net.peer.name` | Remote hostname or similar |
| `net.peer.port` | Remote port number |
| `net.transport` | Transport protocol used |

@@ -106,0 +110,0 @@ ## Useful links

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