From 6617573888ebbb962ab452916916b3b563863858 Mon Sep 17 00:00:00 2001 From: Ali Sabzevari Date: Sat, 4 Sep 2021 11:22:50 +0200 Subject: [PATCH] chore(instrumentation-http): fix lint warnings (#2455) Co-authored-by: Valentin Marchaud --- .../opentelemetry-instrumentation-http/src/http.ts | 12 ++++++------ .../opentelemetry-instrumentation-http/src/utils.ts | 10 +++++----- .../test/functionals/http-package.test.ts | 2 +- .../test/functionals/https-package.test.ts | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/opentelemetry-instrumentation-http/src/http.ts b/packages/opentelemetry-instrumentation-http/src/http.ts index 5dfa740fd6..5ad2160b0e 100644 --- a/packages/opentelemetry-instrumentation-http/src/http.ts +++ b/packages/opentelemetry-instrumentation-http/src/http.ts @@ -71,11 +71,11 @@ export class HttpInstrumentation extends InstrumentationBase { return this._config; } - override setConfig(config: HttpInstrumentationConfig & InstrumentationConfig = {}) { + override setConfig(config: HttpInstrumentationConfig & InstrumentationConfig = {}): void { this._config = Object.assign({}, config); } - init() { + init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] { return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()]; } @@ -169,7 +169,7 @@ export class HttpInstrumentation extends InstrumentationBase { * Creates spans for incoming requests, restoring spans' context if applied. */ protected _getPatchIncomingRequestFunction(component: 'http' | 'https') { - return (original: (event: string, ...args: unknown[]) => boolean) => { + return (original: (event: string, ...args: unknown[]) => boolean): (this: unknown, event: string, ...args: unknown[]) => boolean => { return this._incomingRequestFunction(component, original); }; } @@ -305,7 +305,7 @@ export class HttpInstrumentation extends InstrumentationBase { if (response.aborted && !response.complete) { status = { code: SpanStatusCode.ERROR }; } else { - status = utils.parseResponseStatus(response.statusCode!); + status = utils.parseResponseStatus(response.statusCode); } span.setStatus(status); @@ -351,7 +351,7 @@ export class HttpInstrumentation extends InstrumentationBase { ) { const instrumentation = this; return function incomingRequest( - this: {}, + this: unknown, event: string, ...args: unknown[] ): boolean { @@ -488,7 +488,7 @@ export class HttpInstrumentation extends InstrumentationBase { ): Func { const instrumentation = this; return function outgoingRequest( - this: {}, + this: unknown, options: url.URL | http.RequestOptions | string, ...args: unknown[] ): http.ClientRequest { diff --git a/packages/opentelemetry-instrumentation-http/src/utils.ts b/packages/opentelemetry-instrumentation-http/src/utils.ts index e493df0de5..a24ff6f12a 100644 --- a/packages/opentelemetry-instrumentation-http/src/utils.ts +++ b/packages/opentelemetry-instrumentation-http/src/utils.ts @@ -161,7 +161,7 @@ export const setSpanWithError = ( span: Span, error: Err, obj?: IncomingMessage | ClientRequest -) => { +): void => { const message = error.message; span.setAttributes({ @@ -176,7 +176,7 @@ export const setSpanWithError = ( let status: SpanStatus; if ((obj as IncomingMessage).statusCode) { - status = parseResponseStatus((obj as IncomingMessage).statusCode!); + status = parseResponseStatus((obj as IncomingMessage).statusCode); } else if ((obj as ClientRequest).aborted) { status = { code: SpanStatusCode.ERROR }; } else { @@ -196,7 +196,7 @@ export const setSpanWithError = ( export const setRequestContentLengthAttribute = ( request: IncomingMessage, attributes: SpanAttributes -) => { +): void => { const length = getContentLength(request.headers); if (length === null) return; @@ -217,7 +217,7 @@ export const setRequestContentLengthAttribute = ( export const setResponseContentLengthAttribute = ( response: IncomingMessage, attributes: SpanAttributes -) => { +): void => { const length = getContentLength(response.headers); if (length === null) return; @@ -259,7 +259,7 @@ export const isCompressed = ( export const getRequestInfo = ( options: url.URL | RequestOptions | string, extraOptions?: RequestOptions -) => { +): { origin: string; pathname: string; method: string; optionsParsed: RequestOptions; } => { let pathname = '/'; let origin = ''; let optionsParsed: RequestOptions; diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts index 60ec6fc4e7..8da3577ddb 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts @@ -102,7 +102,7 @@ describe('Packages', () => { ); const result = await httpPackage.get(urlparsed.href!); if (!resHeaders) { - const res = result as AxiosResponse<{}>; + const res = result as AxiosResponse; resHeaders = res.headers; } const spans = memoryExporter.getFinishedSpans(); diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts index 8cec9b73b6..3735e530f9 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts @@ -108,7 +108,7 @@ describe('Packages', () => { ); const result = await httpPackage.get(urlparsed.href!); if (!resHeaders) { - const res = result as AxiosResponse<{}>; + const res = result as AxiosResponse; resHeaders = res.headers; } const spans = memoryExporter.getFinishedSpans();