jaegertracing / jaeger-client-csharp

🛑 This library is DEPRECATED!
https://jaegertracing.io/
Apache License 2.0
304 stars 67 forks source link

Code generation with protobufs for jaeger exporter #197

Closed srikanthccv closed 3 years ago

srikanthccv commented 3 years ago

For some context: https://github.com/jaegertracing/docker-protobuf/issues/24

@Falco20019 Yuri Shkuro directed me here. I am opening this issue to get help in understanding how you generated the code for protobuf. C# is the only client that has grpc support as of now and seems like it got added recently. I had been facing problems with gogo and other indirect import from model.proto and collector.proto of jaeger protos. I would really appreciate the steps you took to generate the code for protos without removing the gogo and other import within the model and collector protos. Thank you.

Falco20019 commented 3 years ago

@lonewolf3739 It‘s not that easy to do. I had to include the gogoprotos to generate everything. You can find the generated code here: https://github.com/jaegertracing/jaeger-client-csharp/tree/master/src/Communication/Jaeger.Communication.Grpc

The easiest way to use the C# protos is to just reference the generated code. I packaged them as Jaeger.Communication.Grpc and put them on NuGet.

To generate them yourself, checkout https://github.com/jaegertracing/jaeger-idl and run make proto. This will generate all of them into proto-gen-csharp (the same files as includes in the NuGET package). The Makefile also shows what is necessary to get it done using the docker-protobuf image where you first opened the issue. This also generates them for all supported languages, not only C#.

If you need to build them as part of your project because you import it in your proto, it will get a lot more complicated. I can explain it, but you would basically need to get all of the protos (from 3 or 4 different repos), pack them in your project and build them using Grpc.Tools.

But for normal usage of the API, I highly advise you to just reference Jaeger.Communication.Grpc and use it.

srikanthccv commented 3 years ago

@Falco20019 Thanks for the explanation. I need to generate code for python which is why I am interested in knowing the steps you took to generate.

To generate them yourself, checkout https://github.com/jaegertracing/jaeger-idl and run make proto

Yes, I tried with this and it generated the code for jaeger protos from idl repo but when I try to use them in project it was giving error.

you would basically need to get all of the protos (from 3 or 4 different repos), pack them in your project and build them using

Is it something like you downloaded the gogo.proto, google/protobuf/*.proto etc from their source and tried to build them?

it will get a lot more complicated.

I am afraid there is no other alternative than to do the same thing you did with C#. It would be really great if you can share the process so that I can follow it to generate code for python.

Thank you.

Falco20019 commented 3 years ago

Sorry, I should have read the original context better to see that you need python.

I think it could be enough to update the Makefile from IDL here: https://github.com/jaegertracing/jaeger-idl/blob/52fb4c944067f7661e6a5fa23ba4c44c6f9c2923/Makefile#L87-L89

It might be enough to add --python_out=${PROTO_GEN_PYTHON_DIR} to the end and escape the line break in line 89. Not sure if the python generator also has something like the internal_access flag. I will create a PR and try it out later today so that we get it into the IDL.

srikanthccv commented 3 years ago

I think it could be enough to update the Makefile from IDL here: https://github.com/jaegertracing/jaeger-idl/blob/52fb4c944067f7661e6a5fa23ba4c44c6f9c2923/Makefile#L87-L89

Yes, this seems to work. I generated the files and so far it is working fine. I have made the changes here https://github.com/jaegertracing/jaeger-idl/pull/67. I will implement sending spans with exporter and check end to end. Thank you.