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

Redefine model/ and api_v2/ types as aliases to jaeger-idl/ types #6602

Merged
merged 11 commits into from
Jan 24, 2025

Conversation

Nabil-Salah
Copy link
Contributor

@Nabil-Salah Nabil-Salah commented Jan 23, 2025

Which problem is this PR solving?

Description of the changes

  • change models and api_v2 models

How was this change tested?

  • make lint, make test

Checklist

@Nabil-Salah Nabil-Salah requested a review from a team as a code owner January 23, 2025 22:53
@Nabil-Salah
Copy link
Contributor Author

Nabil-Salah commented Jan 23, 2025

@yurishkuro
there's a problem i couldn't fix the alias fail in tests because of trace id in multiple testcases
can you suggest how to solve this?

image

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.08%. Comparing base (07e4f57) to head (48e2b6b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/gogocodec/codec.go 50.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6602      +/-   ##
==========================================
- Coverage   96.21%   96.08%   -0.14%     
==========================================
  Files         377      366      -11     
  Lines       21421    20949     -472     
==========================================
- Hits        20611    20128     -483     
- Misses        616      624       +8     
- Partials      194      197       +3     
Flag Coverage Δ
badger_v1 9.57% <0.00%> (-1.06%) ⬇️
badger_v2 1.75% <0.00%> (-1.04%) ⬇️
cassandra-4.x-v1-manual 15.29% <0.00%> (-1.36%) ⬇️
cassandra-4.x-v2-auto 1.74% <0.00%> (-0.98%) ⬇️
cassandra-4.x-v2-manual 1.74% <0.00%> (-0.98%) ⬇️
cassandra-5.x-v1-manual 15.29% <0.00%> (-1.36%) ⬇️
cassandra-5.x-v2-auto 1.74% <0.00%> (-0.98%) ⬇️
cassandra-5.x-v2-manual 1.74% <0.00%> (-0.98%) ⬇️
elasticsearch-6.x-v1 19.42% <0.00%> (-1.02%) ⬇️
elasticsearch-7.x-v1 19.50% <0.00%> (-1.01%) ⬇️
elasticsearch-8.x-v1 19.67% <0.00%> (-1.00%) ⬇️
elasticsearch-8.x-v2 1.75% <0.00%> (-1.04%) ⬇️
grpc_v1 11.02% <50.00%> (-1.18%) ⬇️
grpc_v2 7.77% <50.00%> (-1.29%) ⬇️
kafka-3.x-v1 9.86% <0.00%> (-0.50%) ⬇️
kafka-3.x-v2 1.75% <0.00%> (-1.04%) ⬇️
memory_v2 1.75% <0.00%> (-1.04%) ⬇️
opensearch-1.x-v1 19.55% <0.00%> (-1.00%) ⬇️
opensearch-2.x-v1 19.55% <0.00%> (-1.00%) ⬇️
opensearch-2.x-v2 1.75% <0.00%> (-1.04%) ⬇️
tailsampling-processor 0.47% <0.00%> (-0.05%) ⬇️
unittests 94.91% <0.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Looks very promising! The link check is expected to fail, and unit test needs a bit of investigation, but doesn't look too serious. And the best part the e2e CI tests are green. Feels like a much better approach than the copying we tried before :-)

model/flags.go Outdated Show resolved Hide resolved
proto-gen/api_v2/collector.pb.go Outdated Show resolved Hide resolved
@Nabil-Salah
Copy link
Contributor Author

Looks very promising! The link check is expected to fail, and unit test needs a bit of investigation, but doesn't look too serious. And the best part the e2e CI tests are green. Feels like a much better approach than the copying we tried before :-)

yes and it will ease the transition if at any moment you wanted to remove model files

@yurishkuro
Copy link
Member

when running unit tests locally I am seeing many logs like this

2025/01/23 18:43:56 proto: duplicate proto type registered: jaeger.api_v2.PostSpansRequest

a bit strange.

@Nabil-Salah
Copy link
Contributor Author

Nabil-Salah commented Jan 24, 2025

when running unit tests locally I am seeing many logs like this

2025/01/23 18:43:56 proto: duplicate proto type registered: jaeger.api_v2.PostSpansRequest

a bit strange.

@yurishkuro

i think this happened after I changed .pb.go files to .go

should I remove them or removing their proto registers init functions?
i don't have clue why this happened

@yurishkuro
Copy link
Member

yurishkuro commented Jan 24, 2025

I tracked one issue, in ./pkg/gogocodec package. You need this code in the codec.go instead of the existing mapping:

const (
	jaegerProtoGenPkgPath = "github.com/jaegertracing/jaeger-idl/proto-gen"
	jaegerModelPkgPath    = "github.com/jaegertracing/jaeger-idl/model/v1"
)

model/model.go Outdated Show resolved Hide resolved
model/model.go Outdated Show resolved Hide resolved
model/model.go Outdated Show resolved Hide resolved
model/model.go Outdated Show resolved Hide resolved
model/model.go Outdated Show resolved Hide resolved
model/process.go Outdated Show resolved Hide resolved
@yurishkuro
Copy link
Member

generated-files-check needs tweaks:

@yurishkuro
Copy link
Member

yurishkuro commented Jan 24, 2025

grpc tests failing with

    --- ❌ FAIL: TestGRPCRemoteStorage/GetTrace (1.20s)
panic: invalid Go type model.TraceID for field jaeger.storage.v1.GetTraceRequest.trace_id [recovered]
	panic: invalid Go type model.TraceID for field jaeger.storage.v1.GetTraceRequest.trace_id

Not sure why, you may need to make changes to plugin/storage/grpc/proto/storage.proto and regenerate make proto:

-       (gogoproto.customtype) = "github.com/jaegertracing/jaeger/model.TraceID",
+      (gogoproto.customtype) = "github.com/jaegertracing/jaeger-idl/model/v1.TraceID",

@Nabil-Salah
Copy link
Contributor Author

Nabil-Salah commented Jan 24, 2025

make proto keeps failing because can't find model.proto

image

@yurishkuro
Copy link
Member

Run git submodule init, git submodule update --recursive

Signed-off-by: nabil salah <[email protected]>
@Nabil-Salah
Copy link
Contributor Author

it runs with no problem but still giving e2e grpc fails

model/hash.go Outdated Show resolved Hide resolved
Signed-off-by: nabil salah <[email protected]>
@yurishkuro
Copy link
Member

ok, we will need to troubleshoot, I don't have an obvious next step

model/span.go Outdated Show resolved Hide resolved
model/trace.go Outdated Show resolved Hide resolved
Signed-off-by: nabil salah <[email protected]>
@yurishkuro
Copy link
Member

try this patch. I don't know why gogo still encounters the old model, but I was able to reproduce the error in a unit test and this change below fixed it.

--- a/pkg/gogocodec/codec.go
+++ b/pkg/gogocodec/codec.go
@@ -17,6 +17,9 @@ import (
 const (
        jaegerProtoGenPkgPath = "github.com/jaegertracing/jaeger-idl/proto-gen"
        jaegerModelPkgPath    = "github.com/jaegertracing/jaeger-idl/model/v1"
+
+       jaegerProtoGenPkgPathOld = "github.com/jaegertracing/jaeger/proto-gen"
+       jaegerModelPkgPathOld    = "github.com/jaegertracing/jaeger/model"
 )

 var defaultCodec encoding.CodecV2
@@ -89,5 +92,11 @@ func useGogo(t reflect.Type) bool {
        if strings.HasPrefix(pkg, jaegerModelPkgPath) {
                return true
        }
+       if strings.HasPrefix(pkg, jaegerProtoGenPkgPathOld) {
+               return true
+       }
+       if strings.HasPrefix(pkg, jaegerModelPkgPathOld) {
+               return true
+       }
        return false
 }

Signed-off-by: nabil salah <[email protected]>
@yurishkuro yurishkuro changed the title Convert models to as alias jaegerIdlModel Redefine model/ and api_v2/ types as aliases to jaeger-idl/ types Jan 24, 2025
@Nabil-Salah
Copy link
Contributor Author

Nabil-Salah commented Jan 24, 2025

try this patch. I don't know why gogo still encounters the old model, but I was able to reproduce the error in a unit test and this change below fixed it.

this is weird because we changed proto files that use model.proto already don't know why it happened

@yurishkuro
Copy link
Member

Looks like we made it. This is awesome! I'm going to ignore codecov gap, we will soon be able to clean up that code anyway.

@yurishkuro yurishkuro merged commit 5fa0297 into jaegertracing:main Jan 24, 2025
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants