Skip to content

Commit b3bc7eb

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js-contrib
2 parents 01b2f84 + d579630 commit b3bc7eb

File tree

10 files changed

+35
-12
lines changed

10 files changed

+35
-12
lines changed

metapackages/auto-instrumentations-node/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ registerInstrumentations({
198198
- [@opentelemetry/instrumentation-pino](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-pino)
199199
- [@opentelemetry/instrumentation-redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis)
200200
- [@opentelemetry/instrumentation-restify](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-restify)
201+
- [@opentelemetry/instrumentation-runtime-node](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-runtime-node)
201202
- [@opentelemetry/instrumentation-socket.io](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-socket.io)
202203
- [@opentelemetry/instrumentation-undici](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-undici)
203204
- [@opentelemetry/instrumentation-winston](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-winston)

metapackages/auto-instrumentations-node/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"@opentelemetry/instrumentation-redis-4": "^0.47.0",
8686
"@opentelemetry/instrumentation-restify": "^0.46.0",
8787
"@opentelemetry/instrumentation-router": "^0.45.0",
88+
"@opentelemetry/instrumentation-runtime-node": "^0.13.0",
8889
"@opentelemetry/instrumentation-socket.io": "^0.47.0",
8990
"@opentelemetry/instrumentation-tedious": "^0.19.0",
9091
"@opentelemetry/instrumentation-undici": "^0.11.0",

metapackages/auto-instrumentations-node/src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { RedisInstrumentation as RedisInstrumentationV2 } from '@opentelemetry/i
5353
import { RedisInstrumentation as RedisInstrumentationV4 } from '@opentelemetry/instrumentation-redis-4';
5454
import { RestifyInstrumentation } from '@opentelemetry/instrumentation-restify';
5555
import { RouterInstrumentation } from '@opentelemetry/instrumentation-router';
56+
import { RuntimeNodeInstrumentation } from '@opentelemetry/instrumentation-runtime-node';
5657
import { SocketIoInstrumentation } from '@opentelemetry/instrumentation-socket.io';
5758
import { TediousInstrumentation } from '@opentelemetry/instrumentation-tedious';
5859
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
@@ -131,6 +132,7 @@ const InstrumentationMap = {
131132
'@opentelemetry/instrumentation-redis-4': RedisInstrumentationV4,
132133
'@opentelemetry/instrumentation-restify': RestifyInstrumentation,
133134
'@opentelemetry/instrumentation-router': RouterInstrumentation,
135+
'@opentelemetry/instrumentation-runtime-node': RuntimeNodeInstrumentation,
134136
'@opentelemetry/instrumentation-socket.io': SocketIoInstrumentation,
135137
'@opentelemetry/instrumentation-tedious': TediousInstrumentation,
136138
'@opentelemetry/instrumentation-undici': UndiciInstrumentation,

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/node/instrumentation-runtime-node/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
7777
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
7878
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
7979
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
80-
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-pg
81-
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-pg.svg
80+
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-runtime-node
81+
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-runtime-node.svg

plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class ExpressInstrumentation extends InstrumentationBase<ExpressInstrumen
171171
req: PatchedRequest,
172172
res: express.Response
173173
) {
174-
storeLayerPath(req, layerPath);
174+
const { isLayerPathStored } = storeLayerPath(req, layerPath);
175175
const route = (req[_LAYERS_STORE_PROPERTY] as string[])
176176
.filter(path => path !== '/' && path !== '/*')
177177
.join('')
@@ -280,7 +280,7 @@ export class ExpressInstrumentation extends InstrumentationBase<ExpressInstrumen
280280
req.res?.removeListener('finish', onResponseFinish);
281281
span.end();
282282
}
283-
if (!(req.route && isError)) {
283+
if (!(req.route && isError) && isLayerPathStored) {
284284
(req[_LAYERS_STORE_PROPERTY] as string[]).pop();
285285
}
286286
const callback = args[callbackIdx] as Function;

plugins/node/opentelemetry-instrumentation-express/src/utils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@ import {
3333
* @param request The request where
3434
* @param [value] the value to push into the array
3535
*/
36-
export const storeLayerPath = (request: PatchedRequest, value?: string) => {
36+
export const storeLayerPath = (
37+
request: PatchedRequest,
38+
value?: string
39+
): { isLayerPathStored: boolean } => {
3740
if (Array.isArray(request[_LAYERS_STORE_PROPERTY]) === false) {
3841
Object.defineProperty(request, _LAYERS_STORE_PROPERTY, {
3942
enumerable: false,
4043
value: [],
4144
});
4245
}
43-
if (value === undefined) return;
46+
if (value === undefined) return { isLayerPathStored: false };
47+
4448
(request[_LAYERS_STORE_PROPERTY] as string[]).push(value);
49+
50+
return { isLayerPathStored: true };
4551
};
4652

4753
/**

plugins/node/opentelemetry-instrumentation-express/test/express.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -709,15 +709,18 @@ describe('ExpressInstrumentation', () => {
709709
assert.strictEqual(spans[5].name, 'router - /api/user/:id');
710710
assert.strictEqual(spans[5].kind, testUtils.OtlpSpanKind.INTERNAL);
711711
assert.strictEqual(spans[5].parentSpanId, spans[1].spanId);
712-
assert.strictEqual(spans[6].name, 'router - /:postId');
712+
assert.strictEqual(spans[6].name, 'router - /api/user/:id/posts');
713713
assert.strictEqual(spans[6].kind, testUtils.OtlpSpanKind.INTERNAL);
714714
assert.strictEqual(spans[6].parentSpanId, spans[1].spanId);
715+
assert.strictEqual(spans[7].name, 'middleware - simpleMiddleware2');
716+
assert.strictEqual(spans[7].kind, testUtils.OtlpSpanKind.INTERNAL);
717+
assert.strictEqual(spans[7].parentSpanId, spans[1].spanId);
715718
assert.strictEqual(
716-
spans[7].name,
719+
spans[8].name,
717720
'request handler - /api/user/:id/posts/:postId'
718721
);
719-
assert.strictEqual(spans[7].kind, testUtils.OtlpSpanKind.INTERNAL);
720-
assert.strictEqual(spans[7].parentSpanId, spans[1].spanId);
722+
assert.strictEqual(spans[8].kind, testUtils.OtlpSpanKind.INTERNAL);
723+
assert.strictEqual(spans[8].parentSpanId, spans[1].spanId);
721724
},
722725
});
723726
});

plugins/node/opentelemetry-instrumentation-express/test/fixtures/use-express-nested-router.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ app.use(async function simpleMiddleware(req, res, next) {
4646

4747
const userRouter = express.Router();
4848
const postsRouter = express.Router();
49+
postsRouter.use(async function simpleMiddleware2(req, res, next) {
50+
// Wait a short delay to ensure this "middleware - ..." span clearly starts
51+
// before the "router - ..." span. The test rely on a start-time-based sort
52+
// of the produced spans. If they start in the same millisecond, then tests
53+
// can be flaky.
54+
await promisify(setTimeout)(10);
55+
next();
56+
});
4957

5058
postsRouter.get('/:postId', (req, res, next) => {
5159
res.json({ hello: 'yes' });
@@ -74,7 +82,7 @@ await new Promise(resolve => {
7482
res.on('end', data => {
7583
resolve(data);
7684
});
77-
})
85+
});
7886
});
7987

8088
await new Promise(resolve => server.close(resolve));

plugins/node/opentelemetry-instrumentation-nestjs-core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-nestjs-core
1717

1818
### Supported Versions
1919

20-
- [`@nestjs/core`](https://www.npmjs.com/package/@nestjs/core) versions `>=4.0.0 <11`
20+
- [`@nestjs/core`](https://www.npmjs.com/package/@nestjs/core) versions `>=4.0.0 <12`
2121

2222
## Usage
2323

0 commit comments

Comments
 (0)