test(telemetry): errcheck and Value.String for golangci-lint
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
This commit is contained in:
1 parent
2f3749d1c0
commit
2aa9d8022d
1 file changed
+8
-8
@@ -97,7 +97,7 @@ func TestResourceEnvOverridesDefaults(t *testing.T) {
|
||||
}
|
||||
got := map[string]string{}
|
||||
for _, kv := range tpResource(tp) {
|
||||
got[string(kv.Key)] = kv.Value.Emit()
|
||||
got[string(kv.Key)] = kv.Value.String()
|
||||
}
|
||||
want := map[string]string{"service.name": "tenant-registry-stage", "deployment.environment": "prod", "service.version": "v1", "vcs.ref.head.revision": "c0ffee"}
|
||||
for k, v := range want {
|
||||
@@ -168,8 +168,8 @@ func TestMiddlewareNamesSpanByRoute(t *testing.T) {
|
||||
t.Error("handler context does not carry the server span")
|
||||
}
|
||||
for _, kv := range s.Attributes() {
|
||||
if strings.Contains(kv.Value.Emit(), "acme") || strings.Contains(kv.Value.Emit(), "x=1") {
|
||||
t.Errorf("attribute %s leaks the raw path or query: %q", kv.Key, kv.Value.Emit())
|
||||
if strings.Contains(kv.Value.String(), "acme") || strings.Contains(kv.Value.String(), "x=1") {
|
||||
t.Errorf("attribute %s leaks the raw path or query: %q", kv.Key, kv.Value.String())
|
||||
}
|
||||
}
|
||||
if v, _ := attr(s, "http.response.status_code"); v.AsInt64() != 200 {
|
||||
@@ -205,10 +205,10 @@ func TestTransport(t *testing.T) {
|
||||
get := func(ctx context.Context, path string) error {
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, srv.URL+path, nil)
|
||||
resp, err := client.Do(req)
|
||||
if err == nil {
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
return resp.Body.Close()
|
||||
}
|
||||
|
||||
// Outside a trace: no span, no header.
|
||||
@@ -236,7 +236,7 @@ func TestTransport(t *testing.T) {
|
||||
t.Errorf("client span = %v %q", c.SpanKind(), c.Name())
|
||||
}
|
||||
for _, kv := range c.Attributes() {
|
||||
if strings.Contains(kv.Value.Emit(), "acme") || strings.Contains(kv.Value.Emit(), "token") {
|
||||
if strings.Contains(kv.Value.String(), "acme") || strings.Contains(kv.Value.String(), "token") {
|
||||
t.Errorf("attribute %s leaks the path or query", kv.Key)
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func TestQueryTracer(t *testing.T) {
|
||||
t.Errorf("db.query.text = %q", v.AsString())
|
||||
}
|
||||
for _, kv := range spans[0].Attributes() {
|
||||
if strings.Contains(kv.Value.Emit(), "acme") {
|
||||
if strings.Contains(kv.Value.String(), "acme") {
|
||||
t.Error("query parameters must not be recorded")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user