-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Use official OTLP types in api_v3 and avoid triple-marshaling #5098
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f313486
Use OTLP
yurishkuro 010a1be
wip
yurishkuro c8943fd
wip
yurishkuro 917c0ba
fix
yurishkuro 591e77b
fix
yurishkuro 59539e3
fix
yurishkuro 93b8357
fix
yurishkuro ac91597
fix
yurishkuro a9bb33e
add comments
yurishkuro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ import ( | |
|
||
ui "github.com/jaegertracing/jaeger/model/json" | ||
"github.com/jaegertracing/jaeger/proto-gen/api_v2" | ||
"github.com/jaegertracing/jaeger/proto-gen/api_v3" | ||
) | ||
|
||
// These tests are only run when the environment variable TEST_MODE=integration is set. | ||
|
@@ -180,9 +179,11 @@ func getServicesAPIV3(t *testing.T) { | |
require.NoError(t, err) | ||
body, _ := io.ReadAll(resp.Body) | ||
|
||
var servicesResponse api_v3.GetServicesResponse | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was unnecessary coupling. |
||
var servicesResponse struct { | ||
Services []string | ||
} | ||
err = json.Unmarshal(body, &servicesResponse) | ||
require.NoError(t, err) | ||
require.Len(t, servicesResponse.GetServices(), 1) | ||
assert.Contains(t, servicesResponse.GetServices()[0], "jaeger") | ||
require.Len(t, servicesResponse.Services, 1) | ||
assert.Contains(t, servicesResponse.Services[0], "jaeger") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,33 +15,13 @@ | |
package apiv3 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gogo/protobuf/proto" | ||
model2otel "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger" | ||
"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
|
||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/proto-gen/api_v3" | ||
tracev1 "github.com/jaegertracing/jaeger/proto-gen/otel/trace/v1" | ||
) | ||
|
||
func modelToOTLP(spans []*model.Span) ([]*tracev1.ResourceSpans, error) { | ||
func modelToOTLP(spans []*model.Span) (ptrace.Traces, error) { | ||
batch := &model.Batch{Spans: spans} | ||
td, err := model2otel.ProtoToTraces([]*model.Batch{batch}) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot convert trace to OpenTelemetry: %w", err) | ||
} | ||
req := ptraceotlp.NewExportRequestFromTraces(td) | ||
// OTEL Collector hides the internal proto implementation, so do a roundtrip conversion (inefficient) | ||
b, err := req.MarshalProto() | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot marshal OTLP: %w", err) | ||
} | ||
// use api_v3.SpansResponseChunk which has the same shape as otlp.ExportTraceServiceRequest | ||
var chunk api_v3.SpansResponseChunk | ||
if err := proto.Unmarshal(b, &chunk); err != nil { | ||
return nil, fmt.Errorf("cannot marshal OTLP: %w", err) | ||
} | ||
return chunk.ResourceSpans, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no triple marshaling! |
||
return model2otel.ProtoToTraces([]*model.Batch{batch}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.