(t *testing.T)
| 576 | } |
| 577 | |
| 578 | func 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 | |
| 611 | func BenchmarkUsageTrackerObserve(b *testing.B) { |
| 612 | var ( |
nothing calls this directly
no test coverage detected