ParseDimensionKey take the dimensions key, and gives the scope and the attribute with scope trimmed we are not using traceql.ParseIdentifier because it needs `.` for unscoped attributes and errors out for string without `.` or the scope prefix, also it supports other scopes that we don't support in
(key string)
| 497 | // and errors out for string without `.` or the scope prefix, also it supports other scopes that we don't support |
| 498 | // in cost attribution config |
| 499 | func ParseDimensionKey(key string) (attribute string, scope Scope) { |
| 500 | switch { |
| 501 | case strings.HasPrefix(key, "resource."): |
| 502 | return strings.TrimPrefix(key, "resource."), ScopeResource |
| 503 | case strings.HasPrefix(key, "span."): |
| 504 | return strings.TrimPrefix(key, "span."), ScopeSpan |
| 505 | default: |
| 506 | // it's not `resource.` or `span.` so it's ScopeAll, and the dimensions key is the attribute |
| 507 | return key, ScopeAll |
| 508 | } |
| 509 | } |
no outgoing calls