jaegertracing / docker-protobuf

An all-inclusive protoc Docker image for the Jaeger project
https://hub.docker.com/r/jaegertracing/protobuf
Apache License 2.0
93 stars 35 forks source link

Code generation for opentelemetry python jaeger exporter. #24

Closed srikanthccv closed 3 years ago

srikanthccv commented 3 years ago

Hi, I am trying to generate the the code for jaeger exporter to support protobuf via grpc for open-telemetry. Below are the steps I used to generate the code for python

Generate language specific code

  1. docker run --rm -u $(id -u) -v${PWD}:${PWD} -w${PWD} jaegertracing/protobuf:latest --proto_path=${PWD} \ --python_out=${PWD} --grpc-python_out=${PWD} -I/usr/include/github.com/gogo/protobuf ${PWD}/model.proto ${PWD}/collector.proto

After this step It gave gogoproto import error ModuleNotFoundError: No module named 'gogoproto'.

Generate dependency code

There is one point in README that says The generated code might require dependencies on packages like GoGo or Swagger, then I tried to generate the code for that dependency using

docker run --rm -u $(id -u) -v${PWD}:${PWD} -w${PWD} jaegertracing/protobuf:latest --proto_path=${PWD} \ --python_out=${PWD} /usr/include/github.com/gogo/protobuf/gogoproto/gogo.proto

This generated some code and I moved this to gen/ and when I try to run it crashes with this error

E   TypeError: Couldn't build proto file into descriptor pool!
E   Invalid proto descriptor for file "model.proto":
E     gogoproto/gogo.proto: Import "gogoproto/gogo.proto" has not been loaded.

I looked up if jaeger-python-client has the generated files. It seems the official client supports thrift only as of now. I would really appreciate if you can help with code generation with protobuf.

yurishkuro commented 3 years ago

why are you passing gogo.proto as argument instead of Jaeger's protos?

srikanthccv commented 3 years ago

@yurishkuro I am sorry my mistake. The first step is with the Jaeger's protos only. I updated the comment.

yurishkuro commented 3 years ago

Yeah, I see. I don't think anyone really tried the Python route, aside from just running the generation step.

srikanthccv commented 3 years ago

Oh Ok. I am kind of lost trying to get this work and there don't seem to be good resources on this particular topic. I will help in any possible way. Can I get some pointers on what to do and go about this?

yurishkuro commented 3 years ago

So the only other non-Go example I know is https://github.com/jaegertracing/jaeger-client-csharp, which generated proto classes. I am not sure how it was done, you may want to open a ticket there.

yurishkuro commented 3 years ago

A dirty workaround is to manually edit the proto files and remove all mentions of gogo, because they are only relevant for Go.