diff --git a/packages/opentelemetry-basic-tracer/package.json b/packages/opentelemetry-basic-tracer/package.json index a322d81524a..503e4e66a9d 100644 --- a/packages/opentelemetry-basic-tracer/package.json +++ b/packages/opentelemetry-basic-tracer/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "clean": "rimraf build/*", diff --git a/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts b/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts index 635fe998a07..379f8dda463 100644 --- a/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts +++ b/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts @@ -171,6 +171,7 @@ describe('BasicTracer', () => { const tracer = new BasicTracer({ sampler: NEVER_SAMPLER, scopeManager: new NoopScopeManager(), + logger: new NoopLogger(), }); const span = tracer.startSpan('my-span'); assert.ok(span instanceof NoRecordingSpan); @@ -193,10 +194,11 @@ describe('BasicTracer', () => { assert.strictEqual(span.isRecordingEvents(), true); }); - it('should not create real span when not sampled and recording events false', () => { + it('should not create real span when not sampled and recording events false', () => { const tracer = new BasicTracer({ sampler: NEVER_SAMPLER, scopeManager: new NoopScopeManager(), + logger: new NoopLogger(), }); const span = tracer.startSpan('my-span', { isRecordingEvents: false }); assert.ok(span instanceof NoRecordingSpan); @@ -208,6 +210,7 @@ describe('BasicTracer', () => { const tracer = new BasicTracer({ sampler: NEVER_SAMPLER, scopeManager: new NoopScopeManager(), + logger: new NoopLogger(), }); const span = tracer.startSpan('my-span'); assert.ok(span instanceof NoRecordingSpan); diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index 9bec1774fa6..3999f7a74fd 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -5,7 +5,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index b3d8fa55863..77bf5b28178 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -5,7 +5,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", diff --git a/packages/opentelemetry-node-tracer/package.json b/packages/opentelemetry-node-tracer/package.json index c26e02dd8e6..2b1ba68b113 100644 --- a/packages/opentelemetry-node-tracer/package.json +++ b/packages/opentelemetry-node-tracer/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "clean": "rimraf build/*", diff --git a/packages/opentelemetry-node-tracer/test/NodeTracer.test.ts b/packages/opentelemetry-node-tracer/test/NodeTracer.test.ts index c84fa6a5abc..bb14c6a571b 100644 --- a/packages/opentelemetry-node-tracer/test/NodeTracer.test.ts +++ b/packages/opentelemetry-node-tracer/test/NodeTracer.test.ts @@ -21,10 +21,12 @@ import { HttpTraceContext, NEVER_SAMPLER, NoopLogger, - NOOP_SPAN, + NoRecordingSpan, } from '@opentelemetry/core'; import { AsyncHooksScopeManager } from '@opentelemetry/scope-async-hooks'; import { NodeTracer } from '../src/NodeTracer'; +import { TraceOptions } from '@opentelemetry/types'; +import { Span } from '@opentelemetry/basic-tracer'; describe('NodeTracer', () => { describe('constructor', () => { @@ -83,6 +85,7 @@ describe('NodeTracer', () => { it('should start a span with name only', () => { const tracer = new NodeTracer({ scopeManager: new AsyncHooksScopeManager(), + logger: new NoopLogger(), }); const span = tracer.startSpan('my-span'); assert.ok(span); @@ -91,6 +94,7 @@ describe('NodeTracer', () => { it('should start a span with name and options', () => { const tracer = new NodeTracer({ scopeManager: new AsyncHooksScopeManager(), + logger: new NoopLogger(), }); const span = tracer.startSpan('my-span', {}); assert.ok(span); @@ -100,16 +104,30 @@ describe('NodeTracer', () => { const tracer = new NodeTracer({ sampler: NEVER_SAMPLER, scopeManager: new AsyncHooksScopeManager(), + logger: new NoopLogger(), }); const span = tracer.startSpan('my-span'); - assert.deepStrictEqual(span, NOOP_SPAN); + assert.ok(span instanceof NoRecordingSpan); + assert.strictEqual(span.context().traceOptions, TraceOptions.UNSAMPLED); + assert.strictEqual(span.isRecordingEvents(), false); }); // @todo: implement it('should start a Span with always sampling'); - // @todo: implement - it('should set default attributes on span'); + it('should set default attributes on span', () => { + const defaultAttributes = { + foo: 'bar', + }; + const tracer = new NodeTracer({ + scopeManager: new AsyncHooksScopeManager(), + defaultAttributes, + }); + + const span = tracer.startSpan('my-span') as Span; + assert.ok(span instanceof Span); + assert.deepStrictEqual(span.attributes, defaultAttributes); + }); }); describe('.getCurrentSpan()', () => { @@ -178,7 +196,7 @@ describe('NodeTracer', () => { it('should call exporters with span data'); }); - describe('getBinaryFormat', () => { + describe('.getBinaryFormat()', () => { it('should get default binary formatter', () => { const tracer = new NodeTracer({ scopeManager: new AsyncHooksScopeManager(), diff --git a/packages/opentelemetry-plugin-grpc/package.json b/packages/opentelemetry-plugin-grpc/package.json index 15b16d3ae34..976e3be3ad1 100644 --- a/packages/opentelemetry-plugin-grpc/package.json +++ b/packages/opentelemetry-plugin-grpc/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", diff --git a/packages/opentelemetry-plugin-http2/package.json b/packages/opentelemetry-plugin-http2/package.json index 896b15aac0b..b000f20ccff 100644 --- a/packages/opentelemetry-plugin-http2/package.json +++ b/packages/opentelemetry-plugin-http2/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", diff --git a/packages/opentelemetry-plugin-https/package.json b/packages/opentelemetry-plugin-https/package.json index ccf580dac4a..0b867ada5fd 100644 --- a/packages/opentelemetry-plugin-https/package.json +++ b/packages/opentelemetry-plugin-https/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", diff --git a/packages/opentelemetry-plugin-mongodb/package.json b/packages/opentelemetry-plugin-mongodb/package.json index a5272d131d5..58a4da9e30b 100644 --- a/packages/opentelemetry-plugin-mongodb/package.json +++ b/packages/opentelemetry-plugin-mongodb/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", diff --git a/packages/opentelemetry-plugin-redis/package.json b/packages/opentelemetry-plugin-redis/package.json index 4c2c38b58ea..766d7ed8f99 100644 --- a/packages/opentelemetry-plugin-redis/package.json +++ b/packages/opentelemetry-plugin-redis/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", diff --git a/packages/opentelemetry-scope-async-hooks/package.json b/packages/opentelemetry-scope-async-hooks/package.json index 9f2c6dfb5b1..910e7ba4684 100644 --- a/packages/opentelemetry-scope-async-hooks/package.json +++ b/packages/opentelemetry-scope-async-hooks/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "clean": "rimraf build/*", diff --git a/packages/opentelemetry-scope-base/package.json b/packages/opentelemetry-scope-base/package.json index 26eedab49eb..8fbd5a70457 100644 --- a/packages/opentelemetry-scope-base/package.json +++ b/packages/opentelemetry-scope-base/package.json @@ -6,7 +6,7 @@ "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", "tdd": "yarn test -- --watch-extensions ts --watch", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "clean": "rimraf build/*",