Skip to content

Conversation

@Manik2708
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • This PR refactors the converters to directly convert ptrace.Trace to database models of cassandra

How was this change tested?

  • Unit Tests

Checklist

Signed-off-by: Manik Mehta <mehtamanik96@gmail.com>
@Manik2708
Copy link
Contributor Author

Mistakenly closed the last one, please review @yurishkuro

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 97.73756% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.67%. Comparing base (bf8038e) to head (7dc928c).

Files with missing lines Patch % Lines
...rnal/storage/v2/cassandra/tracestore/to_dbmodel.go 96.89% 2 Missing and 2 partials ⚠️
...al/storage/v2/cassandra/tracestore/from_dbmodel.go 98.68% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7844      +/-   ##
==========================================
+ Coverage   95.45%   95.67%   +0.22%     
==========================================
  Files         301      301              
  Lines       15855    15762      -93     
==========================================
- Hits        15134    15080      -54     
+ Misses        565      541      -24     
+ Partials      156      141      -15     
Flag Coverage Δ
badger_v1 9.27% <0.00%> (+0.09%) ⬆️
badger_v2 1.94% <0.00%> (+0.01%) ⬆️
cassandra-4.x-v1-manual 13.72% <4.52%> (+0.13%) ⬆️
cassandra-4.x-v2-auto 1.93% <0.00%> (+0.01%) ⬆️
cassandra-4.x-v2-manual 1.93% <0.00%> (+0.01%) ⬆️
cassandra-5.x-v1-manual 13.72% <4.52%> (+0.13%) ⬆️
cassandra-5.x-v2-auto 1.93% <0.00%> (+0.01%) ⬆️
cassandra-5.x-v2-manual 1.93% <0.00%> (+0.01%) ⬆️
clickhouse 1.99% <0.00%> (+0.01%) ⬆️
elasticsearch-6.x-v1 17.72% <0.00%> (+0.17%) ⬆️
elasticsearch-7.x-v1 17.75% <0.00%> (+0.17%) ⬆️
elasticsearch-8.x-v1 17.90% <0.00%> (+0.18%) ⬆️
elasticsearch-8.x-v2 1.94% <0.00%> (+0.01%) ⬆️
elasticsearch-9.x-v2 1.94% <0.00%> (+0.01%) ⬆️
grpc_v1 8.93% <0.00%> (+0.09%) ⬆️
grpc_v2 1.94% <0.00%> (+0.01%) ⬆️
kafka-3.x-v2 1.94% <0.00%> (+0.01%) ⬆️
memory_v2 1.94% <0.00%> (+0.01%) ⬆️
opensearch-1.x-v1 17.79% <0.00%> (+0.17%) ⬆️
opensearch-2.x-v1 17.79% <0.00%> (+0.17%) ⬆️
opensearch-2.x-v2 1.94% <0.00%> (+0.01%) ⬆️
opensearch-3.x-v2 1.94% <0.00%> (+0.01%) ⬆️
query 1.94% <0.00%> (+0.01%) ⬆️
tailsampling-processor 0.56% <0.00%> (+<0.01%) ⬆️
unittests 94.29% <97.73%> (+0.21%) ⬆️

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.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Metrics Comparison Summary

Total changes across all snapshots: 0

Detailed changes per snapshot

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 0

  • 🆕 Added: 0 metrics
  • ❌ Removed: 0 metrics
  • 🔄 Modified: 0 metrics
  • 🚫 Excluded: 106 metrics

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 0

  • 🆕 Added: 0 metrics
  • ❌ Removed: 0 metrics
  • 🔄 Modified: 0 metrics
  • 🚫 Excluded: 106 metrics

➡️ View full metrics file

@yurishkuro yurishkuro requested a review from Copilot January 9, 2026 23:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Cassandra v2 trace store converters to work directly with dbmodel.Span instead of Jaeger protobuf models. The changes eliminate intermediate conversions and simplify the data flow by having FromDbModel and ToDbModel functions accept and return dbmodel.Span types.

Changes:

  • Refactored converter functions to use dbmodel.Span directly instead of model.Batch
  • Updated type constants in dbmodel from private to public (e.g., stringTypeStringType)
  • Removed intermediate batch grouping logic and process checksumming functionality
  • Updated test fixtures to reflect the new data structure

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/storage/v2/cassandra/tracestore/to_dbmodel.go Refactored conversion from ptrace.Traces to dbmodel.Span with direct field mappings
internal/storage/v2/cassandra/tracestore/to_dbmodel_test.go Updated tests to use dbmodel types and added edge case coverage
internal/storage/v2/cassandra/tracestore/from_dbmodel.go Simplified conversion from dbmodel.Span to ptrace.Traces, removed batch regrouping logic
internal/storage/v2/cassandra/tracestore/from_dbmodel_test.go Updated tests to work with dbmodel.Span instead of model.Batch
internal/storage/v1/cassandra/spanstore/dbmodel/model.go Exported type constants for public API usage
internal/storage/v1/cassandra/spanstore/dbmodel/converter.go Updated references to use exported constant names
internal/storage/v2/cassandra/tracestore/fixtures/cas_01.json Updated fixture to reflect dbmodel.Span structure
internal/storage/v2/cassandra/tracestore/fixtures/otel_traces_01.json Added missing flags and status fields to test data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +69
//nolint:gosec // G115 // dbspan.SpanID is guaranteed non-negative by schema constraints
span.SetSpanID(idutils.UInt64ToSpanID(uint64(dbspan.SpanID)))
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The nolint directive on line 68 states that dbspan.SpanID is guaranteed non-negative by schema constraints, but int64 can be negative. Consider changing the dbmodel.Span.SpanID field type to uint64 or int64 with validation to ensure this constraint is enforced at the type level rather than relying on comments.

Suggested change
//nolint:gosec // G115 // dbspan.SpanID is guaranteed non-negative by schema constraints
span.SetSpanID(idutils.UInt64ToSpanID(uint64(dbspan.SpanID)))
if dbspan.SpanID >= 0 {
span.SetSpanID(idutils.UInt64ToSpanID(uint64(dbspan.SpanID)))
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That leads to schema change and we don't know what need to be covered for backward compatibility. Doing this can be a different PR

//nolint:gosec // G115 // span.StartTime is guaranteed non-negative by schema constraints
StartTime: int64(span.StartTimestamp()),
//nolint:gosec // G115 // span.EndTime - span.StartTime is guaranteed non-negative by schema constraints
Duration: int64(model.DurationAsMicroseconds(span.EndTimestamp().AsTime().Sub(startTime))),
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The duration calculation converts to microseconds but the variable is named Duration without units, making the unit ambiguous. The comment indicates microseconds, but explicit field documentation or a more descriptive name would improve clarity.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what does this mean? where do we need to add documentation?

Signed-off-by: Manik Mehta <mehtamanik96@gmail.com>
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.

1 participant