Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update API to 0.21.0 #2255

Merged
merged 6 commits into from Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/basic-tracer-node/package.json
Expand Up @@ -24,7 +24,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@opentelemetry/exporter-jaeger": "0.20.0",
"@opentelemetry/tracing": "0.20.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/collector-exporter-node/package.json
Expand Up @@ -28,7 +28,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@opentelemetry/core": "0.20.0",
"@opentelemetry/exporter-collector": "0.20.0",
"@opentelemetry/exporter-collector-grpc": "0.20.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc-js/package.json
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@grpc/grpc-js": "^1.2.12",
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@opentelemetry/exporter-jaeger": "0.20.0",
"@opentelemetry/exporter-zipkin": "0.20.0",
"@opentelemetry/instrumentation": "0.20.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/package.json
Expand Up @@ -28,7 +28,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@opentelemetry/exporter-jaeger": "0.20.0",
"@opentelemetry/exporter-zipkin": "0.20.0",
"@opentelemetry/instrumentation": "0.20.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/http/package.json
Expand Up @@ -28,7 +28,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@opentelemetry/exporter-jaeger": "0.20.0",
"@opentelemetry/exporter-zipkin": "0.20.0",
"@opentelemetry/instrumentation": "0.20.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/https/package.json
Expand Up @@ -29,7 +29,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@opentelemetry/exporter-jaeger": "0.20.0",
"@opentelemetry/exporter-zipkin": "0.20.0",
"@opentelemetry/instrumentation": "0.20.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/tracer-web/package.json
Expand Up @@ -34,7 +34,7 @@
"webpack-merge": "^4.2.2"
},
"dependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@opentelemetry/context-zone": "0.20.0",
"@opentelemetry/core": "0.20.0",
"@opentelemetry/exporter-collector": "0.20.0",
Expand Down
Expand Up @@ -19,10 +19,10 @@
"express": "4.17.1"
},
"devDependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"typescript": "4.3.2"
},
"peerDependencies": {
"@opentelemetry/api": "^0.20.0"
"@opentelemetry/api": "^0.21.0"
}
}
4 changes: 2 additions & 2 deletions packages/opentelemetry-api-metrics/package.json
Expand Up @@ -53,10 +53,10 @@
"access": "public"
},
"peerDependencies": {
"@opentelemetry/api": "^0.20.0"
"@opentelemetry/api": "^0.21.0"
},
"devDependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@types/mocha": "8.2.2",
"@types/node": "14.14.43",
"@types/webpack-env": "1.16.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-context-async-hooks/package.json
Expand Up @@ -40,7 +40,7 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@types/mocha": "8.2.2",
"@types/node": "14.14.43",
"@types/shimmer": "1.0.1",
Expand All @@ -53,6 +53,6 @@
"typescript": "4.3.2"
},
"peerDependencies": {
"@opentelemetry/api": "^0.20.0"
"@opentelemetry/api": "^0.21.0"
}
}
Expand Up @@ -51,7 +51,7 @@ export abstract class AbstractAsyncHooksContextManager

abstract disable(): this;

bind<T>(target: T, context: Context = this.active()): T {
bind<T>(context: Context, target: T): T {
if (target instanceof EventEmitter) {
return this._bindEventEmitter(target, context);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ export abstract class AbstractAsyncHooksContextManager
listeners = new WeakMap();
map[event] = listeners;
}
const patchedListener = contextManager.bind(listener, context);
const patchedListener = contextManager.bind(context, listener);
// store a weak reference of the user listener to ours
listeners.set(listener, patchedListener);
return original.call(this, event, patchedListener);
Expand Down
Expand Up @@ -299,26 +299,26 @@ for (const contextManagerClass of [
describe('.bind(function)', () => {
it('should return the same target (when enabled)', () => {
const test = { a: 1 };
assert.deepStrictEqual(contextManager.bind(test, ROOT_CONTEXT), test);
assert.deepStrictEqual(contextManager.bind(ROOT_CONTEXT, test), test);
});

it('should return the same target (when disabled)', () => {
contextManager.disable();
const test = { a: 1 };
assert.deepStrictEqual(contextManager.bind(test, ROOT_CONTEXT), test);
assert.deepStrictEqual(contextManager.bind(ROOT_CONTEXT, test), test);
contextManager.enable();
});

it('should return current context (when enabled)', done => {
const context = ROOT_CONTEXT.setValue(key1, 1);
const fn = contextManager.bind(() => {
const fn = contextManager.bind(context, () => {
assert.strictEqual(
contextManager.active(),
context,
'should have context'
);
return done();
}, context);
});
fn();
});

Expand All @@ -329,20 +329,20 @@ for (const contextManagerClass of [
it('should return current context (when disabled)', done => {
contextManager.disable();
const context = ROOT_CONTEXT.setValue(key1, 1);
const fn = contextManager.bind(() => {
const fn = contextManager.bind(context, () => {
assert.strictEqual(
contextManager.active(),
context,
'should have context'
);
return done();
}, context);
});
fn();
});

it('should fail to return current context with async op', done => {
const context = ROOT_CONTEXT.setValue(key1, 1);
const fn = contextManager.bind(() => {
const fn = contextManager.bind(context, () => {
assert.strictEqual(contextManager.active(), context);
setTimeout(() => {
assert.strictEqual(
Expand All @@ -352,7 +352,7 @@ for (const contextManagerClass of [
);
return done();
}, 100);
}, context);
});
fn();
});

Expand All @@ -363,32 +363,31 @@ for (const contextManagerClass of [
const context = ROOT_CONTEXT.setValue(key1, 2);
const otherContext = ROOT_CONTEXT.setValue(key1, 3);
const fn = otherContextManager.bind(
contextManager.bind(() => {
otherContext,
contextManager.bind(context, () => {
assert.strictEqual(contextManager.active(), context);
assert.strictEqual(otherContextManager.active(), otherContext);
}, context),
otherContext
);
}));
fn();
});
});

describe('.bind(event-emitter)', () => {
it('should return the same target (when enabled)', () => {
const ee = new EventEmitter();
assert.deepStrictEqual(contextManager.bind(ee, ROOT_CONTEXT), ee);
assert.deepStrictEqual(contextManager.bind(ROOT_CONTEXT, ee), ee);
});

it('should return the same target (when disabled)', () => {
const ee = new EventEmitter();
contextManager.disable();
assert.deepStrictEqual(contextManager.bind(ee, ROOT_CONTEXT), ee);
assert.deepStrictEqual(contextManager.bind(ROOT_CONTEXT, ee), ee);
});

it('should return current context and removeListener (when enabled)', done => {
const ee = new EventEmitter();
const context = ROOT_CONTEXT.setValue(key1, 1);
const patchedEE = contextManager.bind(ee, context);
const patchedEE = contextManager.bind(context, ee);
const handler = () => {
assert.deepStrictEqual(contextManager.active(), context);
patchedEE.removeListener('test', handler);
Expand All @@ -403,7 +402,7 @@ for (const contextManagerClass of [
it('should return current context and removeAllListener (when enabled)', done => {
const ee = new EventEmitter();
const context = ROOT_CONTEXT.setValue(key1, 1);
const patchedEE = contextManager.bind(ee, context);
const patchedEE = contextManager.bind(context, ee);
const handler = () => {
assert.deepStrictEqual(contextManager.active(), context);
patchedEE.removeAllListeners('test');
Expand All @@ -418,7 +417,7 @@ for (const contextManagerClass of [
it('should return current context and removeAllListeners (when enabled)', done => {
const ee = new EventEmitter();
const context = ROOT_CONTEXT.setValue(key1, 1);
const patchedEE = contextManager.bind(ee, context);
const patchedEE = contextManager.bind(context, ee);
const handler = () => {
assert.deepStrictEqual(contextManager.active(), context);
patchedEE.removeAllListeners();
Expand All @@ -441,7 +440,7 @@ for (const contextManagerClass of [
contextManager.disable();
const ee = new EventEmitter();
const context = ROOT_CONTEXT.setValue(key1, 1);
const patchedEE = contextManager.bind(ee, context);
const patchedEE = contextManager.bind(context, ee);
const handler = () => {
assert.deepStrictEqual(contextManager.active(), context);
patchedEE.removeListener('test', handler);
Expand All @@ -456,7 +455,7 @@ for (const contextManagerClass of [
it('should not return current context with async op', done => {
const ee = new EventEmitter();
const context = ROOT_CONTEXT.setValue(key1, 1);
const patchedEE = contextManager.bind(ee, context);
const patchedEE = contextManager.bind(context, ee);
const handler = () => {
assert.deepStrictEqual(contextManager.active(), context);
setImmediate(() => {
Expand All @@ -479,8 +478,8 @@ for (const contextManagerClass of [
const context = ROOT_CONTEXT.setValue(key1, 2);
const otherContext = ROOT_CONTEXT.setValue(key1, 3);
const patchedEE = otherContextManager.bind(
contextManager.bind(ee, context),
otherContext
otherContext,
contextManager.bind(context, ee),
);
const handler = () => {
assert.strictEqual(contextManager.active(), context);
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-context-zone-peer-dep/package.json
Expand Up @@ -46,7 +46,7 @@
},
"devDependencies": {
"@babel/core": "7.14.0",
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"@types/mocha": "8.2.2",
"@types/node": "14.14.43",
"@types/sinon": "9.0.11",
Expand Down Expand Up @@ -74,7 +74,7 @@
"zone.js": "0.11.4"
},
"peerDependencies": {
"@opentelemetry/api": "^0.20.0",
"@opentelemetry/api": "^0.21.0",
"zone.js": "^0.10.2 || ^0.11.0"
},
"sideEffects": false
Expand Down
Expand Up @@ -153,7 +153,7 @@ export class ZoneContextManager implements ContextManager {
listeners = new WeakMap();
target.__ot_listeners[event] = listeners;
}
const patchedListener = contextManager.bind(listener, context);
const patchedListener = contextManager.bind(context, listener);
// store a weak reference of the user listener to ours
listeners.set(listener, patchedListener);
return original.call(this, event, patchedListener, opts);
Expand Down Expand Up @@ -205,7 +205,7 @@ export class ZoneContextManager implements ContextManager {
* @param target
dyladan marked this conversation as resolved.
Show resolved Hide resolved
* @param context A context (span) to be bind to target
*/
bind<T>(target: T | TargetWithEvents, context: Context): T {
bind<T>(context: Context, target: T | TargetWithEvents): T {
dyladan marked this conversation as resolved.
Show resolved Hide resolved
// if no specific context to propagate is given, we use the current one
if (context === undefined) {
context = this.active();
Expand Down
Expand Up @@ -251,54 +251,56 @@ describe('ZoneContextManager', () => {
const ctx = ROOT_CONTEXT.setValue(key1, obj1);
obj1.title = 'a2';
const obj2 = new Obj('b1');
const wrapper: any = contextManager.bind(obj2.getTitle, ctx);
const wrapper: any = contextManager.bind(ctx, obj2.getTitle);
assert.ok(wrapper(), 'a2');
});

it('should return the same target (when enabled)', () => {
const test = { a: 1 };
assert.deepStrictEqual(contextManager.bind(test, ROOT_CONTEXT), test);
assert.deepStrictEqual(contextManager.bind(ROOT_CONTEXT, test), test);
});

it('should return the same target (when disabled)', () => {
contextManager.disable();
const test = { a: 1 };
assert.deepStrictEqual(contextManager.bind(test, ROOT_CONTEXT), test);
assert.deepStrictEqual(contextManager.bind(ROOT_CONTEXT, test), test);
contextManager.enable();
});

it('should return current context (when enabled)', done => {
const context = ROOT_CONTEXT.setValue(key1, { a: 1 });
const fn: any = contextManager.bind(() => {
const fn: any = contextManager.bind(
context,
() => {
assert.strictEqual(
contextManager.active(),
context,
'should have context'
);
return done();
}, context);
});
fn();
});

it('should return root context (when disabled)', done => {
contextManager.disable();
const context = ROOT_CONTEXT.setValue(key1, { a: 1 });
const fn: any = contextManager.bind(() => {
const fn: any = contextManager.bind(context, () => {
assert.strictEqual(
contextManager.active(),
ROOT_CONTEXT,
'should have context'
);
return done();
}, context);
});
fn();
});

it('should bind the the certain context to the target "addEventListener" function', done => {
const ctx1 = ROOT_CONTEXT.setValue(key1, 1);
const element = document.createElement('div');

contextManager.bind(element, ctx1);
contextManager.bind(ctx1, element);

element.addEventListener('click', () => {
assert.strictEqual(contextManager.active(), ctx1);
Expand All @@ -322,7 +324,7 @@ describe('ZoneContextManager', () => {
const ctx1 = ROOT_CONTEXT.setValue(key1, 1);
const element = document.createElement('div');

contextManager.bind(element, ctx1);
contextManager.bind(ctx1, element);

element.addEventListener('click', () => {
assert.strictEqual(contextManager.active(), ctx1);
Expand Down