@@ -3,9 +3,10 @@ package observability_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"queryorchestration/internal/serviceconfig/observability"
|
||||
"testing"
|
||||
|
||||
"queryorchestration/internal/serviceconfig/observability"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
@@ -121,8 +122,9 @@ func New(ctx context.Context, config MetricsConfig) (*Metrics, error) {
|
||||
mux.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
m.server = &http.Server{
|
||||
Addr: fmt.Sprintf(":%d", config.Port),
|
||||
Handler: mux,
|
||||
Addr: fmt.Sprintf(":%d", config.Port),
|
||||
Handler: mux,
|
||||
ReadHeaderTimeout: time.Minute,
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
||||
@@ -27,7 +27,12 @@ func GetFreePortForTesting() (int, error) {
|
||||
defer l.Close()
|
||||
|
||||
// Get the port that was assigned by the OS
|
||||
return l.Addr().(*net.TCPAddr).Port, nil
|
||||
addr, ok := l.Addr().(*net.TCPAddr)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("failed to parse TCP address")
|
||||
}
|
||||
|
||||
return addr.Port, nil
|
||||
}
|
||||
|
||||
func TestMetricsIntegration(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user