Skip to content

Commit 565e8e4

Browse files
committed
observability: ensure method is captured + tests
1 parent ff3c039 commit 565e8e4

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

observability.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type spanWithMetrics struct {
7373

7474
func roundtripTrackingSpan(ctx context.Context, methodName string, traceOpts ...trace.StartOption) (context.Context, *spanWithMetrics) {
7575
ctx, span := trace.StartSpan(ctx, methodName, traceOpts...)
76-
return ctx, &spanWithMetrics{span: span, startTime: time.Now()}
76+
return ctx, &spanWithMetrics{span: span, startTime: time.Now(), method: methodName}
7777
}
7878

7979
func (swm *spanWithMetrics) setError(err error) {

observability_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestUnitRoundtripTrackingOperation(t *testing.T) {
117117
} else {
118118
r0 := vdLatency.Rows[0]
119119
// We need to have the row with the tag "error" since we ended with an error"
120-
wantTags := []tag.Tag{{Key: keyError, Value: errMsg}}
120+
wantTags := []tag.Tag{{Key: keyError, Value: errMsg}, {Key: keyMethod, Value: "a.b.c/D.Foo"}}
121121
if !reflect.DeepEqual(wantTags, r0.Tags) {
122122
t.Errorf("Latency.ViewData.Rows[0].Tags mismatch\nGot: %#v\nWant:%#v\n", r0.Tags, wantTags)
123123
}
@@ -151,7 +151,7 @@ func TestUnitRoundtripTrackingOperation(t *testing.T) {
151151
t.Errorf("Calls.ViewdAta.Rows: Got %d Wanted %d", g, w)
152152
} else {
153153
r0 := vdCalls.Rows[0]
154-
wantTags := []tag.Tag{{Key: keyError, Value: errMsg}}
154+
wantTags := []tag.Tag{{Key: keyError, Value: errMsg}, {Key: keyMethod, Value: "a.b.c/D.Foo"}}
155155
if !reflect.DeepEqual(wantTags, r0.Tags) {
156156
t.Errorf("Calls.ViewData.Rows[0].Tags mismatch\nGot: %#v\nWant:%#v\n", r0.Tags, wantTags)
157157
}

0 commit comments

Comments
 (0)