From 3ef166be2e47fe716139111d2a59db056361a196 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 11 May 2021 16:33:11 +0200 Subject: [PATCH] chore: run lint fix --- .../auto-instrumentations-web/src/utils.ts | 6 +- .../test/utils.test.ts | 3 +- .../src/aws-lambda.ts | 7 ++- .../test/functionals/utils.test.ts | 5 +- .../src/express.ts | 2 +- .../src/graphql.ts | 2 +- .../src/types.ts | 4 +- .../src/utils.ts | 5 +- .../src/hapi.ts | 3 +- .../test/ioredis.test.ts | 8 +-- .../test/connect.test.ts | 2 +- .../src/pg.ts | 4 +- .../test/utils.test.ts | 4 +- .../test/pino.test.ts | 2 +- .../src/documentLoad.ts | 12 ++-- .../src/userInteraction.ts | 2 +- .../test/userInteraction.test.ts | 4 +- .../src/GrpcCensusPropagator.ts | 4 +- .../test/BinaryTraceContext.test.ts | 62 ++----------------- .../test/GrpcCensusPropagator.test.ts | 31 +--------- 20 files changed, 46 insertions(+), 126 deletions(-) diff --git a/metapackages/auto-instrumentations-web/src/utils.ts b/metapackages/auto-instrumentations-web/src/utils.ts index e76cea6ef9..ed0a4d98ec 100644 --- a/metapackages/auto-instrumentations-web/src/utils.ts +++ b/metapackages/auto-instrumentations-web/src/utils.ts @@ -24,8 +24,10 @@ import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xm const InstrumentationMap = { '@opentelemetry/instrumentation-document-load': DocumentLoadInstrumentation, '@opentelemetry/instrumentation-fetch': FetchInstrumentation, - '@opentelemetry/instrumentation-user-interaction': UserInteractionInstrumentation, - '@opentelemetry/instrumentation-xml-http-request': XMLHttpRequestInstrumentation, + '@opentelemetry/instrumentation-user-interaction': + UserInteractionInstrumentation, + '@opentelemetry/instrumentation-xml-http-request': + XMLHttpRequestInstrumentation, }; // Config types inferred automatically from the first argument of the constructor diff --git a/metapackages/auto-instrumentations-web/test/utils.test.ts b/metapackages/auto-instrumentations-web/test/utils.test.ts index 4ee9a9425b..442ed166be 100644 --- a/metapackages/auto-instrumentations-web/test/utils.test.ts +++ b/metapackages/auto-instrumentations-web/test/utils.test.ts @@ -53,7 +53,8 @@ describe('utils', () => { instr.instrumentationName === '@opentelemetry/instrumentation-xml-http-request' ) as any; - const config = instrumentation._config as XMLHttpRequestInstrumentationConfig; + const config = + instrumentation._config as XMLHttpRequestInstrumentationConfig; assert.strictEqual(config.clearTimingResources, clearTimingResources); }); diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/aws-lambda.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/aws-lambda.ts index 656aaa234b..9bb34e7a04 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/aws-lambda.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/aws-lambda.ts @@ -124,9 +124,10 @@ export class AwsLambdaInstrumentation extends InstrumentationBase { attributes: { [SemanticAttributes.FAAS_EXECUTION]: context.awsRequestId, [ResourceAttributes.FAAS_ID]: context.invokedFunctionArn, - [ResourceAttributes.CLOUD_ACCOUNT_ID]: AwsLambdaInstrumentation._extractAccountId( - context.invokedFunctionArn - ), + [ResourceAttributes.CLOUD_ACCOUNT_ID]: + AwsLambdaInstrumentation._extractAccountId( + context.invokedFunctionArn + ), }, }); diff --git a/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts b/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts index 9e93062e3c..514a1fca49 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/test/functionals/utils.test.ts @@ -40,10 +40,7 @@ describe('Utility', () => { it('should throw if type is unknown', () => { try { - utils.satisfiesPattern( - 'google.com', - (true as unknown) as IgnoreMatcher - ); + utils.satisfiesPattern('google.com', true as unknown as IgnoreMatcher); assert.fail(); } catch (error) { assert.strictEqual(error instanceof TypeError, true); diff --git a/plugins/node/opentelemetry-instrumentation-express/src/express.ts b/plugins/node/opentelemetry-instrumentation-express/src/express.ts index fb328cc4a5..acb3780bdf 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/express.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/express.ts @@ -61,7 +61,7 @@ export class ExpressInstrumentation extends InstrumentationBase< ['^4.0.0'], (moduleExports, moduleVersion) => { diag.debug(`Applying patch for express@${moduleVersion}`); - const routerProto = (moduleExports.Router as unknown) as express.Router; + const routerProto = moduleExports.Router as unknown as express.Router; // patch express.Router.route if (isWrapped(routerProto.route)) { this._unwrap(routerProto, 'route'); diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/graphql.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/graphql.ts index 521f7c6716..cfd3e6968d 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/graphql.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/graphql.ts @@ -173,7 +173,7 @@ export class GraphQLInstrumentation extends InstrumentationBase { // case when apollo server is used for example if (arguments.length >= 2) { - const args = (arguments as unknown) as executeArgumentsArray; + const args = arguments as unknown as executeArgumentsArray; processedArgs = instrumentation._wrapExecuteArgs( args[0], args[1], diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts index ee18913311..39bbebf17f 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts @@ -58,8 +58,8 @@ export interface GraphQLInstrumentationConfig extends InstrumentationConfig { /** * Merged and parsed config of default instrumentation config and GraphQL */ -export type GraphQLInstrumentationParsedConfig = Required & - InstrumentationConfig; +export type GraphQLInstrumentationParsedConfig = + Required & InstrumentationConfig; export type executeFunctionWithObj = ( args: graphqlTypes.ExecutionArgs diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts index 9b5d4e047a..6875d22b62 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts @@ -155,9 +155,8 @@ export function getOperation( } function addField(contextValue: any, path: string[], field: GraphQLField) { - return (contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[ - path.join('.') - ] = field); + return (contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')] = + field); } function getField(contextValue: any, path: string[]) { diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/hapi.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/hapi.ts index 9035c68c6a..566fce86d7 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/hapi.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/hapi.ts @@ -187,7 +187,8 @@ export class HapiInstrumentation extends InstrumentationBase { for (let i = 0; i < eventsList.length; i++) { const eventObj = eventsList[i]; if (isLifecycleExtType(eventObj.type)) { - const lifecycleEventObj = eventObj as Hapi.ServerExtEventsRequestObject; + const lifecycleEventObj = + eventObj as Hapi.ServerExtEventsRequestObject; const handler = instrumentation._wrapExtMethods( lifecycleEventObj.method, eventObj.type, diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts b/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts index 55bb8e360b..2212946f8d 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts @@ -67,9 +67,8 @@ const sanitizeEventForAssertion = (span: ReadableSpan) => { span.events.forEach(e => { // stack trace includes data such as /user/{userName}/repos/{projectName} if (e.attributes?.[SemanticAttributes.EXCEPTION_STACKTRACE]) { - e.attributes[ - SemanticAttributes.EXCEPTION_STACKTRACE - ] = predictableStackTrace; + e.attributes[SemanticAttributes.EXCEPTION_STACKTRACE] = + predictableStackTrace; } // since time will change on each test invocation, it is being replaced to predicable value @@ -464,7 +463,8 @@ describe('ioredis', () => { attributes: { [SemanticAttributes.EXCEPTION_MESSAGE]: 'NOSCRIPT No matching script. Please use EVAL.', - [SemanticAttributes.EXCEPTION_STACKTRACE]: predictableStackTrace, + [SemanticAttributes.EXCEPTION_STACKTRACE]: + predictableStackTrace, [SemanticAttributes.EXCEPTION_TYPE]: 'ReplyError', }, name: 'exception', diff --git a/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts b/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts index ded3907cc1..9e0e2121c1 100644 --- a/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts +++ b/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts @@ -184,7 +184,7 @@ describe('NetInstrumentation', () => { assert.strictEqual(span.status.code, SpanStatusCode.ERROR); done(); }); - socket.connect((undefined as unknown) as string); + socket.connect(undefined as unknown as string); }); }); diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/pg.ts b/plugins/node/opentelemetry-instrumentation-pg/src/pg.ts index 00496a190e..67b43c84bf 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/pg.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/pg.ts @@ -236,8 +236,8 @@ export class PgInstrumentation extends InstrumentationBase { [SemanticAttributes.DB_CONNECTION_STRING]: jdbcString, // required [SemanticAttributes.NET_PEER_PORT]: this.options.port, [SemanticAttributes.DB_USER]: this.options.user, - [AttributeNames.IDLE_TIMEOUT_MILLIS]: this.options - .idleTimeoutMillis, + [AttributeNames.IDLE_TIMEOUT_MILLIS]: + this.options.idleTimeoutMillis, [AttributeNames.MAX_CLIENT]: this.options.maxClient, }, }); diff --git a/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts b/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts index 63a6cf98d0..b5de061fbf 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts @@ -51,8 +51,8 @@ describe('utils.ts', () => { const provider = new BasicTracerProvider(); const tracer = provider.getTracer('external'); - const instrumentationConfig: PgInstrumentationConfig & - InstrumentationConfig = {}; + const instrumentationConfig: PgInstrumentationConfig & InstrumentationConfig = + {}; before(() => { provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); diff --git a/plugins/node/opentelemetry-instrumentation-pino/test/pino.test.ts b/plugins/node/opentelemetry-instrumentation-pino/test/pino.test.ts index a322e68cca..dfef81b6cc 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/test/pino.test.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/test/pino.test.ts @@ -191,7 +191,7 @@ describe('PinoInstrumentation', () => { describe('binary arguments', () => { it('is possible to construct logger with undefined options', () => { - logger = pino((undefined as unknown) as Pino.LoggerOptions, stream); + logger = pino(undefined as unknown as Pino.LoggerOptions, stream); const span = tracer.startSpan('abc'); context.with(setSpan(context.active(), span), () => { testInjection(span); diff --git a/plugins/web/opentelemetry-instrumentation-document-load/src/documentLoad.ts b/plugins/web/opentelemetry-instrumentation-document-load/src/documentLoad.ts index 14115ccf70..f54cd16b79 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/src/documentLoad.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/src/documentLoad.ts @@ -73,9 +73,9 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { * @param rootSpan */ private _addResourcesSpans(rootSpan: Span): void { - const resources: PerformanceResourceTiming[] = ((otperformance as unknown) as Performance).getEntriesByType?.( - 'resource' - ) as PerformanceResourceTiming[]; + const resources: PerformanceResourceTiming[] = ( + otperformance as unknown as Performance + ).getEntriesByType?.('resource') as PerformanceResourceTiming[]; if (resources) { resources.forEach(resource => { this._initResourceSpan(resource, rootSpan); @@ -168,9 +168,9 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { */ private _getEntries() { const entries: PerformanceEntries = {}; - const performanceNavigationTiming = ((otperformance as unknown) as Performance).getEntriesByType?.( - 'navigation' - )[0] as PerformanceEntries; + const performanceNavigationTiming = ( + otperformance as unknown as Performance + ).getEntriesByType?.('navigation')[0] as PerformanceEntries; if (performanceNavigationTiming) { const keys = Object.values(PTN); diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/userInteraction.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/userInteraction.ts index d5c6422ba4..65d6cfba4c 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/src/userInteraction.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/userInteraction.ts @@ -622,7 +622,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase * returns Zone */ getZoneWithPrototype(): ZoneTypeWithPrototype | undefined { - const _window: WindowWithZone = (window as unknown) as WindowWithZone; + const _window: WindowWithZone = window as unknown as WindowWithZone; return _window.Zone; } } diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts index 88ad5d1260..b647b89a67 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts @@ -212,7 +212,7 @@ describe('UserInteractionInstrumentation', () => { _createZone: Function; } - const ctxMngrWithPrv = (contextManager as unknown) as CtxMngrWithPrv; + const ctxMngrWithPrv = contextManager as unknown as CtxMngrWithPrv; const newZone = ctxMngrWithPrv._createZone('test', context); const element = createButton(); @@ -314,7 +314,7 @@ describe('UserInteractionInstrumentation', () => { }); it('should handle unpatch', () => { - const _window: WindowWithZone = (window as unknown) as WindowWithZone; + const _window: WindowWithZone = window as unknown as WindowWithZone; const ZoneWithPrototype = _window.Zone; assert.strictEqual( isWrapped(ZoneWithPrototype.prototype.runTask), diff --git a/propagators/opentelemetry-propagator-grpc-census-binary/src/GrpcCensusPropagator.ts b/propagators/opentelemetry-propagator-grpc-census-binary/src/GrpcCensusPropagator.ts index db94423c16..3283ba9ccf 100644 --- a/propagators/opentelemetry-propagator-grpc-census-binary/src/GrpcCensusPropagator.ts +++ b/propagators/opentelemetry-propagator-grpc-census-binary/src/GrpcCensusPropagator.ts @@ -110,10 +110,10 @@ export class GrpcCensusPropagator implements TextMapPropagator { // @TODO FIX ME once this is resolved // https://github.com/open-telemetry/opentelemetry-specification/issues/437 - const values = (getter.get( + const values = getter.get( carrier, GRPC_TRACE_KEY - ) as unknown) as Array; + ) as unknown as Array; // const values = getter.get(carrier, GRPC_TRACE_KEY) as Array; const metadataValue = values.length > 0 ? values[0] : null; diff --git a/propagators/opentelemetry-propagator-grpc-census-binary/test/BinaryTraceContext.test.ts b/propagators/opentelemetry-propagator-grpc-census-binary/test/BinaryTraceContext.test.ts index c3e768a6bd..0e1627bbe4 100644 --- a/propagators/opentelemetry-propagator-grpc-census-binary/test/BinaryTraceContext.test.ts +++ b/propagators/opentelemetry-propagator-grpc-census-binary/test/BinaryTraceContext.test.ts @@ -34,35 +34,8 @@ describe('BinaryTraceContext', () => { traceFlags: TraceFlags.SAMPLED, }, binary: new Uint8Array([ - 0, - 0, - 212, - 205, - 169, - 91, - 101, - 47, - 74, - 11, - 146, - 180, - 73, - 213, - 146, - 159, - 218, - 27, - 1, - 117, - 232, - 237, - 73, - 26, - 236, - 126, - 202, - 2, - 1, + 0, 0, 212, 205, 169, 91, 101, 47, 74, 11, 146, 180, 73, 213, 146, 159, + 218, 27, 1, 117, 232, 237, 73, 26, 236, 126, 202, 2, 1, ]), description: 'span context with 64-bit span ID', }, @@ -73,35 +46,8 @@ describe('BinaryTraceContext', () => { traceFlags: TraceFlags.NONE, }, binary: new Uint8Array([ - 0, - 0, - 212, - 205, - 169, - 91, - 101, - 47, - 74, - 11, - 146, - 180, - 73, - 213, - 146, - 159, - 218, - 27, - 1, - 117, - 232, - 237, - 73, - 26, - 236, - 126, - 202, - 2, - 0, + 0, 0, 212, 205, 169, 91, 101, 47, 74, 11, 146, 180, 73, 213, 146, 159, + 218, 27, 1, 117, 232, 237, 73, 26, 236, 126, 202, 2, 0, ]), description: 'span context with no traceFlags', }, diff --git a/propagators/opentelemetry-propagator-grpc-census-binary/test/GrpcCensusPropagator.test.ts b/propagators/opentelemetry-propagator-grpc-census-binary/test/GrpcCensusPropagator.test.ts index e482304d28..d1d3bce4f6 100644 --- a/propagators/opentelemetry-propagator-grpc-census-binary/test/GrpcCensusPropagator.test.ts +++ b/propagators/opentelemetry-propagator-grpc-census-binary/test/GrpcCensusPropagator.test.ts @@ -251,35 +251,8 @@ describe('GrpcCensusPropagator', () => { function getUnsampledSpanEncodedArray() { return new Uint8Array([ - 0, - 0, - 212, - 205, - 169, - 91, - 101, - 47, - 74, - 11, - 146, - 180, - 73, - 213, - 146, - 159, - 218, - 27, - 1, - 117, - 232, - 237, - 73, - 26, - 236, - 126, - 202, - 2, - 0, + 0, 0, 212, 205, 169, 91, 101, 47, 74, 11, 146, 180, 73, 213, 146, 159, 218, + 27, 1, 117, 232, 237, 73, 26, 236, 126, 202, 2, 0, ]); }