Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(instrumentation-http): fix lint warnings #2455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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