Skip to content

Commit

Permalink
reuse otel's client config
Browse files Browse the repository at this point in the history
Signed-off-by: Harshvir Potpose <[email protected]>
  • Loading branch information
akagami-harsh committed Apr 7, 2024
1 parent 5c07802 commit 3986d8a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 54 deletions.
9 changes: 5 additions & 4 deletions cmd/jaeger/grpc_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ service:
extensions:
jaeger_query:
trace_storage: external-storage
trace_storage_archive: external-storage-archive
# trace_storage_archive: external-storage-archive
ui_config: ./cmd/jaeger/config-ui.json

jaeger_storage:
grpc:
external-storage:
server: localhost:17271
connection-timeout: 5s
external-storage-archive:
server: localhost:17281
connection-timeout: 5s
compression: gzip
# external-storage-archive:
# server: localhost:17281
# connection-timeout: 5s

receivers:
otlp:
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ require (
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mostynb/go-grpc-compression v1.2.2
github.com/mostynb/go-grpc-compression v1.2.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.97.0 // indirect
Expand Down Expand Up @@ -205,9 +205,9 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.97.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.97.0 // indirect
go.opentelemetry.io/collector/config/configcompression v1.4.0
go.opentelemetry.io/collector/config/configcompression v1.4.0 // indirect
go.opentelemetry.io/collector/config/confignet v0.97.0 // indirect
go.opentelemetry.io/collector/config/configopaque v1.4.0
go.opentelemetry.io/collector/config/configopaque v1.4.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.97.0 // indirect
go.opentelemetry.io/collector/config/internal v0.97.0 // indirect
go.opentelemetry.io/collector/confmap/converter/expandconverter v0.97.0 // indirect
Expand Down
56 changes: 9 additions & 47 deletions plugin/storage/grpc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ import (

"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/mostynb/go-grpc-compression/nonclobbering/snappy"
"github.com/mostynb/go-grpc-compression/nonclobbering/zstd"
"go.opentelemetry.io/collector/config/configcompression"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/encoding/gzip"

"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
"github.com/jaegertracing/jaeger/pkg/tenancy"
Expand All @@ -51,16 +50,11 @@ type Configuration struct {
RemoteConnectTimeout time.Duration `yaml:"connection-timeout" mapstructure:"connection-timeout"`
TenancyOpts tenancy.Options

pluginHealthCheck *time.Ticker
pluginHealthCheckDone chan bool
pluginRPCClient plugin.ClientProtocol
remoteConn *grpc.ClientConn

Compression configcompression.Type `yaml:"compression" mapstructure:"compression"`
ReadBufferSize int `yaml:"read_buffer_size" mapstructure:"read_buffer_size"`
WriteBufferSize int `yaml:"write_buffer_size" mapstructure:"write_buffer_size"`
Authority string `yaml:"authority" mapstructure:"authority"`
WaitForReady bool `yaml:"wait_for_ready" mapstructure:"wait_for_ready"`
pluginHealthCheck *time.Ticker
pluginHealthCheckDone chan bool
pluginRPCClient plugin.ClientProtocol
remoteConn *grpc.ClientConn
configgrpc.ClientConfig `mapstructure:",squash"`
}

// ClientPluginServices defines services plugin can expose and its capabilities
Expand Down Expand Up @@ -102,26 +96,7 @@ func (c *Configuration) buildRemote(logger *zap.Logger, tracerProvider trace.Tra
grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.WaitForReady(c.WaitForReady)),
}

if c.Compression.IsCompressed() {
compressionType, err := getGRPCCompressionName(c.Compression)
if err != nil {
return nil, err
}
opts = append(opts, grpc.WithDefaultCallOptions(grpc.UseCompressor(compressionType)))
}

if c.ReadBufferSize > 0 {
opts = append(opts, grpc.WithReadBufferSize(c.ReadBufferSize))
}
if c.WriteBufferSize > 0 {
opts = append(opts, grpc.WithWriteBufferSize(c.WriteBufferSize))
}

if c.Authority != "" {
opts = append(opts, grpc.WithAuthority(c.Authority))
}

c.ClientConfig.ToClientConn(context.Background(), componenttest.NewNopHost(), component.TelemetrySettings{}, opts...)
if c.RemoteTLS.Enabled {
tlsCfg, err := c.RemoteTLS.Config(logger)
if err != nil {
Expand Down Expand Up @@ -254,16 +229,3 @@ func (c *Configuration) startPluginHealthCheck(rpcClient plugin.ClientProtocol,

return c.pluginRPCClient.Ping()
}

func getGRPCCompressionName(compressionType configcompression.Type) (string, error) {
switch compressionType {
case configcompression.TypeGzip:
return gzip.Name, nil
case configcompression.TypeSnappy:
return snappy.Name, nil
case configcompression.TypeZstd:
return zstd.Name, nil
default:
return "", fmt.Errorf("unsupported compression type %q", compressionType)
}
}

0 comments on commit 3986d8a

Please sign in to comment.