Skip to content
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

Fix dot replacement for int #1272

Merged
merged 1 commit into from
Jan 3, 2019
Merged
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
2 changes: 1 addition & 1 deletion plugin/storage/es/spanstore/dbmodel/to_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (td ToDomain) convertTagField(k string, v interface{}) (model.KeyValue, err
// The number is always a float64 therefore type assertion on int (v.(int/64/32)) does not work.
// If 1.0, 2.0.. was stored as float it will be read as int
if pInt, err := strconv.ParseInt(fmt.Sprintf("%v", v), 10, 64); err == nil {
return model.Int64(k, pInt), nil
return model.Int64(dKey, pInt), nil
}
switch val := v.(type) {
case float64:
Expand Down
4 changes: 4 additions & 0 deletions plugin/storage/es/spanstore/dbmodel/to_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,16 @@ func TestTagsMap(t *testing.T) {
}{
{fieldTags: map[string]interface{}{"bool:bool": true}, expected: []model.KeyValue{model.Bool("bool.bool", true)}},
{fieldTags: map[string]interface{}{"int.int": int64(1)}, expected: []model.KeyValue{model.Int64("int.int", 1)}},
{fieldTags: map[string]interface{}{"int:int": int64(2)}, expected: []model.KeyValue{model.Int64("int.int", 2)}},
{fieldTags: map[string]interface{}{"float": float64(1.1)}, expected: []model.KeyValue{model.Float64("float", 1.1)}},
// we are not able to reproduce type for float 123 or any N.0 number therefore returning int
{fieldTags: map[string]interface{}{"float": float64(123)}, expected: []model.KeyValue{model.Int64("float", 123)}},
{fieldTags: map[string]interface{}{"float": float64(123.0)}, expected: []model.KeyValue{model.Int64("float", 123)}},
{fieldTags: map[string]interface{}{"float:float": float64(123)}, expected: []model.KeyValue{model.Int64("float.float", 123)}},
{fieldTags: map[string]interface{}{"str": "foo"}, expected: []model.KeyValue{model.String("str", "foo")}},
{fieldTags: map[string]interface{}{"str:str": "foo"}, expected: []model.KeyValue{model.String("str.str", "foo")}},
{fieldTags: map[string]interface{}{"binary": []byte("foo")}, expected: []model.KeyValue{model.Binary("binary", []byte("foo"))}},
{fieldTags: map[string]interface{}{"binary:binary": []byte("foo")}, expected: []model.KeyValue{model.Binary("binary.binary", []byte("foo"))}},
{fieldTags: map[string]interface{}{"unsupported": struct{}{}}, err: fmt.Errorf("invalid tag type in %+v", struct{}{})},
}
converter := NewToDomain(":")
Expand Down