@opentelemetry/instrumentation-express 0.28.0 → 0.31.0
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/CHANGELOG.md +34 -0
- package/LICENSE +1 -1
- package/README.md +60 -10
- package/build/src/instrumentation.js +15 -3
- package/build/src/instrumentation.js.map +1 -1
- package/build/src/types.d.ts +12 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/package.json +17 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.31.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-express-v0.30.0...instrumentation-express-v0.31.0) (2022-09-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **express:** add requestHook support ([#1091](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1091)) ([bcc048b](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/bcc048b4de1293b0d932ac69dc0b0c056aca13ee))
|
|
9
|
+
* update experimental Otel deps to ^0.31.0 ([#1096](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1096)) ([4c8843b](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/4c8843be14896d1159a622c07eb3a049401ccba1))
|
|
10
|
+
* update experimental Otel deps to ^0.32.0 ([#1143](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1143)) ([6fb1911](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/6fb191139aed2ca763300dcf9adb51121a88f97e))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* mongodb types fails to compile with latest tsc v4.8 ([#1141](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1141)) ([ec9ee13](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/ec9ee131635dc2db88deea4f2efb887ff6f60577))
|
|
16
|
+
|
|
17
|
+
## [0.30.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-express-v0.29.0...instrumentation-express-v0.30.0) (2022-06-08)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* update core dependencies stable ^1.3.1 experimental ^0.29.2 ([141b155](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/141b155e344980b51264e26b26c117b2113bcef6))
|
|
23
|
+
|
|
24
|
+
## [0.29.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-express-v0.28.0...instrumentation-express-v0.29.0) (2022-05-14)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* add supported node versions for all packages ([#973](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/973)) ([baaacbd](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/baaacbdd35ca4baab0afae64647aa8c0380ee4b7))
|
|
30
|
+
* use Otel SDK 1.2/0.28 ([#984](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/984)) ([098c2ed](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/098c2ed6f9c5ab7bd865685018c0777245aab3b7))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* correctly disable Express instrumentation ([#972](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/972)) ([b55b79b](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/b55b79b72451c65080e01c2ec11655cabd5f65d9))
|
|
36
|
+
|
|
3
37
|
## [0.28.0](https://www.github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-express-v0.27.1...instrumentation-express-v0.28.0) (2022-02-06)
|
|
4
38
|
|
|
5
39
|
|
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright [
|
|
189
|
+
Copyright [2022] OpenTelemetry Authors
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
# OpenTelemetry Express Instrumentation for Node.js
|
|
2
2
|
|
|
3
3
|
[![NPM Published Version][npm-img]][npm-url]
|
|
4
|
-
[![dependencies][dependencies-image]][dependencies-url]
|
|
5
|
-
[![devDependencies][devDependencies-image]][devDependencies-url]
|
|
6
4
|
[![Apache License][license-image]][license-image]
|
|
7
5
|
|
|
8
|
-
This module provides automatic instrumentation for [`express`](https://github.com/expressjs/express).
|
|
6
|
+
This module provides automatic instrumentation for the [`express`](https://github.com/expressjs/express) module, which may be loaded using the [`@opentelemetry/sdk-trace-node`](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node) package and is included in the [`@opentelemetry/auto-instrumentations-node`](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) bundle.
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
[@opentelemetry/sdk-trace-node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package.
|
|
8
|
+
If total installation size is not constrained, it is recommended to use the [`@opentelemetry/auto-instrumentations-node`](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) bundle with [@opentelemetry/sdk-node](`https://www.npmjs.com/package/@opentelemetry/sdk-node`) for the most seamless instrumentation experience.
|
|
12
9
|
|
|
13
10
|
Compatible with OpenTelemetry JS API and SDK `1.0+`.
|
|
14
11
|
|
|
@@ -48,7 +45,7 @@ registerInstrumentations({
|
|
|
48
45
|
});
|
|
49
46
|
```
|
|
50
47
|
|
|
51
|
-
See [examples
|
|
48
|
+
See [examples](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express/examples) for a short example.
|
|
52
49
|
|
|
53
50
|
### Caveats
|
|
54
51
|
|
|
@@ -63,6 +60,7 @@ Express instrumentation has few options available to choose from. You can set th
|
|
|
63
60
|
| `ignoreLayers` | `IgnoreMatcher[]` | `[/^\/_internal\//]` | Ignore layers that by match. |
|
|
64
61
|
| `ignoreLayersType`| `ExpressLayerType[]` | `['request_handler']` | Ignore layers of specified type. |
|
|
65
62
|
| `spanNameHook` | `SpanNameHook` | `() => 'my-span-name'` | Can be used to customize span names by returning a new name from the hook. |
|
|
63
|
+
| `requestHook` | `ExpressRequestCustomAttributeFunction (function)` | `(span, info) => {}` | Function for adding custom attributes on Express request. Receives params: `Span, ExpressRequestInfo`. |
|
|
66
64
|
|
|
67
65
|
`ignoreLayers` accepts an array of elements of types:
|
|
68
66
|
|
|
@@ -81,6 +79,62 @@ Express instrumentation has few options available to choose from. You can set th
|
|
|
81
79
|
- `info: ExpressRequestInfo` containing the incoming Express.js request, the current route handler creating a span and `ExpressLayerType` - the type of the handling layer or undefined when renaming the root HTTP instrumentation span.
|
|
82
80
|
- `defaultName: string` - original name proposed by the instrumentation.
|
|
83
81
|
|
|
82
|
+
#### Ignore a whole Express route
|
|
83
|
+
|
|
84
|
+
In order to ignore whole traces that represent a given Express route, use
|
|
85
|
+
the `ignoreIncomingRequestHook` option from
|
|
86
|
+
`@opentelemetry/instrumentation-http` against the route path. Ideally, this
|
|
87
|
+
shouldn't be necessary since spans should a have low cardinality and minimize
|
|
88
|
+
interaction between instrumentation libraies but
|
|
89
|
+
`@opentelemetry/instrumentation-express` renames the root span from
|
|
90
|
+
`@opentelemetry/instrumentation-http` in order to get things in order.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
registerInstrumentations({
|
|
94
|
+
instrumentations: [
|
|
95
|
+
// Express instrumentation expects HTTP layer to be instrumented
|
|
96
|
+
new HttpInstrumentation({
|
|
97
|
+
ignoreIncomingRequestHook(req) {
|
|
98
|
+
// Ignore spans from static assets.
|
|
99
|
+
const isStaticAsset = !!req.url.match(/^\/static\/.*$/);
|
|
100
|
+
return isStaticAsset;
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
new ExpressInstrumentation(),
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Using `requestHook`
|
|
109
|
+
|
|
110
|
+
Instrumentation configuration accepts a custom "hook" function which will be called for every instrumented Express layer involved in a request. Custom attributes can be set on the span or run any custom logic per layer.
|
|
111
|
+
|
|
112
|
+
Here is a simple example that adds to the request handler span some attributes based on the Express request attributes:
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
import { ExpressInstrumentation, ExpressLayerType } from "@opentelemetry/instrumentation-express"
|
|
116
|
+
|
|
117
|
+
const expressInstrumentation = new ExpressInstrumentation({
|
|
118
|
+
requestHook: function (
|
|
119
|
+
span: Span,
|
|
120
|
+
info: ExpressRequestInfo,
|
|
121
|
+
) {
|
|
122
|
+
|
|
123
|
+
if (info.layerType === ExpressLayerType.REQUEST_HANDLER) {
|
|
124
|
+
span.setAttribute(
|
|
125
|
+
'http.method',
|
|
126
|
+
info.request.method
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
span.setAttribute(
|
|
130
|
+
'express.base_url',
|
|
131
|
+
info.request.baseUrl
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
84
138
|
## Useful links
|
|
85
139
|
|
|
86
140
|
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
|
|
@@ -94,9 +148,5 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
|
|
|
94
148
|
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
|
|
95
149
|
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
|
|
96
150
|
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
|
|
97
|
-
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fnode%2Fopentelemetry-instrumentation-express
|
|
98
|
-
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fnode%2Fopentelemetry-instrumentation-express
|
|
99
|
-
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fnode%2Fopentelemetry-instrumentation-express&type=dev
|
|
100
|
-
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fnode%2Fopentelemetry-instrumentation-express&type=dev
|
|
101
151
|
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-dns
|
|
102
152
|
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-dns.svg
|
|
@@ -69,9 +69,10 @@ class ExpressInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
69
69
|
if (moduleExports === undefined)
|
|
70
70
|
return;
|
|
71
71
|
api_1.diag.debug(`Removing patch for express@${moduleVersion}`);
|
|
72
|
-
|
|
73
|
-
this._unwrap(
|
|
74
|
-
this._unwrap(
|
|
72
|
+
const routerProto = moduleExports.Router;
|
|
73
|
+
this._unwrap(routerProto, 'route');
|
|
74
|
+
this._unwrap(routerProto, 'use');
|
|
75
|
+
this._unwrap(moduleExports.application, 'use');
|
|
75
76
|
}),
|
|
76
77
|
];
|
|
77
78
|
}
|
|
@@ -167,6 +168,17 @@ class ExpressInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
167
168
|
const span = instrumentation.tracer.startSpan(spanName, {
|
|
168
169
|
attributes: Object.assign(attributes, metadata.attributes),
|
|
169
170
|
});
|
|
171
|
+
if (instrumentation.getConfig().requestHook) {
|
|
172
|
+
instrumentation_1.safeExecuteInTheMiddle(() => instrumentation.getConfig().requestHook(span, {
|
|
173
|
+
request: req,
|
|
174
|
+
layerType: type,
|
|
175
|
+
route,
|
|
176
|
+
}), e => {
|
|
177
|
+
if (e) {
|
|
178
|
+
api_1.diag.error('express instrumentation: request hook failed', e);
|
|
179
|
+
}
|
|
180
|
+
}, true);
|
|
181
|
+
}
|
|
170
182
|
const startTime = core_1.hrTime();
|
|
171
183
|
let spanHasEnded = false;
|
|
172
184
|
// If we found anything that isnt a middleware, there no point of measuring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,8CAK6B;AAC7B,4CAA0E;AAE1E,mCAOiB;AACjB,+DAA4D;AAC5D,2DAAwD;AACxD,mCAA2E;AAC3E,uCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,8CAK6B;AAC7B,4CAA0E;AAE1E,mCAOiB;AACjB,+DAA4D;AAC5D,2DAAwD;AACxD,mCAA2E;AAC3E,uCAAoC;AACpC,oEAKwC;AACxC,8EAAyE;AAEzE;;;GAGG;AACU,QAAA,aAAa,GAAkB,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAE5E,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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Q,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAC/C;;;;;mBAKG;gBACH,IAAI,CAAC,YAAY,EAAE;oBACjB,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;iBACtC;gBACD,OAAO,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;AAhSD,wDAgSC"}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { kLayerPatched } from './';
|
|
2
2
|
import { Request } from 'express';
|
|
3
|
-
import { SpanAttributes } from '@opentelemetry/api';
|
|
3
|
+
import { Span, SpanAttributes } from '@opentelemetry/api';
|
|
4
4
|
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
5
5
|
import { ExpressLayerType } from './enums/ExpressLayerType';
|
|
6
6
|
/**
|
|
@@ -63,6 +63,15 @@ export declare type SpanNameHook = (info: ExpressRequestInfo,
|
|
|
63
63
|
* supplied by the instrumentation can be used instead.
|
|
64
64
|
*/
|
|
65
65
|
defaultName: string) => string;
|
|
66
|
+
/**
|
|
67
|
+
* Function that can be used to add custom attributes to the current span or the root span on
|
|
68
|
+
* a Express request
|
|
69
|
+
* @param span - The Express middleware layer span.
|
|
70
|
+
* @param info - An instance of ExpressRequestInfo that contains info about the request such as the route, and the layer type.
|
|
71
|
+
*/
|
|
72
|
+
export interface ExpressRequestCustomAttributeFunction {
|
|
73
|
+
(span: Span, info: ExpressRequestInfo): void;
|
|
74
|
+
}
|
|
66
75
|
/**
|
|
67
76
|
* Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-Instrumentation-express#express-Instrumentation-options))
|
|
68
77
|
*/
|
|
@@ -72,5 +81,7 @@ export interface ExpressInstrumentationConfig extends InstrumentationConfig {
|
|
|
72
81
|
/** Ignore specific layers based on their type */
|
|
73
82
|
ignoreLayersType?: ExpressLayerType[];
|
|
74
83
|
spanNameHook?: SpanNameHook;
|
|
84
|
+
/** Function for adding custom attributes on Express request */
|
|
85
|
+
requestHook?: ExpressRequestCustomAttributeFunction;
|
|
75
86
|
}
|
|
76
87
|
//# sourceMappingURL=types.d.ts.map
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.31.0";
|
|
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.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "OpenTelemetry express automatic instrumentation package.",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test-all-versions": "tav",
|
|
10
10
|
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
|
|
11
|
-
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
|
|
12
11
|
"tdd": "yarn test -- --watch-extensions ts --watch",
|
|
13
12
|
"clean": "rimraf build/*",
|
|
14
13
|
"lint": "eslint . --ext .ts",
|
|
15
14
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
16
|
-
"precompile": "tsc --version && lerna run version --scope @opentelemetry/instrumentation-express --include-dependencies",
|
|
15
|
+
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/instrumentation-express --include-dependencies",
|
|
17
16
|
"prewatch": "npm run precompile",
|
|
18
17
|
"version:update": "node ../../../scripts/version-update.js",
|
|
19
|
-
"compile": "
|
|
18
|
+
"compile": "tsc -p .",
|
|
19
|
+
"compile:examples": "cd examples && npm run compile",
|
|
20
20
|
"prepare": "npm run compile",
|
|
21
21
|
"watch": "tsc -w"
|
|
22
22
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"author": "OpenTelemetry Authors",
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=8.
|
|
34
|
+
"node": ">=8.12.0"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"build/src/**/*.js",
|
|
@@ -45,30 +45,32 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@opentelemetry/api": "^1.0.
|
|
48
|
+
"@opentelemetry/api": "^1.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@opentelemetry/api": "1.0.
|
|
52
|
-
"@opentelemetry/context-async-hooks": "1.
|
|
53
|
-
"@opentelemetry/sdk-trace-base": "1.
|
|
54
|
-
"@opentelemetry/sdk-trace-node": "1.
|
|
51
|
+
"@opentelemetry/api": "^1.0.0",
|
|
52
|
+
"@opentelemetry/context-async-hooks": "^1.3.1",
|
|
53
|
+
"@opentelemetry/sdk-trace-base": "^1.3.1",
|
|
54
|
+
"@opentelemetry/sdk-trace-node": "^1.3.1",
|
|
55
55
|
"@types/mocha": "7.0.2",
|
|
56
56
|
"@types/node": "16.11.21",
|
|
57
|
-
"
|
|
57
|
+
"@types/sinon": "10.0.9",
|
|
58
58
|
"express": "4.17.1",
|
|
59
59
|
"gts": "3.1.0",
|
|
60
60
|
"mocha": "7.2.0",
|
|
61
61
|
"nyc": "15.1.0",
|
|
62
62
|
"rimraf": "3.0.2",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
63
|
+
"sinon": "14.0.0",
|
|
64
|
+
"test-all-versions": "5.0.1",
|
|
65
|
+
"ts-mocha": "10.0.0",
|
|
65
66
|
"typescript": "4.3.5"
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
69
|
"@opentelemetry/core": "^1.0.0",
|
|
69
|
-
"@opentelemetry/instrumentation": "^0.
|
|
70
|
+
"@opentelemetry/instrumentation": "^0.32.0",
|
|
70
71
|
"@opentelemetry/semantic-conventions": "^1.0.0",
|
|
71
72
|
"@types/express": "4.17.13"
|
|
72
73
|
},
|
|
73
|
-
"
|
|
74
|
+
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#readme",
|
|
75
|
+
"gitHead": "4a9442ceea7f8555ad6e5f731f92834f3398d5b9"
|
|
74
76
|
}
|