From 272b4b8438d46a3cc536e5f36f3f249bc33de6a2 Mon Sep 17 00:00:00 2001 From: Olivier Albertini Date: Mon, 5 Aug 2019 20:07:28 -0400 Subject: [PATCH] ci: gts fix for ci build Signed-off-by: Olivier Albertini --- .../opentelemetry-basic-tracer/package.json | 2 +- .../opentelemetry-basic-tracer/src/Span.ts | 21 +--- .../opentelemetry-basic-tracer/src/types.ts | 8 +- .../test/BasicTracer.test.ts | 30 ++--- .../test/Span.test.ts | 15 +-- packages/opentelemetry-core/package.json | 2 +- .../context/propagation/BinaryTraceContext.ts | 7 +- .../context/propagation/HttpTraceContext.ts | 39 ++---- .../src/internal/validators.ts | 5 +- .../opentelemetry-core/src/trace/NoopSpan.ts | 4 +- .../src/trace/NoopTracer.ts | 13 +- .../src/trace/TracerDelegate.ts | 5 +- .../src/trace/instrumentation/BasePlugin.ts | 6 +- .../src/trace/spancontext-utils.ts | 7 +- .../test/context/BinaryTraceContext.test.ts | 27 ++--- .../test/context/HttpTraceContext.test.ts | 113 +++++------------- .../test/internal/validators.test.ts | 16 +-- .../test/resources/resource.test.ts | 10 +- .../test/trace/NoopSpan.test.ts | 8 +- .../test/trace/NoopTracer.test.ts | 7 +- .../test/trace/ProbabilitySampler.test.ts | 8 +- .../test/trace/TracerDelegate.test.ts | 20 +--- .../test/trace/globaltracer-utils.test.ts | 14 +-- .../test/trace/spancontext-utils.test.ts | 8 +- .../test/trace/tracestate.test.ts | 20 +--- .../opentelemetry-node-tracer/src/index.ts | 2 +- .../src/instrumentation/PluginLoader.ts | 14 +-- .../src/instrumentation/utils.ts | 13 +- .../test/instrumentation/PluginLoader.test.ts | 6 +- .../test/instrumentation/utils.test.ts | 23 ++-- .../opentelemetry-plugin-http/src/utils.ts | 2 +- .../src/AsyncHooksScopeManager.ts | 9 +- .../asynchooks/AsyncHooksScopeManager.test.ts | 6 +- .../src/NoopScopeManager.ts | 5 +- .../opentelemetry-scope-base/src/types.ts | 5 +- .../test/noop/NoopScopeManager.test.ts | 6 +- packages/opentelemetry-types/package.json | 2 +- .../src/distributed_context/EntryValue.ts | 2 +- .../src/trace/instrumentation/Plugin.ts | 6 +- .../src/trace/span_kind.ts | 2 +- .../opentelemetry-types/src/trace/status.ts | 2 +- .../src/trace/trace_options.ts | 2 +- .../opentelemetry-types/src/trace/tracer.ts | 5 +- 43 files changed, 154 insertions(+), 373 deletions(-) diff --git a/packages/opentelemetry-basic-tracer/package.json b/packages/opentelemetry-basic-tracer/package.json index a322d81524a..8a0d23fffbc 100644 --- a/packages/opentelemetry-basic-tracer/package.json +++ b/packages/opentelemetry-basic-tracer/package.json @@ -41,7 +41,7 @@ "@types/mocha": "^5.2.5", "@types/node": "^12.6.8", "codecov": "^3.1.0", - "gts": "^1.0.0", + "gts": "^1.1.0", "mocha": "^6.1.0", "nyc": "^14.1.1", "ts-mocha": "^6.0.0", diff --git a/packages/opentelemetry-basic-tracer/src/Span.ts b/packages/opentelemetry-basic-tracer/src/Span.ts index a421004853d..0b729be4768 100644 --- a/packages/opentelemetry-basic-tracer/src/Span.ts +++ b/packages/opentelemetry-basic-tracer/src/Span.ts @@ -15,12 +15,7 @@ */ import * as types from '@opentelemetry/types'; -import { - randomSpanId, - randomTraceId, - INVALID_SPAN_CONTEXT, - isValid, -} from '@opentelemetry/core'; +import { randomSpanId, randomTraceId, INVALID_SPAN_CONTEXT, isValid } from '@opentelemetry/core'; import { performance } from 'perf_hooks'; import { TraceOptions } from '@opentelemetry/types'; @@ -36,7 +31,7 @@ export class Span implements types.Span { private readonly _links: types.Link[] = []; private readonly _events: types.Event[] = []; private _status: types.Status = { - code: types.CanonicalCode.OK, + code: types.CanonicalCode.OK }; private _name: string; private _ended = false; @@ -44,11 +39,7 @@ export class Span implements types.Span { private _endTime = 0; /** Constructs a new Span instance. */ - constructor( - parentTracer: types.Tracer, - spanName: string, - options: types.SpanOptions - ) { + constructor(parentTracer: types.Tracer, spanName: string, options: types.SpanOptions) { this._tracer = parentTracer; this._name = spanName; this._spanContext.spanId = randomSpanId(); @@ -132,14 +123,12 @@ export class Span implements types.Span { kind: this._kind, status: this._status, startTime: this._startTime, - endTime: this._endTime, + endTime: this._endTime }); return `Span${json}`; } - private _getParentSpanContext( - parent: types.Span | types.SpanContext | undefined - ): types.SpanContext | undefined { + private _getParentSpanContext(parent: types.Span | types.SpanContext | undefined): types.SpanContext | undefined { if (!parent) return undefined; // parent is a SpanContext diff --git a/packages/opentelemetry-basic-tracer/src/types.ts b/packages/opentelemetry-basic-tracer/src/types.ts index b4e7bdfad24..e66124de174 100644 --- a/packages/opentelemetry-basic-tracer/src/types.ts +++ b/packages/opentelemetry-basic-tracer/src/types.ts @@ -15,13 +15,7 @@ */ import { ScopeManager } from '@opentelemetry/scope-base'; -import { - Attributes, - BinaryFormat, - HttpTextFormat, - Logger, - Sampler, -} from '@opentelemetry/types'; +import { Attributes, BinaryFormat, HttpTextFormat, Logger, Sampler } from '@opentelemetry/types'; /** * BasicTracerConfig provides an interface for configuring a Basic Tracer. diff --git a/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts b/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts index 6b15e2dd0c1..44a9dcc077d 100644 --- a/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts +++ b/packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts @@ -21,7 +21,7 @@ import { HttpTraceContext, NEVER_SAMPLER, NOOP_SPAN, - NoopLogger, + NoopLogger } from '@opentelemetry/core'; import { BasicTracer } from '../src/BasicTracer'; import { NoopScopeManager } from '@opentelemetry/scope-base'; @@ -31,7 +31,7 @@ describe('BasicTracer', () => { describe('constructor', () => { it('should construct an instance with required only options', () => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); assert.ok(tracer instanceof BasicTracer); }); @@ -39,7 +39,7 @@ describe('BasicTracer', () => { it('should construct an instance with binary format', () => { const tracer = new BasicTracer({ binaryFormat: new BinaryTraceContext(), - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); assert.ok(tracer instanceof BasicTracer); }); @@ -47,7 +47,7 @@ describe('BasicTracer', () => { it('should construct an instance with http text format', () => { const tracer = new BasicTracer({ httpTextFormat: new HttpTraceContext(), - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); assert.ok(tracer instanceof BasicTracer); }); @@ -55,7 +55,7 @@ describe('BasicTracer', () => { it('should construct an instance with logger', () => { const tracer = new BasicTracer({ logger: new NoopLogger(), - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); assert.ok(tracer instanceof BasicTracer); }); @@ -63,7 +63,7 @@ describe('BasicTracer', () => { it('should construct an instance with sampler', () => { const tracer = new BasicTracer({ scopeManager: new NoopScopeManager(), - sampler: ALWAYS_SAMPLER, + sampler: ALWAYS_SAMPLER }); assert.ok(tracer instanceof BasicTracer); }); @@ -72,9 +72,9 @@ describe('BasicTracer', () => { const tracer = new BasicTracer({ defaultAttributes: { region: 'eu-west', - asg: 'my-asg', + asg: 'my-asg' }, - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); assert.ok(tracer instanceof BasicTracer); }); @@ -83,7 +83,7 @@ describe('BasicTracer', () => { describe('.startSpan()', () => { it('should start a span with name only', () => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); const span = tracer.startSpan('my-span'); assert.ok(span); @@ -92,7 +92,7 @@ describe('BasicTracer', () => { it('should start a span with name and options', () => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); const span = tracer.startSpan('my-span', {}); assert.ok(span); @@ -102,7 +102,7 @@ describe('BasicTracer', () => { it('should return a default span with no sampling', () => { const tracer = new BasicTracer({ sampler: NEVER_SAMPLER, - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); const span = tracer.startSpan('my-span'); assert.deepStrictEqual(span, NOOP_SPAN); @@ -118,7 +118,7 @@ describe('BasicTracer', () => { describe('.getCurrentSpan()', () => { it('should return null with NoopScopeManager', () => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); const currentSpan = tracer.getCurrentSpan(); assert.deepStrictEqual(currentSpan, null); @@ -128,7 +128,7 @@ describe('BasicTracer', () => { describe('.withSpan()', () => { it('should run scope with NoopScopeManager scope manager', done => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); const span = tracer.startSpan('my-span'); tracer.withSpan(span, () => { @@ -145,7 +145,7 @@ describe('BasicTracer', () => { describe('.getBinaryFormat()', () => { it('should get default binary formatter', () => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); assert.ok(tracer.getBinaryFormat() instanceof BinaryTraceContext); }); @@ -154,7 +154,7 @@ describe('BasicTracer', () => { describe('.getHttpTextFormat()', () => { it('should get default HTTP text formatter', () => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager(), + scopeManager: new NoopScopeManager() }); assert.ok(tracer.getHttpTextFormat() instanceof HttpTraceContext); }); diff --git a/packages/opentelemetry-basic-tracer/test/Span.test.ts b/packages/opentelemetry-basic-tracer/test/Span.test.ts index 6fae8a46637..bebe2bbcd84 100644 --- a/packages/opentelemetry-basic-tracer/test/Span.test.ts +++ b/packages/opentelemetry-basic-tracer/test/Span.test.ts @@ -16,12 +16,7 @@ import * as assert from 'assert'; import { Span } from '../src/Span'; -import { - SpanKind, - SpanContext, - TraceOptions, - CanonicalCode, -} from '@opentelemetry/types'; +import { SpanKind, SpanContext, TraceOptions, CanonicalCode } from '@opentelemetry/types'; import { NoopTracer } from '@opentelemetry/core'; describe('Span', () => { @@ -29,7 +24,7 @@ describe('Span', () => { const spanContext: SpanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', spanId: '6e0c63257de34c92', - traceOptions: TraceOptions.SAMPLED, + traceOptions: TraceOptions.SAMPLED }; const name = 'span1'; @@ -57,7 +52,7 @@ describe('Span', () => { it('should set an attribute', () => { const span = new Span(tracer, name, { - attributes: { service: 'service-1' }, + attributes: { service: 'service-1' } }); ['String', 'Number', 'Boolean'].map(attType => { @@ -82,14 +77,14 @@ describe('Span', () => { const span = new Span(tracer, name, {}); span.setStatus({ code: CanonicalCode.PERMISSION_DENIED, - message: 'This is an error', + message: 'This is an error' }); }); it('should return toString', () => { const span = new Span(tracer, name, { kind: SpanKind.SERVER, - startTime: 100, + startTime: 100 }); const context = span.context(); diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 824e5101384..3a82bda3494 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -48,7 +48,7 @@ "@types/node": "^12.6.8", "@types/webpack-env": "1.13.9", "codecov": "^3.1.0", - "gts": "^1.0.0", + "gts": "^1.1.0", "karma": "^4.1.0", "karma-chrome-launcher": "^2.2.0", "karma-mocha": "^1.3.0", diff --git a/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts b/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts index 75c6f57a3ab..16496ff30d9 100644 --- a/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts +++ b/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts @@ -35,8 +35,7 @@ const SPAN_ID_OFFSET = SPAN_ID_FIELD_ID_OFFSET + ID_SIZE; const TRACE_OPTION_FIELD_ID_OFFSET = SPAN_ID_OFFSET + SPAN_ID_SIZE; const TRACE_OPTIONS_OFFSET = TRACE_OPTION_FIELD_ID_OFFSET + ID_SIZE; -const FORMAT_LENGTH = - 4 * ID_SIZE + TRACE_ID_SIZE + SPAN_ID_SIZE + TRACE_OPTION_SIZE; +const FORMAT_LENGTH = 4 * ID_SIZE + TRACE_ID_SIZE + SPAN_ID_SIZE + TRACE_OPTION_SIZE; export class BinaryTraceContext implements BinaryFormat { toBytes(spanContext: SpanContext): Uint8Array { @@ -88,9 +87,7 @@ export class BinaryTraceContext implements BinaryFormat { } // See serializeSpanContext for byte offsets. result.traceId = toHex(buf.slice(TRACE_ID_OFFSET, SPAN_ID_FIELD_ID_OFFSET)); - result.spanId = toHex( - buf.slice(SPAN_ID_OFFSET, TRACE_OPTION_FIELD_ID_OFFSET) - ); + result.spanId = toHex(buf.slice(SPAN_ID_OFFSET, TRACE_OPTION_FIELD_ID_OFFSET)); result.traceOptions = buf[TRACE_OPTIONS_OFFSET]; return result; } diff --git a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts index b3a90ea60b8..da4fc694423 100644 --- a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts +++ b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts @@ -14,11 +14,7 @@ * limitations under the License. */ -import { - SpanContext, - HttpTextFormat, - TraceOptions, -} from '@opentelemetry/types'; +import { SpanContext, HttpTextFormat, TraceOptions } from '@opentelemetry/types'; import { TraceState } from '../../trace/TraceState'; export const TRACE_PARENT_HEADER = 'traceparent'; @@ -37,11 +33,7 @@ function parse(traceParent: string): SpanContext | null { // tslint:disable-next-line:ban Needed to parse hexadecimal. const traceOptions = parseInt(option, 16); - if ( - !isValidVersion(version) || - !isValidTraceId(traceId) || - !isValidSpanId(spanId) - ) { + if (!isValidVersion(version) || !isValidTraceId(traceId) || !isValidSpanId(spanId)) { return null; } @@ -67,16 +59,10 @@ function isValidSpanId(spanId: string): boolean { * https://www.w3.org/TR/trace-context/ */ export class HttpTraceContext implements HttpTextFormat { - inject( - spanContext: SpanContext, - format: string, - carrier: { [key: string]: unknown } - ) { - const traceParent = `${VERSION}-${spanContext.traceId}-${ - spanContext.spanId - }-0${Number(spanContext.traceOptions || TraceOptions.UNSAMPLED).toString( - 16 - )}`; + inject(spanContext: SpanContext, format: string, carrier: { [key: string]: unknown }) { + const traceParent = `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-0${Number( + spanContext.traceOptions || TraceOptions.UNSAMPLED + ).toString(16)}`; carrier[TRACE_PARENT_HEADER] = traceParent; if (spanContext.traceState) { @@ -84,15 +70,10 @@ export class HttpTraceContext implements HttpTextFormat { } } - extract( - format: string, - carrier: { [key: string]: unknown } - ): SpanContext | null { + extract(format: string, carrier: { [key: string]: unknown }): SpanContext | null { const traceParentHeader = carrier[TRACE_PARENT_HEADER]; if (!traceParentHeader) return null; - const traceParent = Array.isArray(traceParentHeader) - ? traceParentHeader[0] - : traceParentHeader; + const traceParent = Array.isArray(traceParentHeader) ? traceParentHeader[0] : traceParentHeader; const spanContext = parse(traceParent); if (!spanContext) return null; @@ -100,9 +81,7 @@ export class HttpTraceContext implements HttpTextFormat { if (traceStateHeader) { // If more than one `tracestate` header is found, we merge them into a // single header. - const state = Array.isArray(traceStateHeader) - ? traceStateHeader.join(',') - : traceStateHeader; + const state = Array.isArray(traceStateHeader) ? traceStateHeader.join(',') : traceStateHeader; spanContext.traceState = new TraceState(state as string); } return spanContext; diff --git a/packages/opentelemetry-core/src/internal/validators.ts b/packages/opentelemetry-core/src/internal/validators.ts index c22edeba333..35ae4dc05ee 100644 --- a/packages/opentelemetry-core/src/internal/validators.ts +++ b/packages/opentelemetry-core/src/internal/validators.ts @@ -32,8 +32,5 @@ export function validateKey(key: string): boolean { * characters (i.e., the range 0x20 to 0x7E) except comma , and =. */ export function validateValue(value: string): boolean { - return ( - VALID_VALUE_BASE_REGEX.test(value) && - !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value) - ); + return VALID_VALUE_BASE_REGEX.test(value) && !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value); } diff --git a/packages/opentelemetry-core/src/trace/NoopSpan.ts b/packages/opentelemetry-core/src/trace/NoopSpan.ts index 755c718db3b..db3c8d06ce2 100644 --- a/packages/opentelemetry-core/src/trace/NoopSpan.ts +++ b/packages/opentelemetry-core/src/trace/NoopSpan.ts @@ -24,9 +24,7 @@ import { INVALID_SPAN_CONTEXT } from '../trace/spancontext-utils'; * propagation. */ export class NoopSpan implements types.Span { - constructor( - private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT - ) {} + constructor(private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT) {} // Returns a SpanContext. context(): types.SpanContext { diff --git a/packages/opentelemetry-core/src/trace/NoopTracer.ts b/packages/opentelemetry-core/src/trace/NoopTracer.ts index 365ebc1e351..04af6124c88 100644 --- a/packages/opentelemetry-core/src/trace/NoopTracer.ts +++ b/packages/opentelemetry-core/src/trace/NoopTracer.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -import { - Tracer, - SpanOptions, - Span, - HttpTextFormat, - BinaryFormat, -} from '@opentelemetry/types'; +import { Tracer, SpanOptions, Span, HttpTextFormat, BinaryFormat } from '@opentelemetry/types'; import { NOOP_HTTP_TEXT_FORMAT } from '../context/propagation/NoopHttpTextFormat'; import { NOOP_BINARY_FORMAT } from '../context/propagation/NoopBinaryFormat'; import { NOOP_SPAN } from './NoopSpan'; @@ -38,10 +32,7 @@ export class NoopTracer implements Tracer { return NOOP_SPAN; } - withSpan ReturnType>( - span: Span, - fn: T - ): ReturnType { + withSpan ReturnType>(span: Span, fn: T): ReturnType { return fn(); } diff --git a/packages/opentelemetry-core/src/trace/TracerDelegate.ts b/packages/opentelemetry-core/src/trace/TracerDelegate.ts index 97fe214fe09..a05b974ac8a 100644 --- a/packages/opentelemetry-core/src/trace/TracerDelegate.ts +++ b/packages/opentelemetry-core/src/trace/TracerDelegate.ts @@ -63,10 +63,7 @@ export class TracerDelegate implements types.Tracer { ); } - withSpan ReturnType>( - span: types.Span, - fn: T - ): ReturnType { + withSpan ReturnType>(span: types.Span, fn: T): ReturnType { return this._currentTracer.withSpan.apply( this._currentTracer, // tslint:disable-next-line:no-any diff --git a/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts b/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts index 538977435ad..08c96b375a2 100644 --- a/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts +++ b/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts @@ -21,11 +21,7 @@ export abstract class BasePlugin implements Plugin { protected _moduleExports!: T; protected _tracer!: Tracer; - enable( - moduleExports: T, - tracer: Tracer, - config?: { [key: string]: unknown } - ): T { + enable(moduleExports: T, tracer: Tracer, config?: { [key: string]: unknown }): T { this._moduleExports = moduleExports; this._tracer = tracer; return this.patch(); diff --git a/packages/opentelemetry-core/src/trace/spancontext-utils.ts b/packages/opentelemetry-core/src/trace/spancontext-utils.ts index 700672ff06c..1b49f1a1a79 100644 --- a/packages/opentelemetry-core/src/trace/spancontext-utils.ts +++ b/packages/opentelemetry-core/src/trace/spancontext-utils.ts @@ -20,7 +20,7 @@ export const INVALID_SPANID = '0'; export const INVALID_TRACEID = '0'; export const INVALID_SPAN_CONTEXT: SpanContext = { traceId: INVALID_TRACEID, - spanId: INVALID_SPANID, + spanId: INVALID_SPANID }; /** @@ -28,8 +28,5 @@ export const INVALID_SPAN_CONTEXT: SpanContext = { * @return true if this {@link SpanContext} is valid. */ export function isValid(spanContext: SpanContext): boolean { - return ( - spanContext.traceId !== INVALID_TRACEID && - spanContext.spanId !== INVALID_SPANID - ); + return spanContext.traceId !== INVALID_TRACEID && spanContext.spanId !== INVALID_SPANID; } diff --git a/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts b/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts index 226735d79c0..3341529e7d0 100644 --- a/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts +++ b/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts @@ -32,7 +32,7 @@ describe('BinaryTraceContext', () => { structured: { traceId: commonTraceId, spanId: commonSpanId, - traceOptions: TraceOptions.SAMPLED, + traceOptions: TraceOptions.SAMPLED }, binary: new Uint8Array([ 0, @@ -63,9 +63,9 @@ describe('BinaryTraceContext', () => { 126, 202, 2, - 1, + 1 ]), - description: 'span context with 64-bit span ID', + description: 'span context with 64-bit span ID' }, { structured: { traceId: commonTraceId, spanId: commonSpanId }, @@ -98,20 +98,20 @@ describe('BinaryTraceContext', () => { 126, 202, 2, - 0, + 0 ]), - description: 'span context with no traceOptions', + description: 'span context with no traceOptions' }, { structured: null, binary: new Uint8Array([0, 0]), - description: 'incomplete binary span context (by returning null)', + description: 'incomplete binary span context (by returning null)' }, { structured: null, binary: new Uint8Array(58), - description: 'bad binary span context (by returning null)', - }, + description: 'bad binary span context (by returning null)' + } ]; describe('toBytes', () => { @@ -119,10 +119,7 @@ describe('BinaryTraceContext', () => { testCase => testCase.structured && it(`should serialize ${testCase.description}`, () => { - assert.deepStrictEqual( - binaryTraceContext.toBytes(testCase.structured!), - testCase.binary - ); + assert.deepStrictEqual(binaryTraceContext.toBytes(testCase.structured!), testCase.binary); }) ); }); @@ -132,11 +129,7 @@ describe('BinaryTraceContext', () => { it(`should deserialize ${testCase.description}`, () => { assert.deepStrictEqual( binaryTraceContext.fromBytes(testCase.binary), - testCase.structured && - Object.assign( - { traceOptions: TraceOptions.UNSAMPLED }, - testCase.structured - ) + testCase.structured && Object.assign({ traceOptions: TraceOptions.UNSAMPLED }, testCase.structured) ); }) ); diff --git a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts b/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts index 8a32768c46b..63cb9ab0701 100644 --- a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts +++ b/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts @@ -18,7 +18,7 @@ import * as assert from 'assert'; import { HttpTraceContext, TRACE_PARENT_HEADER, - TRACE_STATE_HEADER, + TRACE_STATE_HEADER } from '../../src/context/propagation/HttpTraceContext'; import { SpanContext, TraceOptions } from '@opentelemetry/types'; import { TraceState } from '../../src/trace/TraceState'; @@ -36,14 +36,11 @@ describe('HttpTraceContext', () => { const spanContext: SpanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', spanId: '6e0c63257de34c92', - traceOptions: TraceOptions.SAMPLED, + traceOptions: TraceOptions.SAMPLED }; httpTraceContext.inject(spanContext, 'HttpTraceContext', carrier); - assert.deepStrictEqual( - carrier[TRACE_PARENT_HEADER], - '00-d4cda95b652f4a1592b449d5929fda1b-6e0c63257de34c92-01' - ); + assert.deepStrictEqual(carrier[TRACE_PARENT_HEADER], '00-d4cda95b652f4a1592b449d5929fda1b-6e0c63257de34c92-01'); assert.deepStrictEqual(carrier[TRACE_STATE_HEADER], undefined); }); @@ -52,95 +49,63 @@ describe('HttpTraceContext', () => { traceId: 'd4cda95b652f4a1592b449d5929fda1b', spanId: '6e0c63257de34c92', traceOptions: TraceOptions.SAMPLED, - traceState: new TraceState('foo=bar,baz=qux'), + traceState: new TraceState('foo=bar,baz=qux') }; httpTraceContext.inject(spanContext, '', carrier); - assert.deepStrictEqual( - carrier[TRACE_PARENT_HEADER], - '00-d4cda95b652f4a1592b449d5929fda1b-6e0c63257de34c92-01' - ); + assert.deepStrictEqual(carrier[TRACE_PARENT_HEADER], '00-d4cda95b652f4a1592b449d5929fda1b-6e0c63257de34c92-01'); assert.deepStrictEqual(carrier[TRACE_STATE_HEADER], 'foo=bar,baz=qux'); }); }); describe('extract', () => { it('should extract context of a sampled span from carrier', () => { - carrier[TRACE_PARENT_HEADER] = - '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'; - const extractedSpanContext = httpTraceContext.extract( - 'HttpTraceContext', - carrier - ); + carrier[TRACE_PARENT_HEADER] = '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'; + const extractedSpanContext = httpTraceContext.extract('HttpTraceContext', carrier); assert.deepStrictEqual(extractedSpanContext, { spanId: 'b7ad6b7169203331', traceId: '0af7651916cd43dd8448eb211c80319c', - traceOptions: TraceOptions.SAMPLED, + traceOptions: TraceOptions.SAMPLED }); }); it('returns null if traceparent header is missing', () => { - assert.deepStrictEqual( - httpTraceContext.extract('HttpTraceContext', carrier), - null - ); + assert.deepStrictEqual(httpTraceContext.extract('HttpTraceContext', carrier), null); }); it('returns null if traceparent header is invalid', () => { carrier[TRACE_PARENT_HEADER] = 'invalid!'; - assert.deepStrictEqual( - httpTraceContext.extract('HttpTraceContext', carrier), - null - ); + assert.deepStrictEqual(httpTraceContext.extract('HttpTraceContext', carrier), null); }); it('extracts traceparent from list of header', () => { - carrier[TRACE_PARENT_HEADER] = [ - '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01', - ]; - const extractedSpanContext = httpTraceContext.extract( - 'HttpTraceContext', - carrier - ); + carrier[TRACE_PARENT_HEADER] = ['00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01']; + const extractedSpanContext = httpTraceContext.extract('HttpTraceContext', carrier); assert.deepStrictEqual(extractedSpanContext, { spanId: 'b7ad6b7169203331', traceId: '0af7651916cd43dd8448eb211c80319c', - traceOptions: TraceOptions.SAMPLED, + traceOptions: TraceOptions.SAMPLED }); }); it('extracts tracestate from header', () => { - carrier[TRACE_PARENT_HEADER] = - '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'; + carrier[TRACE_PARENT_HEADER] = '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'; carrier[TRACE_STATE_HEADER] = 'foo=bar,baz=qux'; - const extractedSpanContext = httpTraceContext.extract( - 'HttpTraceContext', - carrier - ); - assert.deepStrictEqual( - extractedSpanContext!.traceState!.get('foo'), - 'bar' - ); - assert.deepStrictEqual( - extractedSpanContext!.traceState!.get('baz'), - 'qux' - ); + const extractedSpanContext = httpTraceContext.extract('HttpTraceContext', carrier); + assert.deepStrictEqual(extractedSpanContext!.traceState!.get('foo'), 'bar'); + assert.deepStrictEqual(extractedSpanContext!.traceState!.get('baz'), 'qux'); }); it('combines multiple tracestate carrier', () => { - carrier[TRACE_PARENT_HEADER] = - '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'; + carrier[TRACE_PARENT_HEADER] = '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'; carrier[TRACE_STATE_HEADER] = ['foo=bar,baz=qux', 'quux=quuz']; - const extractedSpanContext = httpTraceContext.extract( - 'HttpTraceContext', - carrier - ); + const extractedSpanContext = httpTraceContext.extract('HttpTraceContext', carrier); assert.deepStrictEqual(extractedSpanContext, { spanId: 'b7ad6b7169203331', traceId: '0af7651916cd43dd8448eb211c80319c', traceOptions: TraceOptions.SAMPLED, - traceState: new TraceState('foo=bar,baz=qux,quux=quuz'), + traceState: new TraceState('foo=bar,baz=qux,quux=quuz') }); }); @@ -151,43 +116,29 @@ describe('HttpTraceContext', () => { const testCases: Record = { invalidParts_tooShort: '00-ffffffffffffffffffffffffffffffff', - invalidParts_tooLong: - '00-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00-01', + invalidParts_tooLong: '00-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00-01', - invalidVersion_notHex: - '0x-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00', - invalidVersion_tooShort: - '0-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00', - invalidVersion_tooLong: - '000-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00', + invalidVersion_notHex: '0x-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00', + invalidVersion_tooShort: '0-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00', + invalidVersion_tooLong: '000-ffffffffffffffffffffffffffffffff-ffffffffffffffff-00', invalidTraceId_empty: '00--ffffffffffffffff-01', - invalidTraceId_notHex: - '00-fffffffffffffffffffffffffffffffx-ffffffffffffffff-01', - invalidTraceId_allZeros: - '00-00000000000000000000000000000000-ffffffffffffffff-01', + invalidTraceId_notHex: '00-fffffffffffffffffffffffffffffffx-ffffffffffffffff-01', + invalidTraceId_allZeros: '00-00000000000000000000000000000000-ffffffffffffffff-01', invalidTraceId_tooShort: '00-ffffffff-ffffffffffffffff-01', - invalidTraceId_tooLong: - '00-ffffffffffffffffffffffffffffffff00-ffffffffffffffff-01', + invalidTraceId_tooLong: '00-ffffffffffffffffffffffffffffffff00-ffffffffffffffff-01', invalidSpanId_empty: '00-ffffffffffffffffffffffffffffffff--01', - invalidSpanId_notHex: - '00-ffffffffffffffffffffffffffffffff-fffffffffffffffx-01', - invalidSpanId_allZeros: - '00-ffffffffffffffffffffffffffffffff-0000000000000000-01', - invalidSpanId_tooShort: - '00-ffffffffffffffffffffffffffffffff-ffffffff-01', - invalidSpanId_tooLong: - '00-ffffffffffffffffffffffffffffffff-ffffffffffffffff0000-01', + invalidSpanId_notHex: '00-ffffffffffffffffffffffffffffffff-fffffffffffffffx-01', + invalidSpanId_allZeros: '00-ffffffffffffffffffffffffffffffff-0000000000000000-01', + invalidSpanId_tooShort: '00-ffffffffffffffffffffffffffffffff-ffffffff-01', + invalidSpanId_tooLong: '00-ffffffffffffffffffffffffffffffff-ffffffffffffffff0000-01' }; Object.getOwnPropertyNames(testCases).forEach(testCase => { carrier[TRACE_PARENT_HEADER] = testCases[testCase]; - const extractedSpanContext = httpTraceContext.extract( - 'HttpTraceContext', - carrier - ); + const extractedSpanContext = httpTraceContext.extract('HttpTraceContext', carrier); assert.deepStrictEqual(extractedSpanContext, null, testCase); }); }); diff --git a/packages/opentelemetry-core/test/internal/validators.test.ts b/packages/opentelemetry-core/test/internal/validators.test.ts index d17c4a5afdf..a6949fb6cc7 100644 --- a/packages/opentelemetry-core/test/internal/validators.test.ts +++ b/packages/opentelemetry-core/test/internal/validators.test.ts @@ -26,7 +26,7 @@ describe('validators', () => { 'baz*', 'baz*bar', 'baz/', - 'tracestate', + 'tracestate' ]; validKeysTestCases.forEach(testCase => it(`returns true when key contains valid chars ${testCase}`, () => { @@ -34,15 +34,7 @@ describe('validators', () => { }) ); - const invalidKeysTestCases = [ - '1_key', - 'kEy_1', - 'k'.repeat(257), - 'key,', - 'TrAcEsTaTE', - 'TRACESTATE', - '', - ]; + const invalidKeysTestCases = ['1_key', 'kEy_1', 'k'.repeat(257), 'key,', 'TrAcEsTaTE', 'TRACESTATE', '']; invalidKeysTestCases.forEach(testCase => it(`returns true when key contains invalid chars ${testCase}`, () => { assert.ok(!validateKey(testCase)); @@ -62,7 +54,7 @@ describe('validators', () => { '-second', 'first.second', 'TrAcEsTaTE', - 'TRACESTATE', + 'TRACESTATE' ]; validValuesTestCases.forEach(testCase => it(`returns true when value contains valid chars ${testCase}`, () => { @@ -78,7 +70,7 @@ describe('validators', () => { ',baz', 'baz,', 'baz=', - '', + '' ]; invalidValuesTestCases.forEach(testCase => it(`returns true when value contains invalid chars ${testCase}`, () => { diff --git a/packages/opentelemetry-core/test/resources/resource.test.ts b/packages/opentelemetry-core/test/resources/resource.test.ts index 5fbb50ce1a5..63ea99d11ec 100644 --- a/packages/opentelemetry-core/test/resources/resource.test.ts +++ b/packages/opentelemetry-core/test/resources/resource.test.ts @@ -21,15 +21,15 @@ describe('Resource', () => { const resource1 = new Resource({ 'k8s.io/container/name': 'c1', 'k8s.io/namespace/name': 'default', - 'k8s.io/pod/name': 'pod-xyz-123', + 'k8s.io/pod/name': 'pod-xyz-123' }); const resource2 = new Resource({ 'k8s.io/zone': 'zone1', - 'k8s.io/location': 'location', + 'k8s.io/location': 'location' }); const resource3 = new Resource({ 'k8s.io/container/name': 'c2', - 'k8s.io/location': 'location1', + 'k8s.io/location': 'location1' }); const emptyResource = new Resource({}); @@ -39,7 +39,7 @@ describe('Resource', () => { 'k8s.io/namespace/name': 'default', 'k8s.io/pod/name': 'pod-xyz-123', 'k8s.io/zone': 'zone1', - 'k8s.io/location': 'location', + 'k8s.io/location': 'location' }); const actualResource = resource1.merge(resource2); assert.strictEqual(Object.keys(actualResource.labels).length, 5); @@ -51,7 +51,7 @@ describe('Resource', () => { 'k8s.io/container/name': 'c1', 'k8s.io/namespace/name': 'default', 'k8s.io/pod/name': 'pod-xyz-123', - 'k8s.io/location': 'location1', + 'k8s.io/location': 'location1' }); const actualResource = resource1.merge(resource3); assert.strictEqual(Object.keys(actualResource.labels).length, 4); diff --git a/packages/opentelemetry-core/test/trace/NoopSpan.test.ts b/packages/opentelemetry-core/test/trace/NoopSpan.test.ts index 1528b8d145d..d132c8b33ac 100644 --- a/packages/opentelemetry-core/test/trace/NoopSpan.test.ts +++ b/packages/opentelemetry-core/test/trace/NoopSpan.test.ts @@ -23,7 +23,7 @@ describe('NoopSpan', () => { const spanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', spanId: '6e0c63257de34c92', - traceOptions: TraceOptions.UNSAMPLED, + traceOptions: TraceOptions.UNSAMPLED }; const span = new NoopSpan(spanContext); @@ -34,7 +34,7 @@ describe('NoopSpan', () => { span.setAttribute('my_sym_attribute', Symbol('a')); span.setAttributes({ my_string_attribute: 'foo', - my_number_attribute: 123, + my_number_attribute: 123 }); span.addEvent('sent'); @@ -42,12 +42,12 @@ describe('NoopSpan', () => { span.addLink({ traceId: 'd4cda95b652f4a1592b449d5929fda1b', - spanId: '6e0c63257de34c92', + spanId: '6e0c63257de34c92' }); span.addLink( { traceId: 'd4cda95b652f4a1592b449d5929fda1b', - spanId: '6e0c63257de34c92', + spanId: '6e0c63257de34c92' }, { id: '42', key: 'value' } ); diff --git a/packages/opentelemetry-core/test/trace/NoopTracer.test.ts b/packages/opentelemetry-core/test/trace/NoopTracer.test.ts index 600d6066dde..8ccb1215f7b 100644 --- a/packages/opentelemetry-core/test/trace/NoopTracer.test.ts +++ b/packages/opentelemetry-core/test/trace/NoopTracer.test.ts @@ -25,14 +25,11 @@ describe('NoopTracer', () => { const tracer = new NoopTracer(); assert.deepStrictEqual(tracer.startSpan('span-name'), NOOP_SPAN); - assert.deepStrictEqual( - tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }), - NOOP_SPAN - ); + assert.deepStrictEqual(tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }), NOOP_SPAN); assert.deepStrictEqual( tracer.startSpan('span-name2', { kind: SpanKind.CLIENT, - isRecordingEvents: true, + isRecordingEvents: true }), NOOP_SPAN ); diff --git a/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts b/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts index 7651de85544..c8e32b8eef5 100644 --- a/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts +++ b/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts @@ -15,11 +15,7 @@ */ import * as assert from 'assert'; -import { - ProbabilitySampler, - ALWAYS_SAMPLER, - NEVER_SAMPLER, -} from '../../src/trace/sampler/ProbabilitySampler'; +import { ProbabilitySampler, ALWAYS_SAMPLER, NEVER_SAMPLER } from '../../src/trace/sampler/ProbabilitySampler'; describe('ProbabilitySampler', () => { it('should return a always sampler for 1', () => { @@ -27,7 +23,7 @@ describe('ProbabilitySampler', () => { assert.strictEqual( sampler.shouldSample({ traceId: 'd4cda95b652f4a1592b449d5929fda1b', - spanId: '6e0c63257de34c92', + spanId: '6e0c63257de34c92' }), true ); diff --git a/packages/opentelemetry-core/test/trace/TracerDelegate.test.ts b/packages/opentelemetry-core/test/trace/TracerDelegate.test.ts index c6186a9e590..96b3e93c972 100644 --- a/packages/opentelemetry-core/test/trace/TracerDelegate.test.ts +++ b/packages/opentelemetry-core/test/trace/TracerDelegate.test.ts @@ -27,12 +27,12 @@ describe('TracerDelegate', () => { 'withSpan', 'recordSpanData', 'getBinaryFormat', - 'getHttpTextFormat', + 'getHttpTextFormat' ]; const spanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', spanId: '6e0c63257de34c92', - traceOptions: TraceOptions.UNSAMPLED, + traceOptions: TraceOptions.UNSAMPLED }; describe('constructor', () => { @@ -70,10 +70,7 @@ describe('TracerDelegate', () => { it('should use the fallback tracer when stop is called', () => { const dummyTracerUser = new DummyTracer(); const dummyTracerFallback = new DummyTracer(); - const tracerDelegate = new TracerDelegate( - dummyTracerUser, - dummyTracerFallback - ); + const tracerDelegate = new TracerDelegate(dummyTracerUser, dummyTracerFallback); tracerDelegate.stop(); tracerDelegate.startSpan('fallback'); @@ -84,10 +81,7 @@ describe('TracerDelegate', () => { it('should use the user tracer when start is called', () => { const dummyTracerUser = new DummyTracer(); const dummyTracerFallback = new DummyTracer(); - const tracerDelegate = new TracerDelegate( - dummyTracerUser, - dummyTracerFallback - ); + const tracerDelegate = new TracerDelegate(dummyTracerUser, dummyTracerFallback); tracerDelegate.stop(); tracerDelegate.startSpan('fallback'); @@ -97,11 +91,7 @@ describe('TracerDelegate', () => { tracerDelegate.start(); tracerDelegate.startSpan('user'); assert.deepStrictEqual(dummyTracerUser.spyCounter, 1); - assert.deepStrictEqual( - dummyTracerFallback.spyCounter, - 1, - 'Only user tracer counter is incremented' - ); + assert.deepStrictEqual(dummyTracerFallback.spyCounter, 1, 'Only user tracer counter is incremented'); }); }); }); diff --git a/packages/opentelemetry-core/test/trace/globaltracer-utils.test.ts b/packages/opentelemetry-core/test/trace/globaltracer-utils.test.ts index 8f32ae84efb..96a044cd9cd 100644 --- a/packages/opentelemetry-core/test/trace/globaltracer-utils.test.ts +++ b/packages/opentelemetry-core/test/trace/globaltracer-utils.test.ts @@ -16,10 +16,7 @@ import * as assert from 'assert'; import * as types from '@opentelemetry/types'; -import { - getTracer, - initGlobalTracer, -} from '../../src/trace/globaltracer-utils'; +import { getTracer, initGlobalTracer } from '../../src/trace/globaltracer-utils'; import { NoopTracer, NoopSpan } from '../../src'; import { TraceOptions } from '@opentelemetry/types'; @@ -30,7 +27,7 @@ describe('globaltracer-utils', () => { 'withSpan', 'recordSpanData', 'getBinaryFormat', - 'getHttpTextFormat', + 'getHttpTextFormat' ]; it('should expose a tracer via getTracer', () => { @@ -43,7 +40,7 @@ describe('globaltracer-utils', () => { const spanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', spanId: '6e0c63257de34c92', - traceOptions: TraceOptions.UNSAMPLED, + traceOptions: TraceOptions.UNSAMPLED }; const dummySpan = new NoopSpan(spanContext); @@ -72,10 +69,7 @@ describe('globaltracer-utils', () => { }); class TestTracer extends NoopTracer { - startSpan( - name: string, - options?: types.SpanOptions | undefined - ): types.Span { + startSpan(name: string, options?: types.SpanOptions | undefined): types.Span { return dummySpan; } } diff --git a/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts b/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts index 1a3c32c65a4..8c9b90ec38a 100644 --- a/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts +++ b/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts @@ -21,7 +21,7 @@ describe('spancontext-utils', () => { it('should return true for valid spancontext', () => { const spanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', - spanId: '6e0c63257de34c92', + spanId: '6e0c63257de34c92' }; assert.ok(context.isValid(spanContext)); }); @@ -29,7 +29,7 @@ describe('spancontext-utils', () => { it('should return false when traceId is invalid', () => { const spanContext = { traceId: context.INVALID_TRACEID, - spanId: '6e0c63257de34c92', + spanId: '6e0c63257de34c92' }; assert.ok(!context.isValid(spanContext)); }); @@ -37,7 +37,7 @@ describe('spancontext-utils', () => { it('should return false when spanId is invalid', () => { const spanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', - spanId: context.INVALID_SPANID, + spanId: context.INVALID_SPANID }; assert.ok(!context.isValid(spanContext)); }); @@ -45,7 +45,7 @@ describe('spancontext-utils', () => { it('should return false when traceId & spanId is invalid', () => { const spanContext = { traceId: context.INVALID_TRACEID, - spanId: context.INVALID_SPANID, + spanId: context.INVALID_SPANID }; assert.ok(!context.isValid(spanContext)); }); diff --git a/packages/opentelemetry-core/test/trace/tracestate.test.ts b/packages/opentelemetry-core/test/trace/tracestate.test.ts index 43922e3506c..b68e9c8820f 100644 --- a/packages/opentelemetry-core/test/trace/tracestate.test.ts +++ b/packages/opentelemetry-core/test/trace/tracestate.test.ts @@ -36,10 +36,7 @@ describe('TraceState', () => { assert.deepStrictEqual(state.serialize(), 'vendorname1=opaqueValue1'); state.set('vendorname2', 'opaqueValue2'); - assert.deepStrictEqual( - state.serialize(), - 'vendorname2=opaqueValue2,vendorname1=opaqueValue1' - ); + assert.deepStrictEqual(state.serialize(), 'vendorname2=opaqueValue2,vendorname1=opaqueValue1'); }); it('must unset the entries', () => { @@ -54,15 +51,10 @@ describe('TraceState', () => { describe('parse', () => { it('must successfully parse valid state value', () => { - const state = new TraceState( - 'vendorname2=opaqueValue2,vendorname1=opaqueValue1' - ); + const state = new TraceState('vendorname2=opaqueValue2,vendorname1=opaqueValue1'); assert.deepStrictEqual(state.get('vendorname1'), 'opaqueValue1'); assert.deepStrictEqual(state.get('vendorname2'), 'opaqueValue2'); - assert.deepStrictEqual( - state.serialize(), - 'vendorname2=opaqueValue2,vendorname1=opaqueValue1' - ); + assert.deepStrictEqual(state.serialize(), 'vendorname2=opaqueValue2,vendorname1=opaqueValue1'); }); it('must drop states when the items are too long', () => { @@ -108,11 +100,7 @@ describe('TraceState', () => { assert.deepStrictEqual(state['_keys']().length, 32); assert.deepStrictEqual(state.get('a0'), '0'); assert.deepStrictEqual(state.get('a31'), '31'); - assert.deepStrictEqual( - state.get('a32'), - undefined, - 'should truncate from the tail' - ); + assert.deepStrictEqual(state.get('a32'), undefined, 'should truncate from the tail'); }); it('should not count invalid items towards max limit', () => { diff --git a/packages/opentelemetry-node-tracer/src/index.ts b/packages/opentelemetry-node-tracer/src/index.ts index 310d6a16a99..0478f974a47 100644 --- a/packages/opentelemetry-node-tracer/src/index.ts +++ b/packages/opentelemetry-node-tracer/src/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ - export * from './NodeTracer'; +export * from './NodeTracer'; diff --git a/packages/opentelemetry-node-tracer/src/instrumentation/PluginLoader.ts b/packages/opentelemetry-node-tracer/src/instrumentation/PluginLoader.ts index 69978b302f6..66e1ff25c03 100644 --- a/packages/opentelemetry-node-tracer/src/instrumentation/PluginLoader.ts +++ b/packages/opentelemetry-node-tracer/src/instrumentation/PluginLoader.ts @@ -22,7 +22,7 @@ import * as utils from './utils'; export enum HookState { UNINITIALIZED, ENABLED, - DISABLED, + DISABLED } interface PluginNames { @@ -86,17 +86,13 @@ export class PluginLoader { const moduleName = plugins[name]; // Get the module version. const version = utils.getPackageVersion(this.logger, baseDir as string); - this.logger.info( - `PluginLoader#load: trying loading ${name}.${version}` - ); + this.logger.info(`PluginLoader#load: trying loading ${name}.${version}`); // @todo (issues/132): Check if version and supportedVersions are // satisfied if (!version) return exports; - this.logger.debug( - `PluginLoader#load: applying patch to ${name}@${version} using ${moduleName} module` - ); + this.logger.debug(`PluginLoader#load: applying patch to ${name}@${version} using ${moduleName} module`); // Expecting a plugin from module; try { @@ -113,9 +109,7 @@ export class PluginLoader { }); this._hookState = HookState.ENABLED; } else if (this._hookState === HookState.DISABLED) { - this.logger.error( - 'PluginLoader#load: Currently cannot re-enable plugin loader.' - ); + this.logger.error('PluginLoader#load: Currently cannot re-enable plugin loader.'); } else { this.logger.error('PluginLoader#load: Plugin loader already enabled.'); } diff --git a/packages/opentelemetry-node-tracer/src/instrumentation/utils.ts b/packages/opentelemetry-node-tracer/src/instrumentation/utils.ts index de9648e3024..40aea9bdec0 100644 --- a/packages/opentelemetry-node-tracer/src/instrumentation/utils.ts +++ b/packages/opentelemetry-node-tracer/src/instrumentation/utils.ts @@ -34,10 +34,7 @@ export function defaultPackageName(moduleName: string): string { * @param logger The logger to use. * @param [basedir] The base directory. */ -export function getPackageVersion( - logger: Logger, - basedir?: string -): string | null { +export function getPackageVersion(logger: Logger, basedir?: string): string | null { if (!basedir) return null; const pjsonPath = path.join(basedir, 'package.json'); @@ -46,16 +43,12 @@ export function getPackageVersion( // Attempt to parse a string as a semantic version, returning either a // SemVer object or null. if (!semver.parse(version)) { - logger.error( - `getPackageVersion: [${pjsonPath}|${version}] Version string could not be parsed.` - ); + logger.error(`getPackageVersion: [${pjsonPath}|${version}] Version string could not be parsed.`); return null; } return version; } catch (e) { - logger.error( - `getPackageVersion: [${pjsonPath}] An error occurred while retrieving version string. ${e.message}` - ); + logger.error(`getPackageVersion: [${pjsonPath}] An error occurred while retrieving version string. ${e.message}`); return null; } } diff --git a/packages/opentelemetry-node-tracer/test/instrumentation/PluginLoader.test.ts b/packages/opentelemetry-node-tracer/test/instrumentation/PluginLoader.test.ts index fc10b9ea578..5e9dbb21830 100644 --- a/packages/opentelemetry-node-tracer/test/instrumentation/PluginLoader.test.ts +++ b/packages/opentelemetry-node-tracer/test/instrumentation/PluginLoader.test.ts @@ -17,11 +17,7 @@ import { NoopLogger, NoopTracer } from '@opentelemetry/core'; import * as assert from 'assert'; import * as path from 'path'; -import { - HookState, - PluginLoader, - searchPathForTest, -} from '../../src/instrumentation/PluginLoader'; +import { HookState, PluginLoader, searchPathForTest } from '../../src/instrumentation/PluginLoader'; const INSTALLED_PLUGINS_PATH = path.join(__dirname, 'node_modules'); diff --git a/packages/opentelemetry-node-tracer/test/instrumentation/utils.test.ts b/packages/opentelemetry-node-tracer/test/instrumentation/utils.test.ts index 66d25390c59..871e604d6dd 100644 --- a/packages/opentelemetry-node-tracer/test/instrumentation/utils.test.ts +++ b/packages/opentelemetry-node-tracer/test/instrumentation/utils.test.ts @@ -23,16 +23,16 @@ const INSTALLED_PLUGINS_PATH = path.join(__dirname, 'node_modules'); const TEST_MODULES: Array<{ name: string; version: string | null }> = [ { name: 'simple-module', - version: '0.0.1', + version: '0.0.1' }, { name: 'nonexistent-module', - version: null, + version: null }, { name: 'http', - version: null, - }, + version: null + } ]; describe('Instrumentation#utils', () => { @@ -44,14 +44,8 @@ describe('Instrumentation#utils', () => { describe('defaultPackageName', () => { it('should return package name with default scope and a prefix', () => { - assert.strictEqual( - utils.defaultPackageName('http'), - '@opentelemetry/plugin-http' - ); - assert.strictEqual( - utils.defaultPackageName('simple-module'), - '@opentelemetry/plugin-simple-module' - ); + assert.strictEqual(utils.defaultPackageName('http'), '@opentelemetry/plugin-http'); + assert.strictEqual(utils.defaultPackageName('simple-module'), '@opentelemetry/plugin-simple-module'); }); }); @@ -62,10 +56,7 @@ describe('Instrumentation#utils', () => { TEST_MODULES.forEach(testCase => { it(`should return ${testCase.version} for ${testCase.name}`, () => { - assert.strictEqual( - utils.getPackageVersion(logger, testCase.name), - testCase.version - ); + assert.strictEqual(utils.getPackageVersion(logger, testCase.name), testCase.version); }); }); }); diff --git a/packages/opentelemetry-plugin-http/src/utils.ts b/packages/opentelemetry-plugin-http/src/utils.ts index 179a1656eed..8f168ce1476 100644 --- a/packages/opentelemetry-plugin-http/src/utils.ts +++ b/packages/opentelemetry-plugin-http/src/utils.ts @@ -1,7 +1,7 @@ import { Status, CanonicalCode, Span } from '@opentelemetry/types'; import { RequestOptions, IncomingMessage, ClientRequest } from 'http'; import { IgnoreMatcher } from './types'; -import { Attributes } from './enums/Attributes'; +import { Attributes } from './enums/attributes'; import * as url from 'url'; /** diff --git a/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts b/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts index aaff96d696d..6e8087f994d 100644 --- a/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts +++ b/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts @@ -25,7 +25,7 @@ export class AsyncHooksScopeManager implements ScopeManager { this._asyncHook = asyncHooks.createHook({ init: this._init.bind(this), destroy: this._destroy.bind(this), - promiseResolve: this._destroy.bind(this), + promiseResolve: this._destroy.bind(this) }); } @@ -33,10 +33,7 @@ export class AsyncHooksScopeManager implements ScopeManager { return this._scopes[asyncHooks.executionAsyncId()] || null; } - with ReturnType>( - scope: unknown, - fn: T - ): ReturnType { + with ReturnType>(scope: unknown, fn: T): ReturnType { const uid = asyncHooks.executionAsyncId(); const oldScope = this._scopes[uid]; this._scopes[uid] = scope; @@ -84,7 +81,7 @@ export class AsyncHooksScopeManager implements ScopeManager { enumerable: false, configurable: true, writable: false, - value: target.length, + value: target.length }); /** * It isnt possible to tell Typescript that contextWrapper is the same as T diff --git a/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts b/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts index c29f6aa33f4..294a1fa038d 100644 --- a/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts +++ b/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts @@ -106,11 +106,7 @@ describe('AsyncHooksScopeManager', () => { const scope = { a: 1 }; const fn = scopeManager.bind(() => { setTimeout(() => { - assert.strictEqual( - scopeManager.active(), - null, - 'should have no scope' - ); + assert.strictEqual(scopeManager.active(), null, 'should have no scope'); return done(); }, 100); }, scope); diff --git a/packages/opentelemetry-scope-base/src/NoopScopeManager.ts b/packages/opentelemetry-scope-base/src/NoopScopeManager.ts index ed2d039c6fd..32bc468b81b 100644 --- a/packages/opentelemetry-scope-base/src/NoopScopeManager.ts +++ b/packages/opentelemetry-scope-base/src/NoopScopeManager.ts @@ -21,10 +21,7 @@ export class NoopScopeManager implements types.ScopeManager { return null; } - with ReturnType>( - scope: unknown, - fn: T - ): ReturnType { + with ReturnType>(scope: unknown, fn: T): ReturnType { return fn(); } diff --git a/packages/opentelemetry-scope-base/src/types.ts b/packages/opentelemetry-scope-base/src/types.ts index 9e3f1bb5533..db704bde368 100644 --- a/packages/opentelemetry-scope-base/src/types.ts +++ b/packages/opentelemetry-scope-base/src/types.ts @@ -25,10 +25,7 @@ export interface ScopeManager { * @param scope Any object to set as the current active scope * @param fn A callback to be imediately run within a specific scope */ - with ReturnType>( - scope: unknown, - fn: T - ): ReturnType; + with ReturnType>(scope: unknown, fn: T): ReturnType; /** * Bind an object as the current scope (or a specific one) diff --git a/packages/opentelemetry-scope-base/test/noop/NoopScopeManager.test.ts b/packages/opentelemetry-scope-base/test/noop/NoopScopeManager.test.ts index b6ec6791a21..4f957a0e1d2 100644 --- a/packages/opentelemetry-scope-base/test/noop/NoopScopeManager.test.ts +++ b/packages/opentelemetry-scope-base/test/noop/NoopScopeManager.test.ts @@ -46,11 +46,7 @@ describe('NoopScopeManager', () => { it('should run the callback (object as target)', done => { const test = { a: 1 }; scopeManager.with(test, () => { - assert.strictEqual( - scopeManager.active(), - null, - 'should not have scope' - ); + assert.strictEqual(scopeManager.active(), null, 'should not have scope'); return done(); }); }); diff --git a/packages/opentelemetry-types/package.json b/packages/opentelemetry-types/package.json index 8e812170917..93e42204c7e 100644 --- a/packages/opentelemetry-types/package.json +++ b/packages/opentelemetry-types/package.json @@ -38,7 +38,7 @@ "access": "public" }, "devDependencies": { - "gts": "^1.0.0", + "gts": "^1.1.0", "typedoc": "^0.14.2", "typescript": "^3.4.5" } diff --git a/packages/opentelemetry-types/src/distributed_context/EntryValue.ts b/packages/opentelemetry-types/src/distributed_context/EntryValue.ts index 4ba34bf6cdf..72e02850897 100644 --- a/packages/opentelemetry-types/src/distributed_context/EntryValue.ts +++ b/packages/opentelemetry-types/src/distributed_context/EntryValue.ts @@ -36,5 +36,5 @@ export enum EntryTtl { NO_PROPAGATION = 0, /** UNLIMITED_PROPAGATION can propagate unlimited hops. */ - UNLIMITED_PROPAGATION = -1, + UNLIMITED_PROPAGATION = -1 } diff --git a/packages/opentelemetry-types/src/trace/instrumentation/Plugin.ts b/packages/opentelemetry-types/src/trace/instrumentation/Plugin.ts index 1233996a566..300d3ca2192 100644 --- a/packages/opentelemetry-types/src/trace/instrumentation/Plugin.ts +++ b/packages/opentelemetry-types/src/trace/instrumentation/Plugin.ts @@ -26,11 +26,7 @@ export interface Plugin { * @param tracer a tracer instance. * @param [config] an object to configure the plugin. */ - enable( - moduleExports: T, - tracer: Tracer, - config?: { [key: string]: unknown } - ): T; + enable(moduleExports: T, tracer: Tracer, config?: { [key: string]: unknown }): T; /** Method to disable the instrumentation */ disable(): void; diff --git a/packages/opentelemetry-types/src/trace/span_kind.ts b/packages/opentelemetry-types/src/trace/span_kind.ts index 688650f2beb..f306584c3fc 100644 --- a/packages/opentelemetry-types/src/trace/span_kind.ts +++ b/packages/opentelemetry-types/src/trace/span_kind.ts @@ -46,5 +46,5 @@ export enum SpanKind { * broker. Unlike client and server, there is no direct critical path latency * relationship between producer and consumer spans. */ - CONSUMER = 4, + CONSUMER = 4 } diff --git a/packages/opentelemetry-types/src/trace/status.ts b/packages/opentelemetry-types/src/trace/status.ts index be84093ce18..5b8eb0b71c8 100644 --- a/packages/opentelemetry-types/src/trace/status.ts +++ b/packages/opentelemetry-types/src/trace/status.ts @@ -161,5 +161,5 @@ export enum CanonicalCode { * The request does not have valid authentication credentials for the * operation. */ - UNAUTHENTICATED = 16, + UNAUTHENTICATED = 16 } diff --git a/packages/opentelemetry-types/src/trace/trace_options.ts b/packages/opentelemetry-types/src/trace/trace_options.ts index 2bad26194d2..f761d4716e4 100644 --- a/packages/opentelemetry-types/src/trace/trace_options.ts +++ b/packages/opentelemetry-types/src/trace/trace_options.ts @@ -23,5 +23,5 @@ export enum TraceOptions { /** Bit to represent whether trace is unsampled in trace options. */ UNSAMPLED = 0x0, /** Bit to represent whether trace is sampled in trace options. */ - SAMPLED = 0x1, + SAMPLED = 0x1 } diff --git a/packages/opentelemetry-types/src/trace/tracer.ts b/packages/opentelemetry-types/src/trace/tracer.ts index 88362cce89f..20cee7d9e5f 100644 --- a/packages/opentelemetry-types/src/trace/tracer.ts +++ b/packages/opentelemetry-types/src/trace/tracer.ts @@ -53,10 +53,7 @@ export interface Tracer { * @example * tracer.withSpan(span, function() { ... }); */ - withSpan ReturnType>( - span: Span, - fn: T - ): ReturnType; + withSpan ReturnType>(span: Span, fn: T): ReturnType; /** * Send a pre-populated span object to the exporter.