Opentelemetry-js: gRPC plugin issue | TypeError: Cannot read property 'replace' of undefined

Created on 30 Jun 2020  路  5Comments  路  Source: open-telemetry/opentelemetry-js

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

    "@opentelemetry/node": "^0.9.0"
    "@opentelemetry/plugin-grpc": "^0.9.0"

What version of Node are you using?

v13.10.1

What did you do?

I have a gRPC Client and Server applications. I'm trying to get the telemetry on the client application for both gRPC and http requests.

If possible, provide a recipe for reproducing the error.

A simple alive service in my proto file: I also have other unary and BiDi stream calls but I have commented out to test the simple alive call.

rpc alive ( Ok ) returns (Ok); 

in my nodejs I have called this:

const sendAliveHint = () => {
    const md = new grpc.Metadata();
    md.add('myApp', 'Client_App');
    client.alive({}, md, (err, result) => {
        if(err){
            console.error(`Error in connecting to the server`,err);

        } else {
            console.info(`[ALIVE] Server responded: ${JSON.stringify(result)}`);
        }
    });
};

What did you expect to see?

I was not expecting to see any errors and track the metrics on prometheus for both gRPC and http

What did you see instead?

I see this error and the app crashes:

/my-repo/node_modules/@opentelemetry/plugin-grpc/build/src/grpc.js:196
                const name = `grpc.${original.path.replace('/', '')}`;
                                                   ^

TypeError: Cannot read property 'replace' of undefined
    at ServiceClient.clientMethodTrace [as alive] (/my-repo/node_modules/@opentelemetry/plugin-grpc/build/src/grpc.js:196:52)
    at sendAliveHint (/my-repo/client/src/index.js:56:12)
    at Timeout._onTimeout (/my-repo/client/src/index.js:176:5)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
[nodemon] app crashed - waiting for file changes before starting...

Additional context

Add any other context about the problem here.

bug

All 5 comments

I will look into this today

@markwolff it looks like whatever original method which was wrapped with massWrap doesn't have a path property.

@giri-jeedigunta Can you include your package.json version of grpc as well? This seems like a scenario covered here:
https://github.com/open-telemetry/opentelemetry-js/blob/413edb5369536b9be960049edac3b2be96953649/packages/opentelemetry-plugin-grpc/test/fixtures/grpc-test.proto#L6

@giri-jeedigunta Can you include your package.json version of grpc as well? This seems like a scenario covered here:
https://github.com/open-telemetry/opentelemetry-js/blob/413edb5369536b9be960049edac3b2be96953649/packages/opentelemetry-plugin-grpc/test/fixtures/grpc-test.proto#L6

gRPC version:

    "google-protobuf": "^3.11.4",
    "grpc": "^1.24.2",

I will take a look at the test. Thank you !

@markwolff I've spent some time today to analyse this further. This issue is happening when I'm directly using the .proto file to define the service definition not a js file as showcased in the grpc the example.

I have forked the repo and modified the existing gRPC example to reproduce the issue I'm facing.
Here it is: https://github.com/giri-jeedigunta/opentelemetry-js/tree/master/examples/grpc

Also, I do not see this error occurring on gRPC server (npm run jaeger:server). This specifically happens only on the gRPC client (npm run jaeger:client).

Was this page helpful?
0 / 5 - 0 ratings