diff --git a/getting-started/README.md b/getting-started/README.md index e7c5edfe8e0..95daa0cc661 100644 --- a/getting-started/README.md +++ b/getting-started/README.md @@ -54,13 +54,15 @@ This guide uses the example application provided in the `example` directory, but ([link to TypeScript version](ts-example/README.md#install-the-required-opentelemetry-libraries)) -To create traces on NodeJS, you will need `@opentelemetry/node`, `@opentelemetry/core`, and any plugins required by your application such as gRPC, or HTTP. If you are using the example application, you will need to install `@opentelemetry/plugin-http`. +To create traces on NodeJS, you will need `@opentelemetry/node`, `@opentelemetry/core`, and any plugins required by your application such as gRPC, or HTTP. If you are using the example application, you will need to install `@opentelemetry/plugin-http`, `@opentelemetry/plugin-https` and `@opentelemetry/plugin-express`. ```sh $ npm install \ @opentelemetry/core \ @opentelemetry/node \ - @opentelemetry/plugin-http + @opentelemetry/plugin-http \ + @opentelemetry/plugin-https \ + @opentelemetry/plugin-express ``` #### Initialize a global tracer diff --git a/package.json b/package.json index 53f3134d64a..4d578886ac7 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "devDependencies": { "@commitlint/cli": "9.1.1", "@commitlint/config-conventional": "9.1.1", - "@typescript-eslint/eslint-plugin": "3.9.0", - "@typescript-eslint/parser": "3.9.0", + "@typescript-eslint/eslint-plugin": "4.1.1", + "@typescript-eslint/parser": "4.1.1", "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", "eslint": "7.6.0", diff --git a/packages/opentelemetry-api/package.json b/packages/opentelemetry-api/package.json index 3cd3b7aaff8..f9286fd4137 100644 --- a/packages/opentelemetry-api/package.json +++ b/packages/opentelemetry-api/package.json @@ -57,7 +57,7 @@ "devDependencies": { "@types/mocha": "8.0.2", "@types/node": "14.0.27", - "@types/sinon": "4.3.1", + "@types/sinon": "9.0.5", "@types/webpack-env": "1.15.2", "codecov": "3.7.2", "gts": "2.0.2", diff --git a/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts index 1e32db3502a..05b9fd9875a 100644 --- a/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts +++ b/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts @@ -66,8 +66,15 @@ export class AsyncHooksContextManager extends AbstractAsyncHooksContextManager { * Init hook will be called when userland create a async context, setting the * context as the current one if it exist. * @param uid id of the async context + * @param type the resource type */ - private _init(uid: number) { + private _init(uid: number, type: string) { + // ignore TIMERWRAP as they combine timers with same timeout which can lead to + // false context propagation. TIMERWRAP has been removed in node 11 + // every timer has it's own `Timeout` resource anyway which is used to propagete + // context. + if (type === 'TIMERWRAP') return; + const context = this._stack[this._stack.length - 1]; if (context !== undefined) { this._contexts.set(uid, context); diff --git a/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts b/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts index c8ab82ca122..6a2fbf0507a 100644 --- a/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts +++ b/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts @@ -222,6 +222,34 @@ for (const contextManagerClass of [ }); assert.strictEqual(contextManager.active(), Context.ROOT_CONTEXT); }); + + it('should work with timers using the same timeout', done => { + let cnt = 3; + function countDown() { + cnt--; + if (cnt === 0) done(); + if (cnt < 0) throw new Error('too many calls to countDown()'); + } + + const time1 = 2; + const time2 = time1 + 1; + const rootCtx = contextManager.active(); + const innerCtx = rootCtx.setValue(Symbol('test'), 23); + contextManager.with(innerCtx, () => { + setTimeout(() => { + assert.strictEqual(contextManager.active(), innerCtx); + countDown(); + }, time1); + }); + setTimeout(() => { + assert.strictEqual(contextManager.active(), rootCtx); + countDown(); + }, time1); + setTimeout(() => { + assert.strictEqual(contextManager.active(), rootCtx); + countDown(); + }, time2); + }); }); describe('.bind(function)', () => { diff --git a/packages/opentelemetry-exporter-collector-grpc/package.json b/packages/opentelemetry-exporter-collector-grpc/package.json index 3c4f708a07b..2b96b3ae236 100644 --- a/packages/opentelemetry-exporter-collector-grpc/package.json +++ b/packages/opentelemetry-exporter-collector-grpc/package.json @@ -38,7 +38,7 @@ "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", - "build/src/**/*.proto", + "build/protos/**/*.proto", "doc", "LICENSE", "README.md" diff --git a/packages/opentelemetry-exporter-collector-proto/package.json b/packages/opentelemetry-exporter-collector-proto/package.json index 0c12da0e250..bc079f92ea6 100644 --- a/packages/opentelemetry-exporter-collector-proto/package.json +++ b/packages/opentelemetry-exporter-collector-proto/package.json @@ -38,7 +38,7 @@ "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", - "build/src/**/*.proto", + "build/protos/**/*.proto", "doc", "LICENSE", "README.md" diff --git a/packages/opentelemetry-plugin-fetch/package.json b/packages/opentelemetry-plugin-fetch/package.json index e0a56a96c50..d266246450f 100644 --- a/packages/opentelemetry-plugin-fetch/package.json +++ b/packages/opentelemetry-plugin-fetch/package.json @@ -50,7 +50,7 @@ "@types/mocha": "8.0.2", "@types/node": "14.0.27", "@types/shimmer": "1.0.1", - "@types/sinon": "7.5.2", + "@types/sinon": "9.0.5", "@types/webpack-env": "1.15.2", "babel-loader": "8.1.0", "codecov": "3.7.2", @@ -65,7 +65,7 @@ "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", - "sinon": "7.5.0", + "sinon": "9.0.3", "ts-loader": "8.0.2", "ts-mocha": "7.0.0", "ts-node": "8.10.2", diff --git a/packages/opentelemetry-sdk-node/package.json b/packages/opentelemetry-sdk-node/package.json index ad4bc3e3f3b..ee82cab7338 100644 --- a/packages/opentelemetry-sdk-node/package.json +++ b/packages/opentelemetry-sdk-node/package.json @@ -67,7 +67,7 @@ "nyc": "15.1.0", "semver": "7.3.2", "sinon": "9.0.3", - "ts-loader": "7.0.5", + "ts-loader": "8.0.4", "ts-mocha": "7.0.0", "typescript": "3.9.7" }