-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP][collector] Switch to OTEL's http/grpc server #6277
base: main
Are you sure you want to change the base?
[WIP][collector] Switch to OTEL's http/grpc server #6277
Conversation
Signed-off-by: chahatsagarmain <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6277 +/- ##
==========================================
+ Coverage 48.78% 49.01% +0.23%
==========================================
Files 179 180 +1
Lines 10799 11060 +261
==========================================
+ Hits 5268 5421 +153
- Misses 5088 5190 +102
- Partials 443 449 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -106,7 +104,7 @@ func applyGRPCSettings(cfg *configgrpc.ServerConfig, opts *flags.GRPCOptions) { | |||
cfg.NetAddr.Endpoint = opts.HostPort | |||
} | |||
if opts.TLS.Enabled { | |||
cfg.TLSSetting = applyTLSSettings(&opts.TLS) | |||
cfg.TLSSetting = opts.TLS.ToOtelServerConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the approach in the other PRs is to replace the config field type with configtls
, can we use that here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use configtls.ServerConfig here
jaeger/cmd/collector/app/flags/flags.go
Line 145 in 641ddf2
TLS tlscfg.Options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToOtelServerConfig
just returns nil if tls is not enabled , This will work .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then how should i deal with opts.TLS.Enabled
we should deal with it the same way as in the other PRs. The interface in v1 is CLI flags, it doesn't matter if we translate them into internal TLS config of the one from OTEL.
Signed-off-by: chahatsagarmain <[email protected]>
cmd/collector/app/flags/flags.go
Outdated
@@ -142,7 +143,7 @@ type HTTPOptions struct { | |||
// HostPort is the host:port address that the server listens on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I booked #6279
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we replace HTTPOptions/GRPCOptions types with the ones from OTEL in CollectorOptions
struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
Signed-off-by: chahatsagarmain <[email protected]>
@yurishkuro how do i handle tenancy for GRPC after utilzing configgrpc ? |
corsOpts := corsOTLPFlags.InitFromViper(v) | ||
cOpts.OTLP.HTTP.CORS = corsOpts.ToOTELCorsConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't it part of initHTTPFromViper()?
cmd/collector/app/server/grpc.go
Outdated
@@ -52,9 +53,9 @@ func StartGRPCServer(params *GRPCServerParams) (*grpc.Server, error) { | |||
MaxConnectionAgeGrace: params.MaxConnectionAgeGrace, | |||
})) | |||
|
|||
if params.TLSConfig.Enabled { | |||
if params.TLSConfig != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see the PRs I linked before - this code now becomes much simpler, we just use OTEL helpers to create listener and server, and TLS is handled automatically
pkg/config/corscfg/options.go
Outdated
type Options struct { | ||
AllowedOrigins []string | ||
AllowedHeaders []string | ||
} | ||
|
||
func (o *Options) ToOTELCorsConfig() *confighttp.CORSConfig{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't believe we need this, CORS is built into confighttp.Config
Signed-off-by: chahatsagarmain <[email protected]>
@@ -103,24 +99,24 @@ func (c *Collector) Start(options *flags.CollectorOptions) error { | |||
c.spanHandlers = handlerBuilder.BuildHandlers(c.spanProcessor) | |||
|
|||
grpcServer, err := server.StartGRPCServer(&server.GRPCServerParams{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest changing server.GRPCServerParams to directly embed configgrpc struct, so that you don't have to do any field copying here
Signed-off-by: chahatsagarmain <[email protected]>
@yurishkuro the endpoint is being set correctly in test OTLP HTTP Endpoint: :0 OTLP GRPC Endpoint: :0 but the its throwing an error could not start OTLP receiver: could not start the OTLP receiver: listen: unknown network
|
ServerConfig: &configgrpc.ServerConfig{ | ||
NetAddr: confignet.AddrConfig{ | ||
Endpoint: options.GRPC.NetAddr.Endpoint, | ||
}, | ||
TLSSetting: options.GRPC.TLSSetting, | ||
MaxRecvMsgSizeMiB: options.GRPC.MaxRecvMsgSizeMiB, | ||
Keepalive: options.GRPC.Keepalive, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't we just assign the whole struct?
ServerConfig: &configgrpc.ServerConfig{ | |
NetAddr: confignet.AddrConfig{ | |
Endpoint: options.GRPC.NetAddr.Endpoint, | |
}, | |
TLSSetting: options.GRPC.TLSSetting, | |
MaxRecvMsgSizeMiB: options.GRPC.MaxRecvMsgSizeMiB, | |
Keepalive: options.GRPC.Keepalive, | |
}, | |
ServerConfig: options.GRPC, |
}) | ||
if err != nil { | ||
return fmt.Errorf("could not start gRPC server: %w", err) | ||
} | ||
c.grpcServer = grpcServer | ||
|
||
httpServer, err := server.StartHTTPServer(&server.HTTPServerParams{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
c.logger.Info("Not listening for Zipkin HTTP traffic, port not configured") | ||
} else { | ||
fmt.Printf("%v zipkin\n", options.Zipkin.Endpoint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a log instead
} | ||
opts.TLSSetting = tlsOpts.ToOtelServerConfig() | ||
opts.NetAddr.Endpoint = ports.FormatHostPort(v.GetString(cfg.prefix + "." + flagSuffixHostPort)) | ||
opts.MaxRecvMsgSizeMiB = v.GetInt(cfg.prefix+"."+flagSuffixGRPCMaxReceiveMessageLength) * 1024 * 1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.MaxRecvMsgSizeMiB = v.GetInt(cfg.prefix+"."+flagSuffixGRPCMaxReceiveMessageLength) * 1024 * 1024 | |
opts.MaxRecvMsgSizeMiB = v.GetInt(cfg.prefix+"."+flagSuffixGRPCMaxReceiveMessageLength) / (1024 * 1024) |
cOpts.Zipkin.KeepAlive = v.GetBool(flagZipkinKeepAliveEnabled) | ||
cOpts.Zipkin.HTTPHostPort = ports.FormatHostPort(v.GetString(flagZipkinHTTPHostPort)) | ||
// cOpts.Zipkin. = v.GetBool(flagZipkinKeepAliveEnabled) | ||
cOpts.Zipkin.Endpoint = ports.FormatHostPort(v.GetString(flagZipkinHTTPHostPort)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should't this be simply initHTTPFromViper(..., &cOpts.Zipkin, ...)
?
@@ -107,7 +107,7 @@ func TestCollectorOptionsWithFlags_CheckMaxReceiveMessageLength(t *testing.T) { | |||
_, err := c.InitFromViper(v, zap.NewNop()) | |||
require.NoError(t, err) | |||
|
|||
assert.Equal(t, 8388608, c.GRPC.MaxReceiveMessageLength) | |||
assert.Equal(t, 8388608, c.GRPC.MaxRecvMsgSizeMiB) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't there be a change in the expectation here, due to different units?
"--collector.zipkin.keep-alive=false", | ||
}) | ||
c.InitFromViper(v, zap.NewNop()) | ||
// func TestCollectorOptionsWithFlags_CheckZipkinKeepAlive(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After using confighttp.ServerConfig
for Zipkin how should i use keepalive ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confighttp has liveness settings too, what's the problem?
MaxReceiveMessageLength int | ||
MaxConnectionAge time.Duration | ||
MaxConnectionAgeGrace time.Duration | ||
*configgrpc.ServerConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*configgrpc.ServerConfig | |
configgrpc.ServerConfig |
@@ -24,7 +25,7 @@ import ( | |||
|
|||
// HTTPServerParams to construct a new Jaeger Collector HTTP Server | |||
type HTTPServerParams struct { | |||
TLSConfig tlscfg.Options | |||
TLSConfig *configtls.ServerConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLSConfig *configtls.ServerConfig | |
TLSConfig configtls.ServerConfig |
if params.TLSConfig.Enabled { | ||
tlsCfg, err := params.TLSConfig.Config(params.Logger) // This checks if the certificates are correctly provided | ||
if params.TLSConfig != nil { | ||
tlsCfg, err := params.TLSConfig.LoadTLSConfig(context.Background()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
below you are creating a listener manually. The point was to use ToListener and ToServer from confighttp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the next thing to do after fixing all reviewed issues 👍
Are you missing something like this?
|
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test