Skip to content

Commit c241d6c

Browse files
authored
Merge branch 'master' into propagate-context-api
2 parents 0b482fc + 3bc4d57 commit c241d6c

File tree

9 files changed

+48
-11
lines changed

9 files changed

+48
-11
lines changed

getting-started/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ This guide uses the example application provided in the `example` directory, but
5454

5555
([link to TypeScript version](ts-example/README.md#install-the-required-opentelemetry-libraries))
5656

57-
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`.
57+
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`.
5858

5959
```sh
6060
$ npm install \
6161
@opentelemetry/core \
6262
@opentelemetry/node \
63-
@opentelemetry/plugin-http
63+
@opentelemetry/plugin-http \
64+
@opentelemetry/plugin-https \
65+
@opentelemetry/plugin-express
6466
```
6567

6668
#### Initialize a global tracer

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"devDependencies": {
4444
"@commitlint/cli": "9.1.1",
4545
"@commitlint/config-conventional": "9.1.1",
46-
"@typescript-eslint/eslint-plugin": "3.9.0",
47-
"@typescript-eslint/parser": "3.9.0",
46+
"@typescript-eslint/eslint-plugin": "4.1.1",
47+
"@typescript-eslint/parser": "4.1.1",
4848
"beautify-benchmark": "0.2.4",
4949
"benchmark": "2.1.4",
5050
"eslint": "7.6.0",

packages/opentelemetry-api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"devDependencies": {
5858
"@types/mocha": "8.0.2",
5959
"@types/node": "14.0.27",
60-
"@types/sinon": "4.3.1",
60+
"@types/sinon": "9.0.5",
6161
"@types/webpack-env": "1.15.2",
6262
"codecov": "3.7.2",
6363
"gts": "2.0.2",

packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ export class AsyncHooksContextManager extends AbstractAsyncHooksContextManager {
6666
* Init hook will be called when userland create a async context, setting the
6767
* context as the current one if it exist.
6868
* @param uid id of the async context
69+
* @param type the resource type
6970
*/
70-
private _init(uid: number) {
71+
private _init(uid: number, type: string) {
72+
// ignore TIMERWRAP as they combine timers with same timeout which can lead to
73+
// false context propagation. TIMERWRAP has been removed in node 11
74+
// every timer has it's own `Timeout` resource anyway which is used to propagete
75+
// context.
76+
if (type === 'TIMERWRAP') return;
77+
7178
const context = this._stack[this._stack.length - 1];
7279
if (context !== undefined) {
7380
this._contexts.set(uid, context);

packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts

+28
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,34 @@ for (const contextManagerClass of [
222222
});
223223
assert.strictEqual(contextManager.active(), Context.ROOT_CONTEXT);
224224
});
225+
226+
it('should work with timers using the same timeout', done => {
227+
let cnt = 3;
228+
function countDown() {
229+
cnt--;
230+
if (cnt === 0) done();
231+
if (cnt < 0) throw new Error('too many calls to countDown()');
232+
}
233+
234+
const time1 = 2;
235+
const time2 = time1 + 1;
236+
const rootCtx = contextManager.active();
237+
const innerCtx = rootCtx.setValue(Symbol('test'), 23);
238+
contextManager.with(innerCtx, () => {
239+
setTimeout(() => {
240+
assert.strictEqual(contextManager.active(), innerCtx);
241+
countDown();
242+
}, time1);
243+
});
244+
setTimeout(() => {
245+
assert.strictEqual(contextManager.active(), rootCtx);
246+
countDown();
247+
}, time1);
248+
setTimeout(() => {
249+
assert.strictEqual(contextManager.active(), rootCtx);
250+
countDown();
251+
}, time2);
252+
});
225253
});
226254

227255
describe('.bind(function)', () => {

packages/opentelemetry-exporter-collector-grpc/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"build/src/**/*.js",
3939
"build/src/**/*.js.map",
4040
"build/src/**/*.d.ts",
41-
"build/src/**/*.proto",
41+
"build/protos/**/*.proto",
4242
"doc",
4343
"LICENSE",
4444
"README.md"

packages/opentelemetry-exporter-collector-proto/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"build/src/**/*.js",
3939
"build/src/**/*.js.map",
4040
"build/src/**/*.d.ts",
41-
"build/src/**/*.proto",
41+
"build/protos/**/*.proto",
4242
"doc",
4343
"LICENSE",
4444
"README.md"

packages/opentelemetry-plugin-fetch/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@types/mocha": "8.0.2",
5151
"@types/node": "14.0.27",
5252
"@types/shimmer": "1.0.1",
53-
"@types/sinon": "7.5.2",
53+
"@types/sinon": "9.0.5",
5454
"@types/webpack-env": "1.15.2",
5555
"babel-loader": "8.1.0",
5656
"codecov": "3.7.2",
@@ -65,7 +65,7 @@
6565
"mocha": "7.2.0",
6666
"nyc": "15.1.0",
6767
"rimraf": "3.0.2",
68-
"sinon": "7.5.0",
68+
"sinon": "9.0.3",
6969
"ts-loader": "8.0.2",
7070
"ts-mocha": "7.0.0",
7171
"ts-node": "8.10.2",

packages/opentelemetry-sdk-node/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"nyc": "15.1.0",
6868
"semver": "7.3.2",
6969
"sinon": "9.0.3",
70-
"ts-loader": "7.0.5",
70+
"ts-loader": "8.0.4",
7171
"ts-mocha": "7.0.0",
7272
"typescript": "3.9.7"
7373
}

0 commit comments

Comments
 (0)