Skip to content

Commit dc096b6

Browse files
committed
conflicts
Signed-off-by: Manik Mehta <mehtamanik96@gmail.com>
1 parent 72eca6e commit dc096b6

File tree

15 files changed

+349
-144
lines changed

15 files changed

+349
-144
lines changed

.mockery.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,6 @@ packages:
6565
github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore:
6666
config:
6767
all: true
68+
github.com/jaegertracing/jaeger/internal/storage/v1/cassandra/spanstore:
69+
interfaces:
70+
CoreSpanWriter: {}

internal/storage/v1/cassandra/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (f *Factory) CreateSpanWriter() (spanstore.Writer, error) {
143143
if err != nil {
144144
return nil, err
145145
}
146-
return cspanstore.NewSpanWriter(f.session, f.Options.SpanStoreWriteCacheTTL, f.metricsFactory, f.logger, options...)
146+
return cspanstore.NewSpanWriterV1(f.session, f.Options.SpanStoreWriteCacheTTL, f.metricsFactory, f.logger, options...)
147147
}
148148

149149
// CreateDependencyReader implements storage.Factory

internal/storage/v1/cassandra/savetracetest/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func main() {
4646
logger.Fatal("Failed to initialize tracer", zap.Error(err))
4747
}
4848
defer tracerCloser(context.Background())
49-
spanStore, err := cspanstore.NewSpanWriter(cqlSession, time.Hour*12, noScope, logger)
49+
spanStore, err := cspanstore.NewSpanWriterV1(cqlSession, time.Hour*12, noScope, logger)
5050
if err != nil {
5151
logger.Fatal("Failed to create span writer", zap.Error(err))
5252
}

internal/storage/v1/cassandra/spanstore/dbmodel/converter.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ var (
2828
}
2929

3030
domainToDBValueTypeMap = map[model.ValueType]string{
31-
model.StringType: stringType,
32-
model.BoolType: boolType,
33-
model.Int64Type: int64Type,
34-
model.Float64Type: float64Type,
35-
model.BinaryType: binaryType,
31+
model.StringType: StringType,
32+
model.BoolType: BoolType,
33+
model.Int64Type: Int64Type,
34+
model.Float64Type: Float64Type,
35+
model.BinaryType: BinaryType,
3636
}
3737
)
3838

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

153153
func (converter) fromDBTag(tag *KeyValue) (model.KeyValue, error) {
154154
switch tag.ValueType {
155-
case stringType:
155+
case StringType:
156156
return model.String(tag.Key, tag.ValueString), nil
157-
case boolType:
157+
case BoolType:
158158
return model.Bool(tag.Key, tag.ValueBool), nil
159-
case int64Type:
159+
case Int64Type:
160160
return model.Int64(tag.Key, tag.ValueInt64), nil
161-
case float64Type:
161+
case Float64Type:
162162
return model.Float64(tag.Key, tag.ValueFloat64), nil
163-
case binaryType:
163+
case BinaryType:
164164
return model.Binary(tag.Key, tag.ValueBinary), nil
165165
default:
166166
return model.KeyValue{}, fmt.Errorf("invalid ValueType in %+v", tag)

internal/storage/v1/cassandra/spanstore/dbmodel/converter_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@ var (
4646
someDBTags = []KeyValue{
4747
{
4848
Key: someStringTagKey,
49-
ValueType: stringType,
49+
ValueType: StringType,
5050
ValueString: someStringTagValue,
5151
},
5252
{
5353
Key: someBoolTagKey,
54-
ValueType: boolType,
54+
ValueType: BoolType,
5555
ValueBool: someBoolTagValue,
5656
},
5757
{
5858
Key: someLongTagKey,
59-
ValueType: int64Type,
59+
ValueType: Int64Type,
6060
ValueInt64: someLongTagValue,
6161
},
6262
{
6363
Key: someDoubleTagKey,
64-
ValueType: float64Type,
64+
ValueType: Float64Type,
6565
ValueFloat64: someDoubleTagValue,
6666
},
6767
{
6868
Key: someBinaryTagKey,
69-
ValueType: binaryType,
69+
ValueType: BinaryType,
7070
ValueBinary: someBinaryTagValue,
7171
},
7272
}

internal/storage/v1/cassandra/spanstore/dbmodel/model.go

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ const (
1919
childOf = "child-of"
2020
followsFrom = "follows-from"
2121

22-
stringType = "string"
23-
boolType = "bool"
24-
int64Type = "int64"
25-
float64Type = "float64"
26-
binaryType = "binary"
22+
StringType = "string"
23+
BoolType = "bool"
24+
Int64Type = "int64"
25+
Float64Type = "float64"
26+
BinaryType = "binary"
27+
spanKindKey = "span.kind"
2728
)
2829

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

6061
func (t *KeyValue) compareValues(that *KeyValue) int {
6162
switch t.ValueType {
62-
case stringType:
63+
case StringType:
6364
return strings.Compare(t.ValueString, that.ValueString)
64-
case boolType:
65+
case BoolType:
6566
if t.ValueBool != that.ValueBool {
6667
if !t.ValueBool {
6768
return -1
6869
}
6970
return 1
7071
}
71-
case int64Type:
72+
case Int64Type:
7273
return int(t.ValueInt64 - that.ValueInt64)
73-
case float64Type:
74+
case Float64Type:
7475
if t.ValueFloat64 != that.ValueFloat64 {
7576
if t.ValueFloat64 < that.ValueFloat64 {
7677
return -1
7778
}
7879
return 1
7980
}
80-
case binaryType:
81+
case BinaryType:
8182
return bytes.Compare(t.ValueBinary, that.ValueBinary)
8283
default:
8384
return -1 // theoretical case, not stating them equal but placing the base pointer before other
@@ -123,18 +124,18 @@ func (t *KeyValue) Equal(that any) bool {
123124

124125
func (t *KeyValue) AsString() string {
125126
switch t.ValueType {
126-
case stringType:
127+
case StringType:
127128
return t.ValueString
128-
case boolType:
129+
case BoolType:
129130
if t.ValueBool {
130131
return "true"
131132
}
132133
return "false"
133-
case int64Type:
134+
case Int64Type:
134135
return strconv.FormatInt(t.ValueInt64, 10)
135-
case float64Type:
136+
case Float64Type:
136137
return strconv.FormatFloat(t.ValueFloat64, 'g', 10, 64)
137-
case binaryType:
138+
case BinaryType:
138139
return hex.EncodeToString(t.ValueBinary)
139140
default:
140141
return "unknown type " + t.ValueType
@@ -203,3 +204,12 @@ func (t TraceID) ToDomain() model.TraceID {
203204
func (t TraceID) String() string {
204205
return t.ToDomain().String()
205206
}
207+
208+
func GetSpanKind(ds *Span) string {
209+
for _, tag := range ds.Tags {
210+
if tag.Key == spanKindKey {
211+
return tag.ValueString
212+
}
213+
}
214+
return ""
215+
}

internal/storage/v1/cassandra/spanstore/dbmodel/model_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func TestKeyValueAsString(t *testing.T) {
289289
name: "StringType",
290290
kv: KeyValue{
291291
Key: "k",
292-
ValueType: stringType,
292+
ValueType: StringType,
293293
ValueString: "hello",
294294
},
295295
expect: "hello",
@@ -298,7 +298,7 @@ func TestKeyValueAsString(t *testing.T) {
298298
name: "BoolTrue",
299299
kv: KeyValue{
300300
Key: "k",
301-
ValueType: boolType,
301+
ValueType: BoolType,
302302
ValueBool: true,
303303
},
304304
expect: "true",
@@ -307,7 +307,7 @@ func TestKeyValueAsString(t *testing.T) {
307307
name: "BoolFalse",
308308
kv: KeyValue{
309309
Key: "k",
310-
ValueType: boolType,
310+
ValueType: BoolType,
311311
ValueBool: false,
312312
},
313313
expect: "false",
@@ -316,7 +316,7 @@ func TestKeyValueAsString(t *testing.T) {
316316
name: "Int64Type",
317317
kv: KeyValue{
318318
Key: "k",
319-
ValueType: int64Type,
319+
ValueType: Int64Type,
320320
ValueInt64: 12345,
321321
},
322322
expect: "12345",
@@ -325,7 +325,7 @@ func TestKeyValueAsString(t *testing.T) {
325325
name: "Float64Type",
326326
kv: KeyValue{
327327
Key: "k",
328-
ValueType: float64Type,
328+
ValueType: Float64Type,
329329
ValueFloat64: 12.34,
330330
},
331331
expect: "12.34",
@@ -334,7 +334,7 @@ func TestKeyValueAsString(t *testing.T) {
334334
name: "BinaryType",
335335
kv: KeyValue{
336336
Key: "k",
337-
ValueType: binaryType,
337+
ValueType: BinaryType,
338338
ValueBinary: []byte{0xAB, 0xCD, 0xEF},
339339
},
340340
expect: "abcdef",

internal/storage/v1/cassandra/spanstore/dbmodel/tag_filter_exact_match_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ func TestBlacklistFilter(t *testing.T) {
3030
for _, test := range tt {
3131
var inputKVs []KeyValue
3232
for _, i := range test.input {
33-
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: stringType, ValueString: ""})
33+
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: StringType, ValueString: ""})
3434
}
3535
var expectedKVs []KeyValue
3636
for _, e := range test.expected {
37-
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: stringType, ValueString: ""})
37+
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: StringType, ValueString: ""})
3838
}
3939
SortKVs(expectedKVs)
4040

@@ -78,11 +78,11 @@ func TestWhitelistFilter(t *testing.T) {
7878
for _, test := range tt {
7979
var inputKVs []KeyValue
8080
for _, i := range test.input {
81-
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: stringType, ValueString: ""})
81+
inputKVs = append(inputKVs, KeyValue{Key: i, ValueType: StringType, ValueString: ""})
8282
}
8383
var expectedKVs []KeyValue
8484
for _, e := range test.expected {
85-
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: stringType, ValueString: ""})
85+
expectedKVs = append(expectedKVs, KeyValue{Key: e, ValueType: StringType, ValueString: ""})
8686
}
8787
SortKVs(expectedKVs)
8888

internal/storage/v1/cassandra/spanstore/dbmodel/tag_filter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type onlyStringsFilter struct{}
2727
func (onlyStringsFilter) filterStringTags(tags []KeyValue) []KeyValue {
2828
var ret []KeyValue
2929
for _, tag := range tags {
30-
if tag.ValueType == stringType {
30+
if tag.ValueType == StringType {
3131
ret = append(ret, tag)
3232
}
3333
}
@@ -47,7 +47,7 @@ func (f onlyStringsFilter) FilterLogFields(_ *Span, logFields []KeyValue) []KeyV
4747
}
4848

4949
func TestChainedTagFilter(t *testing.T) {
50-
expectedTags := []KeyValue{{Key: someStringTagKey, ValueType: stringType, ValueString: someStringTagValue}}
50+
expectedTags := []KeyValue{{Key: someStringTagKey, ValueType: StringType, ValueString: someStringTagValue}}
5151
filter := NewChainedTagFilter(DefaultTagFilter, onlyStringsFilter{})
5252
filteredTags := filter.FilterProcessTags(nil, someDBTags)
5353
compareTags(t, expectedTags, filteredTags)

internal/storage/v1/cassandra/spanstore/dbmodel/unique_tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func GetAllUniqueTags(span *Span, tagFilter TagFilter) []TagInsertion {
1414
SortKVs(allTags)
1515
uniqueTags := make([]TagInsertion, 0, len(allTags))
1616
for i := range allTags {
17-
if allTags[i].ValueType == binaryType {
17+
if allTags[i].ValueType == BinaryType {
1818
continue // do not index binary tags
1919
}
2020
if i > 0 && allTags[i-1].Equal(&allTags[i]) {

0 commit comments

Comments
 (0)