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

Migrate proto-gen/thrift-gen to jaeger-idl #6494

Open
3 of 8 tasks
yurishkuro opened this issue Jan 6, 2025 · 11 comments
Open
3 of 8 tasks

Migrate proto-gen/thrift-gen to jaeger-idl #6494

yurishkuro opened this issue Jan 6, 2025 · 11 comments
Labels
good first issue Good for beginners help wanted Features that maintainers are willing to accept but do not have cycles to implement

Comments

@yurishkuro
Copy link
Member

yurishkuro commented Jan 6, 2025

In #6408 it was proposed that we break up the circular dependency between Jaeger and OTEL code bases by cloning some of the code from Jaeger to OTEL, in particular the auto-generated classes for Proto and Thrift.

However, it turns out Proto does not work if the same Protobuf type is registered more than once, because Proto uses a global registry. For example, when I used model.proto to generate the output into a different folder proto-gen/model/ (compared to our standard model/) in #6493, then the unit test that tries to use both models fails

panic: proto: duplicate enum registered: jaeger.api_v2.ValueType

goroutine 1 [running]:
github.com/gogo/protobuf/proto.RegisterEnum(...)
        /Users/ysh/golang/pkg/mod/github.com/gogo/[email protected]/proto/properties.go:520
github.com/jaegertracing/jaeger/proto-gen/model.init.0()
        /Users/ysh/dev/jaegertracing/jaeger/proto-gen/model/model.pb.go:713 +0x41c
FAIL    github.com/jaegertracing/jaeger/proto-gen/model 0.452s

As a result, a number of sub-tasks proposed in #6408 will not work if both OTEL and Jaeger have proto-generated types for the same .proto interfaces. This is likely the same issue as reported in open-telemetry/opentelemetry-go-contrib#6555.

One possible workaround is to tweak the IDL files to use a different namespace for the Proto types, e.g. instead of jaeger.api_v2.ValueType the OTEL could use otel.jaeger.api_v2.ValueType. This only works if the generated structs are used to marshal binary payloads like []byte where the namespace of the type does not matter. But if an actual Proto service is implemented then I don't think it can use a different namespace, since then the clients won't be able to use that service.

Since it does not seem like we'd be able to easily avoid OTEL code using some of the Jaeger proto structs, the proposal is to move them out of Jaeger repository. We already include jaeger-idl as a submodule and read the proto files from there to generate code. Instead, we can use jaeger-idl as a regular Go dependency and generate the code in that repository (we already do that today as part of IDL repo CI, but we don't persist that code).

Tasks:

  • reproduce the build steps used in Jaeger to generate proto code in the jaeger-idl repo
  • commit Go code in jaeger-idl repo
  • Upgrade Jaeger to use generated Go code from jaeger-idl as a dependency
    • Delete proto-gen
    • Clean up Makefile.Proto.mk
    • Delete thrift-gen
    • Clean up Makefile.Thrift.mk
  • Upgrade OTEL Contrib to also use types from jaeger-idl instead of from Jaeger
@won-js
Copy link
Contributor

won-js commented Jan 8, 2025

I'll give this issue a try, though it looks a bit challenging for me. However, if someone else wants to work on it, feel free to take it

@danish9039
Copy link
Contributor

working on it !

I'll give this issue a try, though it looks a bit challenging for me. However, if someone else wants to work on it, feel free to take it

currently working on this

@adityachopra29
Copy link
Contributor

Seems like it is taking some time. Also trying this issue.

yurishkuro pushed a commit to jaegertracing/jaeger-idl that referenced this issue Jan 16, 2025
## Which problem is this PR solving?
- Part 1 and 2 of jaegertracing/jaeger#6494
for api_v2

## Description of the changes
- Create makefile for compiling and generating code from .proto files
present
- All locations of proto files, as well as generated code are inspired
from main jaeger repo. (Since no other alteranative was suggested in
issue.)
- Add all the generated code from the proto files as well.
- Create ci-lint file for same.

## How was this change tested?
- CI

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [ ] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: adityachopra29 <[email protected]>
yurishkuro added a commit to jaegertracing/jaeger-idl that referenced this issue Jan 20, 2025
## Which problem is this PR solving?
- Part of jaegertracing/jaeger#6494

## Description of the changes
- Add code gen for `model.proto` into `model/v1` package
- 🛑 breaking change: query.proto changed references to custom types to
local TraceID/SpanID instead of importing the main `jaeger` repo
- Copy minimal set of types from original `model/` that are required by
api_v2, such as TraceID, SpanID, and `Flags` required by `model`
- Add `go.mod` to make it into importable library
- Add basic `go test` to CI

## How was this change tested?
- `go test ./model/v1`

## Checklist
- [ ] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [ ] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [ ] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: Yuri Shkuro <[email protected]>
yurishkuro added a commit that referenced this issue Jan 20, 2025
## Which problem is this PR solving?
- Part of #6494

## Description of the changes
- Bump jaeger-idl submodule
- Adjust code gen to account for different custom types due to
jaegertracing/jaeger-idl#118

## How was this change tested?
- CI

Signed-off-by: Yuri Shkuro <[email protected]>
Manik2708 pushed a commit to Manik2708/jaeger that referenced this issue Jan 21, 2025
## Which problem is this PR solving?
- Part of jaegertracing#6494

## Description of the changes
- Bump jaeger-idl submodule
- Adjust code gen to account for different custom types due to
jaegertracing/jaeger-idl#118

## How was this change tested?
- CI

Signed-off-by: Yuri Shkuro <[email protected]>
yurishkuro added a commit that referenced this issue Jan 22, 2025
## Which problem is this PR solving?
- Part of #6494

## Description of the changes
- If we move TraceID/SpanID types to jaeger-idl we will not be able to
define methods on them, so change to plain functions.

## How was this change tested?
- CI

Signed-off-by: Yuri Shkuro <[email protected]>
yurishkuro added a commit that referenced this issue Jan 22, 2025
## Which problem is this PR solving?
- Part of #6494
- Since `jaeger-idl` repo now includes Go code, as soon as we update the
submodule here it's treated as a real source of Go code, including by
tools like `go fmt`, etc.

## Description of the changes
- Exclude `idl/` from ALL_SOURCES, so that `make fmt` does not apply to
it
- Bump `idl` submodule to latest

## How was this change tested?
- CI

Signed-off-by: Yuri Shkuro <[email protected]>
@Nabil-Salah
Copy link
Contributor

hello @yurishkuro

i was trying to update the main Jaeger repo to use models from jaeger-idl

my approach suggestion is that I can divide it on multiple 2 prs so it can be easy to review and migrate

first I think we can start by

  • Upgrade OTEL Contrib to use types from jaeger-idl -> this will ease jaeger transition

then

  • we can change jaeger to use jaeger-idl it will be easy as it only needs to change jaeger packages and proto files

if you think I'm good to go I can start

@yurishkuro
Copy link
Member Author

@Nabil-Salah I think you have to start with jaeger repo. Because OTEL imports some of the Jaeger code directly, and that code beings the jaeger/model dependencies, while some other code in OTEL might be using jaeger/model dependencies directly. For example, OTEL depends on code from jaeger/cmd/agent, which is using jaeger/model.

Some modules in OTEL might be upgraded independently, but then you may run into a different issue where the same GRPC type is registered twice, and it will not work. Other OTEL modules would definitely not work if you try to upgrade them first.

Having said that, the same, in theory, could happen if we try to upgrade Jaeger first. But I would start there and see what issues we get into. In the worse case we may have to resort to blanket copying of code (temporarily) to break circular dependency, in particular model<>otlp translation from OTEL.

TLDR - need to try it.

@Nabil-Salah
Copy link
Contributor

Nabil-Salah commented Jan 22, 2025

okay will take some investigation time and till you what errors encountered or blocking states I reach
in PRs and will move to jaeger-idl models incrementally in jaeger repo.

@yurishkuro
Copy link
Member Author

@Nabil-Salah I already added dependency on jaeger-idl to the main repo. The change you should make is search/replace the imports of jaeger/model and api_v2 with the equivalent paths from jaeger-idl. And then just see what compiles / builds / CI.

@Nabil-Salah
Copy link
Contributor

I tried multiple of things but it always end up with a domino effect

  • I pick some module and edit it -> I go out trying to fix other modules that depends on it ending with a block state[1]
  • I replace all modules and fix the need of otelids -> I end up with a block state[1]

the two block states are the same

Image

these two files use OTEL what I suggest is that I implement a function that will translate jaeger model Batch from/to jaeger-idl Batch model

it will a cumbersome function but it will be a temporary work until OTEL change

also

  • this will lower the time of code review as it will not be of much a change as it will be just search/replace the imports of jaeger/model and api_v2
  • will make it easy when the OTEL change happens

@yurishkuro
Copy link
Member Author

what I suggest is that I implement a function that will translate jaeger model Batch from/to jaeger-idl Batch model

I don't think this is a good approach. It is inefficient and still keeps the internal dependency on the model/. Instead, I would copy jaegerTranslator code somewhere jaeger/internal and change it to use jaeger-idl model. Then once we release new version of Jaeger no longer using model/, the OTEL will have to do a similar switch to jaeger-idl. Then once they release and we pick it up, we can delete our copy of jaegerTranslator and go back to official OTEL's version.

@yurishkuro
Copy link
Member Author

copy jaegerTranslator and change it to use jaeger-idl mode

this can be a standalone PR, will not affect anything. Put it into internal/jptrace/translator.

@Nabil-Salah
Copy link
Contributor

okay this looks really good idea
will try it

yurishkuro pushed a commit that referenced this issue Jan 24, 2025
)

## Which problem is this PR solving?
- part of #6595
- part of #6494

## Description of the changes
- change models

## How was this change tested?
- `make lint`, `make test`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: nabil salah <[email protected]>
yurishkuro added a commit that referenced this issue Jan 25, 2025
## Which problem is this PR solving?
- Part of #6494

## Description of the changes
- Move OTEL-IDs helpers to v1adapter
- Clean-up model aliases
- Remove unnecessary test in model (it exists in idl/model/v1)
- Prohibit dependencies on `github.com/jaegertracing/jaeger/model` via
linter
- Fix `storage.proto` code-gen to not rely on `model/`

## How was this change tested?
- CI

---------

Signed-off-by: Yuri Shkuro <[email protected]>
yurishkuro pushed a commit that referenced this issue Jan 25, 2025
## Which problem is this PR solving?
- part of #6494 

## Description of the changes
- replace model proto-gen_api_v2 imports to use jaeger-idl
proto-gen/api_v2 imports
- Prohibit dependencies on
github.com/jaegertracing/jaeger/proto-gen/api_v2 via linter

## How was this change tested?
- `make test`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: nabil salah <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for beginners help wanted Features that maintainers are willing to accept but do not have cycles to implement
Projects
None yet
Development

No branches or pull requests

5 participants