Files
07582f6e82 fix: use more attribute to derive http_host (#761)
## Pull Request

### Summary
Use net.peer.name as well url.full and http.url to derive the value of
http_host field. After this
change, external_http_url can be deprecated since
it has a confusing name anyway.

### Related Issues
<!-- Reference any related issues (e.g. Fixes #123, Closes #456) -->
Closes https://github.com/SigNoz/engineering-pod/issues/3794

### Resource Impact
**Will this change affect the application's resource usage?**
- [ ] Yes
- [x] No

If **Yes**, describe:
- **Resources impacted:** (CPU, Memory, Disk, Network, etc.)
- **Expected change:** (e.g., +10% CPU, -150MB RAM)
- **Benchmarks:** Provide before/after results and how they were
measured.
  
<!-- Ideally the test should be done where you keep ingestion rate and
configuration same
and observe the changes in CPU, Memory, Ingestion Rate and the Lag on
Kafka>

---------

Co-authored-by: Nityananda Gohain <[email protected]>
2026-02-05 16:14:38 +05:30

72 lines
1.4 KiB
Go

package utils
import (
"testing"
)
func TestToLookUpMap_String(t *testing.T) {
tests := []struct {
name string
input []string
wantKeys []string
}{
{
name: "with duplicates",
input: []string{"a", "b", "c", "a"},
wantKeys: []string{"a", "b", "c"},
},
{
name: "single element",
input: []string{"x"},
wantKeys: []string{"x"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := ToLookUpMap(tt.input)
if len(result) != len(tt.wantKeys) {
t.Fatalf("expected %d entries, got %d", len(tt.wantKeys), len(result))
}
for _, k := range tt.wantKeys {
if _, ok := result[k]; !ok {
t.Errorf("expected key %q in map", k)
}
}
})
}
}
func TestToLookUpMap_Int(t *testing.T) {
tests := []struct {
name string
input []int
wantKeys []int
}{
{
name: "with duplicates",
input: []int{1, 2, 3, 1},
wantKeys: []int{1, 2, 3},
},
{
name: "single element",
input: []int{42},
wantKeys: []int{42},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := ToLookUpMap(tt.input)
if len(result) != len(tt.wantKeys) {
t.Fatalf("expected %d entries, got %d", len(tt.wantKeys), len(result))
}
for _, k := range tt.wantKeys {
if _, ok := result[k]; !ok {
t.Errorf("expected key %d in map", k)
}
}
})
}
}