Files
traces/pkg/util/attributes_test.go
MarioandGitHub f87e304b60 Service graphs: add dimensions and rename expired edges metric (#1361)
* Service graphs: add dimensions and rename expired edges metric

Add dimensions to the service graphs processor config, which attaches
additional labels to the metrics from spans attributes.

It also renames the expired edges internal metric.

* Address comments
2022-04-06 17:10:42 +03:00

94 lines
1.7 KiB
Go

package util
import (
"testing"
v1common "github.com/grafana/tempo/pkg/tempopb/common/v1"
"github.com/stretchr/testify/assert"
)
func TestStringifyAnyValue(t *testing.T) {
testCases := []struct {
name string
v *v1common.AnyValue
expected string
}{
{
name: "string value",
v: &v1common.AnyValue{
Value: &v1common.AnyValue_StringValue{
StringValue: "test",
},
},
expected: "test",
},
{
name: "int value",
v: &v1common.AnyValue{
Value: &v1common.AnyValue_IntValue{
IntValue: 1,
},
},
expected: "1",
},
{
name: "bool value",
v: &v1common.AnyValue{
Value: &v1common.AnyValue_BoolValue{
BoolValue: true,
},
},
expected: "true",
},
{
name: "float value",
v: &v1common.AnyValue{
Value: &v1common.AnyValue_DoubleValue{
DoubleValue: 1.1,
},
},
expected: "1.1",
},
{
name: "array value",
v: &v1common.AnyValue{
Value: &v1common.AnyValue_ArrayValue{
ArrayValue: &v1common.ArrayValue{
Values: []*v1common.AnyValue{
{
Value: &v1common.AnyValue_StringValue{
StringValue: "test",
},
},
},
},
},
},
expected: "[test]",
},
{
name: "map value",
v: &v1common.AnyValue{
Value: &v1common.AnyValue_KvlistValue{
KvlistValue: &v1common.KeyValueList{
Values: []*v1common.KeyValue{
{
Key: "key",
Value: &v1common.AnyValue{Value: &v1common.AnyValue_StringValue{StringValue: "value"}},
},
},
},
},
},
expected: "{key:value}",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
str := StringifyAnyValue(tc.v)
assert.Equal(t, tc.expected, str)
})
}
}