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.18.0 #1977

Merged
merged 2 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"compile": "tsc --build"
},
"dependencies": {
"@opentelemetry/api": "^0.17.0",
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/context-async-hooks": "^0.17.0",
"@opentelemetry/core": "^0.17.0",
"@opentelemetry/tracing": "^0.17.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-api-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"access": "public"
},
"dependencies": {
"@opentelemetry/api": "^0.17.0"
"@opentelemetry/api": "^0.18.0"
},
"devDependencies": {
"@types/mocha": "8.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-context-async-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
"typescript": "4.1.3"
},
"dependencies": {
"@opentelemetry/context-base": "^0.17.0"
"@opentelemetry/api": "^0.18.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { ContextManager, Context } from '@opentelemetry/context-base';
import { ContextManager, Context } from '@opentelemetry/api';
import { EventEmitter } from 'events';

type Func<T> = (...args: unknown[]) => T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Context, ROOT_CONTEXT } from '@opentelemetry/context-base';
import { Context, ROOT_CONTEXT } from '@opentelemetry/api';
import * as asyncHooks from 'async_hooks';
import { AbstractAsyncHooksContextManager } from './AbstractAsyncHooksContextManager';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Context, ROOT_CONTEXT } from '@opentelemetry/context-base';
import { Context, ROOT_CONTEXT } from '@opentelemetry/api';
import { AsyncLocalStorage } from 'async_hooks';
import { AbstractAsyncHooksContextManager } from './AbstractAsyncHooksContextManager';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
AsyncLocalStorageContextManager,
} from '../src';
import { EventEmitter } from 'events';
import { createContextKey, ROOT_CONTEXT } from '@opentelemetry/context-base';
import { createContextKey, ROOT_CONTEXT } from '@opentelemetry/api';

for (const contextManagerClass of [
AsyncHooksContextManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"zone.js": "0.11.3"
},
"dependencies": {
"@opentelemetry/context-base": "^0.17.0"
"@opentelemetry/api": "^0.18.0"
},
"peerDependencies": {
"zone.js": "^0.10.2 || ^0.11.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
* limitations under the License.
*/

import {
Context,
ContextManager,
ROOT_CONTEXT,
} from '@opentelemetry/context-base';
import { Context, ContextManager, ROOT_CONTEXT } from '@opentelemetry/api';
import { Func, TargetWithEvents } from './types';
import { isListenerObject } from './util';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'zone.js';
import * as sinon from 'sinon';
import * as assert from 'assert';
import { ZoneContextManager } from '../src';
import { ROOT_CONTEXT, createContextKey } from '@opentelemetry/context-base';
import { ROOT_CONTEXT, createContextKey } from '@opentelemetry/api';

let clock: any;

Expand Down
3 changes: 1 addition & 2 deletions packages/opentelemetry-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@
"webpack": "4.46.0"
},
"dependencies": {
"@opentelemetry/api": "^0.17.0",
"@opentelemetry/context-base": "^0.17.0",
"@opentelemetry/api": "^0.18.0",
"semver": "^7.1.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
getBaggage,
setBaggage,
} from '@opentelemetry/api';
import { ROOT_CONTEXT } from '@opentelemetry/context-base';
import { ROOT_CONTEXT } from '@opentelemetry/api';
import * as assert from 'assert';
import {
BAGGAGE_HEADER,
Expand Down
36 changes: 15 additions & 21 deletions packages/opentelemetry-core/test/common/time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,60 +30,54 @@ import {
} from '../../src/common/time';

describe('time', () => {
let sandbox: sinon.SinonSandbox;

beforeEach(() => {
sandbox = sinon.createSandbox();
});

afterEach(() => {
sandbox.restore();
sinon.restore();
});

describe('#hrTime', () => {
it('should return hrtime now', () => {
sandbox.stub(performance, 'timeOrigin').value(11.5);
sandbox.stub(performance, 'now').callsFake(() => 11.3);
sinon.stub(performance, 'timeOrigin').value(11.5);
sinon.stub(performance, 'now').callsFake(() => 11.3);

const output = hrTime();
assert.deepStrictEqual(output, [0, 22800000]);
});

it('should convert performance now', () => {
sandbox.stub(performance, 'timeOrigin').value(11.5);
sinon.stub(performance, 'timeOrigin').value(11.5);
const performanceNow = 11.3;

const output = hrTime(performanceNow);
assert.deepStrictEqual(output, [0, 22800000]);
});

it('should handle nanosecond overflow', () => {
sandbox.stub(performance, 'timeOrigin').value(11.5);
sinon.stub(performance, 'timeOrigin').value(11.5);
const performanceNow = 11.6;

const output = hrTime(performanceNow);
assert.deepStrictEqual(output, [0, 23100000]);
});

it('should allow passed "performanceNow" equal to 0', () => {
sandbox.stub(performance, 'timeOrigin').value(11.5);
sandbox.stub(performance, 'now').callsFake(() => 11.3);
sinon.stub(performance, 'timeOrigin').value(11.5);
sinon.stub(performance, 'now').callsFake(() => 11.3);

const output = hrTime(0);
assert.deepStrictEqual(output, [0, 11500000]);
});

it('should use performance.now() when "performanceNow" is equal to undefined', () => {
sandbox.stub(performance, 'timeOrigin').value(11.5);
sandbox.stub(performance, 'now').callsFake(() => 11.3);
sinon.stub(performance, 'timeOrigin').value(11.5);
sinon.stub(performance, 'now').callsFake(() => 11.3);

const output = hrTime(undefined);
assert.deepStrictEqual(output, [0, 22800000]);
});

it('should use performance.now() when "performanceNow" is equal to null', () => {
sandbox.stub(performance, 'timeOrigin').value(11.5);
sandbox.stub(performance, 'now').callsFake(() => 11.3);
sinon.stub(performance, 'timeOrigin').value(11.5);
sinon.stub(performance, 'now').callsFake(() => 11.3);

const output = hrTime(null as any);
assert.deepStrictEqual(output, [0, 22800000]);
Expand All @@ -98,8 +92,8 @@ describe('time', () => {
},
});

sandbox.stub(performance, 'timeOrigin').value(undefined);
sandbox.stub(performance, 'now').callsFake(() => 11.3);
sinon.stub(performance, 'timeOrigin').value(undefined);
sinon.stub(performance, 'now').callsFake(() => 11.3);

const output = hrTime();
assert.deepStrictEqual(output, [0, 22800000]);
Expand All @@ -121,7 +115,7 @@ describe('time', () => {
});

it('should convert performance.now() hrTime', () => {
sandbox.stub(performance, 'timeOrigin').value(111.5);
sinon.stub(performance, 'timeOrigin').value(111.5);

const timeInput = 11.9;
const output = timeInputToHrTime(timeInput);
Expand All @@ -130,7 +124,7 @@ describe('time', () => {
});

it('should not convert hrtime hrTime', () => {
sandbox.stub(performance, 'timeOrigin').value(111.5);
sinon.stub(performance, 'timeOrigin').value(111.5);

const timeInput: [number, number] = [3138971, 245466222];
const output = timeInputToHrTime(timeInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
getSpanContext,
setSpanContext,
} from '@opentelemetry/api';
import { ROOT_CONTEXT } from '@opentelemetry/context-base';
import { ROOT_CONTEXT } from '@opentelemetry/api';
import * as assert from 'assert';
import {
HttpTraceContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
getSpanContext,
setSpanContext,
} from '@opentelemetry/api';
import { Context, ROOT_CONTEXT } from '@opentelemetry/context-base';
import { Context, ROOT_CONTEXT } from '@opentelemetry/api';
import * as assert from 'assert';
import {
CompositePropagator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,9 @@ export function removeMockEnvironment() {
}

describe('environment', () => {
let sandbox: sinon.SinonSandbox;

beforeEach(() => {
sandbox = sinon.createSandbox();
});

afterEach(() => {
removeMockEnvironment();
sandbox.restore();
sinon.restore();
});

describe('parseEnvironment', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"dependencies": {
"@grpc/proto-loader": "^0.5.4",
"@opentelemetry/api": "^0.17.0",
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/core": "^0.17.0",
"@opentelemetry/exporter-collector": "^0.17.0",
"@opentelemetry/metrics": "^0.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ const testCollectorMetricExporter = (params: TestParams) =>
});

beforeEach(async () => {
// Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped
diag.setLogger();
const credentials = params.useTLS
? grpc.credentials.createSsl(
fs.readFileSync('./test/certs/ca.crt'),
Expand Down Expand Up @@ -162,12 +160,13 @@ const testCollectorMetricExporter = (params: TestParams) =>
afterEach(() => {
exportedData = undefined;
reqMetadata = undefined;
sinon.restore();
});

describe('instance', () => {
it('should warn about headers', () => {
// Need to stub/spy on the underlying logger as the "diag" instance is global
const spyLoggerWarn = sinon.stub(diag.getLogger(), 'warn');
const spyLoggerWarn = sinon.stub(diag, 'warn');
collectorExporter = new CollectorMetricExporter({
serviceName: 'basic-service',
url: address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ const testCollectorExporter = (params: TestParams) =>
});

beforeEach(done => {
// Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped
diag.setLogger();
const credentials = params.useTLS
? grpc.credentials.createSsl(
fs.readFileSync('./test/certs/ca.crt'),
Expand All @@ -139,12 +137,13 @@ const testCollectorExporter = (params: TestParams) =>
afterEach(() => {
exportedData = undefined;
reqMetadata = undefined;
sinon.restore();
});

describe('instance', () => {
it('should warn about headers when using grpc', () => {
// Need to stub/spy on the underlying logger as the "diag" instance is global
const spyLoggerWarn = sinon.stub(diag.getLogger(), 'warn');
const spyLoggerWarn = sinon.stub(diag, 'warn');
collectorExporter = new CollectorTraceExporter({
serviceName: 'basic-service',
url: address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"dependencies": {
"@grpc/proto-loader": "^0.5.4",
"@opentelemetry/api": "^0.17.0",
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/core": "^0.17.0",
"@opentelemetry/exporter-collector": "^0.17.0",
"@opentelemetry/metrics": "^0.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ describe('CollectorMetricExporter - node with proto over http', () => {

describe('export', () => {
beforeEach(async () => {
// Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped
diag.setLogger();
collectorExporterConfig = {
headers: {
foo: 'bar',
Expand Down Expand Up @@ -177,7 +175,7 @@ describe('CollectorMetricExporter - node with proto over http', () => {

it('should log the successful message', done => {
// Need to stub/spy on the underlying logger as the "diag" instance is global
const spyLoggerError = sinon.stub(diag.getLogger(), 'error');
const spyLoggerError = sinon.stub(diag, 'error');

collectorExporter.export(metrics, result => {
assert.strictEqual(result.code, ExportResultCode.SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ describe('CollectorTraceExporter - node with proto over http', () => {

describe('export', () => {
beforeEach(() => {
// Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped
diag.setLogger();
collectorExporterConfig = {
headers: {
foo: 'bar',
Expand Down Expand Up @@ -126,7 +124,7 @@ describe('CollectorTraceExporter - node with proto over http', () => {

it('should log the successful message', done => {
// Need to stub/spy on the underlying logger as the "diag" instance is global
const spyLoggerError = sinon.stub(diag.getLogger(), 'error');
const spyLoggerError = sinon.stub(diag, 'error');

collectorExporter.export(spans, result => {
assert.strictEqual(result.code, ExportResultCode.SUCCESS);
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-collector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"webpack-merge": "5.7.3"
},
"dependencies": {
"@opentelemetry/api": "^0.17.0",
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/api-metrics": "^0.17.0",
"@opentelemetry/core": "^0.17.0",
"@opentelemetry/metrics": "^0.17.0",
Expand Down
Loading