Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize CLI flags to use host:port addresses #1827

Merged
merged 21 commits into from
Mar 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Continue support for deprecated flags in all-in-one
Signed-off-by: Annanay <annanay.a@media.net>
  • Loading branch information
Annanay committed Oct 2, 2019
commit 1ad013f486afdeb39ae788ea49f30bc243139c0e
24 changes: 20 additions & 4 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,18 @@ func startCollector(
server.Register(jc.NewTChanCollectorServer(batchHandler))
server.Register(zc.NewTChanZipkinCollectorServer(batchHandler))
server.Register(sc.NewTChanSamplingManagerServer(sampling.NewHandler(strategyStore)))
listener, err := net.Listen("tcp", cOpts.CollectorTChanAddr)

tchanAddr := getAddressFromCLIOptions(cOpts.CollectorPort, cOpts.CollectorTChanAddr, "collector.http-port", logger)
listener, err := net.Listen("tcp", tchanAddr)
if err != nil {
logger.Fatal("Unable to start listening on channel", zap.Error(err))
}
logger.Info("Starting jaeger-collector TChannel server", zap.String("addr", cOpts.CollectorTChanAddr))
ch.Serve(listener)
}

server, err := startGRPCServer(cOpts.CollectorGRPCAddr, grpcHandler, strategyStore, logger)
grpcAddr := getAddressFromCLIOptions(cOpts.CollectorGRPCPort, cOpts.CollectorGRPCAddr, "collector.grpc-port", logger)
server, err := startGRPCServer(grpcAddr, grpcHandler, strategyStore, logger)
if err != nil {
logger.Fatal("Could not start gRPC collector", zap.Error(err))
}
Expand All @@ -252,11 +255,14 @@ func startCollector(
apiHandler.RegisterRoutes(r)
recoveryHandler := recoveryhandler.NewRecoveryHandler(logger, true)

go startZipkinHTTPAPI(logger, cOpts.CollectorZipkinHTTPAddr, zipkinSpansHandler, recoveryHandler)
zipkinAddr := getAddressFromCLIOptions(cOpts.CollectorZipkinHTTPPort, cOpts.CollectorZipkinHTTPAddr, "collector.zipkin.http-port", logger)

go startZipkinHTTPAPI(logger, zipkinAddr, zipkinSpansHandler, recoveryHandler)

logger.Info("Starting jaeger-collector HTTP server", zap.String("http-addr", cOpts.CollectorHTTPAddr))
go func() {
if err := http.ListenAndServe(cOpts.CollectorHTTPAddr, recoveryHandler(r)); err != nil {
httpAddr := getAddressFromCLIOptions(cOpts.CollectorHTTPPort, cOpts.CollectorHTTPAddr, "collector.http-port", logger)
if err := http.ListenAndServe(httpAddr, recoveryHandler(r)); err != nil {
logger.Fatal("Could not launch jaeger-collector HTTP server", zap.Error(err))
}
hc.Set(healthcheck.Unavailable)
Expand Down Expand Up @@ -358,3 +364,13 @@ func initTracer(metricsFactory metrics.Factory, logger *zap.Logger) io.Closer {
opentracing.SetGlobalTracer(tracer)
return closer
}

// Utility function to decide listening address based on port (deprecated flags) or host:port (new flags)
func getAddressFromCLIOptions(port int, addr string, deprecatedFlag string, logger *zap.Logger) string {
annanay25 marked this conversation as resolved.
Show resolved Hide resolved
if port != 0 {
logger.Warn("Using deprecated configuration", zap.String("option", deprecatedFlag))
return ports.PortToHostPort(port)
}

return addr
}