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

refactor(instrumentation-grpc): fix eslint warnings #5408

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function patchResponseMetadataEvent(
call: EventEmitter,
metadataCapture: metadataCaptureType
) {
call.on('metadata', (responseMetadata: any) => {
call.on('metadata', (responseMetadata: Metadata) => {
metadataCapture.client.captureResponseMetadata(span, responseMetadata);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,22 @@ export class GrpcInstrumentation extends InstrumentationBase<GrpcInstrumentation
this._wrap(
moduleExports.Client.prototype,
'makeUnaryRequest',
this._patchClientRequestMethod(moduleExports, false) as any
this._patchClientRequestMethod(moduleExports, false)
);
this._wrap(
moduleExports.Client.prototype,
'makeClientStreamRequest',
this._patchClientRequestMethod(moduleExports, false) as any
this._patchClientRequestMethod(moduleExports, false)
);
this._wrap(
moduleExports.Client.prototype,
'makeServerStreamRequest',
this._patchClientRequestMethod(moduleExports, true) as any
this._patchClientRequestMethod(moduleExports, true)
);
this._wrap(
moduleExports.Client.prototype,
'makeBidiStreamRequest',
this._patchClientRequestMethod(moduleExports, true) as any
this._patchClientRequestMethod(moduleExports, true)
);
return moduleExports;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ function serverStreamAndBidiHandler<RequestType, ResponseType>(
endSpan();
});

// Types of parameters 'call' and 'call' are incompatible.
// TODO: Investigate this call/signature – it was inherited from very old
// code and the `this: {}` is highly suspicious, and likely isn't doing
// anything useful. There is probably a more precise cast we can do here.
// eslint-disable-next-line @typescript-eslint/ban-types
return (original as Function).call({}, call);
}

Expand Down Expand Up @@ -149,6 +152,11 @@ function clientStreamAndUnaryHandler<RequestType, ResponseType>(
};

context.bind(context.active(), call);

// TODO: Investigate this call/signature – it was inherited from very old
// code and the `this: {}` is highly suspicious, and likely isn't doing
// anything useful. There is probably a more precise cast we can do here.
// eslint-disable-next-line @typescript-eslint/ban-types
return (original as Function).call({}, call, patchedCallback);
}

Expand Down Expand Up @@ -204,10 +212,18 @@ export function handleUntracedServerFunction<RequestType, ResponseType>(
case 'unary':
case 'clientStream':
case 'client_stream':
// TODO: Investigate this call/signature – it was inherited from very old
// code and the `this: {}` is highly suspicious, and likely isn't doing
// anything useful. There is probably a more precise cast we can do here.
// eslint-disable-next-line @typescript-eslint/ban-types
return (originalFunc as Function).call({}, call, callback);
case 'serverStream':
case 'server_stream':
case 'bidi':
// TODO: Investigate this call/signature – it was inherited from very old
// code and the `this: {}` is highly suspicious, and likely isn't doing
// anything useful. There is probably a more precise cast we can do here.
// eslint-disable-next-line @typescript-eslint/ban-types
return (originalFunc as Function).call({}, call);
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type TestGrpcClient = Client & {
interface TestGrpcCall {
description: string;
methodName: string;
method: Function;
method: (...args: any[]) => unknown;
request: TestRequestResponse | TestRequestResponse[];
result: TestRequestResponse | TestRequestResponse[];
metadata?: Metadata;
Expand Down
Loading