From 28a87c05d5593b55f566c71776e67d42c6535c72 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 3 Jan 2019 16:42:15 +0100 Subject: [PATCH] Fix dot replacement for int Signed-off-by: Pavol Loffay --- plugin/storage/es/spanstore/dbmodel/to_domain.go | 2 +- plugin/storage/es/spanstore/dbmodel/to_domain_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/storage/es/spanstore/dbmodel/to_domain.go b/plugin/storage/es/spanstore/dbmodel/to_domain.go index 104e0105a954..105418ed3332 100644 --- a/plugin/storage/es/spanstore/dbmodel/to_domain.go +++ b/plugin/storage/es/spanstore/dbmodel/to_domain.go @@ -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: diff --git a/plugin/storage/es/spanstore/dbmodel/to_domain_test.go b/plugin/storage/es/spanstore/dbmodel/to_domain_test.go index 7a26a4d7d2de..d1578ea56d3b 100644 --- a/plugin/storage/es/spanstore/dbmodel/to_domain_test.go +++ b/plugin/storage/es/spanstore/dbmodel/to_domain_test.go @@ -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(":")