Add tracing manifests and docs; clean up branch lint findings

Manager env block (downward-API resource attrs, commented OTLP
examples), architecture §10 + Decisions entries, README section.
Lint: goconst constants, gofmt, logcheck (Setup now takes its logger
from ctx via logf.FromContext).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-08-24 11:30:27 +02:00
parent 53c0d77ef5
commit aeb4115c72
10 changed files with 207 additions and 44 deletions

View File

@@ -50,17 +50,25 @@ func (i *instrumented) record(op string, err error) {
i.rec.ProviderRequest(i.name, op, resultLabel(err))
}
const (
resultOK = "ok"
resultNotFound = "not_found"
resultQuotaExceeded = "quota_exceeded"
resultPermanent = "permanent"
resultTransient = "transient"
)
func resultLabel(err error) string {
switch Class(err) {
case nil:
return "ok"
return resultOK
case ErrNotFound:
return "not_found"
return resultNotFound
case ErrQuotaExceeded:
return "quota_exceeded"
return resultQuotaExceeded
case ErrPermanent:
return "permanent"
return resultPermanent
default:
return "transient"
return resultTransient
}
}

View File

@@ -33,7 +33,7 @@ func TestWithTracing_spanPerCall(t *testing.T) {
call: func(p Provider) error { _, err := p.Create(context.Background(), CreateRequest{}); return err },
wantSpan: "provider.create",
wantStatus: codes.Ok,
wantResult: "ok",
wantResult: resultOK,
wantAttr: attribute.String("provider.id", "id-1"),
},
{
@@ -42,7 +42,7 @@ func TestWithTracing_spanPerCall(t *testing.T) {
call: func(p Provider) error { _, err := p.Get(context.Background(), "id-1"); return err },
wantSpan: "provider.get",
wantStatus: codes.Ok,
wantResult: "not_found",
wantResult: resultNotFound,
wantAttr: attribute.String("provider.id", "id-1"),
},
{
@@ -51,7 +51,7 @@ func TestWithTracing_spanPerCall(t *testing.T) {
call: func(p Provider) error { return p.Delete(context.Background(), "id-1") },
wantSpan: "provider.delete",
wantStatus: codes.Error,
wantResult: "transient",
wantResult: resultTransient,
wantAttr: attribute.String("provider.id", "id-1"),
},
{
@@ -60,7 +60,7 @@ func TestWithTracing_spanPerCall(t *testing.T) {
call: func(p Provider) error { _, err := p.Create(context.Background(), CreateRequest{}); return err },
wantSpan: "provider.create",
wantStatus: codes.Error,
wantResult: "quota_exceeded",
wantResult: resultQuotaExceeded,
wantAttr: attribute.String("provider.name", "x"),
},
{
@@ -69,7 +69,7 @@ func TestWithTracing_spanPerCall(t *testing.T) {
call: func(p Provider) error { _, err := p.ListByTag(context.Background()); return err },
wantSpan: "provider.list",
wantStatus: codes.Ok,
wantResult: "ok",
wantResult: resultOK,
wantAttr: attribute.Int("provider.instances", 0),
},
}