Skip to content

Commit 7ad7419

Browse files
authored
fix(instrumentation-grpc): attach correct name to diag message (#6097)
1 parent 5333204 commit 7ad7419

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

experimental/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
1414

1515
### :bug: Bug Fixes
1616

17+
* fix(instrumentation-grpc): attach correct name to diag message [#6097](https://github.com/open-telemetry/opentelemetry-js/pull/6043) @pichlermarc
18+
1719
### :books: Documentation
1820

1921
### :house: Internal

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,38 @@ export class GrpcInstrumentation extends InstrumentationBase<GrpcInstrumentation
140140
this._wrap(
141141
moduleExports.Client.prototype,
142142
'makeUnaryRequest',
143-
this._patchClientRequestMethod(moduleExports, false)
143+
this._patchClientRequestMethod(
144+
moduleExports,
145+
false,
146+
'makeUnaryRequest'
147+
)
144148
);
145149
this._wrap(
146150
moduleExports.Client.prototype,
147151
'makeClientStreamRequest',
148-
this._patchClientRequestMethod(moduleExports, false)
152+
this._patchClientRequestMethod(
153+
moduleExports,
154+
false,
155+
'makeClientStreamRequest'
156+
)
149157
);
150158
this._wrap(
151159
moduleExports.Client.prototype,
152160
'makeServerStreamRequest',
153-
this._patchClientRequestMethod(moduleExports, true)
161+
this._patchClientRequestMethod(
162+
moduleExports,
163+
true,
164+
'makeServerStreamRequest'
165+
)
154166
);
155167
this._wrap(
156168
moduleExports.Client.prototype,
157169
'makeBidiStreamRequest',
158-
this._patchClientRequestMethod(moduleExports, true)
170+
this._patchClientRequestMethod(
171+
moduleExports,
172+
true,
173+
'makeBidiStreamRequest'
174+
)
159175
);
160176
return moduleExports;
161177
},
@@ -304,15 +320,14 @@ export class GrpcInstrumentation extends InstrumentationBase<GrpcInstrumentation
304320
*/
305321
private _patchClientRequestMethod<ReturnType extends EventEmitter>(
306322
grpcLib: typeof grpcJs,
307-
hasResponseStream: boolean
323+
hasResponseStream: boolean,
324+
name: string
308325
): (
309326
original: ClientRequestFunction<ReturnType>
310327
) => ClientRequestFunction<ReturnType> {
311328
const instrumentation = this;
312329
return (original: ClientRequestFunction<ReturnType>) => {
313-
instrumentation._diag.debug(
314-
'patched makeClientStreamRequest on grpc client'
315-
);
330+
instrumentation._diag.debug(`patched ${name} on grpc client`);
316331

317332
return function makeClientStreamRequest(this: grpcJs.Client) {
318333
// method must always be at first position

0 commit comments

Comments
 (0)