Skip to content

Commit

Permalink
Update gateway to avoid an extra gRPC call
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Jun 24, 2020
1 parent e193fa5 commit a3482ac
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions receiver/otlpreceiver/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,18 @@ func (r *Receiver) startServer(host component.Host) error {
err := componenterror.ErrAlreadyStarted
r.startServerOnce.Do(func() {
err = nil
// Register the grpc-gateway on the HTTP server mux
c := context.Background()
opts := []grpc.DialOption{grpc.WithInsecure()}
endpoint := r.ln.Addr().String()

_, ok := r.ln.(*net.UnixListener)
if ok {
endpoint = "unix:" + endpoint
}

err = collectortrace.RegisterTraceServiceHandlerFromEndpoint(c, r.gatewayMux, endpoint, opts)
if err != nil {
return
// Register the grpc-gateway on the HTTP server mux
if r.traceReceiver != nil {
if err = collectortrace.RegisterTraceServiceHandlerServer(context.Background(), r.gatewayMux, r.traceReceiver); err != nil {
return
}
}

err = collectormetrics.RegisterMetricsServiceHandlerFromEndpoint(c, r.gatewayMux, endpoint, opts)
if err != nil {
return
if r.metricsReceiver != nil {
if err = collectormetrics.RegisterMetricsServiceHandlerServer(context.Background(), r.gatewayMux, r.metricsReceiver); err != nil {
return
}
}

// Start the gRPC and HTTP/JSON (grpc-gateway) servers on the same port.
Expand Down

0 comments on commit a3482ac

Please sign in to comment.