You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide the code you used to setup the OpenTelemetry SDK
importprocessfrom'process';import*asopentelemetryfrom'@opentelemetry/sdk-node';import{JaegerExporter}from'@opentelemetry/exporter-jaeger';import{Resource}from'@opentelemetry/resources';import{SemanticResourceAttributes}from'@opentelemetry/semantic-conventions';import{getNodeAutoInstrumentations}from'@opentelemetry/auto-instrumentations-node';// configure the SDK to export telemetry data to the console// enable all auto-instrumentations from the meta packageexportconstinitTracing=(name: string)=>{consttraceExporter=newJaegerExporter({endpoint: 'http://main-jaeger-collector.obs:14268/api/traces',});constsdk=newopentelemetry.NodeSDK({resource: newResource({[SemanticResourceAttributes.SERVICE_NAME]: name,}),
traceExporter,instrumentations: [getNodeAutoInstrumentations()],});// gracefully shut down the SDK on process exitprocess.on('SIGTERM',()=>{sdk.shutdown().then(()=>console.log('Tracing terminated')).catch((error)=>console.log('Error terminating tracing',error)).finally(()=>process.exit(0));});// initialize the SDK and register with the OpenTelemetry API// this enables the API to record telemetryreturnsdk.start().then(()=>console.log('Tracing initialized')).catch((error)=>console.log('Error initializing tracing',error));};
What did you do?
So I had a NestJS gRPC server up and running with two RPCs:
Test (Unary)
TestStream (Client side streaming)
I called initTracing in the main, right before calling NestJS bootstrap.
The TestStream function stopped working, generating this error at the client: rpc error: code = Unimplemented desc = The server does not implement the method TestStream
So I've debugged the issue.
Starting with looking for The server does not implement the method in grpc-js code.
I found out that addService was called only with the Test function and not with TestStream.
Basically the original is a function and an object.
The returned function clientMethodTrace is without those extra object entries .
(NestJS detects request/response stream by calling function.requestStream and function.responseStream which does not exist after instrumentation)
I think the correct behavior is to assign all the entries from original back to clientMethodTrace, but I might be wrong.
However I don't think NestJS should change their code since they only rely on grpc-js and it works perfectly fine with it.
Assigning the fields form original back to clientMethodTrace fixed this issue for me.
The text was updated successfully, but these errors were encountered:
What version of OpenTelemetry are you using?
0.26.0
What version of Node are you using?
v14.18.0
Please provide the code you used to setup the OpenTelemetry SDK
What did you do?
So I had a NestJS gRPC server up and running with two RPCs:
I called
initTracing
in the main, right before calling NestJSbootstrap
.The
TestStream
function stopped working, generating this error at the client:rpc error: code = Unimplemented desc = The server does not implement the method TestStream
Results are the same when using
instead of
I've debugged the issue, see Additional Context
Recipe
NestJS main:
NestJS gRPC controller:
Proto:
Additional context
So I've debugged the issue.
Starting with looking for
The server does not implement the method
ingrpc-js
code.I found out that
addService
was called only with theTest
function and not withTestStream
.I looked into NestJS grpc server code and found that it could not detect the
TestStream
function as a client stream, you can checkout the detection mechanism here:https://github.com/nestjs/nest/blob/1394305bf394654a0e2c72142b06bd29277718d9/packages/microservices/server/server-grpc.ts#L98-L157
So I printed out the GrpcObject before and after instrumentation and noticed some changes.
Before grpc instrumentation the object looked like this:
After grpc instrumentation the object looked like this:
I dag into the gRPC instrumentation code and found this function (that generates the
clientMethodTrace
):opentelemetry-js/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts
Lines 268 to 294 in 4e311bd
Basically the
original
is a function and an object.The returned function
clientMethodTrace
is without those extra object entries .(NestJS detects request/response stream by calling
function.requestStream
andfunction.responseStream
which does not exist after instrumentation)I think the correct behavior is to assign all the entries from
original
back toclientMethodTrace
, but I might be wrong.However I don't think NestJS should change their code since they only rely on
grpc-js
and it works perfectly fine with it.Assigning the fields form
original
back toclientMethodTrace
fixed this issue for me.The text was updated successfully, but these errors were encountered: