Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: run lint fix
  • Loading branch information
svrnm committed May 11, 2021
commit 3ef166be2e47fe716139111d2a59db056361a196
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 @@ -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
),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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 @@ -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],
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 @@ -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[]) {
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 @@ -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
Expand Down Expand Up @@ -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',
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
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-instrumentation-pg/src/pg.ts
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 @@ -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);
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 @@ -622,7 +622,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 @@ -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<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 @@ -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,
]);
}

Expand Down