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

gRPC plugin is not working correctly when loaded with @grpc/proto-loader #384

Closed
mayurkale22 opened this issue Oct 1, 2019 · 10 comments
Closed
Labels
bug Something isn't working

Comments

@mayurkale22
Copy link
Member

When a proto file is loaded with @grpc/proto-loader, gRPC plugin instrumentation is not working correctly. Client and Server traces has different traceIds.

Client Traces:
Screen Shot 2019-10-01 at 3 35 12 PM

Server Traces:
Screen Shot 2019-10-01 at 3 35 23 PM

May be something to do with the binary propagation or client methods are not patched properly.

@mayurkale22 mayurkale22 added the bug Something isn't working label Oct 1, 2019
@mayurkale22
Copy link
Member Author

/cc @markwolff

@markwolff
Copy link
Member

markwolff commented Oct 1, 2019

Haven't looked into this yet, but it's probably for a similar reason that patching the internal function makeClientConstructor didn't also patch the externally re-exported makeGenericClientConstructor. Did this scenario work in OC? The issue could be that internal files are patched after external files are.

@mayurkale22
Copy link
Member Author

Did this scenario work in OC?

No, it is not working as expected.

@mayurkale22
Copy link
Member Author

Strangly, with OC when I used lowercase method name in protos: https://github.com/open-telemetry/opentelemetry-js/pull/385/files#diff-a10e9a452e0c1da7f8f0d0f5a70622e4R12, everything works well. Maybe, we are not patching all the client methods properly: https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-grpc/src/grpc.ts#L336-L341

@markwolff
Copy link
Member

Strangly, with OC when I used lowercase method name in protos: https://github.com/open-telemetry/opentelemetry-js/pull/385/files#diff-a10e9a452e0c1da7f8f0d0f5a70622e4R12, everything works well. Maybe, we are not patching all the client methods properly: https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-grpc/src/grpc.ts#L336-L341

Yes the lowercase stuff was a bug I found in OC as well which would be fixed by this. If the lowercase name works in OC, then I shouldn't have to use { internals: true } and there is a bug with the existing patching.

@mayurkale22
Copy link
Member Author

there is a bug with the existing patching.

Possible. While testing found out https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-grpc/src/grpc.ts#L328 is not getting called when using proto-loader.

@markwolff
Copy link
Member

markwolff commented Oct 15, 2019

Looked into this, it is because of lerna linking. The grpc-plugin's devdep grpc internal files are patched because it grabs the basedir within the plugin. For a production sample, I'd imagine it would work because the dev dependency won't be installed and so basedir would resolve to the correct path. To compare with OC, basedir was set in plugin-loader.

I see 2 ways of resolving this:

  1. Ignore it since it would work in an example outside of this repo. Maybe remove lerna linking from this example or add some hacks to how basedir is resolved.
  2. Update the plugin.enable(...) signature to include basedir/version information as it did in OpenCensus

Either way, I will open a PR to fix the issue with .capitalize(...) vs .Capitalize(...)

@mayurkale22 WDYT?

@mayurkale22
Copy link
Member Author

I am fine with the option 1. Do you think I should merge the example - gRPC example using proto-loader #385?

@markwolff
Copy link
Member

I think thats fine. It just wont work if using it by cloning this whole repo.

@mayurkale22
Copy link
Member Author

Closing via #631

lukaswelinder pushed a commit to agile-pm/opentelemetry-js that referenced this issue Jul 24, 2020
* Support configuring sampling endpoint

- Allow users to specify a non standard endpoint to retrieve sampling
priorities from

Signed-off-by: Prithvi Raj <p.r@uber.com>

* Add test

Signed-off-by: Prithvi Raj <p.r@uber.com>

* Fix logic

Signed-off-by: Prithvi Raj <p.r@uber.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants