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

Add Go code generated for api_v2 #116

Merged

Conversation

adityachopra29
Copy link
Contributor

@adityachopra29 adityachopra29 commented Jan 14, 2025

Which problem is this PR solving?

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

Signed-off-by: adityachopra29 <adityachopra2912@gmail.com>
@adityachopra29
Copy link
Contributor Author

adityachopra29 commented Jan 14, 2025

@yurishkuro Please have a look now.
I was not sure where all required proto files must be added, so i took inspiration from the main repo, can change it if that is not required.

Similiarly, since make proto command was already used, I created the command make new-proto for the generation. We can change that according to need

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend skipping /model/ for now, because it has a much higher knock-off effect on Jaeger repo, while the other types are easier to swap, and do not require much of organization. The original ticket was not asking to migrate /model/.

Please ensure that all generated files are organized into a consistent folder hierarchy, rooted at proto-gen

I would recommend starting with a single .proto, e.g. api_v2. There is more housekeeping work that needs to be done first, such as setting up CI to lint & compile, defining a release process, etc. Let's do one module e2e before migrating everything.

@@ -0,0 +1,3357 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it won't be usable if it's in the internal package.

@@ -0,0 +1,27 @@
// Copyright (c) 2019 The Jaeger Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not useful here, we can leave it in Jaeger

@@ -0,0 +1,230 @@
// Copyright (c) 2018 Uber Technologies, Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed in this repo

Signed-off-by: adityachopra29 <adityachopra2912@gmail.com>
@adityachopra29
Copy link
Contributor Author

adityachopra29 commented Jan 15, 2025

I would recommend starting with a single .proto, e.g. api_v2. There is more housekeeping work that needs to be done first, such as setting up CI to lint & compile, defining a release process, etc. Let's do one module e2e before migrating everything.

Okay. I was trying to understand how to setup CI, etc. Can you please explain what all is left in setting up of the CI? @yurishkuro

  • Also, I have made the rest of the changes you have told above regarding api_v3 and removing the 'internal" folder, but since we are first completing api_v2 e2e, I didnt push them right now
  • I have not added proto-gen/api_v2/metrics, since it was dependant on /model
    OPENMETRICS_PROTO_FILES=$(wildcard model/proto/metrics/*.proto)

@yurishkuro
Copy link
Member

what we want in the CI:

  • a re-run of the code generation and fail CI if it finds a difference (see how it's done in the jaeger repo)
  • I think that's it for now

Signed-off-by: adityachopra29 <adityachopra2912@gmail.com>
Signed-off-by: adityachopra29 <adityachopra2912@gmail.com>
@adityachopra29 adityachopra29 changed the title create makefile for proto code generation, add generated code create makefile for proto code generation, add generated code, for api_v2 Jan 16, 2025
endef

.PHONY: new-proto
new-proto: new-proto-api-v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "new"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro
There is already a command make proto in the main Makefile. I didn't want to remove that right now before confirming, so I made the make new-proto command in the meantime.
If we can remove the old make proto command, we can rename it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need two different paths at all? The difference between the two commands is that the old one generates for all languages (and is used mostly as a linter step), while the new one only generates Go types. I would prefer to avoid duplication and be able to support both Go and All languages with a single set of commands.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know, let's hold off on this topic - we can refactor this as as separate issue, I would like to get api_v2 types into this repo first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need two different paths at all?

Yes, I agree. I had planned on replacing that test in the end. Just wanted to show you the changes before making them; hence, I made a new file.

Okay, I will create another pr to make these changes

@yurishkuro
Copy link
Member

I am seeing CI failures

	proto/api_v3/query_service.proto
opentelemetry/proto/trace/v1/trace.proto: File not found.
proto/api_v3/query_service.proto:19:1: Import "opentelemetry/proto/trace/v1/trace.proto" was not found or had errors.
proto/api_v3/query_service.proto:165:3: "opentelemetry.proto.trace.v1.TracesData" is not defined.
proto/api_v3/query_service.proto:125:49: "opentelemetry.proto.trace.v1.TracesData" is not defined.
proto/api_v3/query_service.proto:129:53: "opentelemetry.proto.trace.v1.TracesData" is not defined.
make: *** [Makefile:153: proto-api-v3] Error 1

why is the original workflow affected, what changed? Does your new makefile override something (like variables) in the old one?

Signed-off-by: adityachopra29 <adityachopra2912@gmail.com>
@adityachopra29
Copy link
Contributor Author

@yurishkuro My bad, I had redefined the PROTO_INCLUDES variable, because of which the error was coming. Have pushed the changes

Along the way, I also saw some command variables that were hardcoded in the Makefile (such as docker, sed). We can also change them in another pr.

@yurishkuro yurishkuro changed the title create makefile for proto code generation, add generated code, for api_v2 Add Go code generated for api_v2 Jan 16, 2025
Comment on lines +17 to +18
DOCKER_PROTOBUF_VERSION=0.5.0
DOCKER_PROTOBUF=jaegertracing/protobuf:$(DOCKER_PROTOBUF_VERSION)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are already vars defined in the main Makefile for the same concept, should be using them.

@yurishkuro
Copy link
Member

As discussed, I am going to merge this so that we can start using these types in the jaeger repo. A clean-up / deduplication can be done separately.

@yurishkuro yurishkuro merged commit c003366 into jaegertracing:main Jan 16, 2025
3 checks passed
@yurishkuro
Copy link
Member

@adityachopra29 we will also need go.mod somewhere to make this usable as a go library. And it would be good to have some minimal test to ensure the generated code compiles.

@adityachopra29 adityachopra29 deleted the migrate-proto-gen-jaeger branch January 17, 2025 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants