Skip to content
Open
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
28 changes: 14 additions & 14 deletions internal/storage/v1/cassandra/spanstore/dbmodel/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ const (

var (
dbToDomainRefMap = map[string]model.SpanRefType{
childOf: model.SpanRefType_CHILD_OF,
followsFrom: model.SpanRefType_FOLLOWS_FROM,
ChildOf: model.SpanRefType_CHILD_OF,
FollowsFrom: model.SpanRefType_FOLLOWS_FROM,
}

domainToDBRefMap = map[model.SpanRefType]string{
model.SpanRefType_CHILD_OF: childOf,
model.SpanRefType_FOLLOWS_FROM: followsFrom,
model.SpanRefType_CHILD_OF: ChildOf,
model.SpanRefType_FOLLOWS_FROM: FollowsFrom,
}

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
51 changes: 26 additions & 25 deletions internal/storage/v1/cassandra/spanstore/dbmodel/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import (
)

const (
childOf = "child-of"
followsFrom = "follows-from"

stringType = "string"
boolType = "bool"
int64Type = "int64"
float64Type = "float64"
binaryType = "binary"
ChildOf = "child-of"
FollowsFrom = "follows-from"

StringType = "string"
BoolType = "bool"
Int64Type = "int64"
Float64Type = "float64"
BinaryType = "binary"
Comment on lines +19 to +26
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

These identifiers were made exported (ChildOf, FollowsFrom, StringType, etc.) but they don’t have doc comments. With revive enabled repo-wide, exported constants typically need comments (see e.g. index_filter.go). Please add brief comments for these exported constants (or keep them unexported if they’re not part of the intended API).

Suggested change
ChildOf = "child-of"
FollowsFrom = "follows-from"
StringType = "string"
BoolType = "bool"
Int64Type = "int64"
Float64Type = "float64"
BinaryType = "binary"
// ChildOf is the span reference type for a direct child relationship.
ChildOf = "child-of"
// FollowsFrom is the span reference type for a causal, but not direct child, relationship.
FollowsFrom = "follows-from"
// StringType indicates that a KeyValue holds a string value.
StringType = "string"
// BoolType indicates that a KeyValue holds a boolean value.
BoolType = "bool"
// Int64Type indicates that a KeyValue holds a 64-bit integer value.
Int64Type = "int64"
// Float64Type indicates that a KeyValue holds a 64-bit floating-point value.
Float64Type = "float64"
// BinaryType indicates that a KeyValue holds a binary (byte slice) value.
BinaryType = "binary"

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.

@yurishkuro we need this?

)

// Span is the database representation of a span.
Expand All @@ -34,13 +34,14 @@ type Span struct {
OperationName string
Flags int32
StartTime int64 // microseconds since epoch
Duration int64 // microseconds
Tags []KeyValue
Logs []Log
Refs []SpanRef
Process Process
ServiceName string
SpanHash int64
// Duration is the elapsed time expressed in microseconds
Duration int64
Tags []KeyValue
Logs []Log
Refs []SpanRef
Process Process
ServiceName string
SpanHash int64
}

// KeyValue is the UDT representation of a Jaeger KeyValue.
Expand All @@ -56,25 +57,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 @@ -120,18 +121,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
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