Skip to content

Commit

Permalink
rmvs key-value pair
Browse files Browse the repository at this point in the history
Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com>
  • Loading branch information
sbin64 committed Aug 10, 2023
1 parent 3c8cb9a commit ae6b659
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions examples/hotrod/pkg/tracing/rpcmetrics/observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ func TestObserver(t *testing.T) {
}

for _, testCase := range testCases {
_, span := testTracer.tracer.Start(context.Background(), testCase.name, trace.WithSpanKind(testCase.spanKind), trace.WithTimestamp(ts))
_, span := testTracer.tracer.Start(
context.Background(),
testCase.name, trace.WithSpanKind(testCase.spanKind),
trace.WithTimestamp(ts),
)
if testCase.opNameOverride != "" {
span.SetName(testCase.opNameOverride)
}
Expand All @@ -100,18 +104,16 @@ func TestObserver(t *testing.T) {

func TestTags(t *testing.T) {
type tagTestCase struct {
key string
variant string
value interface{}
attr attribute.KeyValue
metrics []u.ExpectedMetric
}

testCases := []tagTestCase{
{key: "something", value: 42, attr: attribute.Key("something").String(fmt.Sprint(42)), metrics: []u.ExpectedMetric{
{attr: attribute.Key("something").Int(42), metrics: []u.ExpectedMetric{
{Name: "requests", Value: 1, Tags: tags("error", "false")},
}},
{key: "error", value: true, attr: attribute.Key("error").String(fmt.Sprint(true)), metrics: []u.ExpectedMetric{
{attr: attribute.Key("error").Bool(true), metrics: []u.ExpectedMetric{
{Name: "requests", Value: 1, Tags: tags("error", "true")},
}},
}
Expand All @@ -127,8 +129,6 @@ func TestTags(t *testing.T) {
}
for _, v := range status_codes {
testCases = append(testCases, tagTestCase{
key: "http.status_code",
value: v.value,
attr: attribute.Key("http.status_code").String(fmt.Sprint(v.value)),
variant: v.variant,
metrics: []u.ExpectedMetric{
Expand All @@ -142,9 +142,12 @@ func TestTags(t *testing.T) {
for i := range testCase.metrics {
testCase.metrics[i].Tags["endpoint"] = "span"
}
t.Run(fmt.Sprintf("%s-%v-%s", testCase.key, testCase.value, testCase.variant), func(t *testing.T) {
t.Run(fmt.Sprintf("%s-%v-%s", testCase.attr.Key, testCase.attr.Value, testCase.variant), func(t *testing.T) {
withTestTracer(func(testTracer *testTracer) {
_, span := testTracer.tracer.Start(context.Background(), "span", trace.WithSpanKind(trace.SpanKindServer))
_, span := testTracer.tracer.Start(
context.Background(),
"span", trace.WithSpanKind(trace.SpanKindServer),
)
span.SetAttributes(testCase.attr)
span.End()
testTracer.metrics.AssertCounterMetrics(t, testCase.metrics...)
Expand Down

0 comments on commit ae6b659

Please sign in to comment.