Skip to content

Commit 0f2d50a

Browse files
[WIP][collector] Switch to OTEL's http/grpc server (#6277)
## Which problem is this PR solving? - Part of #4316 - Resolves #6279 ## Description of the changes - ## How was this change tested? - ## Checklist - [ ] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [ ] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: chahatsagarmain <[email protected]> Signed-off-by: chahat sagar <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
1 parent 53a8053 commit 0f2d50a

19 files changed

+370
-496
lines changed

cmd/all-in-one/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ by default uses only in-memory database.`,
149149
logger.Fatal("Failed to configure query service", zap.Error(err))
150150
}
151151

152-
tm := tenancy.NewManager(&cOpts.GRPC.Tenancy)
152+
tm := tenancy.NewManager(&cOpts.Tenancy)
153153

154154
// collector
155155
c := collectorApp.New(&collectorApp.CollectorParams{

cmd/collector/app/collector.go

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package app
66
import (
77
"context"
88
"fmt"
9-
"io"
109
"net/http"
1110
"time"
1211

@@ -47,13 +46,10 @@ type Collector struct {
4746
tenancyMgr *tenancy.Manager
4847

4948
// state, read only
50-
hServer *http.Server
51-
grpcServer *grpc.Server
52-
otlpReceiver receiver.Traces
53-
zipkinReceiver receiver.Traces
54-
tlsGRPCCertWatcherCloser io.Closer
55-
tlsHTTPCertWatcherCloser io.Closer
56-
tlsZipkinCertWatcherCloser io.Closer
49+
hServer *http.Server
50+
grpcServer *grpc.Server
51+
otlpReceiver receiver.Traces
52+
zipkinReceiver receiver.Traces
5753
}
5854

5955
// CollectorParams to construct a new Jaeger Collector.
@@ -101,26 +97,19 @@ func (c *Collector) Start(options *flags.CollectorOptions) error {
10197

10298
c.spanProcessor = handlerBuilder.BuildSpanProcessor(additionalProcessors...)
10399
c.spanHandlers = handlerBuilder.BuildHandlers(c.spanProcessor)
104-
105100
grpcServer, err := server.StartGRPCServer(&server.GRPCServerParams{
106-
HostPort: options.GRPC.HostPort,
107-
Handler: c.spanHandlers.GRPCHandler,
108-
TLSConfig: options.GRPC.TLS,
109-
SamplingProvider: c.samplingProvider,
110-
Logger: c.logger,
111-
MaxReceiveMessageLength: options.GRPC.MaxReceiveMessageLength,
112-
MaxConnectionAge: options.GRPC.MaxConnectionAge,
113-
MaxConnectionAgeGrace: options.GRPC.MaxConnectionAgeGrace,
101+
Handler: c.spanHandlers.GRPCHandler,
102+
SamplingProvider: c.samplingProvider,
103+
Logger: c.logger,
104+
ServerConfig: options.GRPC,
114105
})
115106
if err != nil {
116107
return fmt.Errorf("could not start gRPC server: %w", err)
117108
}
118109
c.grpcServer = grpcServer
119-
120110
httpServer, err := server.StartHTTPServer(&server.HTTPServerParams{
121-
HostPort: options.HTTP.HostPort,
111+
ServerConfig: options.HTTP,
122112
Handler: c.spanHandlers.JaegerBatchesHandler,
123-
TLSConfig: options.HTTP.TLS,
124113
HealthCheck: c.hCheck,
125114
MetricsFactory: c.metricsFactory,
126115
SamplingProvider: c.samplingProvider,
@@ -131,11 +120,7 @@ func (c *Collector) Start(options *flags.CollectorOptions) error {
131120
}
132121
c.hServer = httpServer
133122

134-
c.tlsGRPCCertWatcherCloser = &options.GRPC.TLS
135-
c.tlsHTTPCertWatcherCloser = &options.HTTP.TLS
136-
c.tlsZipkinCertWatcherCloser = &options.Zipkin.TLS
137-
138-
if options.Zipkin.HTTPHostPort == "" {
123+
if options.Zipkin.Endpoint == "" {
139124
c.logger.Info("Not listening for Zipkin HTTP traffic, port not configured")
140125
} else {
141126
zipkinReceiver, err := handler.StartZipkinReceiver(options, c.logger, c.spanProcessor, c.tenancyMgr)
@@ -209,17 +194,6 @@ func (c *Collector) Close() error {
209194
}
210195
}
211196

212-
// watchers actually never return errors from Close
213-
if c.tlsGRPCCertWatcherCloser != nil {
214-
_ = c.tlsGRPCCertWatcherCloser.Close()
215-
}
216-
if c.tlsHTTPCertWatcherCloser != nil {
217-
_ = c.tlsHTTPCertWatcherCloser.Close()
218-
}
219-
if c.tlsZipkinCertWatcherCloser != nil {
220-
_ = c.tlsZipkinCertWatcherCloser.Close()
221-
}
222-
223197
return nil
224198
}
225199

cmd/collector/app/collector_test.go

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import (
1313

1414
"github.com/stretchr/testify/assert"
1515
"github.com/stretchr/testify/require"
16+
"go.opentelemetry.io/collector/config/configgrpc"
17+
"go.opentelemetry.io/collector/config/confighttp"
18+
"go.opentelemetry.io/collector/config/confignet"
19+
"go.opentelemetry.io/collector/config/configtls"
1620
"go.uber.org/zap"
1721

1822
"github.com/jaegertracing/jaeger/cmd/collector/app/flags"
@@ -27,13 +31,54 @@ import (
2731
var _ (io.Closer) = (*Collector)(nil)
2832

2933
func optionsForEphemeralPorts() *flags.CollectorOptions {
30-
collectorOpts := &flags.CollectorOptions{}
31-
collectorOpts.GRPC.HostPort = ":0"
32-
collectorOpts.HTTP.HostPort = ":0"
33-
collectorOpts.OTLP.Enabled = true
34-
collectorOpts.OTLP.GRPC.HostPort = ":0"
35-
collectorOpts.OTLP.HTTP.HostPort = ":0"
36-
collectorOpts.Zipkin.HTTPHostPort = ":0"
34+
collectorOpts := &flags.CollectorOptions{
35+
HTTP: confighttp.ServerConfig{
36+
Endpoint: ":0",
37+
TLSSetting: &configtls.ServerConfig{},
38+
},
39+
GRPC: configgrpc.ServerConfig{
40+
NetAddr: confignet.AddrConfig{
41+
Endpoint: ":0",
42+
Transport: confignet.TransportTypeTCP,
43+
},
44+
Keepalive: &configgrpc.KeepaliveServerConfig{
45+
ServerParameters: &configgrpc.KeepaliveServerParameters{
46+
MaxConnectionIdle: 10,
47+
},
48+
},
49+
},
50+
OTLP: struct {
51+
Enabled bool
52+
GRPC configgrpc.ServerConfig
53+
HTTP confighttp.ServerConfig
54+
}{
55+
Enabled: true,
56+
HTTP: confighttp.ServerConfig{
57+
Endpoint: ":0",
58+
TLSSetting: &configtls.ServerConfig{},
59+
},
60+
GRPC: configgrpc.ServerConfig{
61+
NetAddr: confignet.AddrConfig{
62+
Endpoint: ":0",
63+
Transport: confignet.TransportTypeTCP,
64+
},
65+
Keepalive: &configgrpc.KeepaliveServerConfig{
66+
ServerParameters: &configgrpc.KeepaliveServerParameters{
67+
MaxConnectionIdle: 10,
68+
},
69+
},
70+
},
71+
},
72+
Zipkin: struct {
73+
confighttp.ServerConfig
74+
KeepAlive bool
75+
}{
76+
ServerConfig: confighttp.ServerConfig{
77+
Endpoint: ":0",
78+
},
79+
},
80+
Tenancy: tenancy.Options{},
81+
}
3782
return collectorOpts
3883
}
3984

@@ -112,23 +157,23 @@ func TestCollector_StartErrors(t *testing.T) {
112157
var options *flags.CollectorOptions
113158

114159
options = optionsForEphemeralPorts()
115-
options.GRPC.HostPort = ":-1"
160+
options.GRPC.NetAddr.Endpoint = ":-1"
116161
run("gRPC", options, "could not start gRPC server")
117162

118163
options = optionsForEphemeralPorts()
119-
options.HTTP.HostPort = ":-1"
164+
options.HTTP.Endpoint = ":-1"
120165
run("HTTP", options, "could not start HTTP server")
121166

122167
options = optionsForEphemeralPorts()
123-
options.Zipkin.HTTPHostPort = ":-1"
168+
options.Zipkin.Endpoint = ":-1"
124169
run("Zipkin", options, "could not start Zipkin receiver")
125170

126171
options = optionsForEphemeralPorts()
127-
options.OTLP.GRPC.HostPort = ":-1"
172+
options.OTLP.GRPC.NetAddr.Endpoint = ":-1"
128173
run("OTLP/GRPC", options, "could not start OTLP receiver")
129174

130175
options = optionsForEphemeralPorts()
131-
options.OTLP.HTTP.HostPort = ":-1"
176+
options.OTLP.HTTP.Endpoint = ":-1"
132177
run("OTLP/HTTP", options, "could not start OTLP receiver")
133178
}
134179

0 commit comments

Comments
 (0)