Skip to content

Commit b5885e9

Browse files
authored
refactor(instrumentation-grpc): fix eslint warnings (#5408)
1 parent 595d0e9 commit b5885e9

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

experimental/packages/opentelemetry-instrumentation-grpc/src/clientUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function patchResponseMetadataEvent(
102102
call: EventEmitter,
103103
metadataCapture: metadataCaptureType
104104
) {
105-
call.on('metadata', (responseMetadata: any) => {
105+
call.on('metadata', (responseMetadata: Metadata) => {
106106
metadataCapture.client.captureResponseMetadata(span, responseMetadata);
107107
});
108108
}

experimental/packages/opentelemetry-instrumentation-grpc/src/instrumentation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,22 @@ export class GrpcInstrumentation extends InstrumentationBase<GrpcInstrumentation
126126
this._wrap(
127127
moduleExports.Client.prototype,
128128
'makeUnaryRequest',
129-
this._patchClientRequestMethod(moduleExports, false) as any
129+
this._patchClientRequestMethod(moduleExports, false)
130130
);
131131
this._wrap(
132132
moduleExports.Client.prototype,
133133
'makeClientStreamRequest',
134-
this._patchClientRequestMethod(moduleExports, false) as any
134+
this._patchClientRequestMethod(moduleExports, false)
135135
);
136136
this._wrap(
137137
moduleExports.Client.prototype,
138138
'makeServerStreamRequest',
139-
this._patchClientRequestMethod(moduleExports, true) as any
139+
this._patchClientRequestMethod(moduleExports, true)
140140
);
141141
this._wrap(
142142
moduleExports.Client.prototype,
143143
'makeBidiStreamRequest',
144-
this._patchClientRequestMethod(moduleExports, true) as any
144+
this._patchClientRequestMethod(moduleExports, true)
145145
);
146146
return moduleExports;
147147
},

experimental/packages/opentelemetry-instrumentation-grpc/src/serverUtils.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ function serverStreamAndBidiHandler<RequestType, ResponseType>(
108108
endSpan();
109109
});
110110

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

@@ -149,6 +152,11 @@ function clientStreamAndUnaryHandler<RequestType, ResponseType>(
149152
};
150153

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

@@ -204,10 +212,18 @@ export function handleUntracedServerFunction<RequestType, ResponseType>(
204212
case 'unary':
205213
case 'clientStream':
206214
case 'client_stream':
215+
// TODO: Investigate this call/signature – it was inherited from very old
216+
// code and the `this: {}` is highly suspicious, and likely isn't doing
217+
// anything useful. There is probably a more precise cast we can do here.
218+
// eslint-disable-next-line @typescript-eslint/ban-types
207219
return (originalFunc as Function).call({}, call, callback);
208220
case 'serverStream':
209221
case 'server_stream':
210222
case 'bidi':
223+
// TODO: Investigate this call/signature – it was inherited from very old
224+
// code and the `this: {}` is highly suspicious, and likely isn't doing
225+
// anything useful. There is probably a more precise cast we can do here.
226+
// eslint-disable-next-line @typescript-eslint/ban-types
211227
return (originalFunc as Function).call({}, call);
212228
default:
213229
break;

experimental/packages/opentelemetry-instrumentation-grpc/test/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type TestGrpcClient = Client & {
8080
interface TestGrpcCall {
8181
description: string;
8282
methodName: string;
83-
method: Function;
83+
method: (...args: any[]) => unknown;
8484
request: TestRequestResponse | TestRequestResponse[];
8585
result: TestRequestResponse | TestRequestResponse[];
8686
metadata?: Metadata;

0 commit comments

Comments
 (0)