From 4538b5ba2470ac1f9a214cdee7fc3e7f2a0747c3 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 13 May 2021 11:11:53 -0400 Subject: [PATCH 1/8] chore: lint --- packages/opentelemetry-core/src/common/time.ts | 2 +- packages/opentelemetry-core/test/utils/environment.test.ts | 4 ++-- packages/opentelemetry-core/test/utils/wrap.test.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/opentelemetry-core/src/common/time.ts b/packages/opentelemetry-core/src/common/time.ts index ce56ab8605..db66f76dd3 100644 --- a/packages/opentelemetry-core/src/common/time.ts +++ b/packages/opentelemetry-core/src/common/time.ts @@ -39,7 +39,7 @@ function numberToHrtime(epochMillis: number): api.HrTime { function getTimeOrigin(): number { let timeOrigin = performance.timeOrigin; if (typeof timeOrigin !== 'number') { - const perf: TimeOriginLegacy = (performance as unknown) as TimeOriginLegacy; + const perf: TimeOriginLegacy = performance as unknown as TimeOriginLegacy; timeOrigin = perf.timing && perf.timing.fetchStart; } return timeOrigin; diff --git a/packages/opentelemetry-core/test/utils/environment.test.ts b/packages/opentelemetry-core/test/utils/environment.test.ts index a993f10083..7b31b2d736 100644 --- a/packages/opentelemetry-core/test/utils/environment.test.ts +++ b/packages/opentelemetry-core/test/utils/environment.test.ts @@ -38,7 +38,7 @@ export function mockEnvironment(values: RAW_ENVIRONMENT) { }); } else { Object.keys(values).forEach(key => { - ((window as unknown) as RAW_ENVIRONMENT)[key] = String(values[key]); + (window as unknown as RAW_ENVIRONMENT)[key] = String(values[key]); }); } } @@ -53,7 +53,7 @@ export function removeMockEnvironment() { }); } else { Object.keys(lastMock).forEach(key => { - delete ((window as unknown) as RAW_ENVIRONMENT)[key]; + delete (window as unknown as RAW_ENVIRONMENT)[key]; }); } lastMock = {}; diff --git a/packages/opentelemetry-core/test/utils/wrap.test.ts b/packages/opentelemetry-core/test/utils/wrap.test.ts index 25ef129718..5c9b91f85d 100644 --- a/packages/opentelemetry-core/test/utils/wrap.test.ts +++ b/packages/opentelemetry-core/test/utils/wrap.test.ts @@ -27,7 +27,7 @@ function makeWrapped( defineProperty(wrapper, '__wrapped', wrapped); defineProperty(wrapper, '__unwrap', unwrap); defineProperty(wrapper, '__original', original); - return (wrapper as unknown) as ShimWrapped; + return wrapper as unknown as ShimWrapped; } function defineProperty(obj: any, name: string, value: unknown) { From 7af8ed7dc04e93d65257cc4bd32daf3a5451630b Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 13 May 2021 11:52:27 -0400 Subject: [PATCH 2/8] chore: break cache --- .github/workflows/lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 130e33111b..6514f81e81 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,7 +41,8 @@ jobs: metapackages/*/package-lock.json packages/*/package-lock.json integration-tests/*/package-lock.json - key: ${{ runner.os }}-lint-${{ hashFiles('**/package.json') }} + # increment the trailing number to break the cache manually + key: ${{ runner.os }}-lint-${{ hashFiles('**/package.json') }}-0 # On a cache hit, use ci to speed up the install process - name: Bootstrap (cache hit) From 86d6932d4160a044e51a54d3ad416ec988113a02 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 13 May 2021 12:19:51 -0400 Subject: [PATCH 3/8] chore: lint --- .../src/NoopMeter.ts | 9 +++-- .../src/types/Metric.ts | 4 +-- .../src/AbstractAsyncHooksContextManager.ts | 3 +- .../src/ZoneContextManager.ts | 6 ++-- .../src/CollectorMetricExporter.ts | 3 +- .../src/CollectorTraceExporter.ts | 3 +- .../src/util.ts | 18 +++++----- .../test/CollectorMetricExporter.test.ts | 19 +++++----- .../test/CollectorTraceExporter.test.ts | 5 ++- .../test/helper.ts | 17 +-------- .../src/CollectorMetricExporter.ts | 3 +- .../src/CollectorTraceExporter.ts | 3 +- .../test/CollectorMetricExporter.test.ts | 17 ++++----- .../test/CollectorTraceExporter.test.ts | 3 +- .../browser/CollectorMetricExporter.ts | 3 +- .../browser/CollectorTraceExporter.ts | 3 +- .../platform/node/CollectorMetricExporter.ts | 3 +- .../platform/node/CollectorTraceExporter.ts | 3 +- .../browser/CollectorMetricExporter.test.ts | 4 +-- .../test/common/transform.test.ts | 5 ++- .../test/common/transformMetrics.test.ts | 10 +++--- .../test/node/CollectorMetricExporter.test.ts | 4 +-- .../src/transform.ts | 20 +++++------ .../src/types.ts | 8 ++--- .../src/PrometheusExporter.ts | 2 +- .../test/PrometheusExporter.test.ts | 14 ++++---- .../test/PrometheusSerializer.test.ts | 12 +++---- .../src/fetch.ts | 4 +-- .../src/grpc-js/types.ts | 3 +- .../src/grpc/clientUtils.ts | 4 +-- .../test/helper.ts | 35 ++++++++++--------- .../src/utils.ts | 12 +++---- .../test/functionals/http-enable.test.ts | 12 +------ .../test/functionals/utils.test.ts | 6 ++-- .../test/integrations/http-enable.test.ts | 2 +- .../test/integrations/https-enable.test.ts | 2 +- .../test/utils/httpRequest.ts | 2 +- .../test/utils/httpsRequest.ts | 2 +- .../src/xhr.ts | 8 ++--- .../test/xhr.test.ts | 6 ++-- .../src/instrumentation.ts | 3 +- .../src/platform/browser/instrumentation.ts | 3 +- .../src/platform/node/instrumentation.ts | 5 +-- .../instrumentationNodeModuleDefinition.ts | 3 +- .../node/instrumentationNodeModuleFile.ts | 3 +- .../src/BaseObserverMetric.ts | 3 +- .../src/BoundInstrument.ts | 12 ++++--- packages/opentelemetry-metrics/src/Metric.ts | 3 +- .../src/SumObserverMetric.ts | 3 +- .../src/UpDownCounterMetric.ts | 3 +- .../src/UpDownSumObserverMetric.ts | 3 +- .../src/ValueObserverMetric.ts | 3 +- .../src/ValueRecorderMetric.ts | 3 +- .../opentelemetry-metrics/test/Meter.test.ts | 8 +++-- .../test/export/aggregators/Histogram.test.ts | 19 +++------- .../src/B3Propagator.ts | 6 ++-- .../src/B3SinglePropagator.ts | 3 +- .../src/detectors/AwsEc2Detector.ts | 9 ++--- .../opentelemetry-sdk-node/test/sdk.test.ts | 12 ++++--- packages/opentelemetry-tracing/src/Span.ts | 5 ++- .../test/BasicTracerProvider.test.ts | 11 +++--- .../opentelemetry-tracing/test/Tracer.test.ts | 6 ++-- .../opentelemetry-tracing/test/config.test.ts | 6 ++-- .../test/export/BatchSpanProcessor.test.ts | 5 +-- .../test/export/SimpleSpanProcessor.test.ts | 3 +- .../src/StackContextManager.ts | 2 +- .../test/WebTracerProvider.test.ts | 10 +++--- packages/opentelemetry-web/test/utils.test.ts | 16 ++++----- 68 files changed, 230 insertions(+), 243 deletions(-) diff --git a/packages/opentelemetry-api-metrics/src/NoopMeter.ts b/packages/opentelemetry-api-metrics/src/NoopMeter.ts index 45a90b8fd8..56e7bef214 100644 --- a/packages/opentelemetry-api-metrics/src/NoopMeter.ts +++ b/packages/opentelemetry-api-metrics/src/NoopMeter.ts @@ -158,7 +158,8 @@ export class NoopMetric implements UnboundMetric { export class NoopCounterMetric extends NoopMetric - implements Counter { + implements Counter +{ add(value: number, labels: Labels) { this.bind(labels).add(value); } @@ -166,7 +167,8 @@ export class NoopCounterMetric export class NoopValueRecorderMetric extends NoopMetric - implements ValueRecorder { + implements ValueRecorder +{ record(value: number, labels: Labels) { this.bind(labels).record(value); } @@ -174,7 +176,8 @@ export class NoopValueRecorderMetric export class NoopBaseObserverMetric extends NoopMetric - implements BaseObserver { + implements BaseObserver +{ observation() { return { observer: this as BaseObserver, diff --git a/packages/opentelemetry-api-metrics/src/types/Metric.ts b/packages/opentelemetry-api-metrics/src/types/Metric.ts index aebbc46246..cc00964465 100644 --- a/packages/opentelemetry-api-metrics/src/types/Metric.ts +++ b/packages/opentelemetry-api-metrics/src/types/Metric.ts @@ -155,9 +155,7 @@ export interface ValueRecorder extends UnboundMetric { /** Base interface for the Observer metrics. */ export interface BaseObserver extends UnboundMetric { - observation: ( - value: number - ) => { + observation: (value: number) => { value: number; observer: BaseObserver; }; diff --git a/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts index 0f540b62bb..09debf64c6 100644 --- a/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts +++ b/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts @@ -37,7 +37,8 @@ const ADD_LISTENER_METHODS = [ ]; export abstract class AbstractAsyncHooksContextManager - implements ContextManager { + implements ContextManager +{ abstract active(): Context; abstract with ReturnType>( diff --git a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts index edd5a0719e..21da77012b 100644 --- a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts +++ b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts @@ -64,7 +64,7 @@ export class ZoneContextManager implements ContextManager { writable: false, value: target.length, }); - return (contextWrapper as unknown) as T; + return contextWrapper as unknown as T; } /** @@ -72,7 +72,7 @@ export class ZoneContextManager implements ContextManager { * @param context A context (span) to be bind to target */ private _bindListener(obj: T, context: Context): T { - const target = (obj as unknown) as TargetWithEvents; + const target = obj as unknown as TargetWithEvents; if (target.__ot_listeners !== undefined) { return obj; } @@ -215,7 +215,7 @@ export class ZoneContextManager implements ContextManager { } else if (isListenerObject(target)) { this._bindListener(target, context); } - return (target as unknown) as T; + return target as unknown as T; } /** diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts index 8f5b79f45b..823dc7c001 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts @@ -34,7 +34,8 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter { + implements MetricExporter +{ // Converts time to nanoseconds protected readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts index 5166cccb92..d13fca20a8 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts @@ -34,7 +34,8 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter { + implements SpanExporter +{ convert( spans: ReadableSpan[] ): collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest { diff --git a/packages/opentelemetry-exporter-collector-grpc/src/util.ts b/packages/opentelemetry-exporter-collector-grpc/src/util.ts index 16a2b62dfa..21bc723f47 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/util.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/util.ts @@ -51,15 +51,17 @@ export function onInit( const packageObject: any = grpc.loadPackageDefinition(packageDefinition); if (collector.getServiceClientType() === ServiceClientType.SPANS) { - collector.serviceClient = new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( - collector.serverAddress, - credentials - ); + collector.serviceClient = + new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( + collector.serverAddress, + credentials + ); } else { - collector.serviceClient = new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( - collector.serverAddress, - credentials - ); + collector.serviceClient = + new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( + collector.serverAddress, + credentials + ); } if (collector.grpcQueue.length > 0) { diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts index c7b807d77e..e97ecd7737 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts @@ -78,9 +78,8 @@ const testCollectorMetricExporter = (params: TestParams) => includeDirs, }) .then((packageDefinition: protoLoader.PackageDefinition) => { - const packageObject: any = grpc.loadPackageDefinition( - packageDefinition - ); + const packageObject: any = + grpc.loadPackageDefinition(packageDefinition); server.addService( packageObject.opentelemetry.proto.collector.metrics.v1 .MetricsService.service, @@ -139,13 +138,13 @@ const testCollectorMetricExporter = (params: TestParams) => value: 1592602232694000000, }); metrics = []; - const counter: metrics.Metric & - Counter = mockCounter(); - const observer: metrics.Metric & - ValueObserver = mockObserver(observerResult => { - observerResult.observe(3, {}); - observerResult.observe(6, {}); - }); + const counter: metrics.Metric & Counter = + mockCounter(); + const observer: metrics.Metric & ValueObserver = + mockObserver(observerResult => { + observerResult.observe(3, {}); + observerResult.observe(6, {}); + }); const recorder: metrics.Metric & ValueRecorder = mockValueRecorder(); diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts index e090c05471..c9bd8e196c 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts @@ -73,9 +73,8 @@ const testCollectorExporter = (params: TestParams) => includeDirs, }) .then((packageDefinition: protoLoader.PackageDefinition) => { - const packageObject: any = grpc.loadPackageDefinition( - packageDefinition - ); + const packageObject: any = + grpc.loadPackageDefinition(packageDefinition); server.addService( packageObject.opentelemetry.proto.collector.trace.v1.TraceService .service, diff --git a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts index 147fb1c236..6d29a3263b 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts @@ -41,22 +41,7 @@ const meterProvider = new metrics.MeterProvider({ const meter = meterProvider.getMeter('default', '0.0.1'); const traceIdArr = [ - 31, - 16, - 8, - 220, - 142, - 39, - 14, - 133, - 196, - 10, - 13, - 124, - 57, - 57, - 178, - 120, + 31, 16, 8, 220, 142, 39, 14, 133, 196, 10, 13, 124, 57, 57, 178, 120, ]; const spanIdArr = [94, 16, 114, 97, 246, 79, 165, 62]; const parentIdArr = [120, 168, 145, 80, 152, 134, 67, 136]; diff --git a/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts index 73c4156d3b..97e06a9219 100644 --- a/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts @@ -35,7 +35,8 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter { + implements MetricExporter +{ // Converts time to nanoseconds protected readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts index 4c08ddb668..bfe328bb3c 100644 --- a/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts @@ -35,7 +35,8 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter { + implements SpanExporter +{ constructor(config: CollectorExporterNodeConfigBase = {}) { super(config); this.headers = Object.assign( diff --git a/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts index 5f4c4447a5..8b7c074886 100644 --- a/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts @@ -111,13 +111,13 @@ describe('CollectorMetricExporter - node with proto over http', () => { value: 1592602232694000000, }); metrics = []; - const counter: metrics.Metric & - Counter = mockCounter(); - const observer: metrics.Metric & - ValueObserver = mockObserver(observerResult => { - observerResult.observe(3, {}); - observerResult.observe(6, {}); - }); + const counter: metrics.Metric & Counter = + mockCounter(); + const observer: metrics.Metric & ValueObserver = + mockObserver(observerResult => { + observerResult.observe(3, {}); + observerResult.observe(6, {}); + }); const recorder: metrics.Metric & ValueRecorder = mockValueRecorder(); @@ -175,7 +175,8 @@ describe('CollectorMetricExporter - node with proto over http', () => { write: (...writeArgs: any[]) => { const ExportTraceServiceRequestProto = getExportRequestProto(); const data = ExportTraceServiceRequestProto?.decode(writeArgs[0]); - const json = data?.toJSON() as collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest; + const json = + data?.toJSON() as collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest; const metric1 = json.resourceMetrics[0].instrumentationLibraryMetrics[0].metrics[0]; diff --git a/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts index fd812f7a4a..2936b5e53d 100644 --- a/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts @@ -146,7 +146,8 @@ describe('CollectorTraceExporter - node with proto over http', () => { write: (...args: any[]) => { const ExportTraceServiceRequestProto = getExportRequestProto(); const data = ExportTraceServiceRequestProto?.decode(args[0]); - const json = data?.toJSON() as collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest; + const json = + data?.toJSON() as collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest; const span1 = json.resourceSpans[0].instrumentationLibrarySpans[0].spans[0]; assert.ok(typeof span1 !== 'undefined', "span doesn't exist"); diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts index 4b8ce05b41..b0ba0572ed 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts @@ -32,7 +32,8 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter { + implements MetricExporter +{ // Converts time to nanoseconds private readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts index 8115e3a546..1ab830829b 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts @@ -32,7 +32,8 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter { + implements SpanExporter +{ constructor(config: CollectorExporterConfigBase = {}) { super(config); this._headers = Object.assign( diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts index 90800cc250..5a834a1096 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts @@ -32,7 +32,8 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter { + implements MetricExporter +{ // Converts time to nanoseconds protected readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts index f33d90400d..4d8e71f36f 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts @@ -32,7 +32,8 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter { + implements SpanExporter +{ constructor(config: CollectorExporterNodeConfigBase = {}) { super(config); this.headers = Object.assign( diff --git a/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts index 5f40d55c2e..fc736c2718 100644 --- a/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts @@ -64,8 +64,8 @@ describe('CollectorMetricExporter - web', () => { }, 'double-observer2' ); - const recorder: Metric & - ValueRecorder = mockValueRecorder(); + const recorder: Metric & ValueRecorder = + mockValueRecorder(); counter.add(1); recorder.record(7); recorder.record(14); diff --git a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts index f212a7774a..b7c7e0d150 100644 --- a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts @@ -146,9 +146,8 @@ describe('transform', () => { [resource2, new Map([[instrumentationLibrary, [span2, span3]]])], ]); - const result = transform.groupSpansByResourceAndLibrary( - multiResourceTrace - ); + const result = + transform.groupSpansByResourceAndLibrary(multiResourceTrace); assert.deepStrictEqual(result, expected); }); diff --git a/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts b/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts index 62b93cc077..864dcbd2ce 100644 --- a/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts @@ -168,7 +168,7 @@ describe('transformMetrics', () => { metricKind: 0, valueType: 0, }, - labels: { foo: (1 as unknown) as string }, + labels: { foo: 1 as unknown as string }, aggregator: new SumAggregator(), resource: new Resource({}), aggregationTemporality: 0, @@ -208,11 +208,9 @@ describe('transformMetrics', () => { it('should group by instrumentation library', async () => { const [resource] = mockedResources; const [lib1, lib2] = mockedInstrumentationLibraries; - const [ - metric1, - metric2, - metric3, - ] = multiInstrumentationLibraryMetricsGet(observerResult => {}); + const [metric1, metric2, metric3] = multiInstrumentationLibraryMetricsGet( + observerResult => {} + ); const expected = new Map([ [ resource, diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts index dc3c0a98ff..1d0efc5a9a 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts @@ -148,8 +148,8 @@ describe('CollectorMetricExporter - node with json over http', () => { }, 'double-observer2' ); - const recorder: Metric & - ValueRecorder = mockValueRecorder(); + const recorder: Metric & ValueRecorder = + mockValueRecorder(); counter.add(1); recorder.record(7); recorder.record(14); diff --git a/packages/opentelemetry-exporter-jaeger/src/transform.ts b/packages/opentelemetry-exporter-jaeger/src/transform.ts index bb3ea5e5f1..c75104e39c 100644 --- a/packages/opentelemetry-exporter-jaeger/src/transform.ts +++ b/packages/opentelemetry-exporter-jaeger/src/transform.ts @@ -88,18 +88,16 @@ export function spanToThrift(span: ReadableSpan): ThriftSpan { const spanTags: ThriftTag[] = ThriftUtils.getThriftTags(tags); - const logs = span.events.map( - (event): Log => { - const fields: Tag[] = [{ key: 'event', value: event.name }]; - const attrs = event.attributes; - if (attrs) { - Object.keys(attrs).forEach(attr => - fields.push({ key: attr, value: toTagValue(attrs[attr]) }) - ); - } - return { timestamp: hrTimeToMilliseconds(event.time), fields }; + const logs = span.events.map((event): Log => { + const fields: Tag[] = [{ key: 'event', value: event.name }]; + const attrs = event.attributes; + if (attrs) { + Object.keys(attrs).forEach(attr => + fields.push({ key: attr, value: toTagValue(attrs[attr]) }) + ); } - ); + return { timestamp: hrTimeToMilliseconds(event.time), fields }; + }); const spanLogs: ThriftLog[] = ThriftUtils.getThriftLogs(logs); return { diff --git a/packages/opentelemetry-exporter-jaeger/src/types.ts b/packages/opentelemetry-exporter-jaeger/src/types.ts index 67a9dc4363..e482133cf7 100644 --- a/packages/opentelemetry-exporter-jaeger/src/types.ts +++ b/packages/opentelemetry-exporter-jaeger/src/types.ts @@ -37,13 +37,13 @@ export interface ExporterConfig { // Below require is needed as jaeger-client types does not expose the thrift, // udp_sender, util etc. modules. -export const UDPSender = require('jaeger-client/dist/src/reporters/udp_sender') - .default; +export const UDPSender = + require('jaeger-client/dist/src/reporters/udp_sender').default; export const Utils = require('jaeger-client/dist/src/util').default; export const ThriftUtils = require('jaeger-client/dist/src/thrift').default; -export const HTTPSender = require('jaeger-client/dist/src/reporters/http_sender') - .default; +export const HTTPSender = + require('jaeger-client/dist/src/reporters/http_sender').default; export type TagValue = string | number | boolean; diff --git a/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts b/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts index 2fcf960451..190f89ab49 100644 --- a/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts +++ b/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts @@ -140,7 +140,7 @@ export class PrometheusExporter implements MetricExporter { diag.debug('Prometheus exporter was stopped'); } else { if ( - ((err as unknown) as { code: string }).code !== + (err as unknown as { code: string }).code !== 'ERR_SERVER_NOT_RUNNING' ) { globalErrorHandler(err); diff --git a/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts b/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts index 29527736f1..1e5c5b77a9 100644 --- a/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts +++ b/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts @@ -191,15 +191,13 @@ describe('PrometheusExporter', () => { it('should able to call getMetricsRequestHandler function to generate response with metrics', () => { const exporter = new PrometheusExporter({ preventServerStart: true }); - const mockRequest: SinonStubbedInstance = sinon.createStubInstance( - http.IncomingMessage - ); - const mockResponse: SinonStubbedInstance = sinon.createStubInstance( - http.ServerResponse - ); + const mockRequest: SinonStubbedInstance = + sinon.createStubInstance(http.IncomingMessage); + const mockResponse: SinonStubbedInstance = + sinon.createStubInstance(http.ServerResponse); exporter.getMetricsRequestHandler( - (mockRequest as unknown) as http.IncomingMessage, - (mockResponse as unknown) as http.ServerResponse + mockRequest as unknown as http.IncomingMessage, + mockResponse as unknown as http.ServerResponse ); sinon.assert.calledOnce(mockResponse.setHeader); sinon.assert.calledOnce(mockResponse.end); diff --git a/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts b/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts index 07d240ff42..4cc905b512 100644 --- a/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts +++ b/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts @@ -451,12 +451,12 @@ describe('PrometheusSerializer', () => { }).getMeter('test'); const counter = meter.createCounter('test_total') as CounterMetric; counter - .bind(({ + .bind({ object: {}, NaN: NaN, null: null, undefined: undefined, - } as unknown) as Labels) + } as unknown as Labels) .add(1); const records = await counter.getMetricRecord(); const record = records[0]; @@ -509,14 +509,14 @@ describe('PrometheusSerializer', () => { }).getMeter('test'); const counter = meter.createCounter('test_total') as CounterMetric; counter - .bind(({ + .bind({ backslash: '\u005c', // \ => \\ (\u005c\u005c) doubleQuote: '\u0022', // " => \" (\u005c\u0022) lineFeed: '\u000a', // ↵ => \n (\u005c\u006e) backslashN: '\u005c\u006e', // \n => \\n (\u005c\u005c\u006e) backslashDoubleQuote: '\u005c\u0022', // \" => \\\" (\u005c\u005c\u005c\u0022) backslashLineFeed: '\u005c\u000a', // \↵ => \\\n (\u005c\u005c\u005c\u006e) - } as unknown) as Labels) + } as unknown as Labels) .add(1); const records = await counter.getMetricRecord(); const record = records[0]; @@ -549,9 +549,9 @@ describe('PrometheusSerializer', () => { // with an error like: // error while linting: text format parsing error in line 282: expected '=' after label name, found '-' counter - .bind(({ + .bind({ 'account-id': '123456', - } as unknown) as Labels) + } as unknown as Labels) .add(1); const records = await counter.getMetricRecord(); const record = records[0]; diff --git a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index 8d28649794..c9ff89db22 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -378,8 +378,8 @@ export class FetchInstrumentation extends InstrumentationBase< request: Request | RequestInit, result: Response | FetchError ) { - const applyCustomAttributesOnSpan = this._getConfig() - .applyCustomAttributesOnSpan; + const applyCustomAttributesOnSpan = + this._getConfig().applyCustomAttributesOnSpan; if (applyCustomAttributesOnSpan) { safeExecuteInTheMiddle( () => applyCustomAttributesOnSpan(span, request, result), diff --git a/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts b/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts index 06ee4125d0..e0ae1545d2 100644 --- a/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts +++ b/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts @@ -55,7 +55,8 @@ export type GrpcClientFunc = ((...args: unknown[]) => GrpcEmitter) & { export type ServerRegisterFunction = typeof grpcJs.Server.prototype.register; -export type MakeClientConstructorFunction = typeof grpcJs.makeGenericClientConstructor; +export type MakeClientConstructorFunction = + typeof grpcJs.makeGenericClientConstructor; export type { HandleCall } from '@grpc/grpc-js/build/src/server-call'; export type { PackageDefinition } from '@grpc/grpc-js/build/src/make-client'; diff --git a/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts b/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts index 938533024c..3a310e00a6 100644 --- a/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts +++ b/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts @@ -119,7 +119,7 @@ export const makeGrpcClientRemoteCall = function ( } }; context.bind(call); - ((call as unknown) as events.EventEmitter).on( + (call as unknown as events.EventEmitter).on( 'error', (err: grpcTypes.ServiceError) => { span.setStatus({ @@ -134,7 +134,7 @@ export const makeGrpcClientRemoteCall = function ( } ); - ((call as unknown) as events.EventEmitter).on( + (call as unknown as events.EventEmitter).on( 'status', (status: SpanStatus) => { span.setStatus({ code: SpanStatusCode.UNSET }); diff --git a/packages/opentelemetry-instrumentation-grpc/test/helper.ts b/packages/opentelemetry-instrumentation-grpc/test/helper.ts index 1c71e49430..183ada3f9e 100644 --- a/packages/opentelemetry-instrumentation-grpc/test/helper.ts +++ b/packages/opentelemetry-instrumentation-grpc/test/helper.ts @@ -90,24 +90,27 @@ interface TestGrpcCall { } // Compare two arrays using an equal function f -const arrayIsEqual = (f: any) => ([x, ...xs]: any) => ([y, ...ys]: any): any => - x === undefined && y === undefined - ? true - : Boolean(f(x)(y)) && arrayIsEqual(f)(xs)(ys); +const arrayIsEqual = + (f: any) => + ([x, ...xs]: any) => + ([y, ...ys]: any): any => + x === undefined && y === undefined + ? true + : Boolean(f(x)(y)) && arrayIsEqual(f)(xs)(ys); // Return true if two requests has the same num value const requestEqual = (x: TestRequestResponse) => (y: TestRequestResponse) => x.num !== undefined && x.num === y.num; // Check if its equal requests or array of requests -const checkEqual = (x: TestRequestResponse | TestRequestResponse[]) => ( - y: TestRequestResponse | TestRequestResponse[] -) => - x instanceof Array && y instanceof Array - ? arrayIsEqual(requestEqual)(x as any)(y as any) - : !(x instanceof Array) && !(y instanceof Array) - ? requestEqual(x)(y) - : false; +const checkEqual = + (x: TestRequestResponse | TestRequestResponse[]) => + (y: TestRequestResponse | TestRequestResponse[]) => + x instanceof Array && y instanceof Array + ? arrayIsEqual(requestEqual)(x as any)(y as any) + : !(x instanceof Array) && !(y instanceof Array) + ? requestEqual(x)(y) + : false; export const runTests = ( plugin: GrpcInstrumentation, @@ -563,10 +566,10 @@ export const runTests = ( }); }; - const insertError = ( - request: TestRequestResponse | TestRequestResponse[] - ) => (code: number) => - request instanceof Array ? [{ num: code }, ...request] : { num: code }; + const insertError = + (request: TestRequestResponse | TestRequestResponse[]) => + (code: number) => + request instanceof Array ? [{ num: code }, ...request] : { num: code }; const runErrorTest = ( method: typeof methodList[0], diff --git a/packages/opentelemetry-instrumentation-http/src/utils.ts b/packages/opentelemetry-instrumentation-http/src/utils.ts index 769bdac29f..4d88ce808d 100644 --- a/packages/opentelemetry-instrumentation-http/src/utils.ts +++ b/packages/opentelemetry-instrumentation-http/src/utils.ts @@ -197,9 +197,8 @@ export const setRequestContentLengthAttribute = ( if (isCompressed(request.headers)) { attributes[SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH] = length; } else { - attributes[ - SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED - ] = length; + attributes[SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED] = + length; } }; @@ -218,9 +217,8 @@ export const setResponseContentLengthAttribute = ( if (isCompressed(response.headers)) { attributes[SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH] = length; } else { - attributes[ - SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED - ] = length; + attributes[SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED] = + length; } }; @@ -473,7 +471,7 @@ export const getIncomingRequestAttributesOnResponse = ( const { socket } = request; const { statusCode, statusMessage } = response; const { localAddress, localPort, remoteAddress, remotePort } = socket; - const { __ot_middlewares } = (request as unknown) as { + const { __ot_middlewares } = request as unknown as { [key: string]: unknown; }; const route = Array.isArray(__ot_middlewares) diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts index 2361b26756..2567cbf580 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts @@ -277,17 +277,7 @@ describe('HttpInstrumentation', () => { }); const httpErrorCodes = [ - 400, - 401, - 403, - 404, - 429, - 501, - 503, - 504, - 500, - 505, - 597, + 400, 401, 403, 404, 429, 501, 503, 504, 500, 505, 597, ]; for (let i = 0; i < httpErrorCodes.length; i++) { diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts index 570b9b2a47..5bafcb3259 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts @@ -35,9 +35,7 @@ import { AttributeNames } from '../../src/enums/AttributeNames'; describe('Utility', () => { describe('parseResponseStatus()', () => { it('should return ERROR code by default', () => { - const status = utils.parseResponseStatus( - (undefined as unknown) as number - ); + const status = utils.parseResponseStatus(undefined as unknown as number); assert.deepStrictEqual(status, { code: SpanStatusCode.ERROR }); }); @@ -120,7 +118,7 @@ describe('Utility', () => { it('should throw if type is unknown', () => { try { - utils.satisfiesPattern('/TeSt/1', (true as unknown) as IgnoreMatcher); + utils.satisfiesPattern('/TeSt/1', true as unknown as IgnoreMatcher); assert.fail(); } catch (error) { assert.strictEqual(error instanceof TypeError, true); diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts index 75d21dd731..c7d7a4ac60 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts @@ -313,7 +313,7 @@ describe('HttpInstrumentation Integration tests', () => { `${protocol}://localhost:${mockServerPort}/`, options, (resp: http.IncomingMessage) => { - const res = (resp as unknown) as http.IncomingMessage & { + const res = resp as unknown as http.IncomingMessage & { req: http.IncomingMessage; }; diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts index 729aa1fe91..afc21fac4f 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts @@ -322,7 +322,7 @@ describe('HttpsInstrumentation Integration tests', () => { `${protocol}://localhost:${mockServerPort}/`, options, (resp: http.IncomingMessage) => { - const res = (resp as unknown) as http.IncomingMessage & { + const res = resp as unknown as http.IncomingMessage & { req: http.IncomingMessage; }; diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts index f507b7f1f1..d720677902 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts @@ -32,7 +32,7 @@ function get(input: any, options?: any): GetResult { let req: http.ClientRequest; function onGetResponseCb(resp: http.IncomingMessage): void { - const res = (resp as unknown) as http.IncomingMessage & { + const res = resp as unknown as http.IncomingMessage & { req: http.IncomingMessage; }; let data = ''; diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts index f75cf1e566..f00174e38b 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts @@ -36,7 +36,7 @@ function get(input: any, options?: any): GetResult { let req: http.ClientRequest; function onGetResponseCb(resp: http.IncomingMessage): void { - const res = (resp as unknown) as http.IncomingMessage & { + const res = resp as unknown as http.IncomingMessage & { req: http.IncomingMessage; }; let data = ''; diff --git a/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts b/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts index fb7274cdce..905a64b59b 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts +++ b/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts @@ -180,8 +180,8 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase applyCustomAttributesOnSpan(span, xhr), @@ -242,7 +242,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase(); this._usedResources = new WeakSet(); } @@ -271,7 +271,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase { ); spyEntries = sinon.stub( - (performance as unknown) as Performance, + performance as unknown as Performance, 'getEntriesByType' ); spyEntries.withArgs('resource').returns(resources); @@ -212,7 +212,7 @@ describe('xhr', () => { dummySpanExporter = new DummySpanExporter(); exportSpy = sinon.stub(dummySpanExporter, 'export'); clearResourceTimingsSpy = sinon.stub( - (performance as unknown) as Performance, + performance as unknown as Performance, 'clearResourceTimings' ); webTracerProviderWithZone.addSpanProcessor( @@ -762,7 +762,7 @@ describe('xhr', () => { ); spyEntries = sinon.stub( - (performance as unknown) as Performance, + performance as unknown as Performance, 'getEntriesByType' ); spyEntries.withArgs('resource').returns(resources); diff --git a/packages/opentelemetry-instrumentation/src/instrumentation.ts b/packages/opentelemetry-instrumentation/src/instrumentation.ts index 091271d952..2915c361a9 100644 --- a/packages/opentelemetry-instrumentation/src/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/instrumentation.ts @@ -24,7 +24,8 @@ import * as types from './types'; * Base abstract internal class for instrumenting node and web plugins */ export abstract class InstrumentationAbstract - implements types.Instrumentation { + implements types.Instrumentation +{ protected _config: types.InstrumentationConfig; private _tracer: Tracer; diff --git a/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts b/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts index aec1ae3010..a1d260d33c 100644 --- a/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts @@ -22,7 +22,8 @@ import * as types from '../../types'; */ export abstract class InstrumentationBase extends InstrumentationAbstract - implements types.Instrumentation { + implements types.Instrumentation +{ constructor( readonly instrumentationName: string, readonly instrumentationVersion: string, diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index 98900383ff..58f825008e 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -27,7 +27,8 @@ import { diag } from '@opentelemetry/api'; */ export abstract class InstrumentationBase extends InstrumentationAbstract - implements types.Instrumentation { + implements types.Instrumentation +{ private _modules: InstrumentationModuleDefinition[]; private _hooks: RequireInTheMiddle.Hooked[] = []; private _enabled = false; @@ -130,7 +131,7 @@ export abstract class InstrumentationBase { internals: true }, (exports, name, baseDir) => { return this._onRequire( - (module as unknown) as InstrumentationModuleDefinition< + module as unknown as InstrumentationModuleDefinition< typeof exports >, exports, diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts index 9014dcdeeb..e45a943a7f 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts @@ -20,7 +20,8 @@ import { } from './types'; export class InstrumentationNodeModuleDefinition - implements InstrumentationModuleDefinition { + implements InstrumentationModuleDefinition +{ files: InstrumentationModuleFile[]; constructor( public name: string, diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts index bf5a9a71c1..574f17257e 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts @@ -18,7 +18,8 @@ import { InstrumentationModuleFile } from './types'; import { normalize } from 'path'; export class InstrumentationNodeModuleFile - implements InstrumentationModuleFile { + implements InstrumentationModuleFile +{ public name: string; constructor( name: string, diff --git a/packages/opentelemetry-metrics/src/BaseObserverMetric.ts b/packages/opentelemetry-metrics/src/BaseObserverMetric.ts index 30ae3af1e8..6ed58751db 100644 --- a/packages/opentelemetry-metrics/src/BaseObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/BaseObserverMetric.ts @@ -30,7 +30,8 @@ const NOOP_CALLBACK = () => {}; */ export abstract class BaseObserverMetric extends Metric - implements api.BaseObserver { + implements api.BaseObserver +{ protected _callback: (observerResult: api.ObserverResult) => unknown; constructor( diff --git a/packages/opentelemetry-metrics/src/BoundInstrument.ts b/packages/opentelemetry-metrics/src/BoundInstrument.ts index 296bf72909..99e55fd280 100644 --- a/packages/opentelemetry-metrics/src/BoundInstrument.ts +++ b/packages/opentelemetry-metrics/src/BoundInstrument.ts @@ -72,7 +72,8 @@ export class BaseBoundInstrument { */ export class BoundCounter extends BaseBoundInstrument - implements api.BoundCounter { + implements api.BoundCounter +{ constructor( labels: api.Labels, disabled: boolean, @@ -99,7 +100,8 @@ export class BoundCounter */ export class BoundUpDownCounter extends BaseBoundInstrument - implements api.BoundCounter { + implements api.BoundCounter +{ constructor( labels: api.Labels, disabled: boolean, @@ -119,7 +121,8 @@ export class BoundUpDownCounter */ export class BoundValueRecorder extends BaseBoundInstrument - implements api.BoundValueRecorder { + implements api.BoundValueRecorder +{ constructor( labels: api.Labels, disabled: boolean, @@ -139,7 +142,8 @@ export class BoundValueRecorder */ export class BoundObserver extends BaseBoundInstrument - implements api.BoundBaseObserver { + implements api.BoundBaseObserver +{ constructor( labels: api.Labels, disabled: boolean, diff --git a/packages/opentelemetry-metrics/src/Metric.ts b/packages/opentelemetry-metrics/src/Metric.ts index b753b322ea..08deb36c01 100644 --- a/packages/opentelemetry-metrics/src/Metric.ts +++ b/packages/opentelemetry-metrics/src/Metric.ts @@ -22,7 +22,8 @@ import { hashLabels } from './Utils'; /** This is a SDK implementation of {@link Metric} interface. */ export abstract class Metric - implements api.UnboundMetric { + implements api.UnboundMetric +{ protected readonly _disabled: boolean; protected readonly _valueType: api.ValueType; protected readonly _descriptor: MetricDescriptor; diff --git a/packages/opentelemetry-metrics/src/SumObserverMetric.ts b/packages/opentelemetry-metrics/src/SumObserverMetric.ts index 2f4c723ec9..9d2698a000 100644 --- a/packages/opentelemetry-metrics/src/SumObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/SumObserverMetric.ts @@ -25,7 +25,8 @@ import { ObserverResult } from './ObserverResult'; /** This is a SDK implementation of SumObserver Metric. */ export class SumObserverMetric extends BaseObserverMetric - implements api.SumObserver { + implements api.SumObserver +{ constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts index 36650b2336..013905eb48 100644 --- a/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts +++ b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts @@ -25,7 +25,8 @@ import { Metric } from './Metric'; /** This is a SDK implementation of UpDownCounter Metric. */ export class UpDownCounterMetric extends Metric - implements api.UpDownCounter { + implements api.UpDownCounter +{ constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts b/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts index 31cec8af7a..fa8027e38a 100644 --- a/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts @@ -24,7 +24,8 @@ import { MetricKind } from './export/types'; /** This is a SDK implementation of UpDownSumObserver Metric. */ export class UpDownSumObserverMetric extends BaseObserverMetric - implements api.UpDownSumObserver { + implements api.UpDownSumObserver +{ constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/ValueObserverMetric.ts b/packages/opentelemetry-metrics/src/ValueObserverMetric.ts index a7ac5c5ff5..97b1d4316b 100644 --- a/packages/opentelemetry-metrics/src/ValueObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/ValueObserverMetric.ts @@ -23,7 +23,8 @@ import { MetricKind } from './export/types'; /** This is a SDK implementation of Value Observer Metric. */ export class ValueObserverMetric extends BaseObserverMetric - implements api.ValueObserver { + implements api.ValueObserver +{ constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts b/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts index cda854d8ed..fbeab95b6d 100644 --- a/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts +++ b/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts @@ -25,7 +25,8 @@ import { Metric } from './Metric'; /** This is a SDK implementation of Value Recorder Metric. */ export class ValueRecorderMetric extends Metric - implements api.ValueRecorder { + implements api.ValueRecorder +{ constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/test/Meter.test.ts b/packages/opentelemetry-metrics/test/Meter.test.ts index b1e6389b5d..3083e41bd1 100644 --- a/packages/opentelemetry-metrics/test/Meter.test.ts +++ b/packages/opentelemetry-metrics/test/Meter.test.ts @@ -966,7 +966,8 @@ describe('Meter', () => { return Math.random(); } - const metricRecords: MetricRecord[] = await valueObserver.getMetricRecord(); + const metricRecords: MetricRecord[] = + await valueObserver.getMetricRecord(); assert.strictEqual(metricRecords.length, 4); const metric1 = metricRecords[0]; @@ -1200,7 +1201,7 @@ describe('Meter', () => { setTimeout(resolve, 1); }), ]).then((stats: unknown[]) => { - const apps = (stats[0] as unknown) as Stat[]; + const apps = stats[0] as unknown as Stat[]; apps.forEach(app => { observerBatchResult.observe({ app: app.name, core: '1' }, [ tempMetric.observation(app.core1.temp), @@ -1269,7 +1270,8 @@ describe('Meter', () => { // simulate some waiting await setTimeout(() => {}, 5); - const cpuUsageMetricRecords: MetricRecord[] = await cpuUsageMetric.getMetricRecord(); + const cpuUsageMetricRecords: MetricRecord[] = + await cpuUsageMetric.getMetricRecord(); const value = cpuUsageMetric .bind({ foo: 'bar' }) .getAggregator() diff --git a/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts b/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts index 6ebf7bdf64..2b7a22a903 100644 --- a/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts +++ b/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts @@ -30,22 +30,13 @@ describe('HistogramAggregator', () => { it('should sort boundaries', () => { const aggregator = new HistogramAggregator([ - 200, - 500, - 300, - 700, - 1000, - 1500, + 200, 500, 300, 700, 1000, 1500, ]); const point = aggregator.toPoint().value as Histogram; - assert.deepEqual(point.buckets.boundaries, [ - 200, - 300, - 500, - 700, - 1000, - 1500, - ]); + assert.deepEqual( + point.buckets.boundaries, + [200, 300, 500, 700, 1000, 1500] + ); }); it('should throw if no boundaries are defined', () => { diff --git a/packages/opentelemetry-propagator-b3/src/B3Propagator.ts b/packages/opentelemetry-propagator-b3/src/B3Propagator.ts index 7b40ef0527..54a2b3e804 100644 --- a/packages/opentelemetry-propagator-b3/src/B3Propagator.ts +++ b/packages/opentelemetry-propagator-b3/src/B3Propagator.ts @@ -34,8 +34,10 @@ import { B3InjectEncoding, B3PropagatorConfig } from './types'; * Based on: https://github.com/openzipkin/b3-propagation */ export class B3Propagator implements TextMapPropagator { - private readonly _b3MultiPropagator: B3MultiPropagator = new B3MultiPropagator(); - private readonly _b3SinglePropagator: B3SinglePropagator = new B3SinglePropagator(); + private readonly _b3MultiPropagator: B3MultiPropagator = + new B3MultiPropagator(); + private readonly _b3SinglePropagator: B3SinglePropagator = + new B3SinglePropagator(); private readonly _inject: ( context: Context, carrier: unknown, diff --git a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts index acd36820e8..fc2aeda718 100644 --- a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts +++ b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts @@ -30,7 +30,8 @@ import { import { B3_CONTEXT_HEADER } from './constants'; import { B3_DEBUG_FLAG_KEY } from './common'; -const B3_CONTEXT_REGEX = /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/; +const B3_CONTEXT_REGEX = + /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/; const PADDING = '0'.repeat(16); const SAMPLED_VALUES = new Set(['d', '1']); const DEBUG_STATE = 'd'; diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts index 99d30c9049..37e765fe76 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts @@ -57,13 +57,8 @@ class AwsEc2Detector implements Detector { */ async detect(_config?: ResourceDetectionConfig): Promise { const token = await this._fetchToken(); - const { - accountId, - instanceId, - instanceType, - region, - availabilityZone, - } = await this._fetchIdentity(token); + const { accountId, instanceId, instanceType, region, availabilityZone } = + await this._fetchIdentity(token); const hostname = await this._fetchHost(token); return new Resource({ diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts index f9274caad3..75b3178730 100644 --- a/packages/opentelemetry-sdk-node/test/sdk.test.ts +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -113,7 +113,8 @@ describe('Node SDK', () => { propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); - const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = + trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NoopTracerProvider); assert.ok(metrics.getMeterProvider() instanceof NoopMeterProvider); @@ -135,7 +136,8 @@ describe('Node SDK', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = + trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider); }); @@ -158,7 +160,8 @@ describe('Node SDK', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = + trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider); }); @@ -177,7 +180,8 @@ describe('Node SDK', () => { propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); - const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = + trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NoopTracerProvider); assert.ok(metrics.getMeterProvider() instanceof MeterProvider); diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index d7a18fbe2e..4a5ba7c361 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -192,9 +192,8 @@ export class Span implements api.Span, ReadableSpan { attributes[SemanticAttributes.EXCEPTION_MESSAGE] = exception; } else if (exception) { if (exception.code) { - attributes[ - SemanticAttributes.EXCEPTION_TYPE - ] = exception.code.toString(); + attributes[SemanticAttributes.EXCEPTION_TYPE] = + exception.code.toString(); } else if (exception.name) { attributes[SemanticAttributes.EXCEPTION_TYPE] = exception.name; } diff --git a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts index 06bdb2d6e0..406162096b 100644 --- a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts @@ -49,9 +49,9 @@ import { describe('BasicTracerProvider', () => { let removeEvent: Function | undefined; - const envSource = (typeof window !== 'undefined' - ? window - : process.env) as any; + const envSource = ( + typeof window !== 'undefined' ? window : process.env + ) as any; beforeEach(() => { context.disable(); @@ -370,10 +370,7 @@ describe('BasicTracerProvider', () => { const span = tracer.startSpan( 'my-span', {}, - setSpanContext( - ROOT_CONTEXT, - ('invalid-parent' as unknown) as SpanContext - ) + setSpanContext(ROOT_CONTEXT, 'invalid-parent' as unknown as SpanContext) ); assert.ok(span instanceof Span); assert.deepStrictEqual((span as Span).parentSpanId, undefined); diff --git a/packages/opentelemetry-tracing/test/Tracer.test.ts b/packages/opentelemetry-tracing/test/Tracer.test.ts index cde378b4eb..bb57d0b99d 100644 --- a/packages/opentelemetry-tracing/test/Tracer.test.ts +++ b/packages/opentelemetry-tracing/test/Tracer.test.ts @@ -34,9 +34,9 @@ import { describe('Tracer', () => { const tracerProvider = new BasicTracerProvider(); - const envSource = (typeof window !== 'undefined' - ? window - : process.env) as any; + const envSource = ( + typeof window !== 'undefined' ? window : process.env + ) as any; class TestSampler implements Sampler { shouldSample() { diff --git a/packages/opentelemetry-tracing/test/config.test.ts b/packages/opentelemetry-tracing/test/config.test.ts index 7f81183c13..9edbbd8147 100644 --- a/packages/opentelemetry-tracing/test/config.test.ts +++ b/packages/opentelemetry-tracing/test/config.test.ts @@ -23,9 +23,9 @@ import * as assert from 'assert'; import { buildSamplerFromEnv } from '../src/config'; describe('config', () => { - const envSource = (typeof window !== 'undefined' - ? window - : process.env) as any; + const envSource = ( + typeof window !== 'undefined' ? window : process.env + ) as any; describe('buildSamplerFromEnv()', () => { afterEach(() => { diff --git a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts index 4f5d734713..6a44e9d60d 100644 --- a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts +++ b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts @@ -84,7 +84,7 @@ describe('BatchSpanProcessor', () => { let env: Record; if (typeof process === 'undefined') { - env = (window as unknown) as Record; + env = window as unknown as Record; } else { env = process.env as Record; } @@ -362,7 +362,8 @@ describe('BatchSpanProcessor', () => { processor.onEnd(span); processor.forceFlush().then(() => { - const exporterCreatedSpans = testTracingExporter.getExporterCreatedSpans(); + const exporterCreatedSpans = + testTracingExporter.getExporterCreatedSpans(); assert.equal(exporterCreatedSpans.length, 0); done(); diff --git a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts index b3a5f1ecd5..1fa32c6aa9 100644 --- a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts +++ b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts @@ -191,7 +191,8 @@ describe('SimpleSpanProcessor', () => { processor.onEnd(span); - const exporterCreatedSpans = testTracingExporter.getExporterCreatedSpans(); + const exporterCreatedSpans = + testTracingExporter.getExporterCreatedSpans(); assert.equal(exporterCreatedSpans.length, 0); }); }); diff --git a/packages/opentelemetry-web/src/StackContextManager.ts b/packages/opentelemetry-web/src/StackContextManager.ts index 0c87d6e7c6..7c01a0205b 100644 --- a/packages/opentelemetry-web/src/StackContextManager.ts +++ b/packages/opentelemetry-web/src/StackContextManager.ts @@ -50,7 +50,7 @@ export class StackContextManager implements ContextManager { writable: false, value: target.length, }); - return (contextWrapper as unknown) as T; + return contextWrapper as unknown as T; } /** diff --git a/packages/opentelemetry-web/test/WebTracerProvider.test.ts b/packages/opentelemetry-web/test/WebTracerProvider.test.ts index a73845bfff..68d870717a 100644 --- a/packages/opentelemetry-web/test/WebTracerProvider.test.ts +++ b/packages/opentelemetry-web/test/WebTracerProvider.test.ts @@ -96,12 +96,10 @@ describe('WebTracerProvider', () => { getSpan(context.active()) === rootSpan, 'Current span is rootSpan' ); - const concurrentSpan1 = webTracerWithZone.startSpan( - 'concurrentSpan1' - ); - const concurrentSpan2 = webTracerWithZone.startSpan( - 'concurrentSpan2' - ); + const concurrentSpan1 = + webTracerWithZone.startSpan('concurrentSpan1'); + const concurrentSpan2 = + webTracerWithZone.startSpan('concurrentSpan2'); context.with(setSpan(context.active(), concurrentSpan1), () => { setTimeout(() => { diff --git a/packages/opentelemetry-web/test/utils.test.ts b/packages/opentelemetry-web/test/utils.test.ts index 3296ff6252..0556c89f9c 100644 --- a/packages/opentelemetry-web/test/utils.test.ts +++ b/packages/opentelemetry-web/test/utils.test.ts @@ -132,10 +132,10 @@ describe('utils', () => { it('should add all network events to span', () => { const addEventSpy = sinon.spy(); const setAttributeSpy = sinon.spy(); - const span = ({ + const span = { addEvent: addEventSpy, setAttribute: setAttributeSpy, - } as unknown) as tracing.Span; + } as unknown as tracing.Span; const entries = { [PTN.FETCH_START]: 123, [PTN.DOMAIN_LOOKUP_START]: 123, @@ -162,9 +162,9 @@ describe('utils', () => { describe(`when entry is ${value}`, () => { it('should add event to span', () => { const addEventSpy = sinon.spy(); - const span = ({ + const span = { addEvent: addEventSpy, - } as unknown) as tracing.Span; + } as unknown as tracing.Span; const entries = { [PTN.FETCH_START]: value, } as PerformanceEntries; @@ -184,9 +184,9 @@ describe('utils', () => { describe('when entry is not numeric', () => { it('should NOT add event to span', () => { const addEventSpy = sinon.spy(); - const span = ({ + const span = { addEvent: addEventSpy, - } as unknown) as tracing.Span; + } as unknown as tracing.Span; const entries = { [PTN.FETCH_START]: 'non-numeric', } as unknown; @@ -205,9 +205,9 @@ describe('utils', () => { describe('when entries does NOT contain the performance', () => { it('should NOT add event to span', () => { const addEventSpy = sinon.spy(); - const span = ({ + const span = { addEvent: addEventSpy, - } as unknown) as tracing.Span; + } as unknown as tracing.Span; const entries = { [PTN.FETCH_START]: 123, } as PerformanceEntries; From 0136d058e5f4d7a81c2661e9f668f94628e4a279 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 13 May 2021 14:56:54 -0400 Subject: [PATCH 4/8] chore: remove gts --- eslint.config.js | 13 ++++++++----- package.json | 4 +++- packages/opentelemetry-api-metrics/package.json | 1 - .../opentelemetry-api-metrics/src/types/Metric.ts | 4 +--- .../opentelemetry-context-async-hooks/package.json | 1 - .../package.json | 1 - .../src/ZoneContextManager.ts | 6 +++--- packages/opentelemetry-context-zone/package.json | 1 - packages/opentelemetry-core/package.json | 1 - packages/opentelemetry-core/src/common/time.ts | 2 +- .../test/utils/environment.test.ts | 4 ++-- packages/opentelemetry-core/test/utils/wrap.test.ts | 2 +- .../package.json | 1 - .../package.json | 1 - .../opentelemetry-exporter-collector/package.json | 1 - packages/opentelemetry-exporter-jaeger/package.json | 1 - packages/opentelemetry-exporter-jaeger/src/types.ts | 2 ++ .../opentelemetry-exporter-prometheus/package.json | 1 - packages/opentelemetry-exporter-zipkin/package.json | 1 - .../package.json | 1 - .../opentelemetry-instrumentation-grpc/package.json | 1 - .../opentelemetry-instrumentation-http/package.json | 1 - .../package.json | 1 - packages/opentelemetry-instrumentation/package.json | 1 - .../src/platform/node/instrumentation.ts | 1 + packages/opentelemetry-metrics/package.json | 1 - packages/opentelemetry-metrics/src/Meter.ts | 1 + packages/opentelemetry-metrics/src/MeterProvider.ts | 1 + packages/opentelemetry-node/package.json | 1 - packages/opentelemetry-propagator-b3/package.json | 1 - .../opentelemetry-propagator-b3/src/B3Propagator.ts | 6 ++++-- .../src/B3SinglePropagator.ts | 3 ++- .../opentelemetry-propagator-jaeger/package.json | 1 - .../package.json | 1 - .../package.json | 1 - packages/opentelemetry-resources/package.json | 1 - packages/opentelemetry-sdk-node/package.json | 1 - .../opentelemetry-semantic-conventions/package.json | 1 - .../opentelemetry-shim-opentracing/package.json | 1 - packages/opentelemetry-tracing/package.json | 1 - .../src/BasicTracerProvider.ts | 1 + packages/opentelemetry-web/package.json | 1 - packages/template/package.json | 3 --- 43 files changed, 31 insertions(+), 50 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 938de96c05..4fe97c7b9a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,11 +1,10 @@ module.exports = { plugins: [ "@typescript-eslint", - "header" - ], - extends: [ - "./node_modules/gts", + "header", + "node" ], + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], parser: "@typescript-eslint/parser", parserOptions: { "project": "./tsconfig.json" @@ -13,6 +12,7 @@ module.exports = { rules: { "@typescript-eslint/no-floating-promises": 2, "@typescript-eslint/no-this-alias": "off", + "brace-style": ["error", "1tbs"], "eqeqeq": [ "error", "smart" @@ -32,8 +32,10 @@ module.exports = { "@typescript-eslint/no-shadow": ["warn"], "@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_", "args": "after-used"}], "@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }], + "@typescript-eslint/no-empty-function": ["off"], + "@typescript-eslint/ban-types": ["warn"], + "@typescript-eslint/no-shadow": ["warn"], "arrow-parens": ["error", "as-needed"], - "prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }], "node/no-deprecated-api": ["warn"], "header/header": [2, "block", [{ pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm, @@ -53,6 +55,7 @@ module.exports = { "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-shadow": ["off"], + "@typescript-eslint/no-floating-promises": ["off"], } } ] diff --git a/package.json b/package.json index b71d1f0fd2..7d9d0ea3bc 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,6 @@ "eslint-plugin-header": "3.1.1", "eslint-plugin-import": "2.22.1", "gh-pages": "3.1.0", - "gts": "3.1.0", "husky": "4.3.8", "lerna": "3.22.1", "lerna-changelog": "1.0.1", @@ -69,5 +68,8 @@ "pre-commit": "npm run lint:changed", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } + }, + "dependencies": { + "eslint-plugin-node": "^11.1.0" } } diff --git a/packages/opentelemetry-api-metrics/package.json b/packages/opentelemetry-api-metrics/package.json index 19dd39a057..27a71227d9 100644 --- a/packages/opentelemetry-api-metrics/package.json +++ b/packages/opentelemetry-api-metrics/package.json @@ -61,7 +61,6 @@ "@types/node": "14.14.43", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-api-metrics/src/types/Metric.ts b/packages/opentelemetry-api-metrics/src/types/Metric.ts index aebbc46246..cc00964465 100644 --- a/packages/opentelemetry-api-metrics/src/types/Metric.ts +++ b/packages/opentelemetry-api-metrics/src/types/Metric.ts @@ -155,9 +155,7 @@ export interface ValueRecorder extends UnboundMetric { /** Base interface for the Observer metrics. */ export interface BaseObserver extends UnboundMetric { - observation: ( - value: number - ) => { + observation: (value: number) => { value: number; observer: BaseObserver; }; diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 790af59ff8..7cca3257e2 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -45,7 +45,6 @@ "@types/node": "14.14.43", "@types/shimmer": "1.0.1", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index c5c0e6f68d..c2ad6c8fb2 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -54,7 +54,6 @@ "@types/zone.js": "0.5.12", "babel-loader": "8.2.2", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts index edd5a0719e..21da77012b 100644 --- a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts +++ b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts @@ -64,7 +64,7 @@ export class ZoneContextManager implements ContextManager { writable: false, value: target.length, }); - return (contextWrapper as unknown) as T; + return contextWrapper as unknown as T; } /** @@ -72,7 +72,7 @@ export class ZoneContextManager implements ContextManager { * @param context A context (span) to be bind to target */ private _bindListener(obj: T, context: Context): T { - const target = (obj as unknown) as TargetWithEvents; + const target = obj as unknown as TargetWithEvents; if (target.__ot_listeners !== undefined) { return obj; } @@ -215,7 +215,7 @@ export class ZoneContextManager implements ContextManager { } else if (isListenerObject(target)) { this._bindListener(target, context); } - return (target as unknown) as T; + return target as unknown as T; } /** diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index b1f19d0ded..caf9420685 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -49,7 +49,6 @@ "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", "codecov": "3.8.1", - "gts": "3.1.0", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", "karma-mocha": "2.0.1", diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 3ce816418e..08325e3ddb 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -63,7 +63,6 @@ "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-core/src/common/time.ts b/packages/opentelemetry-core/src/common/time.ts index ce56ab8605..db66f76dd3 100644 --- a/packages/opentelemetry-core/src/common/time.ts +++ b/packages/opentelemetry-core/src/common/time.ts @@ -39,7 +39,7 @@ function numberToHrtime(epochMillis: number): api.HrTime { function getTimeOrigin(): number { let timeOrigin = performance.timeOrigin; if (typeof timeOrigin !== 'number') { - const perf: TimeOriginLegacy = (performance as unknown) as TimeOriginLegacy; + const perf: TimeOriginLegacy = performance as unknown as TimeOriginLegacy; timeOrigin = perf.timing && perf.timing.fetchStart; } return timeOrigin; diff --git a/packages/opentelemetry-core/test/utils/environment.test.ts b/packages/opentelemetry-core/test/utils/environment.test.ts index a993f10083..7b31b2d736 100644 --- a/packages/opentelemetry-core/test/utils/environment.test.ts +++ b/packages/opentelemetry-core/test/utils/environment.test.ts @@ -38,7 +38,7 @@ export function mockEnvironment(values: RAW_ENVIRONMENT) { }); } else { Object.keys(values).forEach(key => { - ((window as unknown) as RAW_ENVIRONMENT)[key] = String(values[key]); + (window as unknown as RAW_ENVIRONMENT)[key] = String(values[key]); }); } } @@ -53,7 +53,7 @@ export function removeMockEnvironment() { }); } else { Object.keys(lastMock).forEach(key => { - delete ((window as unknown) as RAW_ENVIRONMENT)[key]; + delete (window as unknown as RAW_ENVIRONMENT)[key]; }); } lastMock = {}; diff --git a/packages/opentelemetry-core/test/utils/wrap.test.ts b/packages/opentelemetry-core/test/utils/wrap.test.ts index 25ef129718..5c9b91f85d 100644 --- a/packages/opentelemetry-core/test/utils/wrap.test.ts +++ b/packages/opentelemetry-core/test/utils/wrap.test.ts @@ -27,7 +27,7 @@ function makeWrapped( defineProperty(wrapper, '__wrapped', wrapped); defineProperty(wrapper, '__unwrap', unwrap); defineProperty(wrapper, '__original', original); - return (wrapper as unknown) as ShimWrapped; + return wrapper as unknown as ShimWrapped; } function defineProperty(obj: any, name: string, value: unknown) { diff --git a/packages/opentelemetry-exporter-collector-grpc/package.json b/packages/opentelemetry-exporter-collector-grpc/package.json index 88713dc2a9..a259e72bf1 100644 --- a/packages/opentelemetry-exporter-collector-grpc/package.json +++ b/packages/opentelemetry-exporter-collector-grpc/package.json @@ -53,7 +53,6 @@ "@types/sinon": "9.0.11", "codecov": "3.8.1", "cpx": "1.5.0", - "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-exporter-collector-proto/package.json b/packages/opentelemetry-exporter-collector-proto/package.json index ba9637f6e1..a3f606d859 100644 --- a/packages/opentelemetry-exporter-collector-proto/package.json +++ b/packages/opentelemetry-exporter-collector-proto/package.json @@ -53,7 +53,6 @@ "@types/sinon": "9.0.11", "codecov": "3.8.1", "cpx": "1.5.0", - "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index c35b3374d4..1e743a9af7 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -62,7 +62,6 @@ "babel-loader": "8.2.2", "codecov": "3.8.1", "cpx": "1.5.0", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index 139dbe447d..7399629051 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -46,7 +46,6 @@ "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-exporter-jaeger/src/types.ts b/packages/opentelemetry-exporter-jaeger/src/types.ts index 67a9dc4363..9e5c3f0055 100644 --- a/packages/opentelemetry-exporter-jaeger/src/types.ts +++ b/packages/opentelemetry-exporter-jaeger/src/types.ts @@ -37,6 +37,7 @@ export interface ExporterConfig { // Below require is needed as jaeger-client types does not expose the thrift, // udp_sender, util etc. modules. +/* eslint-disable @typescript-eslint/no-var-requires */ export const UDPSender = require('jaeger-client/dist/src/reporters/udp_sender') .default; export const Utils = require('jaeger-client/dist/src/util').default; @@ -44,6 +45,7 @@ export const ThriftUtils = require('jaeger-client/dist/src/thrift').default; export const HTTPSender = require('jaeger-client/dist/src/reporters/http_sender') .default; +/* eslint-enable @typescript-eslint/no-var-requires */ export type TagValue = string | number | boolean; diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index 27e7d6a2d1..8477905ad1 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -44,7 +44,6 @@ "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index 748b18216d..d485b87b62 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -59,7 +59,6 @@ "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-instrumentation-fetch/package.json b/packages/opentelemetry-instrumentation-fetch/package.json index f45017bba8..0a1090ed83 100644 --- a/packages/opentelemetry-instrumentation-fetch/package.json +++ b/packages/opentelemetry-instrumentation-fetch/package.json @@ -58,7 +58,6 @@ "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-instrumentation-grpc/package.json b/packages/opentelemetry-instrumentation-grpc/package.json index f4aefe3ca3..392911764c 100644 --- a/packages/opentelemetry-instrumentation-grpc/package.json +++ b/packages/opentelemetry-instrumentation-grpc/package.json @@ -55,7 +55,6 @@ "@types/sinon": "9.0.11", "codecov": "3.8.1", "grpc": "1.24.7", - "gts": "3.1.0", "mocha": "7.2.0", "node-pre-gyp": "0.17.0", "nyc": "15.1.0", diff --git a/packages/opentelemetry-instrumentation-http/package.json b/packages/opentelemetry-instrumentation-http/package.json index d0bf47045c..fd29b04c5b 100644 --- a/packages/opentelemetry-instrumentation-http/package.json +++ b/packages/opentelemetry-instrumentation-http/package.json @@ -56,7 +56,6 @@ "axios": "0.21.1", "codecov": "3.8.1", "got": "9.6.0", - "gts": "3.1.0", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-instrumentation-xml-http-request/package.json b/packages/opentelemetry-instrumentation-xml-http-request/package.json index af7cf75d35..603e2e52f2 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/package.json +++ b/packages/opentelemetry-instrumentation-xml-http-request/package.json @@ -57,7 +57,6 @@ "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-instrumentation/package.json b/packages/opentelemetry-instrumentation/package.json index 409397964b..511cda4985 100644 --- a/packages/opentelemetry-instrumentation/package.json +++ b/packages/opentelemetry-instrumentation/package.json @@ -79,7 +79,6 @@ "babel-loader": "8.2.2", "codecov": "3.8.1", "cpx": "1.5.0", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index 98900383ff..f50cff4252 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -73,6 +73,7 @@ export abstract class InstrumentationBase return exports; } + // eslint-disable-next-line @typescript-eslint/no-var-requires const version = require(path.join(baseDir, 'package.json')).version; module.moduleVersion = version; if (module.name === name) { diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index d00bcba7dd..6978335b41 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -50,7 +50,6 @@ "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-metrics/src/Meter.ts b/packages/opentelemetry-metrics/src/Meter.ts index d42c9f15c6..348c554dec 100644 --- a/packages/opentelemetry-metrics/src/Meter.ts +++ b/packages/opentelemetry-metrics/src/Meter.ts @@ -31,6 +31,7 @@ import { UpDownCounterMetric } from './UpDownCounterMetric'; import { UpDownSumObserverMetric } from './UpDownSumObserverMetric'; import { ValueObserverMetric } from './ValueObserverMetric'; import { ValueRecorderMetric } from './ValueRecorderMetric'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const merge = require('lodash.merge'); /** diff --git a/packages/opentelemetry-metrics/src/MeterProvider.ts b/packages/opentelemetry-metrics/src/MeterProvider.ts index b305456a9e..b38243ae13 100644 --- a/packages/opentelemetry-metrics/src/MeterProvider.ts +++ b/packages/opentelemetry-metrics/src/MeterProvider.ts @@ -18,6 +18,7 @@ import * as api from '@opentelemetry/api-metrics'; import { Resource } from '@opentelemetry/resources'; import { Meter } from '.'; import { DEFAULT_CONFIG, MeterConfig } from './types'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const merge = require('lodash.merge'); /** diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index 34da33956e..5f31927896 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -50,7 +50,6 @@ "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-propagator-b3/package.json b/packages/opentelemetry-propagator-b3/package.json index 1c2535d32b..3d43aff3f6 100644 --- a/packages/opentelemetry-propagator-b3/package.json +++ b/packages/opentelemetry-propagator-b3/package.json @@ -50,7 +50,6 @@ "@types/mocha": "8.2.2", "@types/node": "14.14.43", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/packages/opentelemetry-propagator-b3/src/B3Propagator.ts b/packages/opentelemetry-propagator-b3/src/B3Propagator.ts index 7b40ef0527..54a2b3e804 100644 --- a/packages/opentelemetry-propagator-b3/src/B3Propagator.ts +++ b/packages/opentelemetry-propagator-b3/src/B3Propagator.ts @@ -34,8 +34,10 @@ import { B3InjectEncoding, B3PropagatorConfig } from './types'; * Based on: https://github.com/openzipkin/b3-propagation */ export class B3Propagator implements TextMapPropagator { - private readonly _b3MultiPropagator: B3MultiPropagator = new B3MultiPropagator(); - private readonly _b3SinglePropagator: B3SinglePropagator = new B3SinglePropagator(); + private readonly _b3MultiPropagator: B3MultiPropagator = + new B3MultiPropagator(); + private readonly _b3SinglePropagator: B3SinglePropagator = + new B3SinglePropagator(); private readonly _inject: ( context: Context, carrier: unknown, diff --git a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts index acd36820e8..fc2aeda718 100644 --- a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts +++ b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts @@ -30,7 +30,8 @@ import { import { B3_CONTEXT_HEADER } from './constants'; import { B3_DEBUG_FLAG_KEY } from './common'; -const B3_CONTEXT_REGEX = /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/; +const B3_CONTEXT_REGEX = + /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/; const PADDING = '0'.repeat(16); const SAMPLED_VALUES = new Set(['d', '1']); const DEBUG_STATE = 'd'; diff --git a/packages/opentelemetry-propagator-jaeger/package.json b/packages/opentelemetry-propagator-jaeger/package.json index 353765fef6..156efa08fc 100644 --- a/packages/opentelemetry-propagator-jaeger/package.json +++ b/packages/opentelemetry-propagator-jaeger/package.json @@ -53,7 +53,6 @@ "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-resource-detector-aws/package.json b/packages/opentelemetry-resource-detector-aws/package.json index d469dc43d5..0c436485fd 100644 --- a/packages/opentelemetry-resource-detector-aws/package.json +++ b/packages/opentelemetry-resource-detector-aws/package.json @@ -44,7 +44,6 @@ "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-resource-detector-gcp/package.json b/packages/opentelemetry-resource-detector-gcp/package.json index a2a283c9dd..abb647da0f 100644 --- a/packages/opentelemetry-resource-detector-gcp/package.json +++ b/packages/opentelemetry-resource-detector-gcp/package.json @@ -45,7 +45,6 @@ "@types/node": "14.14.43", "@types/semver": "7.3.5", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index 5c3c178771..d8ae074e6e 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -53,7 +53,6 @@ "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-sdk-node/package.json b/packages/opentelemetry-sdk-node/package.json index 6de91cb1f3..bbbb23e17e 100644 --- a/packages/opentelemetry-sdk-node/package.json +++ b/packages/opentelemetry-sdk-node/package.json @@ -63,7 +63,6 @@ "@types/sinon": "9.0.11", "codecov": "3.8.1", "gcp-metadata": "^4.1.4", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index a2e90a7450..9394b07656 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -47,7 +47,6 @@ "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index 30ecc063f4..2a3f2b1ee2 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -45,7 +45,6 @@ "@types/mocha": "8.2.2", "@types/node": "14.14.43", "codecov": "3.8.1", - "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index 4fe9a038bc..f67ef5f0cb 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -60,7 +60,6 @@ "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts index 436bf313a7..4166d77394 100644 --- a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts +++ b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts @@ -34,6 +34,7 @@ import { DEFAULT_CONFIG } from './config'; import { MultiSpanProcessor } from './MultiSpanProcessor'; import { NoopSpanProcessor } from './export/NoopSpanProcessor'; import { SDKRegistrationConfig, TracerConfig } from './types'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const merge = require('lodash.merge'); import { SpanExporter } from './export/SpanExporter'; import { BatchSpanProcessor } from './export/BatchSpanProcessor'; diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index e0d73f1716..3e5d84a856 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -57,7 +57,6 @@ "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", "codecov": "3.8.1", - "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/template/package.json b/packages/template/package.json index aeefcf09f5..4c4901cff6 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -88,8 +88,5 @@ "karma-spec-reporter": "0.0.32", "karma-webpack": "4.0.2", "webpack": "4.44.2" - }, - "Add these to devDependencies for linting": { - "gts": "3.1.0" } } From 1b257ae529aee3a22a763d77be5b8e2a38c9a8d1 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 19 May 2021 11:52:41 -0400 Subject: [PATCH 5/8] chore: lint --- packages/opentelemetry-api-metrics/src/NoopMeter.ts | 9 +++------ .../src/AbstractAsyncHooksContextManager.ts | 3 +-- .../src/CollectorMetricExporter.ts | 3 +-- .../src/CollectorTraceExporter.ts | 3 +-- .../src/CollectorMetricExporter.ts | 3 +-- .../src/CollectorTraceExporter.ts | 3 +-- .../src/platform/browser/CollectorMetricExporter.ts | 3 +-- .../src/platform/browser/CollectorTraceExporter.ts | 3 +-- .../src/platform/node/CollectorMetricExporter.ts | 3 +-- .../src/platform/node/CollectorTraceExporter.ts | 3 +-- .../src/instrumentation.ts | 3 +-- .../src/platform/browser/instrumentation.ts | 3 +-- .../src/platform/node/instrumentation.ts | 3 +-- .../node/instrumentationNodeModuleDefinition.ts | 3 +-- .../platform/node/instrumentationNodeModuleFile.ts | 3 +-- .../opentelemetry-metrics/src/BaseObserverMetric.ts | 3 +-- .../opentelemetry-metrics/src/BoundInstrument.ts | 12 ++++-------- packages/opentelemetry-metrics/src/Metric.ts | 3 +-- .../opentelemetry-metrics/src/SumObserverMetric.ts | 3 +-- .../opentelemetry-metrics/src/UpDownCounterMetric.ts | 3 +-- .../src/UpDownSumObserverMetric.ts | 3 +-- .../opentelemetry-metrics/src/ValueObserverMetric.ts | 3 +-- .../opentelemetry-metrics/src/ValueRecorderMetric.ts | 3 +-- 23 files changed, 28 insertions(+), 56 deletions(-) diff --git a/packages/opentelemetry-api-metrics/src/NoopMeter.ts b/packages/opentelemetry-api-metrics/src/NoopMeter.ts index 56e7bef214..45a90b8fd8 100644 --- a/packages/opentelemetry-api-metrics/src/NoopMeter.ts +++ b/packages/opentelemetry-api-metrics/src/NoopMeter.ts @@ -158,8 +158,7 @@ export class NoopMetric implements UnboundMetric { export class NoopCounterMetric extends NoopMetric - implements Counter -{ + implements Counter { add(value: number, labels: Labels) { this.bind(labels).add(value); } @@ -167,8 +166,7 @@ export class NoopCounterMetric export class NoopValueRecorderMetric extends NoopMetric - implements ValueRecorder -{ + implements ValueRecorder { record(value: number, labels: Labels) { this.bind(labels).record(value); } @@ -176,8 +174,7 @@ export class NoopValueRecorderMetric export class NoopBaseObserverMetric extends NoopMetric - implements BaseObserver -{ + implements BaseObserver { observation() { return { observer: this as BaseObserver, diff --git a/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts index 09debf64c6..0f540b62bb 100644 --- a/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts +++ b/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts @@ -37,8 +37,7 @@ const ADD_LISTENER_METHODS = [ ]; export abstract class AbstractAsyncHooksContextManager - implements ContextManager -{ + implements ContextManager { abstract active(): Context; abstract with ReturnType>( diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts index 823dc7c001..8f5b79f45b 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts @@ -34,8 +34,7 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter -{ + implements MetricExporter { // Converts time to nanoseconds protected readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts index d13fca20a8..5166cccb92 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts @@ -34,8 +34,7 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter -{ + implements SpanExporter { convert( spans: ReadableSpan[] ): collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest { diff --git a/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts index 97e06a9219..73c4156d3b 100644 --- a/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector-proto/src/CollectorMetricExporter.ts @@ -35,8 +35,7 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter -{ + implements MetricExporter { // Converts time to nanoseconds protected readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts index bfe328bb3c..4c08ddb668 100644 --- a/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector-proto/src/CollectorTraceExporter.ts @@ -35,8 +35,7 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter -{ + implements SpanExporter { constructor(config: CollectorExporterNodeConfigBase = {}) { super(config); this.headers = Object.assign( diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts index b0ba0572ed..4b8ce05b41 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorMetricExporter.ts @@ -32,8 +32,7 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter -{ + implements MetricExporter { // Converts time to nanoseconds private readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts index 1ab830829b..8115e3a546 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts @@ -32,8 +32,7 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter -{ + implements SpanExporter { constructor(config: CollectorExporterConfigBase = {}) { super(config); this._headers = Object.assign( diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts index 5a834a1096..90800cc250 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts @@ -32,8 +32,7 @@ export class CollectorMetricExporter MetricRecord, collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest > - implements MetricExporter -{ + implements MetricExporter { // Converts time to nanoseconds protected readonly _startTime = new Date().getTime() * 1000000; diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts index 4d8e71f36f..f33d90400d 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts @@ -32,8 +32,7 @@ export class CollectorTraceExporter ReadableSpan, collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > - implements SpanExporter -{ + implements SpanExporter { constructor(config: CollectorExporterNodeConfigBase = {}) { super(config); this.headers = Object.assign( diff --git a/packages/opentelemetry-instrumentation/src/instrumentation.ts b/packages/opentelemetry-instrumentation/src/instrumentation.ts index 2915c361a9..091271d952 100644 --- a/packages/opentelemetry-instrumentation/src/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/instrumentation.ts @@ -24,8 +24,7 @@ import * as types from './types'; * Base abstract internal class for instrumenting node and web plugins */ export abstract class InstrumentationAbstract - implements types.Instrumentation -{ + implements types.Instrumentation { protected _config: types.InstrumentationConfig; private _tracer: Tracer; diff --git a/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts b/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts index a1d260d33c..aec1ae3010 100644 --- a/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/platform/browser/instrumentation.ts @@ -22,8 +22,7 @@ import * as types from '../../types'; */ export abstract class InstrumentationBase extends InstrumentationAbstract - implements types.Instrumentation -{ + implements types.Instrumentation { constructor( readonly instrumentationName: string, readonly instrumentationVersion: string, diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index 69b9eb9c88..d7f5291665 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -27,8 +27,7 @@ import { diag } from '@opentelemetry/api'; */ export abstract class InstrumentationBase extends InstrumentationAbstract - implements types.Instrumentation -{ + implements types.Instrumentation { private _modules: InstrumentationModuleDefinition[]; private _hooks: RequireInTheMiddle.Hooked[] = []; private _enabled = false; diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts index e45a943a7f..9014dcdeeb 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts @@ -20,8 +20,7 @@ import { } from './types'; export class InstrumentationNodeModuleDefinition - implements InstrumentationModuleDefinition -{ + implements InstrumentationModuleDefinition { files: InstrumentationModuleFile[]; constructor( public name: string, diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts index 574f17257e..bf5a9a71c1 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts @@ -18,8 +18,7 @@ import { InstrumentationModuleFile } from './types'; import { normalize } from 'path'; export class InstrumentationNodeModuleFile - implements InstrumentationModuleFile -{ + implements InstrumentationModuleFile { public name: string; constructor( name: string, diff --git a/packages/opentelemetry-metrics/src/BaseObserverMetric.ts b/packages/opentelemetry-metrics/src/BaseObserverMetric.ts index 6ed58751db..30ae3af1e8 100644 --- a/packages/opentelemetry-metrics/src/BaseObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/BaseObserverMetric.ts @@ -30,8 +30,7 @@ const NOOP_CALLBACK = () => {}; */ export abstract class BaseObserverMetric extends Metric - implements api.BaseObserver -{ + implements api.BaseObserver { protected _callback: (observerResult: api.ObserverResult) => unknown; constructor( diff --git a/packages/opentelemetry-metrics/src/BoundInstrument.ts b/packages/opentelemetry-metrics/src/BoundInstrument.ts index 99e55fd280..296bf72909 100644 --- a/packages/opentelemetry-metrics/src/BoundInstrument.ts +++ b/packages/opentelemetry-metrics/src/BoundInstrument.ts @@ -72,8 +72,7 @@ export class BaseBoundInstrument { */ export class BoundCounter extends BaseBoundInstrument - implements api.BoundCounter -{ + implements api.BoundCounter { constructor( labels: api.Labels, disabled: boolean, @@ -100,8 +99,7 @@ export class BoundCounter */ export class BoundUpDownCounter extends BaseBoundInstrument - implements api.BoundCounter -{ + implements api.BoundCounter { constructor( labels: api.Labels, disabled: boolean, @@ -121,8 +119,7 @@ export class BoundUpDownCounter */ export class BoundValueRecorder extends BaseBoundInstrument - implements api.BoundValueRecorder -{ + implements api.BoundValueRecorder { constructor( labels: api.Labels, disabled: boolean, @@ -142,8 +139,7 @@ export class BoundValueRecorder */ export class BoundObserver extends BaseBoundInstrument - implements api.BoundBaseObserver -{ + implements api.BoundBaseObserver { constructor( labels: api.Labels, disabled: boolean, diff --git a/packages/opentelemetry-metrics/src/Metric.ts b/packages/opentelemetry-metrics/src/Metric.ts index 08deb36c01..b753b322ea 100644 --- a/packages/opentelemetry-metrics/src/Metric.ts +++ b/packages/opentelemetry-metrics/src/Metric.ts @@ -22,8 +22,7 @@ import { hashLabels } from './Utils'; /** This is a SDK implementation of {@link Metric} interface. */ export abstract class Metric - implements api.UnboundMetric -{ + implements api.UnboundMetric { protected readonly _disabled: boolean; protected readonly _valueType: api.ValueType; protected readonly _descriptor: MetricDescriptor; diff --git a/packages/opentelemetry-metrics/src/SumObserverMetric.ts b/packages/opentelemetry-metrics/src/SumObserverMetric.ts index 9d2698a000..2f4c723ec9 100644 --- a/packages/opentelemetry-metrics/src/SumObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/SumObserverMetric.ts @@ -25,8 +25,7 @@ import { ObserverResult } from './ObserverResult'; /** This is a SDK implementation of SumObserver Metric. */ export class SumObserverMetric extends BaseObserverMetric - implements api.SumObserver -{ + implements api.SumObserver { constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts index 013905eb48..36650b2336 100644 --- a/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts +++ b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts @@ -25,8 +25,7 @@ import { Metric } from './Metric'; /** This is a SDK implementation of UpDownCounter Metric. */ export class UpDownCounterMetric extends Metric - implements api.UpDownCounter -{ + implements api.UpDownCounter { constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts b/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts index fa8027e38a..31cec8af7a 100644 --- a/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/UpDownSumObserverMetric.ts @@ -24,8 +24,7 @@ import { MetricKind } from './export/types'; /** This is a SDK implementation of UpDownSumObserver Metric. */ export class UpDownSumObserverMetric extends BaseObserverMetric - implements api.UpDownSumObserver -{ + implements api.UpDownSumObserver { constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/ValueObserverMetric.ts b/packages/opentelemetry-metrics/src/ValueObserverMetric.ts index 97b1d4316b..a7ac5c5ff5 100644 --- a/packages/opentelemetry-metrics/src/ValueObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/ValueObserverMetric.ts @@ -23,8 +23,7 @@ import { MetricKind } from './export/types'; /** This is a SDK implementation of Value Observer Metric. */ export class ValueObserverMetric extends BaseObserverMetric - implements api.ValueObserver -{ + implements api.ValueObserver { constructor( name: string, options: api.MetricOptions, diff --git a/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts b/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts index fbeab95b6d..cda854d8ed 100644 --- a/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts +++ b/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts @@ -25,8 +25,7 @@ import { Metric } from './Metric'; /** This is a SDK implementation of Value Recorder Metric. */ export class ValueRecorderMetric extends Metric - implements api.ValueRecorder -{ + implements api.ValueRecorder { constructor( name: string, options: api.MetricOptions, From c836140bdf7b400d053138e1f2dc05a51331551f Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 19 May 2021 12:17:38 -0400 Subject: [PATCH 6/8] chore: minimal linting --- .../src/types/Metric.ts | 4 +- .../src/ZoneContextManager.ts | 6 +- .../opentelemetry-core/src/common/time.ts | 2 +- .../test/utils/environment.test.ts | 4 +- .../test/utils/wrap.test.ts | 2 +- .../src/util.ts | 18 +++--- .../test/CollectorMetricExporter.test.ts | 19 +++--- .../test/CollectorTraceExporter.test.ts | 5 +- .../test/helper.ts | 17 ++++- .../test/CollectorMetricExporter.test.ts | 17 +++-- .../test/CollectorTraceExporter.test.ts | 3 +- .../browser/CollectorMetricExporter.test.ts | 4 +- .../test/common/transform.test.ts | 5 +- .../test/common/transformMetrics.test.ts | 10 +-- .../test/node/CollectorMetricExporter.test.ts | 4 +- .../src/transform.ts | 20 +++--- .../src/PrometheusExporter.ts | 2 +- .../test/PrometheusExporter.test.ts | 14 +++-- .../test/PrometheusSerializer.test.ts | 12 ++-- .../src/fetch.ts | 61 +++++++++++++----- .../test/fetch.test.ts | 63 +++++++++---------- .../src/grpc-js/types.ts | 3 +- .../src/grpc/clientUtils.ts | 4 +- .../test/helper.ts | 35 +++++------ .../src/utils.ts | 12 ++-- .../test/functionals/http-enable.test.ts | 12 +++- .../test/functionals/utils.test.ts | 6 +- .../test/integrations/http-enable.test.ts | 2 +- .../test/integrations/https-enable.test.ts | 2 +- .../test/utils/httpRequest.ts | 2 +- .../test/utils/httpsRequest.ts | 2 +- .../src/xhr.ts | 8 +-- .../test/xhr.test.ts | 6 +- .../src/platform/node/instrumentation.ts | 2 +- .../opentelemetry-metrics/test/Meter.test.ts | 8 +-- .../test/export/aggregators/Histogram.test.ts | 19 ++++-- .../src/B3Propagator.ts | 6 +- .../src/B3SinglePropagator.ts | 3 +- .../src/detectors/AwsEc2Detector.ts | 9 ++- .../opentelemetry-sdk-node/test/sdk.test.ts | 12 ++-- packages/opentelemetry-tracing/src/Span.ts | 5 +- .../test/BasicTracerProvider.test.ts | 11 ++-- .../opentelemetry-tracing/test/Tracer.test.ts | 6 +- .../opentelemetry-tracing/test/config.test.ts | 6 +- .../test/export/BatchSpanProcessor.test.ts | 5 +- .../test/export/SimpleSpanProcessor.test.ts | 3 +- .../src/StackContextManager.ts | 2 +- .../test/WebTracerProvider.test.ts | 10 +-- packages/opentelemetry-web/test/utils.test.ts | 16 ++--- 49 files changed, 288 insertions(+), 221 deletions(-) diff --git a/packages/opentelemetry-api-metrics/src/types/Metric.ts b/packages/opentelemetry-api-metrics/src/types/Metric.ts index cc00964465..aebbc46246 100644 --- a/packages/opentelemetry-api-metrics/src/types/Metric.ts +++ b/packages/opentelemetry-api-metrics/src/types/Metric.ts @@ -155,7 +155,9 @@ export interface ValueRecorder extends UnboundMetric { /** Base interface for the Observer metrics. */ export interface BaseObserver extends UnboundMetric { - observation: (value: number) => { + observation: ( + value: number + ) => { value: number; observer: BaseObserver; }; diff --git a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts index 21da77012b..edd5a0719e 100644 --- a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts +++ b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts @@ -64,7 +64,7 @@ export class ZoneContextManager implements ContextManager { writable: false, value: target.length, }); - return contextWrapper as unknown as T; + return (contextWrapper as unknown) as T; } /** @@ -72,7 +72,7 @@ export class ZoneContextManager implements ContextManager { * @param context A context (span) to be bind to target */ private _bindListener(obj: T, context: Context): T { - const target = obj as unknown as TargetWithEvents; + const target = (obj as unknown) as TargetWithEvents; if (target.__ot_listeners !== undefined) { return obj; } @@ -215,7 +215,7 @@ export class ZoneContextManager implements ContextManager { } else if (isListenerObject(target)) { this._bindListener(target, context); } - return target as unknown as T; + return (target as unknown) as T; } /** diff --git a/packages/opentelemetry-core/src/common/time.ts b/packages/opentelemetry-core/src/common/time.ts index db66f76dd3..ce56ab8605 100644 --- a/packages/opentelemetry-core/src/common/time.ts +++ b/packages/opentelemetry-core/src/common/time.ts @@ -39,7 +39,7 @@ function numberToHrtime(epochMillis: number): api.HrTime { function getTimeOrigin(): number { let timeOrigin = performance.timeOrigin; if (typeof timeOrigin !== 'number') { - const perf: TimeOriginLegacy = performance as unknown as TimeOriginLegacy; + const perf: TimeOriginLegacy = (performance as unknown) as TimeOriginLegacy; timeOrigin = perf.timing && perf.timing.fetchStart; } return timeOrigin; diff --git a/packages/opentelemetry-core/test/utils/environment.test.ts b/packages/opentelemetry-core/test/utils/environment.test.ts index 7b31b2d736..a993f10083 100644 --- a/packages/opentelemetry-core/test/utils/environment.test.ts +++ b/packages/opentelemetry-core/test/utils/environment.test.ts @@ -38,7 +38,7 @@ export function mockEnvironment(values: RAW_ENVIRONMENT) { }); } else { Object.keys(values).forEach(key => { - (window as unknown as RAW_ENVIRONMENT)[key] = String(values[key]); + ((window as unknown) as RAW_ENVIRONMENT)[key] = String(values[key]); }); } } @@ -53,7 +53,7 @@ export function removeMockEnvironment() { }); } else { Object.keys(lastMock).forEach(key => { - delete (window as unknown as RAW_ENVIRONMENT)[key]; + delete ((window as unknown) as RAW_ENVIRONMENT)[key]; }); } lastMock = {}; diff --git a/packages/opentelemetry-core/test/utils/wrap.test.ts b/packages/opentelemetry-core/test/utils/wrap.test.ts index 5c9b91f85d..25ef129718 100644 --- a/packages/opentelemetry-core/test/utils/wrap.test.ts +++ b/packages/opentelemetry-core/test/utils/wrap.test.ts @@ -27,7 +27,7 @@ function makeWrapped( defineProperty(wrapper, '__wrapped', wrapped); defineProperty(wrapper, '__unwrap', unwrap); defineProperty(wrapper, '__original', original); - return wrapper as unknown as ShimWrapped; + return (wrapper as unknown) as ShimWrapped; } function defineProperty(obj: any, name: string, value: unknown) { diff --git a/packages/opentelemetry-exporter-collector-grpc/src/util.ts b/packages/opentelemetry-exporter-collector-grpc/src/util.ts index 21bc723f47..16a2b62dfa 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/util.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/util.ts @@ -51,17 +51,15 @@ export function onInit( const packageObject: any = grpc.loadPackageDefinition(packageDefinition); if (collector.getServiceClientType() === ServiceClientType.SPANS) { - collector.serviceClient = - new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( - collector.serverAddress, - credentials - ); + collector.serviceClient = new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( + collector.serverAddress, + credentials + ); } else { - collector.serviceClient = - new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( - collector.serverAddress, - credentials - ); + collector.serviceClient = new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( + collector.serverAddress, + credentials + ); } if (collector.grpcQueue.length > 0) { diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts index e97ecd7737..c7b807d77e 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts @@ -78,8 +78,9 @@ const testCollectorMetricExporter = (params: TestParams) => includeDirs, }) .then((packageDefinition: protoLoader.PackageDefinition) => { - const packageObject: any = - grpc.loadPackageDefinition(packageDefinition); + const packageObject: any = grpc.loadPackageDefinition( + packageDefinition + ); server.addService( packageObject.opentelemetry.proto.collector.metrics.v1 .MetricsService.service, @@ -138,13 +139,13 @@ const testCollectorMetricExporter = (params: TestParams) => value: 1592602232694000000, }); metrics = []; - const counter: metrics.Metric & Counter = - mockCounter(); - const observer: metrics.Metric & ValueObserver = - mockObserver(observerResult => { - observerResult.observe(3, {}); - observerResult.observe(6, {}); - }); + const counter: metrics.Metric & + Counter = mockCounter(); + const observer: metrics.Metric & + ValueObserver = mockObserver(observerResult => { + observerResult.observe(3, {}); + observerResult.observe(6, {}); + }); const recorder: metrics.Metric & ValueRecorder = mockValueRecorder(); diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts index c9bd8e196c..e090c05471 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts @@ -73,8 +73,9 @@ const testCollectorExporter = (params: TestParams) => includeDirs, }) .then((packageDefinition: protoLoader.PackageDefinition) => { - const packageObject: any = - grpc.loadPackageDefinition(packageDefinition); + const packageObject: any = grpc.loadPackageDefinition( + packageDefinition + ); server.addService( packageObject.opentelemetry.proto.collector.trace.v1.TraceService .service, diff --git a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts index 6d29a3263b..147fb1c236 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts @@ -41,7 +41,22 @@ const meterProvider = new metrics.MeterProvider({ const meter = meterProvider.getMeter('default', '0.0.1'); const traceIdArr = [ - 31, 16, 8, 220, 142, 39, 14, 133, 196, 10, 13, 124, 57, 57, 178, 120, + 31, + 16, + 8, + 220, + 142, + 39, + 14, + 133, + 196, + 10, + 13, + 124, + 57, + 57, + 178, + 120, ]; const spanIdArr = [94, 16, 114, 97, 246, 79, 165, 62]; const parentIdArr = [120, 168, 145, 80, 152, 134, 67, 136]; diff --git a/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts index 8b7c074886..5f4c4447a5 100644 --- a/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts @@ -111,13 +111,13 @@ describe('CollectorMetricExporter - node with proto over http', () => { value: 1592602232694000000, }); metrics = []; - const counter: metrics.Metric & Counter = - mockCounter(); - const observer: metrics.Metric & ValueObserver = - mockObserver(observerResult => { - observerResult.observe(3, {}); - observerResult.observe(6, {}); - }); + const counter: metrics.Metric & + Counter = mockCounter(); + const observer: metrics.Metric & + ValueObserver = mockObserver(observerResult => { + observerResult.observe(3, {}); + observerResult.observe(6, {}); + }); const recorder: metrics.Metric & ValueRecorder = mockValueRecorder(); @@ -175,8 +175,7 @@ describe('CollectorMetricExporter - node with proto over http', () => { write: (...writeArgs: any[]) => { const ExportTraceServiceRequestProto = getExportRequestProto(); const data = ExportTraceServiceRequestProto?.decode(writeArgs[0]); - const json = - data?.toJSON() as collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest; + const json = data?.toJSON() as collectorTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest; const metric1 = json.resourceMetrics[0].instrumentationLibraryMetrics[0].metrics[0]; diff --git a/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts index 2936b5e53d..fd812f7a4a 100644 --- a/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts @@ -146,8 +146,7 @@ describe('CollectorTraceExporter - node with proto over http', () => { write: (...args: any[]) => { const ExportTraceServiceRequestProto = getExportRequestProto(); const data = ExportTraceServiceRequestProto?.decode(args[0]); - const json = - data?.toJSON() as collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest; + const json = data?.toJSON() as collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest; const span1 = json.resourceSpans[0].instrumentationLibrarySpans[0].spans[0]; assert.ok(typeof span1 !== 'undefined', "span doesn't exist"); diff --git a/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts index fc736c2718..5f40d55c2e 100644 --- a/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts @@ -64,8 +64,8 @@ describe('CollectorMetricExporter - web', () => { }, 'double-observer2' ); - const recorder: Metric & ValueRecorder = - mockValueRecorder(); + const recorder: Metric & + ValueRecorder = mockValueRecorder(); counter.add(1); recorder.record(7); recorder.record(14); diff --git a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts index b7c7e0d150..f212a7774a 100644 --- a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts @@ -146,8 +146,9 @@ describe('transform', () => { [resource2, new Map([[instrumentationLibrary, [span2, span3]]])], ]); - const result = - transform.groupSpansByResourceAndLibrary(multiResourceTrace); + const result = transform.groupSpansByResourceAndLibrary( + multiResourceTrace + ); assert.deepStrictEqual(result, expected); }); diff --git a/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts b/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts index 864dcbd2ce..62b93cc077 100644 --- a/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts @@ -168,7 +168,7 @@ describe('transformMetrics', () => { metricKind: 0, valueType: 0, }, - labels: { foo: 1 as unknown as string }, + labels: { foo: (1 as unknown) as string }, aggregator: new SumAggregator(), resource: new Resource({}), aggregationTemporality: 0, @@ -208,9 +208,11 @@ describe('transformMetrics', () => { it('should group by instrumentation library', async () => { const [resource] = mockedResources; const [lib1, lib2] = mockedInstrumentationLibraries; - const [metric1, metric2, metric3] = multiInstrumentationLibraryMetricsGet( - observerResult => {} - ); + const [ + metric1, + metric2, + metric3, + ] = multiInstrumentationLibraryMetricsGet(observerResult => {}); const expected = new Map([ [ resource, diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts index 1d0efc5a9a..dc3c0a98ff 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts @@ -148,8 +148,8 @@ describe('CollectorMetricExporter - node with json over http', () => { }, 'double-observer2' ); - const recorder: Metric & ValueRecorder = - mockValueRecorder(); + const recorder: Metric & + ValueRecorder = mockValueRecorder(); counter.add(1); recorder.record(7); recorder.record(14); diff --git a/packages/opentelemetry-exporter-jaeger/src/transform.ts b/packages/opentelemetry-exporter-jaeger/src/transform.ts index c75104e39c..bb3ea5e5f1 100644 --- a/packages/opentelemetry-exporter-jaeger/src/transform.ts +++ b/packages/opentelemetry-exporter-jaeger/src/transform.ts @@ -88,16 +88,18 @@ export function spanToThrift(span: ReadableSpan): ThriftSpan { const spanTags: ThriftTag[] = ThriftUtils.getThriftTags(tags); - const logs = span.events.map((event): Log => { - const fields: Tag[] = [{ key: 'event', value: event.name }]; - const attrs = event.attributes; - if (attrs) { - Object.keys(attrs).forEach(attr => - fields.push({ key: attr, value: toTagValue(attrs[attr]) }) - ); + const logs = span.events.map( + (event): Log => { + const fields: Tag[] = [{ key: 'event', value: event.name }]; + const attrs = event.attributes; + if (attrs) { + Object.keys(attrs).forEach(attr => + fields.push({ key: attr, value: toTagValue(attrs[attr]) }) + ); + } + return { timestamp: hrTimeToMilliseconds(event.time), fields }; } - return { timestamp: hrTimeToMilliseconds(event.time), fields }; - }); + ); const spanLogs: ThriftLog[] = ThriftUtils.getThriftLogs(logs); return { diff --git a/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts b/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts index 190f89ab49..2fcf960451 100644 --- a/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts +++ b/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts @@ -140,7 +140,7 @@ export class PrometheusExporter implements MetricExporter { diag.debug('Prometheus exporter was stopped'); } else { if ( - (err as unknown as { code: string }).code !== + ((err as unknown) as { code: string }).code !== 'ERR_SERVER_NOT_RUNNING' ) { globalErrorHandler(err); diff --git a/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts b/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts index 1e5c5b77a9..29527736f1 100644 --- a/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts +++ b/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts @@ -191,13 +191,15 @@ describe('PrometheusExporter', () => { it('should able to call getMetricsRequestHandler function to generate response with metrics', () => { const exporter = new PrometheusExporter({ preventServerStart: true }); - const mockRequest: SinonStubbedInstance = - sinon.createStubInstance(http.IncomingMessage); - const mockResponse: SinonStubbedInstance = - sinon.createStubInstance(http.ServerResponse); + const mockRequest: SinonStubbedInstance = sinon.createStubInstance( + http.IncomingMessage + ); + const mockResponse: SinonStubbedInstance = sinon.createStubInstance( + http.ServerResponse + ); exporter.getMetricsRequestHandler( - mockRequest as unknown as http.IncomingMessage, - mockResponse as unknown as http.ServerResponse + (mockRequest as unknown) as http.IncomingMessage, + (mockResponse as unknown) as http.ServerResponse ); sinon.assert.calledOnce(mockResponse.setHeader); sinon.assert.calledOnce(mockResponse.end); diff --git a/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts b/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts index 4cc905b512..07d240ff42 100644 --- a/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts +++ b/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts @@ -451,12 +451,12 @@ describe('PrometheusSerializer', () => { }).getMeter('test'); const counter = meter.createCounter('test_total') as CounterMetric; counter - .bind({ + .bind(({ object: {}, NaN: NaN, null: null, undefined: undefined, - } as unknown as Labels) + } as unknown) as Labels) .add(1); const records = await counter.getMetricRecord(); const record = records[0]; @@ -509,14 +509,14 @@ describe('PrometheusSerializer', () => { }).getMeter('test'); const counter = meter.createCounter('test_total') as CounterMetric; counter - .bind({ + .bind(({ backslash: '\u005c', // \ => \\ (\u005c\u005c) doubleQuote: '\u0022', // " => \" (\u005c\u0022) lineFeed: '\u000a', // ↵ => \n (\u005c\u006e) backslashN: '\u005c\u006e', // \n => \\n (\u005c\u005c\u006e) backslashDoubleQuote: '\u005c\u0022', // \" => \\\" (\u005c\u005c\u005c\u0022) backslashLineFeed: '\u005c\u000a', // \↵ => \\\n (\u005c\u005c\u005c\u006e) - } as unknown as Labels) + } as unknown) as Labels) .add(1); const records = await counter.getMetricRecord(); const record = records[0]; @@ -549,9 +549,9 @@ describe('PrometheusSerializer', () => { // with an error like: // error while linting: text format parsing error in line 282: expected '=' after label name, found '-' counter - .bind({ + .bind(({ 'account-id': '123456', - } as unknown as Labels) + } as unknown) as Labels) .add(1); const records = await counter.getMetricRecord(); const record = records[0]; diff --git a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index c9ff89db22..ec6cae7cf4 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -314,6 +314,27 @@ export class FetchInstrumentation extends InstrumentationBase< } const spanData = plugin._prepareSpanData(url); + function endSpanOnError(span: api.Span, error: FetchError) { + plugin._applyAttributesAfterFetch(span, options, error); + plugin._endSpan(span, spanData, { + status: error.status || 0, + statusText: error.message, + url, + }); + } + + function endSpanOnSuccess(span: api.Span, response: Response) { + plugin._applyAttributesAfterFetch(span, options, response); + if (response.status >= 200 && response.status < 400) { + plugin._endSpan(span, spanData, response); + } else { + plugin._endSpan(span, spanData, { + status: response.status, + statusText: response.statusText, + url, + }); + } + } function onSuccess( span: api.Span, resolve: ( @@ -322,15 +343,28 @@ export class FetchInstrumentation extends InstrumentationBase< response: Response ) { try { - plugin._applyAttributesAfterFetch(span, options, response); - if (response.status >= 200 && response.status < 400) { - plugin._endSpan(span, spanData, response); + const resClone = response.clone(); + const body = resClone.body; + if (body) { + const reader = body.getReader(); + const read = (): void => { + reader.read().then( + ({ done }) => { + if (done) { + endSpanOnSuccess(span, response); + } else { + read(); + } + }, + error => { + endSpanOnError(span, error); + } + ); + }; + read(); } else { - plugin._endSpan(span, spanData, { - status: response.status, - statusText: response.statusText, - url, - }); + // some older browsers don't have .body implemented + endSpanOnSuccess(span, response); } } finally { resolve(response); @@ -343,12 +377,7 @@ export class FetchInstrumentation extends InstrumentationBase< error: FetchError ) { try { - plugin._applyAttributesAfterFetch(span, options, error); - plugin._endSpan(span, spanData, { - status: error.status || 0, - statusText: error.message, - url, - }); + endSpanOnError(span, error); } finally { reject(error); } @@ -378,8 +407,8 @@ export class FetchInstrumentation extends InstrumentationBase< request: Request | RequestInit, result: Response | FetchError ) { - const applyCustomAttributesOnSpan = - this._getConfig().applyCustomAttributesOnSpan; + const applyCustomAttributesOnSpan = this._getConfig() + .applyCustomAttributesOnSpan; if (applyCustomAttributesOnSpan) { safeExecuteInTheMiddle( () => applyCustomAttributesOnSpan(span, request, result), diff --git a/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts b/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts index a9568f71cc..51b05134f3 100644 --- a/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts +++ b/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts @@ -51,8 +51,8 @@ class DummySpanExporter implements tracing.SpanExporter { } } -const getData = (url: string, method?: string) => - fetch(url, { +const getData = (url: string, method?: string) => { + return fetch(url, { method: method || 'GET', headers: { foo: 'bar', @@ -60,6 +60,7 @@ const getData = (url: string, method?: string) => 'Content-Type': 'application/json', }, }); +}; const CUSTOM_ATTRIBUTE_KEY = 'span kind'; const defaultResource = { @@ -235,37 +236,33 @@ describe('fetch', () => { rootSpan = webTracerWithZone.startSpan('root'); api.context.with(api.setSpan(api.context.active(), rootSpan), () => { fakeNow = 0; - getData(fileUrl, method).then( - response => { - // this is a bit tricky as the only way to get all request headers from - // fetch is to use json() - response.json().then( - json => { - lastResponse = json; - const headers: { [key: string]: string } = {}; - Object.keys(lastResponse.headers).forEach(key => { - headers[key.toLowerCase()] = lastResponse.headers[key]; - }); - lastResponse.headers = headers; - // OBSERVER_WAIT_TIME_MS - sinon.clock.tick(300); - done(); - }, - () => { - lastResponse = undefined; - // OBSERVER_WAIT_TIME_MS - sinon.clock.tick(300); - done(); - } - ); - }, - () => { - lastResponse = undefined; - // OBSERVER_WAIT_TIME_MS - sinon.clock.tick(300); + void getData(fileUrl, method) + .then( + response => { + // this is a bit tricky as the only way to get all request headers from + // fetch is to use json() + return response.json().then( + json => { + lastResponse = json; + const headers: { [key: string]: string } = {}; + Object.keys(lastResponse.headers).forEach(key => { + headers[key.toLowerCase()] = lastResponse.headers[key]; + }); + lastResponse.headers = headers; + }, + () => { + lastResponse = undefined; + } + ); + }, + () => { + lastResponse = undefined; + } + ) + .then(sinon.clock.runAllAsync) + .then(() => { done(); - } - ); + }); fakeNow = 300; }); }; @@ -529,7 +526,7 @@ describe('fetch', () => { it('should set trace headers with a request object', () => { const r = new Request('url'); - window.fetch(r); + window.fetch(r).catch(() => {}); assert.ok(typeof r.headers.get(X_B3_TRACE_ID) === 'string'); }); diff --git a/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts b/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts index e0ae1545d2..06ee4125d0 100644 --- a/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts +++ b/packages/opentelemetry-instrumentation-grpc/src/grpc-js/types.ts @@ -55,8 +55,7 @@ export type GrpcClientFunc = ((...args: unknown[]) => GrpcEmitter) & { export type ServerRegisterFunction = typeof grpcJs.Server.prototype.register; -export type MakeClientConstructorFunction = - typeof grpcJs.makeGenericClientConstructor; +export type MakeClientConstructorFunction = typeof grpcJs.makeGenericClientConstructor; export type { HandleCall } from '@grpc/grpc-js/build/src/server-call'; export type { PackageDefinition } from '@grpc/grpc-js/build/src/make-client'; diff --git a/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts b/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts index 3a310e00a6..938533024c 100644 --- a/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts +++ b/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts @@ -119,7 +119,7 @@ export const makeGrpcClientRemoteCall = function ( } }; context.bind(call); - (call as unknown as events.EventEmitter).on( + ((call as unknown) as events.EventEmitter).on( 'error', (err: grpcTypes.ServiceError) => { span.setStatus({ @@ -134,7 +134,7 @@ export const makeGrpcClientRemoteCall = function ( } ); - (call as unknown as events.EventEmitter).on( + ((call as unknown) as events.EventEmitter).on( 'status', (status: SpanStatus) => { span.setStatus({ code: SpanStatusCode.UNSET }); diff --git a/packages/opentelemetry-instrumentation-grpc/test/helper.ts b/packages/opentelemetry-instrumentation-grpc/test/helper.ts index 183ada3f9e..1c71e49430 100644 --- a/packages/opentelemetry-instrumentation-grpc/test/helper.ts +++ b/packages/opentelemetry-instrumentation-grpc/test/helper.ts @@ -90,27 +90,24 @@ interface TestGrpcCall { } // Compare two arrays using an equal function f -const arrayIsEqual = - (f: any) => - ([x, ...xs]: any) => - ([y, ...ys]: any): any => - x === undefined && y === undefined - ? true - : Boolean(f(x)(y)) && arrayIsEqual(f)(xs)(ys); +const arrayIsEqual = (f: any) => ([x, ...xs]: any) => ([y, ...ys]: any): any => + x === undefined && y === undefined + ? true + : Boolean(f(x)(y)) && arrayIsEqual(f)(xs)(ys); // Return true if two requests has the same num value const requestEqual = (x: TestRequestResponse) => (y: TestRequestResponse) => x.num !== undefined && x.num === y.num; // Check if its equal requests or array of requests -const checkEqual = - (x: TestRequestResponse | TestRequestResponse[]) => - (y: TestRequestResponse | TestRequestResponse[]) => - x instanceof Array && y instanceof Array - ? arrayIsEqual(requestEqual)(x as any)(y as any) - : !(x instanceof Array) && !(y instanceof Array) - ? requestEqual(x)(y) - : false; +const checkEqual = (x: TestRequestResponse | TestRequestResponse[]) => ( + y: TestRequestResponse | TestRequestResponse[] +) => + x instanceof Array && y instanceof Array + ? arrayIsEqual(requestEqual)(x as any)(y as any) + : !(x instanceof Array) && !(y instanceof Array) + ? requestEqual(x)(y) + : false; export const runTests = ( plugin: GrpcInstrumentation, @@ -566,10 +563,10 @@ export const runTests = ( }); }; - const insertError = - (request: TestRequestResponse | TestRequestResponse[]) => - (code: number) => - request instanceof Array ? [{ num: code }, ...request] : { num: code }; + const insertError = ( + request: TestRequestResponse | TestRequestResponse[] + ) => (code: number) => + request instanceof Array ? [{ num: code }, ...request] : { num: code }; const runErrorTest = ( method: typeof methodList[0], diff --git a/packages/opentelemetry-instrumentation-http/src/utils.ts b/packages/opentelemetry-instrumentation-http/src/utils.ts index 4d88ce808d..769bdac29f 100644 --- a/packages/opentelemetry-instrumentation-http/src/utils.ts +++ b/packages/opentelemetry-instrumentation-http/src/utils.ts @@ -197,8 +197,9 @@ export const setRequestContentLengthAttribute = ( if (isCompressed(request.headers)) { attributes[SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH] = length; } else { - attributes[SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED] = - length; + attributes[ + SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED + ] = length; } }; @@ -217,8 +218,9 @@ export const setResponseContentLengthAttribute = ( if (isCompressed(response.headers)) { attributes[SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH] = length; } else { - attributes[SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED] = - length; + attributes[ + SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED + ] = length; } }; @@ -471,7 +473,7 @@ export const getIncomingRequestAttributesOnResponse = ( const { socket } = request; const { statusCode, statusMessage } = response; const { localAddress, localPort, remoteAddress, remotePort } = socket; - const { __ot_middlewares } = request as unknown as { + const { __ot_middlewares } = (request as unknown) as { [key: string]: unknown; }; const route = Array.isArray(__ot_middlewares) diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts index 2567cbf580..2361b26756 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts @@ -277,7 +277,17 @@ describe('HttpInstrumentation', () => { }); const httpErrorCodes = [ - 400, 401, 403, 404, 429, 501, 503, 504, 500, 505, 597, + 400, + 401, + 403, + 404, + 429, + 501, + 503, + 504, + 500, + 505, + 597, ]; for (let i = 0; i < httpErrorCodes.length; i++) { diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts index 5bafcb3259..570b9b2a47 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts @@ -35,7 +35,9 @@ import { AttributeNames } from '../../src/enums/AttributeNames'; describe('Utility', () => { describe('parseResponseStatus()', () => { it('should return ERROR code by default', () => { - const status = utils.parseResponseStatus(undefined as unknown as number); + const status = utils.parseResponseStatus( + (undefined as unknown) as number + ); assert.deepStrictEqual(status, { code: SpanStatusCode.ERROR }); }); @@ -118,7 +120,7 @@ describe('Utility', () => { it('should throw if type is unknown', () => { try { - utils.satisfiesPattern('/TeSt/1', true as unknown as IgnoreMatcher); + utils.satisfiesPattern('/TeSt/1', (true as unknown) as IgnoreMatcher); assert.fail(); } catch (error) { assert.strictEqual(error instanceof TypeError, true); diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts index c7d7a4ac60..75d21dd731 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts @@ -313,7 +313,7 @@ describe('HttpInstrumentation Integration tests', () => { `${protocol}://localhost:${mockServerPort}/`, options, (resp: http.IncomingMessage) => { - const res = resp as unknown as http.IncomingMessage & { + const res = (resp as unknown) as http.IncomingMessage & { req: http.IncomingMessage; }; diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts index afc21fac4f..729aa1fe91 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts @@ -322,7 +322,7 @@ describe('HttpsInstrumentation Integration tests', () => { `${protocol}://localhost:${mockServerPort}/`, options, (resp: http.IncomingMessage) => { - const res = resp as unknown as http.IncomingMessage & { + const res = (resp as unknown) as http.IncomingMessage & { req: http.IncomingMessage; }; diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts index d720677902..f507b7f1f1 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts @@ -32,7 +32,7 @@ function get(input: any, options?: any): GetResult { let req: http.ClientRequest; function onGetResponseCb(resp: http.IncomingMessage): void { - const res = resp as unknown as http.IncomingMessage & { + const res = (resp as unknown) as http.IncomingMessage & { req: http.IncomingMessage; }; let data = ''; diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts index f00174e38b..f75cf1e566 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts @@ -36,7 +36,7 @@ function get(input: any, options?: any): GetResult { let req: http.ClientRequest; function onGetResponseCb(resp: http.IncomingMessage): void { - const res = resp as unknown as http.IncomingMessage & { + const res = (resp as unknown) as http.IncomingMessage & { req: http.IncomingMessage; }; let data = ''; diff --git a/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts b/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts index 905a64b59b..fb7274cdce 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts +++ b/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts @@ -180,8 +180,8 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase applyCustomAttributesOnSpan(span, xhr), @@ -242,7 +242,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase(); this._usedResources = new WeakSet(); } @@ -271,7 +271,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase { ); spyEntries = sinon.stub( - performance as unknown as Performance, + (performance as unknown) as Performance, 'getEntriesByType' ); spyEntries.withArgs('resource').returns(resources); @@ -212,7 +212,7 @@ describe('xhr', () => { dummySpanExporter = new DummySpanExporter(); exportSpy = sinon.stub(dummySpanExporter, 'export'); clearResourceTimingsSpy = sinon.stub( - performance as unknown as Performance, + (performance as unknown) as Performance, 'clearResourceTimings' ); webTracerProviderWithZone.addSpanProcessor( @@ -762,7 +762,7 @@ describe('xhr', () => { ); spyEntries = sinon.stub( - performance as unknown as Performance, + (performance as unknown) as Performance, 'getEntriesByType' ); spyEntries.withArgs('resource').returns(resources); diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index d7f5291665..f50cff4252 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -131,7 +131,7 @@ export abstract class InstrumentationBase { internals: true }, (exports, name, baseDir) => { return this._onRequire( - module as unknown as InstrumentationModuleDefinition< + (module as unknown) as InstrumentationModuleDefinition< typeof exports >, exports, diff --git a/packages/opentelemetry-metrics/test/Meter.test.ts b/packages/opentelemetry-metrics/test/Meter.test.ts index 3083e41bd1..b1e6389b5d 100644 --- a/packages/opentelemetry-metrics/test/Meter.test.ts +++ b/packages/opentelemetry-metrics/test/Meter.test.ts @@ -966,8 +966,7 @@ describe('Meter', () => { return Math.random(); } - const metricRecords: MetricRecord[] = - await valueObserver.getMetricRecord(); + const metricRecords: MetricRecord[] = await valueObserver.getMetricRecord(); assert.strictEqual(metricRecords.length, 4); const metric1 = metricRecords[0]; @@ -1201,7 +1200,7 @@ describe('Meter', () => { setTimeout(resolve, 1); }), ]).then((stats: unknown[]) => { - const apps = stats[0] as unknown as Stat[]; + const apps = (stats[0] as unknown) as Stat[]; apps.forEach(app => { observerBatchResult.observe({ app: app.name, core: '1' }, [ tempMetric.observation(app.core1.temp), @@ -1270,8 +1269,7 @@ describe('Meter', () => { // simulate some waiting await setTimeout(() => {}, 5); - const cpuUsageMetricRecords: MetricRecord[] = - await cpuUsageMetric.getMetricRecord(); + const cpuUsageMetricRecords: MetricRecord[] = await cpuUsageMetric.getMetricRecord(); const value = cpuUsageMetric .bind({ foo: 'bar' }) .getAggregator() diff --git a/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts b/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts index 2b7a22a903..6ebf7bdf64 100644 --- a/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts +++ b/packages/opentelemetry-metrics/test/export/aggregators/Histogram.test.ts @@ -30,13 +30,22 @@ describe('HistogramAggregator', () => { it('should sort boundaries', () => { const aggregator = new HistogramAggregator([ - 200, 500, 300, 700, 1000, 1500, + 200, + 500, + 300, + 700, + 1000, + 1500, ]); const point = aggregator.toPoint().value as Histogram; - assert.deepEqual( - point.buckets.boundaries, - [200, 300, 500, 700, 1000, 1500] - ); + assert.deepEqual(point.buckets.boundaries, [ + 200, + 300, + 500, + 700, + 1000, + 1500, + ]); }); it('should throw if no boundaries are defined', () => { diff --git a/packages/opentelemetry-propagator-b3/src/B3Propagator.ts b/packages/opentelemetry-propagator-b3/src/B3Propagator.ts index 54a2b3e804..7b40ef0527 100644 --- a/packages/opentelemetry-propagator-b3/src/B3Propagator.ts +++ b/packages/opentelemetry-propagator-b3/src/B3Propagator.ts @@ -34,10 +34,8 @@ import { B3InjectEncoding, B3PropagatorConfig } from './types'; * Based on: https://github.com/openzipkin/b3-propagation */ export class B3Propagator implements TextMapPropagator { - private readonly _b3MultiPropagator: B3MultiPropagator = - new B3MultiPropagator(); - private readonly _b3SinglePropagator: B3SinglePropagator = - new B3SinglePropagator(); + private readonly _b3MultiPropagator: B3MultiPropagator = new B3MultiPropagator(); + private readonly _b3SinglePropagator: B3SinglePropagator = new B3SinglePropagator(); private readonly _inject: ( context: Context, carrier: unknown, diff --git a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts index fc2aeda718..acd36820e8 100644 --- a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts +++ b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts @@ -30,8 +30,7 @@ import { import { B3_CONTEXT_HEADER } from './constants'; import { B3_DEBUG_FLAG_KEY } from './common'; -const B3_CONTEXT_REGEX = - /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/; +const B3_CONTEXT_REGEX = /((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/; const PADDING = '0'.repeat(16); const SAMPLED_VALUES = new Set(['d', '1']); const DEBUG_STATE = 'd'; diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts index 37e765fe76..99d30c9049 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts @@ -57,8 +57,13 @@ class AwsEc2Detector implements Detector { */ async detect(_config?: ResourceDetectionConfig): Promise { const token = await this._fetchToken(); - const { accountId, instanceId, instanceType, region, availabilityZone } = - await this._fetchIdentity(token); + const { + accountId, + instanceId, + instanceType, + region, + availabilityZone, + } = await this._fetchIdentity(token); const hostname = await this._fetchHost(token); return new Resource({ diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts index 75b3178730..f9274caad3 100644 --- a/packages/opentelemetry-sdk-node/test/sdk.test.ts +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -113,8 +113,7 @@ describe('Node SDK', () => { propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); - const apiTracerProvider = - trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NoopTracerProvider); assert.ok(metrics.getMeterProvider() instanceof NoopMeterProvider); @@ -136,8 +135,7 @@ describe('Node SDK', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - const apiTracerProvider = - trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider); }); @@ -160,8 +158,7 @@ describe('Node SDK', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - const apiTracerProvider = - trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider); }); @@ -180,8 +177,7 @@ describe('Node SDK', () => { propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); - const apiTracerProvider = - trace.getTracerProvider() as ProxyTracerProvider; + const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; assert.ok(apiTracerProvider.getDelegate() instanceof NoopTracerProvider); assert.ok(metrics.getMeterProvider() instanceof MeterProvider); diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index 4a5ba7c361..d7a18fbe2e 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -192,8 +192,9 @@ export class Span implements api.Span, ReadableSpan { attributes[SemanticAttributes.EXCEPTION_MESSAGE] = exception; } else if (exception) { if (exception.code) { - attributes[SemanticAttributes.EXCEPTION_TYPE] = - exception.code.toString(); + attributes[ + SemanticAttributes.EXCEPTION_TYPE + ] = exception.code.toString(); } else if (exception.name) { attributes[SemanticAttributes.EXCEPTION_TYPE] = exception.name; } diff --git a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts index 406162096b..06bdb2d6e0 100644 --- a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts @@ -49,9 +49,9 @@ import { describe('BasicTracerProvider', () => { let removeEvent: Function | undefined; - const envSource = ( - typeof window !== 'undefined' ? window : process.env - ) as any; + const envSource = (typeof window !== 'undefined' + ? window + : process.env) as any; beforeEach(() => { context.disable(); @@ -370,7 +370,10 @@ describe('BasicTracerProvider', () => { const span = tracer.startSpan( 'my-span', {}, - setSpanContext(ROOT_CONTEXT, 'invalid-parent' as unknown as SpanContext) + setSpanContext( + ROOT_CONTEXT, + ('invalid-parent' as unknown) as SpanContext + ) ); assert.ok(span instanceof Span); assert.deepStrictEqual((span as Span).parentSpanId, undefined); diff --git a/packages/opentelemetry-tracing/test/Tracer.test.ts b/packages/opentelemetry-tracing/test/Tracer.test.ts index bb57d0b99d..cde378b4eb 100644 --- a/packages/opentelemetry-tracing/test/Tracer.test.ts +++ b/packages/opentelemetry-tracing/test/Tracer.test.ts @@ -34,9 +34,9 @@ import { describe('Tracer', () => { const tracerProvider = new BasicTracerProvider(); - const envSource = ( - typeof window !== 'undefined' ? window : process.env - ) as any; + const envSource = (typeof window !== 'undefined' + ? window + : process.env) as any; class TestSampler implements Sampler { shouldSample() { diff --git a/packages/opentelemetry-tracing/test/config.test.ts b/packages/opentelemetry-tracing/test/config.test.ts index 9edbbd8147..7f81183c13 100644 --- a/packages/opentelemetry-tracing/test/config.test.ts +++ b/packages/opentelemetry-tracing/test/config.test.ts @@ -23,9 +23,9 @@ import * as assert from 'assert'; import { buildSamplerFromEnv } from '../src/config'; describe('config', () => { - const envSource = ( - typeof window !== 'undefined' ? window : process.env - ) as any; + const envSource = (typeof window !== 'undefined' + ? window + : process.env) as any; describe('buildSamplerFromEnv()', () => { afterEach(() => { diff --git a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts index 6a44e9d60d..4f5d734713 100644 --- a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts +++ b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts @@ -84,7 +84,7 @@ describe('BatchSpanProcessor', () => { let env: Record; if (typeof process === 'undefined') { - env = window as unknown as Record; + env = (window as unknown) as Record; } else { env = process.env as Record; } @@ -362,8 +362,7 @@ describe('BatchSpanProcessor', () => { processor.onEnd(span); processor.forceFlush().then(() => { - const exporterCreatedSpans = - testTracingExporter.getExporterCreatedSpans(); + const exporterCreatedSpans = testTracingExporter.getExporterCreatedSpans(); assert.equal(exporterCreatedSpans.length, 0); done(); diff --git a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts index 1fa32c6aa9..b3a5f1ecd5 100644 --- a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts +++ b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts @@ -191,8 +191,7 @@ describe('SimpleSpanProcessor', () => { processor.onEnd(span); - const exporterCreatedSpans = - testTracingExporter.getExporterCreatedSpans(); + const exporterCreatedSpans = testTracingExporter.getExporterCreatedSpans(); assert.equal(exporterCreatedSpans.length, 0); }); }); diff --git a/packages/opentelemetry-web/src/StackContextManager.ts b/packages/opentelemetry-web/src/StackContextManager.ts index 7c01a0205b..0c87d6e7c6 100644 --- a/packages/opentelemetry-web/src/StackContextManager.ts +++ b/packages/opentelemetry-web/src/StackContextManager.ts @@ -50,7 +50,7 @@ export class StackContextManager implements ContextManager { writable: false, value: target.length, }); - return contextWrapper as unknown as T; + return (contextWrapper as unknown) as T; } /** diff --git a/packages/opentelemetry-web/test/WebTracerProvider.test.ts b/packages/opentelemetry-web/test/WebTracerProvider.test.ts index 68d870717a..a73845bfff 100644 --- a/packages/opentelemetry-web/test/WebTracerProvider.test.ts +++ b/packages/opentelemetry-web/test/WebTracerProvider.test.ts @@ -96,10 +96,12 @@ describe('WebTracerProvider', () => { getSpan(context.active()) === rootSpan, 'Current span is rootSpan' ); - const concurrentSpan1 = - webTracerWithZone.startSpan('concurrentSpan1'); - const concurrentSpan2 = - webTracerWithZone.startSpan('concurrentSpan2'); + const concurrentSpan1 = webTracerWithZone.startSpan( + 'concurrentSpan1' + ); + const concurrentSpan2 = webTracerWithZone.startSpan( + 'concurrentSpan2' + ); context.with(setSpan(context.active(), concurrentSpan1), () => { setTimeout(() => { diff --git a/packages/opentelemetry-web/test/utils.test.ts b/packages/opentelemetry-web/test/utils.test.ts index 0556c89f9c..3296ff6252 100644 --- a/packages/opentelemetry-web/test/utils.test.ts +++ b/packages/opentelemetry-web/test/utils.test.ts @@ -132,10 +132,10 @@ describe('utils', () => { it('should add all network events to span', () => { const addEventSpy = sinon.spy(); const setAttributeSpy = sinon.spy(); - const span = { + const span = ({ addEvent: addEventSpy, setAttribute: setAttributeSpy, - } as unknown as tracing.Span; + } as unknown) as tracing.Span; const entries = { [PTN.FETCH_START]: 123, [PTN.DOMAIN_LOOKUP_START]: 123, @@ -162,9 +162,9 @@ describe('utils', () => { describe(`when entry is ${value}`, () => { it('should add event to span', () => { const addEventSpy = sinon.spy(); - const span = { + const span = ({ addEvent: addEventSpy, - } as unknown as tracing.Span; + } as unknown) as tracing.Span; const entries = { [PTN.FETCH_START]: value, } as PerformanceEntries; @@ -184,9 +184,9 @@ describe('utils', () => { describe('when entry is not numeric', () => { it('should NOT add event to span', () => { const addEventSpy = sinon.spy(); - const span = { + const span = ({ addEvent: addEventSpy, - } as unknown as tracing.Span; + } as unknown) as tracing.Span; const entries = { [PTN.FETCH_START]: 'non-numeric', } as unknown; @@ -205,9 +205,9 @@ describe('utils', () => { describe('when entries does NOT contain the performance', () => { it('should NOT add event to span', () => { const addEventSpy = sinon.spy(); - const span = { + const span = ({ addEvent: addEventSpy, - } as unknown as tracing.Span; + } as unknown) as tracing.Span; const entries = { [PTN.FETCH_START]: 123, } as PerformanceEntries; From 6a3c617d5970998ebb40bfe8dc2024fb40401b9b Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 19 May 2021 12:24:25 -0400 Subject: [PATCH 7/8] fix dependency --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 7d9d0ea3bc..506c7c1dad 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "eslint-config-airbnb-base": "14.2.1", "eslint-plugin-header": "3.1.1", "eslint-plugin-import": "2.22.1", + "eslint-plugin-node": "^11.1.0", "gh-pages": "3.1.0", "husky": "4.3.8", "lerna": "3.22.1", @@ -68,8 +69,5 @@ "pre-commit": "npm run lint:changed", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } - }, - "dependencies": { - "eslint-plugin-node": "^11.1.0" } } From b7c48c4bd476dcd7aef1835b00c587ba024f94d6 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 19 May 2021 12:29:26 -0400 Subject: [PATCH 8/8] chore: less verbose warn output --- eslint.config.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eslint.config.js b/eslint.config.js index 4fe97c7b9a..a1514132f9 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -33,7 +33,11 @@ module.exports = { "@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_", "args": "after-used"}], "@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }], "@typescript-eslint/no-empty-function": ["off"], - "@typescript-eslint/ban-types": ["warn"], + "@typescript-eslint/ban-types": ["warn", { + "types": { + "Function": null, + } + }], "@typescript-eslint/no-shadow": ["warn"], "arrow-parens": ["error", "as-needed"], "node/no-deprecated-api": ["warn"], @@ -56,6 +60,8 @@ module.exports = { "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-shadow": ["off"], "@typescript-eslint/no-floating-promises": ["off"], + "@typescript-eslint/no-non-null-assertion": ["off"], + "@typescript-eslint/explicit-module-boundary-types": ["off"] } } ]