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

@opentelemetry/instrumentation-express

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-express - npm Package Compare versions

Comparing version 0.31.2 to 0.31.3

build/src/internal-types.d.ts

5

build/src/index.d.ts
export * from './instrumentation';
export { ExpressLayerType } from './enums/ExpressLayerType';
export { ExpressInstrumentationConfig } from './types';
export * from './enums/ExpressLayerType';
export * from './enums/AttributeNames';
export * from './types';
//# sourceMappingURL=index.d.ts.map

6

build/src/index.js

@@ -28,6 +28,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpressLayerType = void 0;
__exportStar(require("./instrumentation"), exports);
var ExpressLayerType_1 = require("./enums/ExpressLayerType");
Object.defineProperty(exports, "ExpressLayerType", { enumerable: true, get: function () { return ExpressLayerType_1.ExpressLayerType; } });
__exportStar(require("./enums/ExpressLayerType"), exports);
__exportStar(require("./enums/AttributeNames"), exports);
__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map
import type * as express from 'express';
import { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
/**
* This symbol is used to mark express layer as being already instrumented
* since its possible to use a given layer multiple times (ex: middlewares)
*/
export declare const kLayerPatched: unique symbol;
/** Express instrumentation for OpenTelemetry */

@@ -10,0 +5,0 @@ export declare class ExpressInstrumentation extends InstrumentationBase<typeof express> {

@@ -18,6 +18,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpressInstrumentation = exports.kLayerPatched = void 0;
exports.ExpressInstrumentation = void 0;
const core_1 = require("@opentelemetry/core");
const api_1 = require("@opentelemetry/api");
const types_1 = require("./types");
const ExpressLayerType_1 = require("./enums/ExpressLayerType");

@@ -29,7 +28,3 @@ const AttributeNames_1 = require("./enums/AttributeNames");

const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
/**
* This symbol is used to mark express layer as being already instrumented
* since its possible to use a given layer multiple times (ex: middlewares)
*/
exports.kLayerPatched = Symbol('express-layer-patched');
const internal_types_1 = require("./internal-types");
/** Express instrumentation for OpenTelemetry */

@@ -127,5 +122,5 @@ class ExpressInstrumentation extends instrumentation_1.InstrumentationBase {

// avoid patching multiple times the same layer
if (layer[exports.kLayerPatched] === true)
if (layer[internal_types_1.kLayerPatched] === true)
return;
layer[exports.kLayerPatched] = true;
layer[internal_types_1.kLayerPatched] = true;
this._wrap(layer, 'handle', (original) => {

@@ -136,3 +131,3 @@ if (original.length === 4)

utils_1.storeLayerPath(req, layerPath);
const route = req[types_1._LAYERS_STORE_PROPERTY]
const route = req[internal_types_1._LAYERS_STORE_PROPERTY]
.filter(path => path !== '/' && path !== '/*')

@@ -160,3 +155,3 @@ .join('');

if (type === ExpressLayerType_1.ExpressLayerType.MIDDLEWARE) {
req[types_1._LAYERS_STORE_PROPERTY].pop();
req[internal_types_1._LAYERS_STORE_PROPERTY].pop();
}

@@ -215,3 +210,3 @@ return original.apply(this, arguments);

if (!(req.route && arguments[0] instanceof Error)) {
req[types_1._LAYERS_STORE_PROPERTY].pop();
req[internal_types_1._LAYERS_STORE_PROPERTY].pop();
}

@@ -218,0 +213,0 @@ const callback = args[callbackIdx];

@@ -1,51 +0,5 @@

import { kLayerPatched } from './';
import type { Request } from 'express';
import { Span, SpanAttributes } from '@opentelemetry/api';
import { Span } from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { ExpressLayerType } from './enums/ExpressLayerType';
/**
* This const define where on the `request` object the Instrumentation will mount the
* current stack of express layer.
*
* It is necessary because express doesnt store the different layers
* (ie: middleware, router etc) that it called to get to the current layer.
* Given that, the only way to know the route of a given layer is to
* store the path of where each previous layer has been mounted.
*
* ex: bodyParser > auth middleware > /users router > get /:id
* in this case the stack would be: ["/users", "/:id"]
*
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
* stack: ["/api", "/v1", "/users", ":id"]
*
*/
export declare const _LAYERS_STORE_PROPERTY = "__ot_middlewares";
export declare type PatchedRequest = {
[_LAYERS_STORE_PROPERTY]?: string[];
} & Request;
export declare type PathParams = string | RegExp | Array<string | RegExp>;
export declare type ExpressRouter = {
params: {
[key: string]: string;
};
_params: string[];
caseSensitive: boolean;
mergeParams: boolean;
strict: boolean;
stack: ExpressLayer[];
};
export declare type ExpressLayer = {
handle: Function;
[kLayerPatched]?: boolean;
name: string;
params: {
[key: string]: string;
};
path: string;
regexp: RegExp;
};
export declare type LayerMetadata = {
attributes: SpanAttributes;
name: string;
};
export declare type IgnoreMatcher = string | RegExp | ((name: string) => boolean);

@@ -52,0 +6,0 @@ export declare type ExpressRequestInfo = {

@@ -18,21 +18,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports._LAYERS_STORE_PROPERTY = void 0;
const _1 = require("./");
/**
* This const define where on the `request` object the Instrumentation will mount the
* current stack of express layer.
*
* It is necessary because express doesnt store the different layers
* (ie: middleware, router etc) that it called to get to the current layer.
* Given that, the only way to know the route of a given layer is to
* store the path of where each previous layer has been mounted.
*
* ex: bodyParser > auth middleware > /users router > get /:id
* in this case the stack would be: ["/users", "/:id"]
*
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
* stack: ["/api", "/v1", "/users", ":id"]
*
*/
exports._LAYERS_STORE_PROPERTY = '__ot_middlewares';
//# sourceMappingURL=types.js.map
import { SpanAttributes } from '@opentelemetry/api';
import { ExpressLayer, PatchedRequest, ExpressInstrumentationConfig } from './types';
import { ExpressInstrumentationConfig } from './types';
import { ExpressLayerType } from './enums/ExpressLayerType';
import { ExpressLayer, PatchedRequest } from './internal-types';
/**

@@ -5,0 +6,0 @@ * Store layers path in the request to be able to construct route later

@@ -19,5 +19,5 @@ "use strict";

exports.isLayerIgnored = exports.getLayerMetadata = exports.storeLayerPath = void 0;
const types_1 = require("./types");
const ExpressLayerType_1 = require("./enums/ExpressLayerType");
const AttributeNames_1 = require("./enums/AttributeNames");
const internal_types_1 = require("./internal-types");
/**

@@ -29,4 +29,4 @@ * Store layers path in the request to be able to construct route later

const storeLayerPath = (request, value) => {
if (Array.isArray(request[types_1._LAYERS_STORE_PROPERTY]) === false) {
Object.defineProperty(request, types_1._LAYERS_STORE_PROPERTY, {
if (Array.isArray(request[internal_types_1._LAYERS_STORE_PROPERTY]) === false) {
Object.defineProperty(request, internal_types_1._LAYERS_STORE_PROPERTY, {
enumerable: false,

@@ -38,3 +38,3 @@ value: [],

return;
request[types_1._LAYERS_STORE_PROPERTY].push(value);
request[internal_types_1._LAYERS_STORE_PROPERTY].push(value);
};

@@ -41,0 +41,0 @@ exports.storeLayerPath = storeLayerPath;

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

export declare const VERSION = "0.31.2";
export declare const VERSION = "0.31.3";
//# sourceMappingURL=version.d.ts.map

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

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

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

"@types/mocha": "7.0.2",
"@types/node": "16.11.21",
"@types/node": "18.11.7",
"@types/sinon": "10.0.9",

@@ -76,3 +76,3 @@ "express": "4.17.1",

"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#readme",
"gitHead": "35226602b92a7587f16a1eb959e4f3b3948f6e9d"
"gitHead": "bd79bd04cba3f16658caf37d9a5c65e5bd5980f6"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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