fix: OpenTelemetry unit tests
This commit is contained in:
parent
9843757834
commit
a3ac456199
1 changed files with 12 additions and 7 deletions
|
@ -287,8 +287,8 @@ func TestOpenTelemetry_GaugeCollectorSet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOpenTelemetry(t *testing.T) {
|
func TestOpenTelemetry(t *testing.T) {
|
||||||
c := make(chan *string)
|
c := make(chan *string, 5)
|
||||||
defer close(c)
|
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
gzr, err := gzip.NewReader(r.Body)
|
gzr, err := gzip.NewReader(r.Body)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -308,7 +308,11 @@ func TestOpenTelemetry(t *testing.T) {
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
close(c)
|
||||||
|
ts.Close()
|
||||||
|
})
|
||||||
|
|
||||||
sURL, err := url.Parse(ts.URL)
|
sURL, err := url.Parse(ts.URL)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -439,10 +443,11 @@ func TestOpenTelemetry(t *testing.T) {
|
||||||
|
|
||||||
assertMessage(t, *msgEntryPointReqDurationHistogram, expectedEntryPointReqDuration)
|
assertMessage(t, *msgEntryPointReqDurationHistogram, expectedEntryPointReqDuration)
|
||||||
|
|
||||||
// We need to unlock the HTTP Server for the last export call when stopping
|
// Stopping OpenTelemetry.
|
||||||
// OpenTelemetry.
|
|
||||||
go func() {
|
go func() {
|
||||||
<-c
|
|
||||||
}()
|
|
||||||
StopOpenTelemetry()
|
StopOpenTelemetry()
|
||||||
|
}()
|
||||||
|
|
||||||
|
// We need to unlock the HTTP Server for the last export call.
|
||||||
|
<-c
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue