Skip to content

Commit 05603c0

Browse files
author
Yuri Shkuro
committed
Fix tests
Signed-off-by: Yuri Shkuro <ys@uber.com>
1 parent 6df9249 commit 05603c0

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

cmd/agent/app/builder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ func (b *Builder) CreateAgent(logger *zap.Logger) (*Agent, error) {
154154
return nil, err
155155
}
156156
httpServer := b.HTTPServer.GetHTTPServer(b.CollectorServiceName, mainReporter.Channel(), mFactory)
157-
if b.metricsFactory == nil {
158-
httpServer.Handler.(*http.ServeMux).Handle(b.Metrics.HTTPRoute, b.Metrics.Handler())
157+
if h := b.Metrics.Handler(); b.metricsFactory != nil && h != nil {
158+
httpServer.Handler.(*http.ServeMux).Handle(b.Metrics.HTTPRoute, h)
159159
}
160160
return NewAgent(processors, httpServer, logger), nil
161161
}

pkg/metrics/builder_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package metrics
1616

1717
import (
1818
"flag"
19-
"net/http"
2019
"testing"
2120

2221
"github.com/spf13/cobra"
@@ -89,9 +88,7 @@ func TestBuilder(t *testing.T) {
8988
}
9089
require.NotNil(t, mf)
9190
if testCase.handler {
92-
require.NotNil(t, b.handler)
93-
mux := http.NewServeMux()
94-
b.RegisterHandler(mux.Handle)
91+
require.NotNil(t, b.Handler())
9592
}
9693
}
9794
}

0 commit comments

Comments
 (0)