(t *testing.T)
| 263 | } |
| 264 | |
| 265 | func TestCollectDoesNotPanic(t *testing.T) { |
| 266 | tests := []struct { |
| 267 | name string |
| 268 | dimensions map[string]string |
| 269 | wantErr bool |
| 270 | }{ |
| 271 | { |
| 272 | name: "invalid prometheus label - __name__", |
| 273 | dimensions: map[string]string{ |
| 274 | "span.attr": "__name__", |
| 275 | }, |
| 276 | wantErr: true, |
| 277 | }, |
| 278 | { |
| 279 | name: "invalid prometheus label - starts with __", |
| 280 | dimensions: map[string]string{ |
| 281 | "resource.service": "__invalid__", |
| 282 | }, |
| 283 | wantErr: true, |
| 284 | }, |
| 285 | { |
| 286 | name: "sanitized into invalid prometheus label", |
| 287 | dimensions: map[string]string{ |
| 288 | "👻👻👻": "", |
| 289 | }, |
| 290 | wantErr: true, |
| 291 | }, |
| 292 | { |
| 293 | name: "sanitized into invalid prometheus label - dashes", |
| 294 | dimensions: map[string]string{ |
| 295 | "--test": "", |
| 296 | }, |
| 297 | wantErr: true, |
| 298 | }, |
| 299 | { |
| 300 | name: "valid dimensions", |
| 301 | dimensions: map[string]string{ |
| 302 | "span.attr": "attribute", |
| 303 | "resource.service": "service", |
| 304 | "span.http.method": "", |
| 305 | }, |
| 306 | wantErr: false, |
| 307 | }, |
| 308 | } |
| 309 | |
| 310 | // Minimal test data |
| 311 | data := []*v1.ResourceSpans{ |
| 312 | { |
| 313 | Resource: &v1resource.Resource{ |
| 314 | Attributes: []*v1common.KeyValue{ |
| 315 | { |
| 316 | Key: "service.name", |
| 317 | Value: &v1common.AnyValue{Value: &v1common.AnyValue_StringValue{StringValue: "svc"}}, |
| 318 | }, |
| 319 | }, |
| 320 | }, |
| 321 | ScopeSpans: []*v1.ScopeSpans{ |
| 322 | { |
nothing calls this directly
no test coverage detected