Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/config/configtest"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/exporter/jaegerexporter"

"github.com/jaegertracing/jaeger/cmd/opentelemetry/app/receiver/jaegerreceiver"
Expand Down Expand Up @@ -59,10 +62,28 @@ func TestDefaultValueFromViper(t *testing.T) {
}

cfg := f.CreateDefaultConfig().(*jaegerexporter.Config)
assert.Equal(t, "foo", cfg.GRPCClientSettings.Endpoint)
tlsConfig := cfg.TLSSetting
assert.Equal(t, false, tlsConfig.Insecure)
assert.Equal(t, "ca.crt", tlsConfig.CAFile)

qs := exporterhelper.CreateDefaultQueueSettings()
qs.Enabled = false
assert.Equal(t, &jaegerexporter.Config{
ExporterSettings: configmodels.ExporterSettings{
TypeVal: "jaeger",
NameVal: "jaeger",
},
TimeoutSettings: exporterhelper.CreateDefaultTimeoutSettings(),
RetrySettings: exporterhelper.CreateDefaultRetrySettings(),
QueueSettings: qs,
GRPCClientSettings: configgrpc.GRPCClientSettings{
WriteBufferSize: 512 * 1024,
Endpoint: "foo",
TLSSetting: configtls.TLSClientSetting{
Insecure: false,
TLSSetting: configtls.TLSSetting{
CAFile: "ca.crt",
},
},
},
}, cfg)
}

func TestLoadConfigAndFlags(t *testing.T) {
Expand Down
21 changes: 15 additions & 6 deletions cmd/opentelemetry/app/receiver/jaegerreceiver/jaeger_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package jaegerreceiver

import (
"context"
"fmt"

"github.com/spf13/viper"
"go.opentelemetry.io/collector/component"
Expand All @@ -31,6 +32,7 @@ import (
grpcRep "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc"
collectorApp "github.com/jaegertracing/jaeger/cmd/collector/app"
"github.com/jaegertracing/jaeger/plugin/sampling/strategystore/static"
"github.com/jaegertracing/jaeger/ports"
)

// Factory wraps jaegerreceiver.Factory and makes the default config configurable via viper.
Expand Down Expand Up @@ -87,15 +89,22 @@ func configureCollector(v *viper.Viper, cfg *jaegerreceiver.Config) {
Endpoint: cOpts.CollectorGRPCHostPort,
},
}
if cOpts.TLS.CertPath != "" && cOpts.TLS.KeyPath != "" {
cfg.GRPC.TLSSetting = &configtls.TLSServerSetting{
ClientCAFile: cOpts.TLS.ClientCAPath,
TLSSetting: configtls.TLSSetting{
KeyFile: cOpts.TLS.KeyPath,
CertFile: cOpts.TLS.CertPath,
}
if cOpts.TLS.Enabled == true {
Copy link
Copy Markdown
Member

@joe-elliott joe-elliott Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can simplify if cOpts.TLS.Enabled {

Should enabling TLS through the Jaeger Collector options also turn on TLS for HTTP below? Ignore. I see that the collector settings are specific to GRPC.

if cfg.GRPC == nil {
cfg.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: fmt.Sprintf(":%d", ports.CollectorGRPC),
},
}
}
cfg.GRPC.TLSSetting = &configtls.TLSServerSetting{
ClientCAFile: cOpts.TLS.ClientCAPath,
TLSSetting: configtls.TLSSetting{
CertFile: cOpts.TLS.CertPath,
KeyFile: cOpts.TLS.KeyPath,
},
}
}
if v.IsSet(collectorApp.CollectorHTTPHostPort) {
cfg.ThriftHTTP = &confighttp.HTTPServerSettings{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,31 @@ func TestDefaultValueFromViper(t *testing.T) {
Protocols: jaegerreceiver.Protocols{},
},
},
{
name: "collectorTLS",
flags: []string{
"--collector.grpc.tls.enabled=true",
"--collector.grpc.tls.cert=/cert.pem",
"--collector.grpc.tls.key=/key.pem",
"--collector.grpc.tls.client-ca=/client-ca.pem",
},
expected: &jaegerreceiver.Config{
Protocols: jaegerreceiver.Protocols{
GRPC: &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: ":14250",
},
TLSSetting: &configtls.TLSServerSetting{
TLSSetting: configtls.TLSSetting{
CertFile: "/cert.pem",
KeyFile: "/key.pem",
},
ClientCAFile: "/client-ca.pem",
},
},
},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down