@opentelemetry/instrumentation-express 0.31.2 → 0.31.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/index.d.ts +3 -2
- package/build/src/index.js +3 -3
- package/build/src/index.js.map +1 -1
- package/build/src/instrumentation.d.ts +0 -5
- package/build/src/instrumentation.js +7 -12
- package/build/src/instrumentation.js.map +1 -1
- package/build/src/internal-types.d.ts +53 -0
- package/build/src/internal-types.js +41 -0
- package/build/src/internal-types.js.map +1 -0
- package/build/src/types.d.ts +1 -47
- package/build/src/types.js +0 -19
- package/build/src/types.js.map +1 -1
- package/build/src/utils.d.ts +2 -1
- package/build/src/utils.js +4 -4
- package/build/src/utils.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/package.json +3 -3
package/build/src/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './instrumentation';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export * from './enums/ExpressLayerType';
|
|
3
|
+
export * from './enums/AttributeNames';
|
|
4
|
+
export * from './types';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.js
CHANGED
|
@@ -25,8 +25,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
25
25
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.ExpressLayerType = void 0;
|
|
29
28
|
__exportStar(require("./instrumentation"), exports);
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
__exportStar(require("./enums/ExpressLayerType"), exports);
|
|
30
|
+
__exportStar(require("./enums/AttributeNames"), exports);
|
|
31
|
+
__exportStar(require("./types"), exports);
|
|
32
32
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,oDAAkC;AAClC,2DAAyC;AACzC,yDAAuC;AACvC,0CAAwB"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type * as express from 'express';
|
|
2
2
|
import { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';
|
|
3
3
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
4
|
-
/**
|
|
5
|
-
* This symbol is used to mark express layer as being already instrumented
|
|
6
|
-
* since its possible to use a given layer multiple times (ex: middlewares)
|
|
7
|
-
*/
|
|
8
|
-
export declare const kLayerPatched: unique symbol;
|
|
9
4
|
/** Express instrumentation for OpenTelemetry */
|
|
10
5
|
export declare class ExpressInstrumentation extends InstrumentationBase<typeof express> {
|
|
11
6
|
constructor(config?: ExpressInstrumentationConfig);
|
|
@@ -15,21 +15,16 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ExpressInstrumentation =
|
|
18
|
+
exports.ExpressInstrumentation = void 0;
|
|
19
19
|
const core_1 = require("@opentelemetry/core");
|
|
20
20
|
const api_1 = require("@opentelemetry/api");
|
|
21
|
-
const types_1 = require("./types");
|
|
22
21
|
const ExpressLayerType_1 = require("./enums/ExpressLayerType");
|
|
23
22
|
const AttributeNames_1 = require("./enums/AttributeNames");
|
|
24
23
|
const utils_1 = require("./utils");
|
|
25
24
|
const version_1 = require("./version");
|
|
26
25
|
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
27
26
|
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
28
|
-
|
|
29
|
-
* This symbol is used to mark express layer as being already instrumented
|
|
30
|
-
* since its possible to use a given layer multiple times (ex: middlewares)
|
|
31
|
-
*/
|
|
32
|
-
exports.kLayerPatched = Symbol('express-layer-patched');
|
|
27
|
+
const internal_types_1 = require("./internal-types");
|
|
33
28
|
/** Express instrumentation for OpenTelemetry */
|
|
34
29
|
class ExpressInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
35
30
|
constructor(config = {}) {
|
|
@@ -122,15 +117,15 @@ class ExpressInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
122
117
|
_applyPatch(layer, layerPath) {
|
|
123
118
|
const instrumentation = this;
|
|
124
119
|
// avoid patching multiple times the same layer
|
|
125
|
-
if (layer[
|
|
120
|
+
if (layer[internal_types_1.kLayerPatched] === true)
|
|
126
121
|
return;
|
|
127
|
-
layer[
|
|
122
|
+
layer[internal_types_1.kLayerPatched] = true;
|
|
128
123
|
this._wrap(layer, 'handle', (original) => {
|
|
129
124
|
if (original.length === 4)
|
|
130
125
|
return original;
|
|
131
126
|
return function (req, res) {
|
|
132
127
|
utils_1.storeLayerPath(req, layerPath);
|
|
133
|
-
const route = req[
|
|
128
|
+
const route = req[internal_types_1._LAYERS_STORE_PROPERTY]
|
|
134
129
|
.filter(path => path !== '/' && path !== '/*')
|
|
135
130
|
.join('');
|
|
136
131
|
const attributes = {
|
|
@@ -153,7 +148,7 @@ class ExpressInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
153
148
|
// verify against the config if the layer should be ignored
|
|
154
149
|
if (utils_1.isLayerIgnored(metadata.name, type, instrumentation._config)) {
|
|
155
150
|
if (type === ExpressLayerType_1.ExpressLayerType.MIDDLEWARE) {
|
|
156
|
-
req[
|
|
151
|
+
req[internal_types_1._LAYERS_STORE_PROPERTY].pop();
|
|
157
152
|
}
|
|
158
153
|
return original.apply(this, arguments);
|
|
159
154
|
}
|
|
@@ -207,7 +202,7 @@ class ExpressInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
207
202
|
span.end();
|
|
208
203
|
}
|
|
209
204
|
if (!(req.route && arguments[0] instanceof Error)) {
|
|
210
|
-
req[
|
|
205
|
+
req[internal_types_1._LAYERS_STORE_PROPERTY].pop();
|
|
211
206
|
}
|
|
212
207
|
const callback = args[callbackIdx];
|
|
213
208
|
return api_1.context.bind(newContext, callback).apply(this, arguments);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,8CAA8E;AAC9E,4CAA0E;
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,8CAA8E;AAC9E,4CAA0E;AAG1E,+DAA4D;AAC5D,2DAAwD;AACxD,mCAA2E;AAC3E,uCAAoC;AACpC,oEAKwC;AACxC,8EAAyE;AACzE,qDAM0B;AAE1B,gDAAgD;AAChD,MAAa,sBAAuB,SAAQ,qCAE3C;IACC,YAAY,SAAuC,EAAE;QACnD,KAAK,CACH,wCAAwC,EACxC,iBAAO,EACP,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAC1B,CAAC;IACJ,CAAC;IAEQ,SAAS,CAAC,SAAuC,EAAE;QAC1D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC,OAAuC,CAAC;IACtD,CAAC;IAED,IAAI;QACF,OAAO;YACL,IAAI,qDAAmC,CACrC,SAAS,EACT,CAAC,QAAQ,CAAC,EACV,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE;gBAC/B,UAAI,CAAC,KAAK,CAAC,8BAA8B,aAAa,EAAE,CAAC,CAAC;gBAC1D,MAAM,WAAW,GAAG,aAA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,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY,CAAC,IAAwB,EAAE,WAAmB;;QACxD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC;QAE3C,IAAI,CAAC,CAAC,IAAI,YAAY,QAAQ,CAAC,EAAE;YAC/B,OAAO,WAAW,CAAC;SACpB;QAED,IAAI;YACF,OAAO,MAAA,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,mCAAI,WAAW,CAAC;SAC/C;QAAC,OAAO,GAAG,EAAE;YACZ,UAAI,CAAC,KAAK,CACR,+DAA+D,EAC/D,GAAG,CACJ,CAAC;YACF,OAAO,WAAW,CAAC;SACpB;IACH,CAAC;CACF;AA7RD,wDA6RC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
import { SpanAttributes } from '@opentelemetry/api';
|
|
3
|
+
/**
|
|
4
|
+
* This symbol is used to mark express layer as being already instrumented
|
|
5
|
+
* since its possible to use a given layer multiple times (ex: middlewares)
|
|
6
|
+
*/
|
|
7
|
+
export declare const kLayerPatched: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* This const define where on the `request` object the Instrumentation will mount the
|
|
10
|
+
* current stack of express layer.
|
|
11
|
+
*
|
|
12
|
+
* It is necessary because express doesnt store the different layers
|
|
13
|
+
* (ie: middleware, router etc) that it called to get to the current layer.
|
|
14
|
+
* Given that, the only way to know the route of a given layer is to
|
|
15
|
+
* store the path of where each previous layer has been mounted.
|
|
16
|
+
*
|
|
17
|
+
* ex: bodyParser > auth middleware > /users router > get /:id
|
|
18
|
+
* in this case the stack would be: ["/users", "/:id"]
|
|
19
|
+
*
|
|
20
|
+
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
|
|
21
|
+
* stack: ["/api", "/v1", "/users", ":id"]
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export declare const _LAYERS_STORE_PROPERTY = "__ot_middlewares";
|
|
25
|
+
export declare type PatchedRequest = {
|
|
26
|
+
[_LAYERS_STORE_PROPERTY]?: string[];
|
|
27
|
+
} & Request;
|
|
28
|
+
export declare type PathParams = string | RegExp | Array<string | RegExp>;
|
|
29
|
+
export declare type ExpressRouter = {
|
|
30
|
+
params: {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
};
|
|
33
|
+
_params: string[];
|
|
34
|
+
caseSensitive: boolean;
|
|
35
|
+
mergeParams: boolean;
|
|
36
|
+
strict: boolean;
|
|
37
|
+
stack: ExpressLayer[];
|
|
38
|
+
};
|
|
39
|
+
export declare type ExpressLayer = {
|
|
40
|
+
handle: Function;
|
|
41
|
+
[kLayerPatched]?: boolean;
|
|
42
|
+
name: string;
|
|
43
|
+
params: {
|
|
44
|
+
[key: string]: string;
|
|
45
|
+
};
|
|
46
|
+
path: string;
|
|
47
|
+
regexp: RegExp;
|
|
48
|
+
};
|
|
49
|
+
export declare type LayerMetadata = {
|
|
50
|
+
attributes: SpanAttributes;
|
|
51
|
+
name: string;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=internal-types.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports._LAYERS_STORE_PROPERTY = exports.kLayerPatched = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* This symbol is used to mark express layer as being already instrumented
|
|
21
|
+
* since its possible to use a given layer multiple times (ex: middlewares)
|
|
22
|
+
*/
|
|
23
|
+
exports.kLayerPatched = Symbol('express-layer-patched');
|
|
24
|
+
/**
|
|
25
|
+
* This const define where on the `request` object the Instrumentation will mount the
|
|
26
|
+
* current stack of express layer.
|
|
27
|
+
*
|
|
28
|
+
* It is necessary because express doesnt store the different layers
|
|
29
|
+
* (ie: middleware, router etc) that it called to get to the current layer.
|
|
30
|
+
* Given that, the only way to know the route of a given layer is to
|
|
31
|
+
* store the path of where each previous layer has been mounted.
|
|
32
|
+
*
|
|
33
|
+
* ex: bodyParser > auth middleware > /users router > get /:id
|
|
34
|
+
* in this case the stack would be: ["/users", "/:id"]
|
|
35
|
+
*
|
|
36
|
+
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
|
|
37
|
+
* stack: ["/api", "/v1", "/users", ":id"]
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
exports._LAYERS_STORE_PROPERTY = '__ot_middlewares';
|
|
41
|
+
//# sourceMappingURL=internal-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-types.js","sourceRoot":"","sources":["../../src/internal-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH;;;GAGG;AACU,QAAA,aAAa,GAAkB,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;GAeG;AACU,QAAA,sBAAsB,GAAG,kBAAkB,CAAC"}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
import { kLayerPatched } from './';
|
|
2
1
|
import type { Request } from 'express';
|
|
3
|
-
import { Span
|
|
2
|
+
import { Span } from '@opentelemetry/api';
|
|
4
3
|
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
5
4
|
import { ExpressLayerType } from './enums/ExpressLayerType';
|
|
6
|
-
/**
|
|
7
|
-
* This const define where on the `request` object the Instrumentation will mount the
|
|
8
|
-
* current stack of express layer.
|
|
9
|
-
*
|
|
10
|
-
* It is necessary because express doesnt store the different layers
|
|
11
|
-
* (ie: middleware, router etc) that it called to get to the current layer.
|
|
12
|
-
* Given that, the only way to know the route of a given layer is to
|
|
13
|
-
* store the path of where each previous layer has been mounted.
|
|
14
|
-
*
|
|
15
|
-
* ex: bodyParser > auth middleware > /users router > get /:id
|
|
16
|
-
* in this case the stack would be: ["/users", "/:id"]
|
|
17
|
-
*
|
|
18
|
-
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
|
|
19
|
-
* stack: ["/api", "/v1", "/users", ":id"]
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export declare const _LAYERS_STORE_PROPERTY = "__ot_middlewares";
|
|
23
|
-
export declare type PatchedRequest = {
|
|
24
|
-
[_LAYERS_STORE_PROPERTY]?: string[];
|
|
25
|
-
} & Request;
|
|
26
|
-
export declare type PathParams = string | RegExp | Array<string | RegExp>;
|
|
27
|
-
export declare type ExpressRouter = {
|
|
28
|
-
params: {
|
|
29
|
-
[key: string]: string;
|
|
30
|
-
};
|
|
31
|
-
_params: string[];
|
|
32
|
-
caseSensitive: boolean;
|
|
33
|
-
mergeParams: boolean;
|
|
34
|
-
strict: boolean;
|
|
35
|
-
stack: ExpressLayer[];
|
|
36
|
-
};
|
|
37
|
-
export declare type ExpressLayer = {
|
|
38
|
-
handle: Function;
|
|
39
|
-
[kLayerPatched]?: boolean;
|
|
40
|
-
name: string;
|
|
41
|
-
params: {
|
|
42
|
-
[key: string]: string;
|
|
43
|
-
};
|
|
44
|
-
path: string;
|
|
45
|
-
regexp: RegExp;
|
|
46
|
-
};
|
|
47
|
-
export declare type LayerMetadata = {
|
|
48
|
-
attributes: SpanAttributes;
|
|
49
|
-
name: string;
|
|
50
|
-
};
|
|
51
5
|
export declare type IgnoreMatcher = string | RegExp | ((name: string) => boolean);
|
|
52
6
|
export declare type ExpressRequestInfo = {
|
|
53
7
|
request: Request;
|
package/build/src/types.js
CHANGED
|
@@ -15,23 +15,4 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports._LAYERS_STORE_PROPERTY = void 0;
|
|
19
|
-
const _1 = require("./");
|
|
20
|
-
/**
|
|
21
|
-
* This const define where on the `request` object the Instrumentation will mount the
|
|
22
|
-
* current stack of express layer.
|
|
23
|
-
*
|
|
24
|
-
* It is necessary because express doesnt store the different layers
|
|
25
|
-
* (ie: middleware, router etc) that it called to get to the current layer.
|
|
26
|
-
* Given that, the only way to know the route of a given layer is to
|
|
27
|
-
* store the path of where each previous layer has been mounted.
|
|
28
|
-
*
|
|
29
|
-
* ex: bodyParser > auth middleware > /users router > get /:id
|
|
30
|
-
* in this case the stack would be: ["/users", "/:id"]
|
|
31
|
-
*
|
|
32
|
-
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
|
|
33
|
-
* stack: ["/api", "/v1", "/users", ":id"]
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
exports._LAYERS_STORE_PROPERTY = '__ot_middlewares';
|
|
37
18
|
//# sourceMappingURL=types.js.map
|
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SpanAttributes } from '@opentelemetry/api';
|
|
2
|
-
import {
|
|
2
|
+
import { ExpressInstrumentationConfig } from './types';
|
|
3
3
|
import { ExpressLayerType } from './enums/ExpressLayerType';
|
|
4
|
+
import { ExpressLayer, PatchedRequest } from './internal-types';
|
|
4
5
|
/**
|
|
5
6
|
* Store layers path in the request to be able to construct route later
|
|
6
7
|
* @param request The request where
|
package/build/src/utils.js
CHANGED
|
@@ -16,24 +16,24 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isLayerIgnored = exports.getLayerMetadata = exports.storeLayerPath = void 0;
|
|
19
|
-
const types_1 = require("./types");
|
|
20
19
|
const ExpressLayerType_1 = require("./enums/ExpressLayerType");
|
|
21
20
|
const AttributeNames_1 = require("./enums/AttributeNames");
|
|
21
|
+
const internal_types_1 = require("./internal-types");
|
|
22
22
|
/**
|
|
23
23
|
* Store layers path in the request to be able to construct route later
|
|
24
24
|
* @param request The request where
|
|
25
25
|
* @param [value] the value to push into the array
|
|
26
26
|
*/
|
|
27
27
|
const storeLayerPath = (request, value) => {
|
|
28
|
-
if (Array.isArray(request[
|
|
29
|
-
Object.defineProperty(request,
|
|
28
|
+
if (Array.isArray(request[internal_types_1._LAYERS_STORE_PROPERTY]) === false) {
|
|
29
|
+
Object.defineProperty(request, internal_types_1._LAYERS_STORE_PROPERTY, {
|
|
30
30
|
enumerable: false,
|
|
31
31
|
value: [],
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
if (value === undefined)
|
|
35
35
|
return;
|
|
36
|
-
request[
|
|
36
|
+
request[internal_types_1._LAYERS_STORE_PROPERTY].push(value);
|
|
37
37
|
};
|
|
38
38
|
exports.storeLayerPath = storeLayerPath;
|
|
39
39
|
/**
|
package/build/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/ut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C,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE;gBACnC,OAAO,IAAI,CAAC;aACb;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,gBAAgB;KACjB;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAvBW,QAAA,cAAc,kBAuBzB"}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.31.
|
|
1
|
+
export declare const VERSION = "0.31.3";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/instrumentation-express",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.3",
|
|
4
4
|
"description": "OpenTelemetry express automatic instrumentation package.",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@opentelemetry/sdk-trace-base": "^1.3.1",
|
|
54
54
|
"@opentelemetry/sdk-trace-node": "^1.3.1",
|
|
55
55
|
"@types/mocha": "7.0.2",
|
|
56
|
-
"@types/node": "
|
|
56
|
+
"@types/node": "18.11.7",
|
|
57
57
|
"@types/sinon": "10.0.9",
|
|
58
58
|
"express": "4.17.1",
|
|
59
59
|
"gts": "3.1.0",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"@types/express": "4.17.13"
|
|
73
73
|
},
|
|
74
74
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#readme",
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "bd79bd04cba3f16658caf37d9a5c65e5bd5980f6"
|
|
76
76
|
}
|