MCPcopy
hub / github.com/grafana/tempo / TestParseDimensionKey

Function TestParseDimensionKey

modules/distributor/usage/tracker_test.go:578–609  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

576}
577
578func TestParseDimensionKey(t *testing.T) {
579 tests := []struct {
580 input string
581 expectedAttr string
582 expectedScope Scope
583 }{
584 {input: "resource.service.name", expectedAttr: "service.name", expectedScope: ScopeResource},
585 {input: "resource.k8s.cluster.name", expectedAttr: "k8s.cluster.name", expectedScope: ScopeResource},
586 {input: "resource.k8s.namespace.name", expectedAttr: "k8s.namespace.name", expectedScope: ScopeResource},
587 {input: "resource.telemetry.sdk.name", expectedAttr: "telemetry.sdk.name", expectedScope: ScopeResource},
588 {input: "span.db.system", expectedAttr: "db.system", expectedScope: ScopeSpan},
589 {input: "span.http.method", expectedAttr: "http.method", expectedScope: ScopeSpan},
590 {input: "span.rpc.method", expectedAttr: "rpc.method", expectedScope: ScopeSpan},
591 {input: "span.k8s.namespace.name", expectedAttr: "k8s.namespace.name", expectedScope: ScopeSpan},
592 {input: "http.status_code", expectedAttr: "http.status_code", expectedScope: ScopeAll},
593 {input: "service.name", expectedAttr: "service.name", expectedScope: ScopeAll},
594 {input: "k8s.namespace.name", expectedAttr: "k8s.namespace.name", expectedScope: ScopeAll},
595 {input: "k8s.cluster.name", expectedAttr: "k8s.cluster.name", expectedScope: ScopeAll},
596 {input: "user.team", expectedAttr: "user.team", expectedScope: ScopeAll},
597 {input: "teamName", expectedAttr: "teamName", expectedScope: ScopeAll},
598 {input: "team_name", expectedAttr: "team_name", expectedScope: ScopeAll},
599 {input: "MyCustomAttribute", expectedAttr: "MyCustomAttribute", expectedScope: ScopeAll},
600 }
601
602 for _, tt := range tests {
603 t.Run(tt.input, func(t *testing.T) {
604 attr, scope := ParseDimensionKey(tt.input)
605 require.Equal(t, tt.expectedAttr, attr)
606 require.Equal(t, tt.expectedScope, scope)
607 })
608 }
609}
610
611func BenchmarkUsageTrackerObserve(b *testing.B) {
612 var (

Callers

nothing calls this directly

Calls 3

ParseDimensionKeyFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected