Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Jun 3, 2021
1 parent afc14d8 commit c4d73cd
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 115 deletions.
6 changes: 4 additions & 2 deletions metapackages/auto-instrumentations-web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion metapackages/auto-instrumentations-web/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export interface GraphQLInstrumentationConfig extends InstrumentationConfig {
/**
* Merged and parsed config of default instrumentation config and GraphQL
*/
export type GraphQLInstrumentationParsedConfig = Required<GraphQLInstrumentationConfig> &
InstrumentationConfig;
export type GraphQLInstrumentationParsedConfig =
Required<GraphQLInstrumentationConfig> & InstrumentationConfig;

export type executeFunctionWithObj = (
args: graphqlTypes.ExecutionArgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,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[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,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(trace.setSpan(context.active(), span), () => {
testInjection(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<unknown> {
* @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);
Expand Down Expand Up @@ -168,9 +168,9 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<unknown> {
*/
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase<unknown>
* returns Zone
*/
getZoneWithPrototype(): ZoneTypeWithPrototype | undefined {
const _window: WindowWithZone = (window as unknown) as WindowWithZone;
const _window: WindowWithZone = window as unknown as WindowWithZone;
return _window.Zone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,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<Buffer>;
) as unknown as Array<Buffer>;
// const values = getter.get(carrier, GRPC_TRACE_KEY) as Array<Buffer>;
const metadataValue = values.length > 0 ? values[0] : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand All @@ -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',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,35 +250,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,
]);
}

Expand Down

0 comments on commit c4d73cd

Please sign in to comment.