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

[v2][adjuster] Implement otlp to model translator with post processing #6394

Merged
merged 14 commits into from
Dec 23, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Dec 23, 2024

Which problem is this PR solving?

Description of the changes

  • Implemented a translator in jptrace with a function ProtoFromTraces that is a wrapper of the upstream ProtoFromTraces in opentelemetry-collector-contrib jaeger translator. This function appends the warnings in jaeger.internal.warnings to the corresponding warnings field in the proto model.

How was this change tested?

  • Added unit tests

Checklist

@mahadzaryab1 mahadzaryab1 changed the title [WIP][v2][adjuster] Implement otlp to model translator with post processing [v2][adjuster] Implement otlp to model translator with post processing Dec 23, 2024
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.24%. Comparing base (6bec1ad) to head (52c01c6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6394   +/-   ##
=======================================
  Coverage   96.23%   96.24%           
=======================================
  Files         364      365    +1     
  Lines       20868    20907   +39     
=======================================
+ Hits        20082    20121   +39     
  Misses        601      601           
  Partials      185      185           
Flag Coverage Δ
badger_v1 8.99% <0.00%> (-0.05%) ⬇️
badger_v2 1.63% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v1-manual 14.96% <0.00%> (-0.09%) ⬇️
cassandra-4.x-v2-auto 1.57% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v2-manual 1.57% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v1-manual 14.96% <0.00%> (-0.09%) ⬇️
cassandra-5.x-v2-auto 1.57% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v2-manual 1.57% <0.00%> (-0.01%) ⬇️
elasticsearch-6.x-v1 18.66% <0.00%> (-0.11%) ⬇️
elasticsearch-7.x-v1 18.74% <0.00%> (-0.11%) ⬇️
elasticsearch-8.x-v1 18.90% <0.00%> (-0.10%) ⬇️
elasticsearch-8.x-v2 1.62% <0.00%> (-0.01%) ⬇️
grpc_v1 10.67% <0.00%> (-0.06%) ⬇️
grpc_v2 7.92% <0.00%> (-0.05%) ⬇️
kafka-v1 9.35% <0.00%> (-0.06%) ⬇️
kafka-v2 1.63% <0.00%> (-0.01%) ⬇️
memory_v2 1.63% <0.00%> (-0.01%) ⬇️
opensearch-1.x-v1 18.78% <0.00%> (-0.11%) ⬇️
opensearch-2.x-v1 18.79% <0.00%> (-0.10%) ⬇️
opensearch-2.x-v2 1.63% <0.00%> (-0.01%) ⬇️
tailsampling-processor 0.47% <0.00%> (-0.01%) ⬇️
unittests 95.09% <100.00%> (+<0.01%) ⬆️

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.

cmd/query/app/otlp_translator.go Show resolved Hide resolved

func ProtoFromTraces(traces ptrace.Traces) []*model.Batch {
batches := otlp2jaeger.ProtoFromTraces(traces)
for i, batch := range batches {
Copy link
Member

Choose a reason for hiding this comment

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

Seems unsafe, is it guaranteed that batches and resources have identical cardinality?

Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Dec 23, 2024

Choose a reason for hiding this comment

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

@yurishkuro I was following the logic in the upstream translator: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/translator/jaeger/traces_to_jaegerproto.go#L25. Let me know if I'm misunderstanding.

Copy link
Member

Choose a reason for hiding this comment

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

but how do we know upstream logic won't change? A robust way would be to build a map of spanId->*model.Span first and then loop through ptrace spans, find corresponding model.Span and transfer attributes into warnings.

btw, we should probably delete those attributes from model.Span, since ptrace would just copy them.

@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review December 23, 2024 14:52
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner December 23, 2024 14:52
@mahadzaryab1 mahadzaryab1 requested a review from jkowall December 23, 2024 14:52
@dosubot dosubot bot added the v2 label Dec 23, 2024
spans := scopes.At(j).Spans()
for k := 0; k < spans.Len(); k++ {
span := spans.At(k)
spanMap[span.SpanID()] = span
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better the other way. You can't guarantee no dups in ptrace. If you keep a map for model.Span then you guarantee that all warnings from ptrace will be captured

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@mahadzaryab1 mahadzaryab1 merged commit 4ecb086 into jaegertracing:main Dec 23, 2024
54 checks passed
@mahadzaryab1 mahadzaryab1 deleted the translation branch December 23, 2024 17:00
Manik2708 pushed a commit to Manik2708/jaeger that referenced this pull request Jan 5, 2025
jaegertracing#6394)

## Which problem is this PR solving?
- Towards jaegertracing#6344

## Description of the changes
- Implemented a translator in `jptrace` with a function
`ProtoFromTraces` that is a wrapper of the upstream `ProtoFromTraces` in
opentelemetry-collector-contrib jaeger translator. This function appends
the warnings in `jaeger.internal.warnings` to the corresponding warnings
field in the proto model.

## How was this change tested?
- Added unit tests

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] 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: Mahad Zaryab <[email protected]>
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