Skip to content

[ES][v2] Implement WriteTraces for v2 #7020

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

Merged
merged 2 commits into from
Apr 13, 2025

Conversation

Manik2708
Copy link
Contributor

@Manik2708 Manik2708 commented Apr 13, 2025

Which problem is this PR solving?

Description of the changes

  • Implement the WriteTraces method for v2

How was this change tested?

  • Unit Tests

Checklist

Signed-off-by: Manik2708 <[email protected]>
@Manik2708 Manik2708 requested a review from a team as a code owner April 13, 2025 18:43
@Manik2708 Manik2708 requested a review from mahadzaryab1 April 13, 2025 18:43

// WriteTraces convert the traces to ES Span model and write into the database
func (t *TraceWriter) WriteTraces(_ context.Context, td ptrace.Traces) error {
dbSpans := ToDBModel(td)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once tagDotReplacement is embedded, this must be replaced by lambda function

Copy link

codecov bot commented Apr 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.01%. Comparing base (59970f0) to head (a913a6e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7020      +/-   ##
==========================================
+ Coverage   95.99%   96.01%   +0.01%     
==========================================
  Files         346      347       +1     
  Lines       20622    20637      +15     
==========================================
+ Hits        19797    19815      +18     
+ Misses        622      620       -2     
+ Partials      203      202       -1     
Flag Coverage Δ
badger_v1 10.48% <ø> (ø)
badger_v2 2.17% <ø> (ø)
cassandra-4.x-v1-manual 15.77% <ø> (ø)
cassandra-4.x-v2-auto 2.16% <ø> (ø)
cassandra-4.x-v2-manual 2.16% <ø> (ø)
cassandra-5.x-v1-manual 15.77% <ø> (ø)
cassandra-5.x-v2-auto 2.16% <ø> (ø)
cassandra-5.x-v2-manual 2.16% <ø> (ø)
elasticsearch-6.x-v1 20.87% <ø> (ø)
elasticsearch-7.x-v1 20.96% <ø> (ø)
elasticsearch-8.x-v1 21.13% <ø> (ø)
elasticsearch-8.x-v2 2.17% <ø> (ø)
grpc_v1 11.56% <ø> (ø)
grpc_v2 8.43% <ø> (ø)
kafka-3.x-v1 10.77% <ø> (ø)
kafka-3.x-v2 2.17% <ø> (ø)
memory_v2 2.17% <ø> (ø)
opensearch-1.x-v1 21.01% <ø> (ø)
opensearch-2.x-v1 21.01% <ø> (ø)
opensearch-2.x-v2 2.17% <ø> (ø)
tailsampling-processor 0.59% <ø> (ø)
unittests 94.82% <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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dbSpans := ToDBModel(td)
for i := 0; i < len(dbSpans); i++ {
span := &dbSpans[i]
t.spanWriter.WriteSpan(model.EpochMicrosecondsAsTime(span.StartTime), 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 this is where we should start diverging with v1 implementation. One of the strengths of v2 storage API is that it allows batch writes. v1 API was a single span at a time. So v1 writer had a workaround by running a background batch insert, which also had a problem of not being able to report errors from the writes.

I think we can do better in v2. I don't know if we even need to have a background batching, because this can already configured in the pipeline above the storage. Instead we can treat each payload as already large-enough batch and write all spans in a single request.

return nil
}

func (t *TraceWriter) CreateTemplates(spanTemplate, serviceTemplate string, indexPrefix cfg.IndexPrefix) error {
Copy link
Member

Choose a reason for hiding this comment

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

why is this a public function? Who would be calling it?

coreWriter.On("Close").Return(nil)
writer := TraceWriter{spanWriter: coreWriter}
err := writer.Close()
require.NoError(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

one-sided test. Wrap it in a loop for _, expErr := range []error{nil, assert.AnError} and check that correct value is returned from Close.

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 think it's ok to merge as a first version but we will need to review the batch writes

@yurishkuro yurishkuro added the changelog:exprimental Change to an experimental part of the code label Apr 13, 2025
@yurishkuro yurishkuro enabled auto-merge April 13, 2025 22:18
@yurishkuro yurishkuro added this pull request to the merge queue Apr 13, 2025
Merged via the queue into jaegertracing:main with commit f2f4479 Apr 13, 2025
59 of 60 checks passed
amilbcahat pushed a commit to amilbcahat/jaeger that referenced this pull request May 4, 2025
## Which problem is this PR solving?
-  Fixes a part of: jaegertracing#6458 

## Description of the changes
- Implement the `WriteTraces` method for v2

## How was this change tested?
- 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: Manik2708 <[email protected]>
amilbcahat pushed a commit to amilbcahat/jaeger that referenced this pull request May 4, 2025
## Which problem is this PR solving?
-  Fixes a part of: jaegertracing#6458

## Description of the changes
- Implement the `WriteTraces` method for v2

## How was this change tested?
- 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: Manik2708 <[email protected]>
Signed-off-by: amol-verma-allen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants