(t *testing.T)
| 361 | } |
| 362 | |
| 363 | func TestSpanClassifier(t *testing.T) { |
| 364 | tests := []struct { |
| 365 | name string |
| 366 | span RawSpan |
| 367 | wantType string |
| 368 | wantAddress string |
| 369 | }{ |
| 370 | { |
| 371 | name: "db.query", |
| 372 | span: RawSpan{Op: "db.query", Data: map[string]string{"server.address": "db.host.com"}}, |
| 373 | wantType: "db", |
| 374 | wantAddress: "db.host.com", |
| 375 | }, |
| 376 | { |
| 377 | name: "db with db.name fallback", |
| 378 | span: RawSpan{Op: "db.redis", Data: map[string]string{"db.name": "cache-0"}}, |
| 379 | wantType: "db", |
| 380 | wantAddress: "cache-0", |
| 381 | }, |
| 382 | { |
| 383 | name: "http.client", |
| 384 | span: RawSpan{Op: "http.client", Data: map[string]string{"http.url": "https://api.example.com:8080/path"}}, |
| 385 | wantType: "http", |
| 386 | wantAddress: "api.example.com:8080", |
| 387 | }, |
| 388 | { |
| 389 | name: "cache.get", |
| 390 | span: RawSpan{Op: "cache.get", Data: map[string]string{"server.address": "redis.local"}}, |
| 391 | wantType: "cache", |
| 392 | wantAddress: "redis.local", |
| 393 | }, |
| 394 | { |
| 395 | name: "queue.publish", |
| 396 | span: RawSpan{Op: "queue.publish", Data: map[string]string{"messaging.destination": "orders-queue"}}, |
| 397 | wantType: "queue", |
| 398 | wantAddress: "orders-queue", |
| 399 | }, |
| 400 | { |
| 401 | name: "unknown op", |
| 402 | span: RawSpan{Op: "custom.op"}, |
| 403 | wantType: "unknown", |
| 404 | }, |
| 405 | } |
| 406 | |
| 407 | for _, tt := range tests { |
| 408 | t.Run(tt.name, func(t *testing.T) { |
| 409 | peerType, peerAddress := classifySpan(tt.span) |
| 410 | if peerType != tt.wantType { |
| 411 | t.Errorf("peerType = %q, want %q", peerType, tt.wantType) |
| 412 | } |
| 413 | if peerAddress != tt.wantAddress { |
| 414 | t.Errorf("peerAddress = %q, want %q", peerAddress, tt.wantAddress) |
| 415 | } |
| 416 | }) |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | func TestEnvelopeParser(t *testing.T) { |
nothing calls this directly
no test coverage detected