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 to OTel 0.15.0 #315

Merged
merged 3 commits into from
Jan 22, 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 @@ -43,8 +43,8 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/core": "^0.14.0",
"@opentelemetry/tracing": "^0.14.0",
"@opentelemetry/core": "^0.15.0",
"@opentelemetry/tracing": "^0.15.0",
"@types/mocha": "8.0.1",
"@types/node": "14.0.27",
"@types/sinon": "9.0.4",
Expand All @@ -60,8 +60,8 @@
"typescript": "3.9.7"
},
"dependencies": {
"@opentelemetry/api": "^0.14.0",
"@opentelemetry/core": "^0.14.0",
"@opentelemetry/resources": "^0.14.0"
"@opentelemetry/api": "^0.15.0",
"@opentelemetry/core": "^0.15.0",
"@opentelemetry/resources": "^0.15.0"
}
}
2 changes: 1 addition & 1 deletion metapackages/plugins-node-core-and-contrib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"@opentelemetry/plugin-pg": "^0.12.1",
"@opentelemetry/plugin-pg-pool": "^0.12.1",
"@opentelemetry/plugin-redis": "^0.12.1",
"@opentelemetry/plugins-node-core": "^0.14.0"
"@opentelemetry/plugins-node-core": "^0.15.0"
}
}
9 changes: 5 additions & 4 deletions packages/opentelemetry-host-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/exporter-prometheus": "^0.14.0",
"@opentelemetry/exporter-prometheus": "^0.15.0",
"@types/mocha": "8.0.2",
"@types/node": "14.0.27",
"@types/sinon": "9.0.4",
Expand All @@ -61,9 +61,10 @@
"typescript": "3.9.7"
},
"dependencies": {
"@opentelemetry/api": "^0.14.0",
"@opentelemetry/core": "^0.14.0",
"@opentelemetry/metrics": "^0.14.0",
"@opentelemetry/api": "^0.15.0",
"@opentelemetry/api-metrics": "^0.15.0",
"@opentelemetry/core": "^0.15.0",
"@opentelemetry/metrics": "^0.15.0",
"systeminformation": "^4.31.0"
}
}
9 changes: 5 additions & 4 deletions packages/opentelemetry-host-metrics/src/BaseMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* limitations under the License.
*/

import * as api from '@opentelemetry/api';
import { Logger, NoopLogger } from '@opentelemetry/api';
import * as api from '@opentelemetry/api-metrics';
import * as metrics from '@opentelemetry/metrics';

import { VERSION } from './version';
Expand All @@ -23,7 +24,7 @@ import { VERSION } from './version';
* Metrics Collector Configuration
*/
export interface MetricsCollectorConfig {
logger?: api.Logger;
logger?: Logger;
// maximum timeout to wait for stats collection default is 500ms
maxTimeoutUpdateMS?: number;
// Meter Provider
Expand All @@ -47,15 +48,15 @@ const DEFAULT_KEY = 'name';
* Base Class for metrics
*/
export abstract class BaseMetrics {
protected _logger: api.Logger | undefined;
protected _logger: Logger | undefined;
protected _maxTimeoutUpdateMS: number;
protected _meter: metrics.Meter;
private _name: string;
private _boundCounters: { [key: string]: api.BoundCounter } = {};
private _metricNameSeparator: string;

constructor(config: MetricsCollectorConfig) {
this._logger = config.logger || new api.NoopLogger();
this._logger = config.logger || new NoopLogger();
this._name = config.name || DEFAULT_NAME;
this._maxTimeoutUpdateMS =
config.maxTimeoutUpdateMS || DEFAULT_MAX_TIMEOUT_UPDATE_MS;
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-host-metrics/src/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { BaseMetrics } from './BaseMetrics';
import * as api from '@opentelemetry/api';
import * as api from '@opentelemetry/api-metrics';
import * as enums from './enum';

import { getCpuUsageData, getMemoryData } from './stats/common';
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"typescript": "3.9.6"
},
"dependencies": {
"@opentelemetry/api": "^0.14.0",
"@opentelemetry/core": "^0.14.0",
"@opentelemetry/tracing": "^0.14.0"
"@opentelemetry/api": "^0.15.0",
"@opentelemetry/core": "^0.15.0",
"@opentelemetry/tracing": "^0.15.0"
}
}
12 changes: 6 additions & 6 deletions plugins/node/opentelemetry-hapi-instrumentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
},
"devDependencies": {
"@hapi/hapi": "20.0.1",
"@opentelemetry/context-async-hooks": "^0.14.0",
"@opentelemetry/node": "^0.14.0",
"@opentelemetry/tracing": "^0.14.0",
"@opentelemetry/context-async-hooks": "^0.15.0",
"@opentelemetry/node": "^0.15.0",
"@opentelemetry/tracing": "^0.15.0",
"@types/hapi__hapi": "20.0.1",
"@types/mocha": "7.0.2",
"@types/node": "12.12.47",
Expand All @@ -64,9 +64,9 @@
"typescript": "3.9.6"
},
"dependencies": {
"@opentelemetry/api": "^0.14.0",
"@opentelemetry/core": "^0.14.0",
"@opentelemetry/semantic-conventions": "^0.14.0",
"@opentelemetry/api": "^0.15.0",
"@opentelemetry/core": "^0.15.0",
"@opentelemetry/semantic-conventions": "^0.15.0",
"shimmer": "^1.2.1"
}
}
7 changes: 4 additions & 3 deletions plugins/node/opentelemetry-hapi-instrumentation/src/hapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { context, getSpan, setSpan } from '@opentelemetry/api';
import { BasePlugin } from '@opentelemetry/core';
import type * as Hapi from '@hapi/hapi';
import { VERSION } from './version';
Expand Down Expand Up @@ -328,15 +329,15 @@ export class HapiInstrumentation extends BasePlugin<typeof Hapi> {
const newHandler: PatchableExtMethod = async function (
...params: Parameters<Hapi.Lifecycle.Method>
) {
if (instrumentation._tracer.getCurrentSpan() === undefined) {
if (getSpan(context.active()) === undefined) {
return await method(...params);
}
const metadata = getExtMetadata(extPoint, pluginName);
const span = instrumentation._tracer.startSpan(metadata.name, {
attributes: metadata.attributes,
});
let res;
await instrumentation._tracer.withSpan(span, async () => {
await context.with(setSpan(context.active(), span), async () => {
res = await method(...params);
});
span.end();
Expand Down Expand Up @@ -368,7 +369,7 @@ export class HapiInstrumentation extends BasePlugin<typeof Hapi> {
h: Hapi.ResponseToolkit,
err?: Error
) {
if (instrumentation._tracer.getCurrentSpan() === undefined) {
if (getSpan(context.active()) === undefined) {
return await oldHandler(request, h, err);
}
const metadata = getRouteMetadata(route, pluginName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/

import { context } from '@opentelemetry/api';
import { NoopLogger } from '@opentelemetry/core';
import { context, NoopLogger, setSpan } from '@opentelemetry/api';
import { NodeTracerProvider } from '@opentelemetry/node';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import {
Expand Down Expand Up @@ -122,7 +121,7 @@ describe('Hapi Instrumentation - Hapi.Plugin Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -173,7 +172,7 @@ describe('Hapi Instrumentation - Hapi.Plugin Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res1 = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -243,7 +242,7 @@ describe('Hapi Instrumentation - Hapi.Plugin Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res1 = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -301,7 +300,7 @@ describe('Hapi Instrumentation - Hapi.Plugin Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/package',
Expand Down Expand Up @@ -342,7 +341,7 @@ describe('Hapi Instrumentation - Hapi.Plugin Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/package',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/

import { context } from '@opentelemetry/api';
import { NoopLogger } from '@opentelemetry/core';
import { context, NoopLogger, setSpan } from '@opentelemetry/api';
import { NodeTracerProvider } from '@opentelemetry/node';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import {
Expand Down Expand Up @@ -72,7 +71,7 @@ describe('Hapi Instrumentation - Server.Ext Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -113,7 +112,7 @@ describe('Hapi Instrumentation - Server.Ext Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -159,7 +158,7 @@ describe('Hapi Instrumentation - Server.Ext Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -219,7 +218,7 @@ describe('Hapi Instrumentation - Server.Ext Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -282,7 +281,7 @@ describe('Hapi Instrumentation - Server.Ext Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/test',
Expand Down Expand Up @@ -313,7 +312,7 @@ describe('Hapi Instrumentation - Server.Ext Tests', () => {

it('does not instrument Hapi.ServerExtPointFunction handlers', async () => {
const rootSpan = tracer.startSpan('rootSpan');
await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
server.ext('onPreStart', async (server: hapi.Server) => {
return;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/

import { context } from '@opentelemetry/api';
import { NoopLogger } from '@opentelemetry/core';
import { context, NoopLogger, setSpan } from '@opentelemetry/api';
import { NodeTracerProvider } from '@opentelemetry/node';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import {
Expand Down Expand Up @@ -75,7 +74,7 @@ describe('Hapi Instrumentation - Core Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/',
Expand Down Expand Up @@ -117,7 +116,7 @@ describe('Hapi Instrumentation - Core Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/',
Expand Down Expand Up @@ -162,7 +161,7 @@ describe('Hapi Instrumentation - Core Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/',
Expand Down Expand Up @@ -210,7 +209,7 @@ describe('Hapi Instrumentation - Core Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const resFirst = await server.inject({
method: 'GET',
url: '/first',
Expand Down Expand Up @@ -264,7 +263,7 @@ describe('Hapi Instrumentation - Core Tests', () => {
await server.start();
assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/users/1',
Expand Down Expand Up @@ -334,7 +333,7 @@ describe('Hapi Instrumentation - Core Tests', () => {

assert.strictEqual(memoryExporter.getFinishedSpans().length, 0);

await tracer.withSpan(rootSpan, async () => {
await context.with(setSpan(context.active(), rootSpan), async () => {
const res = await server.inject({
method: 'GET',
url: '/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/tracing": "^0.14.0",
"@opentelemetry/tracing": "^0.15.0",
"@types/graphql": "14.5.0",
"@types/mocha": "8.0.1",
"@types/node": "14.0.27",
Expand All @@ -61,7 +61,7 @@
"typescript": "3.9.7"
},
"dependencies": {
"@opentelemetry/api": "^0.14.0",
"@opentelemetry/instrumentation": "^0.14.0"
"@opentelemetry/api": "^0.15.0",
"@opentelemetry/instrumentation": "^0.15.0"
}
}
Loading