Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ packages:
github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore:
config:
all: true
github.com/jaegertracing/jaeger/internal/storage/v1/cassandra/spanstore:
interfaces:
CoreSpanWriter: {}
2 changes: 1 addition & 1 deletion internal/storage/v1/cassandra/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (f *Factory) CreateSpanWriter() (spanstore.Writer, error) {
if err != nil {
return nil, err
}
return cspanstore.NewSpanWriter(f.session, f.Options.SpanStoreWriteCacheTTL, f.metricsFactory, f.logger, options...)
return cspanstore.NewSpanWriterV1(f.session, f.Options.SpanStoreWriteCacheTTL, f.metricsFactory, f.logger, options...)
}

// CreateDependencyReader implements storage.Factory
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/v1/cassandra/savetracetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
logger.Fatal("Failed to initialize tracer", zap.Error(err))
}
defer tracerCloser(context.Background())
spanStore, err := cspanstore.NewSpanWriter(cqlSession, time.Hour*12, noScope, logger)
spanStore, err := cspanstore.NewSpanWriterV1(cqlSession, time.Hour*12, noScope, logger)
if err != nil {
logger.Fatal("Failed to create span writer", zap.Error(err))
}
Expand Down
20 changes: 10 additions & 10 deletions internal/storage/v1/cassandra/spanstore/dbmodel/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ var (
}

domainToDBValueTypeMap = map[model.ValueType]string{
model.StringType: stringType,
model.BoolType: boolType,
model.Int64Type: int64Type,
model.Float64Type: float64Type,
model.BinaryType: binaryType,
model.StringType: StringType,
model.BoolType: BoolType,
model.Int64Type: Int64Type,
model.Float64Type: Float64Type,
model.BinaryType: BinaryType,
}
)

Expand Down Expand Up @@ -152,15 +152,15 @@ func (c converter) fromDBWarnings(tags []KeyValue) ([]string, error) {

func (converter) fromDBTag(tag *KeyValue) (model.KeyValue, error) {
switch tag.ValueType {
case stringType:
case StringType:
return model.String(tag.Key, tag.ValueString), nil
case boolType:
case BoolType:
return model.Bool(tag.Key, tag.ValueBool), nil
case int64Type:
case Int64Type:
return model.Int64(tag.Key, tag.ValueInt64), nil
case float64Type:
case Float64Type:
return model.Float64(tag.Key, tag.ValueFloat64), nil
case binaryType:
case BinaryType:
return model.Binary(tag.Key, tag.ValueBinary), nil
default:
return model.KeyValue{}, fmt.Errorf("invalid ValueType in %+v", tag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ var (
someDBTags = []KeyValue{
{
Key: someStringTagKey,
ValueType: stringType,
ValueType: StringType,
ValueString: someStringTagValue,
},
{
Key: someBoolTagKey,
ValueType: boolType,
ValueType: BoolType,
ValueBool: someBoolTagValue,
},
{
Key: someLongTagKey,
ValueType: int64Type,
ValueType: Int64Type,
ValueInt64: someLongTagValue,
},
{
Key: someDoubleTagKey,
ValueType: float64Type,
ValueType: Float64Type,
ValueFloat64: someDoubleTagValue,
},
{
Key: someBinaryTagKey,
ValueType: binaryType,
ValueType: BinaryType,
ValueBinary: someBinaryTagValue,
},
}
Expand Down
40 changes: 25 additions & 15 deletions internal/storage/v1/cassandra/spanstore/dbmodel/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ const (
childOf = "child-of"
followsFrom = "follows-from"

stringType = "string"
boolType = "bool"
int64Type = "int64"
float64Type = "float64"
binaryType = "binary"
StringType = "string"
BoolType = "bool"
Int64Type = "int64"
Float64Type = "float64"
BinaryType = "binary"
Comment on lines +22 to +26
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason of doing this is because we need them in writer_test and following the same we may require them in writer v2 also

spanKindKey = "span.kind"
)

// TraceID is a serializable form of model.TraceID
Expand Down Expand Up @@ -59,25 +60,25 @@ type KeyValue struct {

func (t *KeyValue) compareValues(that *KeyValue) int {
switch t.ValueType {
case stringType:
case StringType:
return strings.Compare(t.ValueString, that.ValueString)
case boolType:
case BoolType:
if t.ValueBool != that.ValueBool {
if !t.ValueBool {
return -1
}
return 1
}
case int64Type:
case Int64Type:
return int(t.ValueInt64 - that.ValueInt64)
case float64Type:
case Float64Type:
if t.ValueFloat64 != that.ValueFloat64 {
if t.ValueFloat64 < that.ValueFloat64 {
return -1
}
return 1
}
case binaryType:
case BinaryType:
return bytes.Compare(t.ValueBinary, that.ValueBinary)
default:
return -1 // theoretical case, not stating them equal but placing the base pointer before other
Expand Down Expand Up @@ -123,18 +124,18 @@ func (t *KeyValue) Equal(that any) bool {

func (t *KeyValue) AsString() string {
switch t.ValueType {
case stringType:
case StringType:
return t.ValueString
case boolType:
case BoolType:
if t.ValueBool {
return "true"
}
return "false"
case int64Type:
case Int64Type:
return strconv.FormatInt(t.ValueInt64, 10)
case float64Type:
case Float64Type:
return strconv.FormatFloat(t.ValueFloat64, 'g', 10, 64)
case binaryType:
case BinaryType:
return hex.EncodeToString(t.ValueBinary)
default:
return "unknown type " + t.ValueType
Expand Down Expand Up @@ -203,3 +204,12 @@ func (t TraceID) ToDomain() model.TraceID {
func (t TraceID) String() string {
return t.ToDomain().String()
}

func GetSpanKind(ds *Span) string {
for _, tag := range ds.Tags {
if tag.Key == spanKindKey {
return tag.ValueString
}
}
return ""
}
12 changes: 6 additions & 6 deletions internal/storage/v1/cassandra/spanstore/dbmodel/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func TestKeyValueAsString(t *testing.T) {
name: "StringType",
kv: KeyValue{
Key: "k",
ValueType: stringType,
ValueType: StringType,
ValueString: "hello",
},
expect: "hello",
Expand All @@ -298,7 +298,7 @@ func TestKeyValueAsString(t *testing.T) {
name: "BoolTrue",
kv: KeyValue{
Key: "k",
ValueType: boolType,
ValueType: BoolType,
ValueBool: true,
},
expect: "true",
Expand All @@ -307,7 +307,7 @@ func TestKeyValueAsString(t *testing.T) {
name: "BoolFalse",
kv: KeyValue{
Key: "k",
ValueType: boolType,
ValueType: BoolType,
ValueBool: false,
},
expect: "false",
Expand All @@ -316,7 +316,7 @@ func TestKeyValueAsString(t *testing.T) {
name: "Int64Type",
kv: KeyValue{
Key: "k",
ValueType: int64Type,
ValueType: Int64Type,
ValueInt64: 12345,
},
expect: "12345",
Expand All @@ -325,7 +325,7 @@ func TestKeyValueAsString(t *testing.T) {
name: "Float64Type",
kv: KeyValue{
Key: "k",
ValueType: float64Type,
ValueType: Float64Type,
ValueFloat64: 12.34,
},
expect: "12.34",
Expand All @@ -334,7 +334,7 @@ func TestKeyValueAsString(t *testing.T) {
name: "BinaryType",
kv: KeyValue{
Key: "k",
ValueType: binaryType,
ValueType: BinaryType,
ValueBinary: []byte{0xAB, 0xCD, 0xEF},
},
expect: "abcdef",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func TestBlacklistFilter(t *testing.T) {
for _, test := range tt {
var inputKVs []KeyValue
for _, i := range test.input {
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: stringType, ValueString: ""})
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: StringType, ValueString: ""})
}
var expectedKVs []KeyValue
for _, e := range test.expected {
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: stringType, ValueString: ""})
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: StringType, ValueString: ""})
}
SortKVs(expectedKVs)

Expand Down Expand Up @@ -78,11 +78,11 @@ func TestWhitelistFilter(t *testing.T) {
for _, test := range tt {
var inputKVs []KeyValue
for _, i := range test.input {
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: stringType, ValueString: ""})
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: StringType, ValueString: ""})
}
var expectedKVs []KeyValue
for _, e := range test.expected {
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: stringType, ValueString: ""})
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: StringType, ValueString: ""})
}
SortKVs(expectedKVs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type onlyStringsFilter struct{}
func (onlyStringsFilter) filterStringTags(tags []KeyValue) []KeyValue {
var ret []KeyValue
for _, tag := range tags {
if tag.ValueType == stringType {
if tag.ValueType == StringType {
ret = append(ret, tag)
}
}
Expand All @@ -47,7 +47,7 @@ func (f onlyStringsFilter) FilterLogFields(_ *Span, logFields []KeyValue) []KeyV
}

func TestChainedTagFilter(t *testing.T) {
expectedTags := []KeyValue{{Key: someStringTagKey, ValueType: stringType, ValueString: someStringTagValue}}
expectedTags := []KeyValue{{Key: someStringTagKey, ValueType: StringType, ValueString: someStringTagValue}}
filter := NewChainedTagFilter(DefaultTagFilter, onlyStringsFilter{})
filteredTags := filter.FilterProcessTags(nil, someDBTags)
compareTags(t, expectedTags, filteredTags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func GetAllUniqueTags(span *Span, tagFilter TagFilter) []TagInsertion {
SortKVs(allTags)
uniqueTags := make([]TagInsertion, 0, len(allTags))
for i := range allTags {
if allTags[i].ValueType == binaryType {
if allTags[i].ValueType == BinaryType {
continue // do not index binary tags
}
if i > 0 && allTags[i-1].Equal(&allTags[i]) {
Expand Down
Loading
Loading