1
0
Fork 0

fix: opentelemetry unit tests

This commit is contained in:
Michael 2024-01-24 16:58:05 +01:00 committed by GitHub
parent 190b9b1afa
commit aece9a1051
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 71 additions and 55 deletions

View file

@ -13,12 +13,13 @@ import (
)
func TestDatadog(t *testing.T) {
t.Cleanup(StopDatadog)
udp.SetAddr(":18125")
// This is needed to make sure that UDP Listener listens for data a bit longer, otherwise it will quit after a millisecond
udp.Timeout = 5 * time.Second
datadogRegistry := RegisterDatadog(context.Background(), &types.Datadog{Address: ":18125", PushInterval: ptypes.Duration(time.Second), AddEntryPointsLabels: true, AddRoutersLabels: true, AddServicesLabels: true})
defer StopDatadog()
if !datadogRegistry.IsEpEnabled() || !datadogRegistry.IsRouterEnabled() || !datadogRegistry.IsSvcEnabled() {
t.Errorf("DatadogRegistry should return true for IsEnabled(), IsRouterEnabled() and IsSvcEnabled()")
@ -27,9 +28,7 @@ func TestDatadog(t *testing.T) {
}
func TestDatadogWithPrefix(t *testing.T) {
t.Cleanup(func() {
StopDatadog()
})
t.Cleanup(StopDatadog)
udp.SetAddr(":18125")
// This is needed to make sure that UDP Listener listens for data a bit longer, otherwise it will quit after a millisecond