Skip to content

Commit

Permalink
chore(instrumentation-http): fix lint warnings (#2455)
Browse files Browse the repository at this point in the history
Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
  • Loading branch information
alisabzevari and vmarchaud committed Sep 4, 2021
1 parent 7dc2538 commit 6617573
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions packages/opentelemetry-instrumentation-http/src/http.ts
Expand Up @@ -71,11 +71,11 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
return this._config;
}

override setConfig(config: HttpInstrumentationConfig & InstrumentationConfig = {}) {
override setConfig(config: HttpInstrumentationConfig & InstrumentationConfig = {}): void {
this._config = Object.assign({}, config);
}

init() {
init(): [InstrumentationNodeModuleDefinition<Https>, InstrumentationNodeModuleDefinition<Http>] {
return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];
}

Expand Down Expand Up @@ -169,7 +169,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
* 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);
};
}
Expand Down Expand Up @@ -305,7 +305,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
if (response.aborted && !response.complete) {
status = { code: SpanStatusCode.ERROR };
} else {
status = utils.parseResponseStatus(response.statusCode!);
status = utils.parseResponseStatus(response.statusCode);
}

span.setStatus(status);
Expand Down Expand Up @@ -351,7 +351,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
) {
const instrumentation = this;
return function incomingRequest(
this: {},
this: unknown,
event: string,
...args: unknown[]
): boolean {
Expand Down Expand Up @@ -488,7 +488,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
): Func<http.ClientRequest> {
const instrumentation = this;
return function outgoingRequest(
this: {},
this: unknown,
options: url.URL | http.RequestOptions | string,
...args: unknown[]
): http.ClientRequest {
Expand Down
10 changes: 5 additions & 5 deletions packages/opentelemetry-instrumentation-http/src/utils.ts
Expand Up @@ -161,7 +161,7 @@ export const setSpanWithError = (
span: Span,
error: Err,
obj?: IncomingMessage | ClientRequest
) => {
): void => {
const message = error.message;

span.setAttributes({
Expand All @@ -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 {
Expand All @@ -196,7 +196,7 @@ export const setSpanWithError = (
export const setRequestContentLengthAttribute = (
request: IncomingMessage,
attributes: SpanAttributes
) => {
): void => {
const length = getContentLength(request.headers);
if (length === null) return;

Expand All @@ -217,7 +217,7 @@ export const setRequestContentLengthAttribute = (
export const setResponseContentLengthAttribute = (
response: IncomingMessage,
attributes: SpanAttributes
) => {
): void => {
const length = getContentLength(response.headers);
if (length === null) return;

Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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<unknown>;
resHeaders = res.headers;
}
const spans = memoryExporter.getFinishedSpans();
Expand Down
Expand Up @@ -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<unknown>;
resHeaders = res.headers;
}
const spans = memoryExporter.getFinishedSpans();
Expand Down

0 comments on commit 6617573

Please sign in to comment.