diff --git a/cmd/agent/app/flags.go b/cmd/agent/app/flags.go index 34bb80d2598..7032d79873c 100644 --- a/cmd/agent/app/flags.go +++ b/cmd/agent/app/flags.go @@ -30,7 +30,8 @@ const ( suffixServerQueueSize = "server-queue-size" suffixServerMaxPacketSize = "server-max-packet-size" suffixServerHostPort = "server-host-port" - httpServerHostPort = "http-server.host-port" + // HTTPServerHostPort is the flag for HTTP endpoint + HTTPServerHostPort = "http-server.host-port" ) var defaultProcessors = []struct { @@ -52,8 +53,13 @@ func AddFlags(flags *flag.FlagSet) { flags.Int(prefix+suffixServerMaxPacketSize, defaultMaxPacketSize, "max packet size for the UDP server") flags.String(prefix+suffixServerHostPort, ":"+strconv.Itoa(p.port), "host:port for the UDP server") } + AddOTELFlags(flags) +} + +// AddOTELFlags adds flags that are exposed by OTEL collector +func AddOTELFlags(flags *flag.FlagSet) { flags.String( - httpServerHostPort, + HTTPServerHostPort, defaultHTTPServerHostPort, "host:port of the http server (e.g. for /sampling point and /baggageRestrictions endpoint)") } @@ -70,7 +76,7 @@ func (b *Builder) InitFromViper(v *viper.Viper) *Builder { b.Processors = append(b.Processors, *p) } - b.HTTPServer.HostPort = portNumToHostPort(v.GetString(httpServerHostPort)) + b.HTTPServer.HostPort = portNumToHostPort(v.GetString(HTTPServerHostPort)) return b } diff --git a/cmd/agent/app/reporter/grpc/flags.go b/cmd/agent/app/reporter/grpc/flags.go index e557a8be6fb..43c25502b82 100644 --- a/cmd/agent/app/reporter/grpc/flags.go +++ b/cmd/agent/app/reporter/grpc/flags.go @@ -39,9 +39,14 @@ var tlsFlagsConfig = tlscfg.ClientFlagsConfig{ // AddFlags adds flags for Options. func AddFlags(flags *flag.FlagSet) { - flags.String(collectorHostPort, "", "Comma-separated string representing host:port of a static list of collectors to connect to directly") flags.Uint(retry, defaultMaxRetry, "Sets the maximum number of retries for a call") flags.Int(discoveryMinPeers, 3, "Max number of collectors to which the agent will try to connect at any given time") + AddOTELFlags(flags) +} + +// AddOTELFlags adds flags that are exposed by OTEL collector +func AddOTELFlags(flags *flag.FlagSet) { + flags.String(collectorHostPort, "", "Comma-separated string representing host:port of a static list of collectors to connect to directly") tlsFlagsConfig.AddFlags(flags) } diff --git a/cmd/collector/app/builder_flags.go b/cmd/collector/app/builder_flags.go index 06f2768e67e..1c989c4f544 100644 --- a/cmd/collector/app/builder_flags.go +++ b/cmd/collector/app/builder_flags.go @@ -27,13 +27,15 @@ import ( ) const ( - collectorDynQueueSizeMemory = "collector.queue-size-memory" - collectorQueueSize = "collector.queue-size" - collectorNumWorkers = "collector.num-workers" - collectorHTTPPort = "collector.http-port" - collectorGRPCPort = "collector.grpc-port" - collectorHTTPHostPort = "collector.http-server.host-port" - collectorGRPCHostPort = "collector.grpc-server.host-port" + collectorDynQueueSizeMemory = "collector.queue-size-memory" + collectorQueueSize = "collector.queue-size" + collectorNumWorkers = "collector.num-workers" + collectorHTTPPort = "collector.http-port" + collectorGRPCPort = "collector.grpc-port" + // CollectorHTTPHostPort is the flag for collector HTTP port + CollectorHTTPHostPort = "collector.http-server.host-port" + // CollectorGRPCHostPort is the flag for collector gRPC port + CollectorGRPCHostPort = "collector.grpc-server.host-port" collectorZipkinHTTPPort = "collector.zipkin.http-port" collectorZipkinHTTPHostPort = "collector.zipkin.host-port" collectorTags = "collector.tags" @@ -79,16 +81,21 @@ type CollectorOptions struct { func AddFlags(flags *flag.FlagSet) { flags.Int(collectorQueueSize, DefaultQueueSize, "The queue size of the collector") flags.Int(collectorNumWorkers, DefaultNumWorkers, "The number of workers pulling items from the queue") - flags.Int(collectorHTTPPort, 0, collectorHTTPPortWarning+" see --"+collectorHTTPHostPort) - flags.Int(collectorGRPCPort, 0, collectorGRPCPortWarning+" see --"+collectorGRPCHostPort) + flags.Int(collectorHTTPPort, 0, collectorHTTPPortWarning+" see --"+CollectorHTTPHostPort) + flags.Int(collectorGRPCPort, 0, collectorGRPCPortWarning+" see --"+CollectorGRPCHostPort) flags.Int(collectorZipkinHTTPPort, 0, collectorZipkinHTTPPortWarning+" see --"+collectorZipkinHTTPHostPort) - flags.String(collectorHTTPHostPort, ports.PortToHostPort(ports.CollectorHTTP), "The host:port (e.g. 127.0.0.1:5555 or :5555) of the collector's HTTP server") - flags.String(collectorGRPCHostPort, ports.PortToHostPort(ports.CollectorGRPC), "The host:port (e.g. 127.0.0.1:5555 or :5555) of the collector's GRPC server") - flags.String(collectorZipkinHTTPHostPort, ports.PortToHostPort(0), "The host:port (e.g. 127.0.0.1:5555 or :5555) of the collector's Zipkin server") flags.Uint(collectorDynQueueSizeMemory, 0, "(experimental) The max memory size in MiB to use for the dynamic queue.") flags.String(collectorTags, "", "One or more tags to be added to the Process tags of all spans passing through this collector. Ex: key1=value1,key2=${envVar:defaultValue}") flags.String(collectorZipkinAllowedOrigins, "*", "Comma separated list of allowed origins for the Zipkin collector service, default accepts all") flags.String(collectorZipkinAllowedHeaders, "content-type", "Comma separated list of allowed headers for the Zipkin collector service, default content-type") + AddOTELFlags(flags) +} + +// AddOTELFlags adds flags that are exposed by OTEL collector +func AddOTELFlags(flags *flag.FlagSet) { + flags.String(collectorZipkinHTTPHostPort, ports.PortToHostPort(0), "The host:port (e.g. 127.0.0.1:5555 or :5555) of the collector's Zipkin server") + flags.String(CollectorHTTPHostPort, ports.PortToHostPort(ports.CollectorHTTP), "The host:port (e.g. 127.0.0.1:5555 or :5555) of the collector's HTTP server") + flags.String(CollectorGRPCHostPort, ports.PortToHostPort(ports.CollectorGRPC), "The host:port (e.g. 127.0.0.1:5555 or :5555) of the collector's GRPC server") tlsFlagsConfig.AddFlags(flags) } @@ -97,8 +104,8 @@ func (cOpts *CollectorOptions) InitFromViper(v *viper.Viper) *CollectorOptions { cOpts.DynQueueSizeMemory = v.GetUint(collectorDynQueueSizeMemory) * 1024 * 1024 // we receive in MiB and store in bytes cOpts.QueueSize = v.GetInt(collectorQueueSize) cOpts.NumWorkers = v.GetInt(collectorNumWorkers) - cOpts.CollectorHTTPHostPort = getAddressFromCLIOptions(v.GetInt(collectorHTTPPort), v.GetString(collectorHTTPHostPort)) - cOpts.CollectorGRPCHostPort = getAddressFromCLIOptions(v.GetInt(collectorGRPCPort), v.GetString(collectorGRPCHostPort)) + cOpts.CollectorHTTPHostPort = getAddressFromCLIOptions(v.GetInt(collectorHTTPPort), v.GetString(CollectorHTTPHostPort)) + cOpts.CollectorGRPCHostPort = getAddressFromCLIOptions(v.GetInt(collectorGRPCPort), v.GetString(CollectorGRPCHostPort)) cOpts.CollectorZipkinHTTPHostPort = getAddressFromCLIOptions(v.GetInt(collectorZipkinHTTPPort), v.GetString(collectorZipkinHTTPHostPort)) cOpts.CollectorTags = flags.ParseJaegerTags(v.GetString(collectorTags)) cOpts.CollectorZipkinAllowedOrigins = v.GetString(collectorZipkinAllowedOrigins) diff --git a/cmd/opentelemetry-collector/app/defaults/default_config.go b/cmd/opentelemetry-collector/app/defaults/default_config.go index 4092f75244e..6ede8202b40 100644 --- a/cmd/opentelemetry-collector/app/defaults/default_config.go +++ b/cmd/opentelemetry-collector/app/defaults/default_config.go @@ -76,19 +76,24 @@ func CollectorConfig(storageType string, zipkinHostPort string, factories config func createCollectorReceivers(zipkinHostPort string, factories config.Factories) configmodels.Receivers { jaeger := factories.Receivers["jaeger"].CreateDefaultConfig().(*jaegerreceiver.Config) - // TODO load and serve sampling strategies - // TODO bind sampling strategies file - jaeger.Protocols = map[string]*receiver.SecureReceiverSettings{ - "grpc": { + if jaeger.Protocols == nil { + jaeger.Protocols = map[string]*receiver.SecureReceiverSettings{} + } + // The CreateDefaultConfig is enabling protocols from flags + // we do not want to override it here + if _, ok := jaeger.Protocols["grpc"]; !ok { + jaeger.Protocols["grpc"] = &receiver.SecureReceiverSettings{ ReceiverSettings: configmodels.ReceiverSettings{ Endpoint: gRPCEndpoint, }, - }, - "thrift_http": { + } + } + if _, ok := jaeger.Protocols["thrift_http"]; !ok { + jaeger.Protocols["thrift_http"] = &receiver.SecureReceiverSettings{ ReceiverSettings: configmodels.ReceiverSettings{ Endpoint: httpThriftBinaryEndpoint, }, - }, + } } recvs := map[string]configmodels.Receiver{ "jaeger": jaeger, @@ -159,17 +164,19 @@ func AgentConfig(factories config.Factories) *configmodels.Config { func createAgentReceivers(factories config.Factories) configmodels.Receivers { jaeger := factories.Receivers["jaeger"].CreateDefaultConfig().(*jaegerreceiver.Config) - jaeger.Protocols = map[string]*receiver.SecureReceiverSettings{ - "thrift_compact": { + if _, ok := jaeger.Protocols["thrift_compact"]; !ok { + jaeger.Protocols["thrift_compact"] = &receiver.SecureReceiverSettings{ ReceiverSettings: configmodels.ReceiverSettings{ Endpoint: udpThriftCompactEndpoint, }, - }, - "thrift_binary": { + } + } + if _, ok := jaeger.Protocols["thrift_binary"]; !ok { + jaeger.Protocols["thrift_binary"] = &receiver.SecureReceiverSettings{ ReceiverSettings: configmodels.ReceiverSettings{ Endpoint: udpThriftBinaryEndpoint, }, - }, + } } recvs := configmodels.Receivers{ "jaeger": jaeger, diff --git a/cmd/opentelemetry-collector/app/defaults/default_config_test.go b/cmd/opentelemetry-collector/app/defaults/default_config_test.go index c9befea7b47..e8d51efb9c6 100644 --- a/cmd/opentelemetry-collector/app/defaults/default_config_test.go +++ b/cmd/opentelemetry-collector/app/defaults/default_config_test.go @@ -20,16 +20,19 @@ import ( "testing" "github.com/open-telemetry/opentelemetry-collector/config" + "github.com/open-telemetry/opentelemetry-collector/config/configgrpc" "github.com/open-telemetry/opentelemetry-collector/config/configmodels" "github.com/open-telemetry/opentelemetry-collector/exporter/jaegerexporter" "github.com/open-telemetry/opentelemetry-collector/processor/resourceprocessor" + "github.com/open-telemetry/opentelemetry-collector/receiver" "github.com/open-telemetry/opentelemetry-collector/receiver/jaegerreceiver" + "github.com/open-telemetry/opentelemetry-collector/receiver/zipkinreceiver" "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap" - "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc" + "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/exporter/cassandra" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/exporter/elasticsearch" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/exporter/grpcplugin" @@ -118,7 +121,7 @@ func TestDefaultCollectorConfig(t *testing.T) { } for _, test := range tests { t.Run(test.storageType, func(t *testing.T) { - v, _ := jConfig.Viperize(grpc.AddFlags) + v, _ := jConfig.Viperize(app.AddComponentFlags) factories := Components(v) for key, val := range test.config { v.Set(key, val) @@ -162,6 +165,87 @@ func TestDefaultCollectorConfig(t *testing.T) { } } +func TestCreateCollectorReceivers(t *testing.T) { + tests := []struct { + name string + args []string + zipkinHostPort string + receivers configmodels.Receivers + }{ + { + name: "defaultWithoutZipkin", + args: []string{}, + zipkinHostPort: ":0", + receivers: configmodels.Receivers{ + "jaeger": &jaegerreceiver.Config{ + TypeVal: "jaeger", + NameVal: "jaeger", + Protocols: map[string]*receiver.SecureReceiverSettings{ + "grpc": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: gRPCEndpoint, + }, + }, + "thrift_http": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: httpThriftBinaryEndpoint, + }, + }, + }, + }, + }, + }, + { + name: "configurationViaFlags", + args: []string{ + "--collector.grpc-server.host-port=host:11", + "--collector.grpc.tls.cert=cacert.crt", + "--collector.grpc.tls.key=keycert.crt", + "--collector.http-server.host-port=host2:22", + }, + zipkinHostPort: "localhost:55", + receivers: configmodels.Receivers{ + "jaeger": &jaegerreceiver.Config{ + TypeVal: "jaeger", + NameVal: "jaeger", + Protocols: map[string]*receiver.SecureReceiverSettings{ + "grpc": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: "host:11", + }, + TLSCredentials: &receiver.TLSCredentials{ + CertFile: "cacert.crt", + KeyFile: "keycert.crt", + }, + }, + "thrift_http": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: "host2:22", + }, + }, + }, + }, + "zipkin": &zipkinreceiver.Config{ + ReceiverSettings: configmodels.ReceiverSettings{ + NameVal: "zipkin", + TypeVal: "zipkin", + Endpoint: "localhost:55", + }, + }, + }, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + v, c := jConfig.Viperize(app.AddComponentFlags) + require.NoError(t, c.ParseFlags(test.args)) + factories := Components(v) + recvs := createCollectorReceivers(test.zipkinHostPort, factories) + assert.Equal(t, test.receivers, recvs) + }) + } +} + func TestDefaultAgentConfig(t *testing.T) { tests := []struct { config map[string]interface{} @@ -196,7 +280,7 @@ func TestDefaultAgentConfig(t *testing.T) { } for _, test := range tests { t.Run(fmt.Sprintf("%v", test.config), func(t *testing.T) { - v, _ := jConfig.Viperize(grpc.AddFlags) + v, _ := jConfig.Viperize(app.AddComponentFlags) for key, val := range test.config { v.Set(key, val) } @@ -221,6 +305,84 @@ func TestDefaultAgentConfig(t *testing.T) { } } +func TestCreateAgentReceivers(t *testing.T) { + tests := []struct { + args []string + receivers configmodels.Receivers + }{ + { + args: []string{""}, + receivers: configmodels.Receivers{ + "jaeger": &jaegerreceiver.Config{ + TypeVal: "jaeger", + NameVal: "jaeger", + Protocols: map[string]*receiver.SecureReceiverSettings{ + "thrift_compact": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: udpThriftCompactEndpoint, + }, + }, + "thrift_binary": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: udpThriftBinaryEndpoint, + }, + }, + }, + }, + }, + }, + { + args: []string{ + "--processor.jaeger-binary.server-host-port=host:1", + "--processor.jaeger-compact.server-host-port=host:2", + "--reporter.grpc.host-port=coll:33", + "--reporter.grpc.tls.enabled=true", + "--reporter.grpc.tls.ca=cacert.pem", + "--reporter.grpc.tls.cert=cert.pem", + "--reporter.grpc.tls.key=key.key", + }, + receivers: configmodels.Receivers{ + "jaeger": &jaegerreceiver.Config{ + TypeVal: "jaeger", + NameVal: "jaeger", + RemoteSampling: &jaegerreceiver.RemoteSamplingConfig{ + GRPCSettings: configgrpc.GRPCSettings{ + Endpoint: "coll:33", + TLSConfig: configgrpc.TLSConfig{ + UseSecure: true, + CaCert: "cacert.pem", + ClientCert: "cert.pem", + ClientKey: "key.key", + }, + }, + }, + Protocols: map[string]*receiver.SecureReceiverSettings{ + "thrift_binary": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: "host:1", + }, + }, + "thrift_compact": { + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: "host:2", + }, + }, + }, + }, + }, + }, + } + for _, test := range tests { + t.Run(fmt.Sprintf("%v", test.args), func(t *testing.T) { + v, c := jConfig.Viperize(app.AddComponentFlags) + require.NoError(t, c.ParseFlags(test.args)) + factories := Components(v) + recvs := createAgentReceivers(factories) + assert.Equal(t, test.receivers, recvs) + }) + } +} + func TestDefaultIngesterConfig(t *testing.T) { tests := []struct { storageType string diff --git a/cmd/opentelemetry-collector/app/exporter/jaegerexporter/.nocover b/cmd/opentelemetry-collector/app/exporter/jaegerexporter/.nocover deleted file mode 100644 index 9d6cf4b7fb6..00000000000 --- a/cmd/opentelemetry-collector/app/exporter/jaegerexporter/.nocover +++ /dev/null @@ -1 +0,0 @@ -FIXME diff --git a/cmd/opentelemetry-collector/app/exporter/jaegerexporter/jaeger_exporter.go b/cmd/opentelemetry-collector/app/exporter/jaegerexporter/jaeger_exporter.go index e7a64e76c26..0b88f794e07 100644 --- a/cmd/opentelemetry-collector/app/exporter/jaegerexporter/jaeger_exporter.go +++ b/cmd/opentelemetry-collector/app/exporter/jaegerexporter/jaeger_exporter.go @@ -22,7 +22,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector/exporter/jaegerexporter" "github.com/spf13/viper" - "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc" + grpcRep "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc" ) // Factory wraps jaegerexporter.Factory and makes the default config configurable via viper. @@ -44,15 +44,17 @@ func (f Factory) Type() configmodels.Type { // CreateDefaultConfig returns default configuration of Factory. // This function implements OTEL component.ExporterFactoryBase interface. func (f Factory) CreateDefaultConfig() configmodels.Exporter { - repCfg := grpc.ConnBuilder{} + repCfg := grpcRep.ConnBuilder{} repCfg.InitFromViper(f.Viper) cfg := f.Wrapped.CreateDefaultConfig().(*jaegerexporter.Config) if len(repCfg.CollectorHostPorts) > 0 { cfg.Endpoint = repCfg.CollectorHostPorts[0] } - cfg.GRPCSettings.UseSecure = repCfg.TLS.Enabled - cfg.GRPCSettings.CertPemFile = repCfg.TLS.CertPath - cfg.GRPCSettings.ServerNameOverride = repCfg.TLS.ServerName + cfg.GRPCSettings.TLSConfig.UseSecure = repCfg.TLS.Enabled + cfg.GRPCSettings.TLSConfig.CaCert = repCfg.TLS.CAPath + cfg.GRPCSettings.TLSConfig.ClientCert = repCfg.TLS.CertPath + cfg.GRPCSettings.TLSConfig.ClientKey = repCfg.TLS.KeyPath + cfg.GRPCSettings.TLSConfig.ServerNameOverride = repCfg.TLS.ServerName return cfg } diff --git a/cmd/opentelemetry-collector/app/exporter/jaegerexporter/jaeger_exporter_test.go b/cmd/opentelemetry-collector/app/exporter/jaegerexporter/jaeger_exporter_test.go new file mode 100644 index 00000000000..ab327d05ab6 --- /dev/null +++ b/cmd/opentelemetry-collector/app/exporter/jaegerexporter/jaeger_exporter_test.go @@ -0,0 +1,101 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package jaegerexporter + +import ( + "context" + "path" + "testing" + + "github.com/open-telemetry/opentelemetry-collector/component" + "github.com/open-telemetry/opentelemetry-collector/config" + "github.com/open-telemetry/opentelemetry-collector/config/configerror" + "github.com/open-telemetry/opentelemetry-collector/config/configmodels" + "github.com/open-telemetry/opentelemetry-collector/exporter/jaegerexporter" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/receiver/jaegerreceiver" + jConfig "github.com/jaegertracing/jaeger/pkg/config" +) + +func TestDefaultValues(t *testing.T) { + v, c := jConfig.Viperize(jaegerreceiver.AddFlags) + err := c.ParseFlags([]string{}) + require.NoError(t, err) + + factory := &Factory{Viper: v, Wrapped: &jaegerexporter.Factory{}} + cfg := factory.CreateDefaultConfig().(*jaegerexporter.Config) + assert.Empty(t, cfg.GRPCSettings.Endpoint) + tlsConf := cfg.TLSConfig + assert.False(t, tlsConf.UseSecure) + assert.Empty(t, tlsConf.CaCert) + assert.Empty(t, tlsConf.ClientKey) + assert.Empty(t, tlsConf.ClientCert) + assert.Empty(t, tlsConf.ServerNameOverride) +} + +func TestDefaultValueFromViper(t *testing.T) { + v, c := jConfig.Viperize(jaegerreceiver.AddFlags) + err := c.ParseFlags([]string{"--reporter.grpc.host-port=foo", "--reporter.grpc.tls.enabled=true", "--reporter.grpc.tls.ca=ca.crt"}) + require.NoError(t, err) + + f := &Factory{ + Wrapped: &jaegerexporter.Factory{}, + Viper: v, + } + + cfg := f.CreateDefaultConfig().(*jaegerexporter.Config) + assert.Equal(t, "foo", cfg.GRPCSettings.Endpoint) + tlsConfig := cfg.TLSConfig + assert.Equal(t, true, tlsConfig.UseSecure) + assert.Equal(t, "ca.crt", tlsConfig.CaCert) +} + +func TestLoadConfigAndFlags(t *testing.T) { + factories, err := config.ExampleComponents() + require.NoError(t, err) + + v, c := jConfig.Viperize(jaegerreceiver.AddFlags) + err = c.ParseFlags([]string{"--reporter.grpc.host-port=foo"}) + require.NoError(t, err) + + factory := &Factory{Viper: v, Wrapped: &jaegerexporter.Factory{}} + assert.Equal(t, "foo", factory.CreateDefaultConfig().(*jaegerexporter.Config).GRPCSettings.Endpoint) + + factories.Exporters["jaeger"] = factory + colConfig, err := config.LoadConfigFile(t, path.Join(".", "testdata", "config.yaml"), factories) + require.NoError(t, err) + require.NotNil(t, colConfig) + + cfg := colConfig.Exporters["jaeger"].(*jaegerexporter.Config) + assert.Equal(t, "bar", cfg.GRPCSettings.Endpoint) +} + +func TestType(t *testing.T) { + f := &Factory{ + Wrapped: &jaegerexporter.Factory{}, + } + assert.Equal(t, configmodels.Type("jaeger"), f.Type()) +} + +func TestCreateMetricsExporter(t *testing.T) { + f := &Factory{ + Wrapped: &jaegerexporter.Factory{}, + } + mReceiver, err := f.CreateMetricsExporter(context.Background(), component.ExporterCreateParams{}, nil) + assert.Equal(t, configerror.ErrDataTypeIsNotSupported, err) + assert.Nil(t, mReceiver) +} diff --git a/cmd/opentelemetry-collector/app/exporter/jaegerexporter/testdata/config.yaml b/cmd/opentelemetry-collector/app/exporter/jaegerexporter/testdata/config.yaml new file mode 100644 index 00000000000..14f994fd098 --- /dev/null +++ b/cmd/opentelemetry-collector/app/exporter/jaegerexporter/testdata/config.yaml @@ -0,0 +1,16 @@ +receivers: + examplereceiver: + +processors: + exampleprocessor: + +exporters: + jaeger: + endpoint: bar + +service: + pipelines: + traces: + receivers: [examplereceiver] + processors: [exampleprocessor] + exporters: [jaeger] diff --git a/cmd/opentelemetry-collector/app/util.go b/cmd/opentelemetry-collector/app/flags.go similarity index 71% rename from cmd/opentelemetry-collector/app/util.go rename to cmd/opentelemetry-collector/app/flags.go index 65afa2592dc..e60dc078f02 100644 --- a/cmd/opentelemetry-collector/app/util.go +++ b/cmd/opentelemetry-collector/app/flags.go @@ -19,15 +19,26 @@ import ( "fmt" "strings" + jConfigFile "github.com/jaegertracing/jaeger/cmd/flags" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/exporter/cassandra" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/exporter/elasticsearch" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/exporter/grpcplugin" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/exporter/kafka" + "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/processor/resourceprocessor" + "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/receiver/jaegerreceiver" ) -// StorageFlags return a function that adds storage flags. +// AddComponentFlags adds all flags exposed by components +func AddComponentFlags(flags *flag.FlagSet) { + // Jaeger receiver (via sampling strategies receiver) exposes the same flags as exporter. + jaegerreceiver.AddFlags(flags) + resourceprocessor.AddFlags(flags) + jConfigFile.AddConfigFileFlag(flags) +} + +// AddStorageFlags return a function that adds storage flags. // storage parameter can contain a comma separated list of supported Jaeger storage backends. -func StorageFlags(storage string) (func(*flag.FlagSet), error) { +func AddStorageFlags(storage string) (func(*flag.FlagSet), error) { var flagFn []func(*flag.FlagSet) for _, s := range strings.Split(storage, ",") { switch s { diff --git a/cmd/opentelemetry-collector/app/processor/resourceprocessor/flags.go b/cmd/opentelemetry-collector/app/processor/resourceprocessor/flags.go new file mode 100644 index 00000000000..fd783f24cc9 --- /dev/null +++ b/cmd/opentelemetry-collector/app/processor/resourceprocessor/flags.go @@ -0,0 +1,28 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package resourceprocessor + +import ( + "flag" + "fmt" + + "github.com/jaegertracing/jaeger/cmd/agent/app/reporter" +) + +// AddFlags adds flags for Options. +func AddFlags(flags *flag.FlagSet) { + flags.String(reporter.AgentTagsDeprecated, "", fmt.Sprintf("(deprecated, use --%s) One or more tags to be added to the Process tags of all spans passing through this agent. Ex: key1=value1,key2=${envVar:defaultValue}", resourceLabels)) + flags.String(resourceLabels, "", "One or more tags to be added to the Process tags of all spans passing through this agent. Ex: key1=value1,key2=${envVar:defaultValue}") +} diff --git a/cmd/opentelemetry-collector/app/processor/resourceprocessor/resource_processor.go b/cmd/opentelemetry-collector/app/processor/resourceprocessor/resource_processor.go index a4cfe891ab2..feb18e1e2fc 100644 --- a/cmd/opentelemetry-collector/app/processor/resourceprocessor/resource_processor.go +++ b/cmd/opentelemetry-collector/app/processor/resourceprocessor/resource_processor.go @@ -15,9 +15,6 @@ package resourceprocessor import ( - "flag" - "fmt" - "github.com/open-telemetry/opentelemetry-collector/component" "github.com/open-telemetry/opentelemetry-collector/config/configmodels" "github.com/open-telemetry/opentelemetry-collector/consumer" @@ -88,9 +85,3 @@ func (f Factory) CreateMetricsProcessor( ) (component.MetricsProcessorOld, error) { return f.Wrapped.CreateMetricsProcessor(logger, nextConsumer, cfg) } - -// AddFlags adds flags for Options. -func AddFlags(flags *flag.FlagSet) { - flags.String(reporter.AgentTagsDeprecated, "", fmt.Sprintf("(deprecated, use --%s) One or more tags to be added to the Process tags of all spans passing through this agent. Ex: key1=value1,key2=${envVar:defaultValue}", resourceLabels)) - flags.String(resourceLabels, "", "One or more tags to be added to the Process tags of all spans passing through this agent. Ex: key1=value1,key2=${envVar:defaultValue}") -} diff --git a/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/flags.go b/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/flags.go new file mode 100644 index 00000000000..e0c7d8ef776 --- /dev/null +++ b/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/flags.go @@ -0,0 +1,41 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package jaegerreceiver + +import ( + "flag" + "strconv" + + agentApp "github.com/jaegertracing/jaeger/cmd/agent/app" + 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" +) + +const ( + thriftBinaryHostPort = "processor.jaeger-binary.server-host-port" + thriftCompactHostPort = "processor.jaeger-compact.server-host-port" +) + +// AddFlags adds flags to flag set. +func AddFlags(flags *flag.FlagSet) { + flags.String(thriftBinaryHostPort, ":"+strconv.Itoa(ports.AgentJaegerThriftBinaryUDP), "host:port for the UDP server") + flags.String(thriftCompactHostPort, ":"+strconv.Itoa(ports.AgentJaegerThriftCompactUDP), "host:port for the UDP server") + collectorApp.AddOTELFlags(flags) + agentApp.AddOTELFlags(flags) + grpcRep.AddOTELFlags(flags) + static.AddOTELFlags(flags) +} diff --git a/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver.go b/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver.go index f90f4ca8c12..54913d3ed3c 100644 --- a/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver.go +++ b/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver.go @@ -20,10 +20,13 @@ import ( "github.com/open-telemetry/opentelemetry-collector/component" "github.com/open-telemetry/opentelemetry-collector/config/configmodels" "github.com/open-telemetry/opentelemetry-collector/consumer" + "github.com/open-telemetry/opentelemetry-collector/receiver" "github.com/open-telemetry/opentelemetry-collector/receiver/jaegerreceiver" "github.com/spf13/viper" - "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc" + agentApp "github.com/jaegertracing/jaeger/cmd/agent/app" + 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" ) @@ -48,9 +51,58 @@ func (f *Factory) Type() configmodels.Type { func (f *Factory) CreateDefaultConfig() configmodels.Receiver { cfg := f.Wrapped.CreateDefaultConfig().(*jaegerreceiver.Config) cfg.RemoteSampling = createDefaultSamplingConfig(f.Viper) + configureAgent(f.Viper, cfg) + configureCollector(f.Viper, cfg) return cfg } +func configureAgent(v *viper.Viper, cfg *jaegerreceiver.Config) { + aOpts := agentApp.Builder{} + aOpts.InitFromViper(v) + if v.IsSet(thriftBinaryHostPort) { + cfg.Protocols["thrift_binary"] = &receiver.SecureReceiverSettings{ + ReceiverSettings: configmodels.ReceiverSettings{ + // TODO OTEL does not expose number of workers and queue length + Endpoint: v.GetString(thriftBinaryHostPort), + }, + } + } + if v.IsSet(thriftCompactHostPort) { + cfg.Protocols["thrift_compact"] = &receiver.SecureReceiverSettings{ + ReceiverSettings: configmodels.ReceiverSettings{ + // TODO OTEL does not expose number of workers and queue length + Endpoint: v.GetString(thriftCompactHostPort), + }, + } + } +} + +func configureCollector(v *viper.Viper, cfg *jaegerreceiver.Config) { + cOpts := collectorApp.CollectorOptions{} + cOpts.InitFromViper(v) + if v.IsSet(collectorApp.CollectorGRPCHostPort) { + cfg.Protocols["grpc"] = &receiver.SecureReceiverSettings{ + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: cOpts.CollectorGRPCHostPort, + }, + } + if cOpts.TLS.CertPath != "" && cOpts.TLS.KeyPath != "" { + cfg.Protocols["grpc"].TLSCredentials = &receiver.TLSCredentials{ + // TODO client-ca is missing in OTEL https://github.com/open-telemetry/opentelemetry-collector/issues/963 + KeyFile: cOpts.TLS.KeyPath, + CertFile: cOpts.TLS.CertPath, + } + } + } + if v.IsSet(collectorApp.CollectorHTTPHostPort) { + cfg.Protocols["thrift_http"] = &receiver.SecureReceiverSettings{ + ReceiverSettings: configmodels.ReceiverSettings{ + Endpoint: cOpts.CollectorHTTPHostPort, + }, + } + } +} + func createDefaultSamplingConfig(v *viper.Viper) *jaegerreceiver.RemoteSamplingConfig { var samplingConf *jaegerreceiver.RemoteSamplingConfig strategyFile := v.GetString(static.SamplingStrategiesFile) @@ -59,7 +111,14 @@ func createDefaultSamplingConfig(v *viper.Viper) *jaegerreceiver.RemoteSamplingC StrategyFile: strategyFile, } } - repCfg := grpc.ConnBuilder{} + if v.IsSet(agentApp.HTTPServerHostPort) { + if samplingConf == nil { + samplingConf = &jaegerreceiver.RemoteSamplingConfig{} + } + samplingConf.HostEndpoint = v.GetString(agentApp.HTTPServerHostPort) + } + + repCfg := grpcRep.ConnBuilder{} repCfg.InitFromViper(v) // This is for agent mode. // This uses --reporter.grpc.host-port flag to set the fetch endpoint for the sampling strategies. @@ -68,7 +127,12 @@ func createDefaultSamplingConfig(v *viper.Viper) *jaegerreceiver.RemoteSamplingC if samplingConf == nil { samplingConf = &jaegerreceiver.RemoteSamplingConfig{} } - samplingConf.FetchEndpoint = repCfg.CollectorHostPorts[0] + samplingConf.GRPCSettings.Endpoint = repCfg.CollectorHostPorts[0] + samplingConf.GRPCSettings.TLSConfig.UseSecure = repCfg.TLS.Enabled + samplingConf.GRPCSettings.TLSConfig.CaCert = repCfg.TLS.CAPath + samplingConf.GRPCSettings.TLSConfig.ClientCert = repCfg.TLS.CertPath + samplingConf.GRPCSettings.TLSConfig.ClientKey = repCfg.TLS.KeyPath + samplingConf.GRPCSettings.TLSConfig.ServerNameOverride = repCfg.TLS.ServerName } return samplingConf } diff --git a/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver_test.go b/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver_test.go index 48335f4a258..8e0ef6a6c54 100644 --- a/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver_test.go +++ b/cmd/opentelemetry-collector/app/receiver/jaegerreceiver/jaeger_receiver_test.go @@ -16,50 +16,149 @@ package jaegerreceiver import ( "context" + "fmt" "path" "testing" "github.com/open-telemetry/opentelemetry-collector/component" "github.com/open-telemetry/opentelemetry-collector/config" "github.com/open-telemetry/opentelemetry-collector/config/configerror" + "github.com/open-telemetry/opentelemetry-collector/config/configgrpc" "github.com/open-telemetry/opentelemetry-collector/config/configmodels" + "github.com/open-telemetry/opentelemetry-collector/receiver" "github.com/open-telemetry/opentelemetry-collector/receiver/jaegerreceiver" - "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + collectorApp "github.com/jaegertracing/jaeger/cmd/collector/app" jConfig "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/plugin/sampling/strategystore/static" ) func TestDefaultValues(t *testing.T) { - v, c := jConfig.Viperize(static.AddFlags) + v, c := jConfig.Viperize(AddFlags) err := c.ParseFlags([]string{}) require.NoError(t, err) factory := &Factory{Viper: v, Wrapped: &jaegerreceiver.Factory{}} cfg := factory.CreateDefaultConfig().(*jaegerreceiver.Config) assert.Nil(t, cfg.RemoteSampling) + assert.Empty(t, cfg.Protocols) } func TestDefaultValueFromViper(t *testing.T) { - v := viper.New() - v.Set(static.SamplingStrategiesFile, "config.json") - - f := &Factory{ - Wrapped: &jaegerreceiver.Factory{}, - Viper: v, + tests := []struct { + name string + flags []string + expected *jaegerreceiver.Config + }{ + { + name: "samplingStrategyFile", + flags: []string{fmt.Sprintf("--%s=%s", static.SamplingStrategiesFile, "conf.json")}, + expected: &jaegerreceiver.Config{ + RemoteSampling: &jaegerreceiver.RemoteSamplingConfig{ + StrategyFile: "conf.json", + }, + Protocols: map[string]*receiver.SecureReceiverSettings{}, + }, + }, + { + name: "thriftCompact", + flags: []string{fmt.Sprintf("--%s=%s", thriftCompactHostPort, "localhost:9999")}, + expected: &jaegerreceiver.Config{ + Protocols: map[string]*receiver.SecureReceiverSettings{ + "thrift_compact": {ReceiverSettings: configmodels.ReceiverSettings{Endpoint: "localhost:9999"}}, + }, + }, + }, + { + name: "thriftBinary", + flags: []string{fmt.Sprintf("--%s=%s", thriftBinaryHostPort, "localhost:8888")}, + expected: &jaegerreceiver.Config{ + Protocols: map[string]*receiver.SecureReceiverSettings{ + "thrift_binary": {ReceiverSettings: configmodels.ReceiverSettings{Endpoint: "localhost:8888"}}, + }, + }, + }, + { + name: "grpc", + flags: []string{fmt.Sprintf("--%s=%s", collectorApp.CollectorGRPCHostPort, "localhost:7894")}, + expected: &jaegerreceiver.Config{ + Protocols: map[string]*receiver.SecureReceiverSettings{ + "grpc": {ReceiverSettings: configmodels.ReceiverSettings{Endpoint: "localhost:7894"}}, + }, + }, + }, + { + name: "thriftHttp", + flags: []string{fmt.Sprintf("--%s=%s", collectorApp.CollectorHTTPHostPort, "localhost:8080")}, + expected: &jaegerreceiver.Config{ + Protocols: map[string]*receiver.SecureReceiverSettings{ + "thrift_http": {ReceiverSettings: configmodels.ReceiverSettings{Endpoint: "localhost:8080"}}, + }, + }, + }, + { + name: "thriftHttpAndThriftBinary", + flags: []string{fmt.Sprintf("--%s=%s", collectorApp.CollectorHTTPHostPort, "localhost:8089"), fmt.Sprintf("--%s=%s", thriftBinaryHostPort, "localhost:2222")}, + expected: &jaegerreceiver.Config{ + Protocols: map[string]*receiver.SecureReceiverSettings{ + "thrift_http": {ReceiverSettings: configmodels.ReceiverSettings{Endpoint: "localhost:8089"}}, + "thrift_binary": {ReceiverSettings: configmodels.ReceiverSettings{Endpoint: "localhost:2222"}}, + }, + }, + }, + { + name: "remoteSampling", + flags: []string{ + "--http-server.host-port=machine:1", + "--sampling.strategies-file=foo", + "--reporter.grpc.host-port=coll:33", + "--reporter.grpc.tls.enabled=true", + "--reporter.grpc.tls.ca=cacert.pem", + "--reporter.grpc.tls.cert=cert.pem", + "--reporter.grpc.tls.key=key.key", + }, + expected: &jaegerreceiver.Config{ + RemoteSampling: &jaegerreceiver.RemoteSamplingConfig{ + StrategyFile: "foo", + HostEndpoint: "machine:1", + GRPCSettings: configgrpc.GRPCSettings{ + Endpoint: "coll:33", + TLSConfig: configgrpc.TLSConfig{ + UseSecure: true, + CaCert: "cacert.pem", + ClientCert: "cert.pem", + ClientKey: "key.key", + }, + }, + }, + Protocols: map[string]*receiver.SecureReceiverSettings{}, + }, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + v, c := jConfig.Viperize(AddFlags) + err := c.ParseFlags(test.flags) + require.NoError(t, err) + f := &Factory{ + Wrapped: &jaegerreceiver.Factory{}, + Viper: v, + } + cfg := f.CreateDefaultConfig().(*jaegerreceiver.Config) + test.expected.TypeVal = "jaeger" + test.expected.NameVal = "jaeger" + assert.Equal(t, test.expected, cfg) + }) } - - cfg := f.CreateDefaultConfig().(*jaegerreceiver.Config) - assert.Equal(t, "config.json", cfg.RemoteSampling.StrategyFile) } func TestLoadConfigAndFlags(t *testing.T) { factories, err := config.ExampleComponents() require.NoError(t, err) - v, c := jConfig.Viperize(static.AddFlags) + v, c := jConfig.Viperize(AddFlags) err = c.ParseFlags([]string{"--sampling.strategies-file=bar.json"}) require.NoError(t, err) diff --git a/cmd/opentelemetry-collector/cmd/agent/main.go b/cmd/opentelemetry-collector/cmd/agent/main.go index 508627d12c5..b9d0adcb00b 100644 --- a/cmd/opentelemetry-collector/cmd/agent/main.go +++ b/cmd/opentelemetry-collector/cmd/agent/main.go @@ -25,13 +25,11 @@ import ( "github.com/open-telemetry/opentelemetry-collector/service/builder" "github.com/spf13/viper" - "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc" jflags "github.com/jaegertracing/jaeger/cmd/flags" + "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/defaults" - "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/processor/resourceprocessor" jconfig "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/version" - "github.com/jaegertracing/jaeger/plugin/sampling/strategystore/static" ) func main() { @@ -77,10 +75,7 @@ func main() { cmd := svc.Command() jconfig.AddFlags(v, cmd, - jflags.AddConfigFileFlag, - grpc.AddFlags, - static.AddFlags, - resourceprocessor.AddFlags, + app.AddComponentFlags, ) // parse flags to propagate Jaeger config file flag value to viper diff --git a/cmd/opentelemetry-collector/cmd/collector/main.go b/cmd/opentelemetry-collector/cmd/collector/main.go index 5282fa48b18..4bd5073706c 100644 --- a/cmd/opentelemetry-collector/cmd/collector/main.go +++ b/cmd/opentelemetry-collector/cmd/collector/main.go @@ -25,15 +25,12 @@ import ( "github.com/open-telemetry/opentelemetry-collector/service/builder" "github.com/spf13/viper" - "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc" collectorApp "github.com/jaegertracing/jaeger/cmd/collector/app" jflags "github.com/jaegertracing/jaeger/cmd/flags" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/defaults" - "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/processor/resourceprocessor" jConfig "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/version" - "github.com/jaegertracing/jaeger/plugin/sampling/strategystore/static" "github.com/jaegertracing/jaeger/plugin/storage" ) @@ -89,19 +86,15 @@ func main() { // Add Jaeger specific flags to service command // this passes flag values to viper. - storageFlags, err := app.StorageFlags(storageType) + storageFlags, err := app.AddStorageFlags(storageType) if err != nil { handleErr(err) } cmd := svc.Command() jConfig.AddFlags(v, cmd, - collectorApp.AddFlags, - jflags.AddConfigFileFlag, + app.AddComponentFlags, storageFlags, - static.AddFlags, - grpc.AddFlags, - resourceprocessor.AddFlags, ) // parse flags to propagate Jaeger config file flag value to viper diff --git a/cmd/opentelemetry-collector/cmd/ingester/main.go b/cmd/opentelemetry-collector/cmd/ingester/main.go index 4564f4123e9..2729ac71ace 100644 --- a/cmd/opentelemetry-collector/cmd/ingester/main.go +++ b/cmd/opentelemetry-collector/cmd/ingester/main.go @@ -26,7 +26,6 @@ import ( "github.com/spf13/viper" jflags "github.com/jaegertracing/jaeger/cmd/flags" - ingesterApp "github.com/jaegertracing/jaeger/cmd/ingester/app" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app" "github.com/jaegertracing/jaeger/cmd/opentelemetry-collector/app/defaults" jconfig "github.com/jaegertracing/jaeger/pkg/config" @@ -84,7 +83,7 @@ func main() { // Add Jaeger specific flags to service command // this passes flag values to viper. - storageFlags, err := app.StorageFlags(storageType) + storageFlags, err := app.AddStorageFlags(storageType) if err != nil { handleErr(err) } @@ -92,8 +91,7 @@ func main() { cmd := svc.Command() jconfig.AddFlags(v, cmd, - jflags.AddConfigFileFlag, - ingesterApp.AddFlags, + app.AddComponentFlags, storageFlags, ) diff --git a/cmd/opentelemetry-collector/go.mod b/cmd/opentelemetry-collector/go.mod index 32687c0779f..d6bd9bd5c03 100644 --- a/cmd/opentelemetry-collector/go.mod +++ b/cmd/opentelemetry-collector/go.mod @@ -10,7 +10,7 @@ require ( github.com/Shopify/sarama v1.22.2-0.20190604114437-cd910a683f9f github.com/imdario/mergo v0.3.9 github.com/jaegertracing/jaeger v1.17.0 - github.com/open-telemetry/opentelemetry-collector v0.3.1-0.20200505202444-021607d68586 + github.com/open-telemetry/opentelemetry-collector v0.3.1-0.20200512031848-f588c89b4778 github.com/open-telemetry/opentelemetry-proto v0.3.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.6.2 diff --git a/cmd/opentelemetry-collector/go.sum b/cmd/opentelemetry-collector/go.sum index 9b24761d417..d5a25b2aba9 100644 --- a/cmd/opentelemetry-collector/go.sum +++ b/cmd/opentelemetry-collector/go.sum @@ -954,6 +954,8 @@ github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/open-telemetry/opentelemetry-collector v0.3.1-0.20200505202444-021607d68586 h1:HD0/Opa/WiWaG+B6LP+5XT9lYqpErWd6DjH3ah9mQrU= github.com/open-telemetry/opentelemetry-collector v0.3.1-0.20200505202444-021607d68586/go.mod h1:ht/uOm+HLoXWjhq6seX/BoTwlR0dtCKFe2Y23YRk2a4= +github.com/open-telemetry/opentelemetry-collector v0.3.1-0.20200512031848-f588c89b4778 h1:wcE5bWypMq95vlZGikUklYB6VPyg3pke/32nei5/Sww= +github.com/open-telemetry/opentelemetry-collector v0.3.1-0.20200512031848-f588c89b4778/go.mod h1:+q6GyqO1FHatlq93uplydIVjRhBrv04oQ23AbOqcn6E= github.com/open-telemetry/opentelemetry-proto v0.3.0 h1:+ASAtcayvoELyCF40+rdCMlBOhZIn5TPDez85zSYc30= github.com/open-telemetry/opentelemetry-proto v0.3.0/go.mod h1:PMR5GI0F7BSpio+rBGFxNm6SLzg3FypDTcFuQZnO+F8= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -968,6 +970,8 @@ github.com/openzipkin/zipkin-go v0.2.1 h1:noL5/5Uf1HpVl3wNsfkZhIKbSWCVi5jgqkONNx github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/orijtech/prometheus-go-metrics-exporter v0.0.4 h1:AAHKuTu2lX4eMPKV+CRcTug9KdMZ/Ckez7KK+ddEQfM= github.com/orijtech/prometheus-go-metrics-exporter v0.0.4/go.mod h1:BiTx/ugZex8LheBk3j53tktWaRdFjV5FCfT2o0P7msE= +github.com/orijtech/prometheus-go-metrics-exporter v0.0.5 h1:76JFgRIgNDA3pW1fUhmqinU2u5ndHv1gvapDfGG+7/c= +github.com/orijtech/prometheus-go-metrics-exporter v0.0.5/go.mod h1:BiTx/ugZex8LheBk3j53tktWaRdFjV5FCfT2o0P7msE= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/ory/dockertest/v3 v3.5.4/go.mod h1:J8ZUbNB2FOhm1cFZW9xBpDsODqsSWcyYgtJYVPcnF70= github.com/ory/fosite v0.29.0/go.mod h1:0atSZmXO7CAcs6NPMI/Qtot8tmZYj04Nddoold4S2h0= diff --git a/crossdock/jaeger-docker-compose.yml b/crossdock/jaeger-docker-compose.yml index fe3c90d14f6..84218978456 100644 --- a/crossdock/jaeger-docker-compose.yml +++ b/crossdock/jaeger-docker-compose.yml @@ -3,7 +3,7 @@ version: '2' services: jaeger-collector: image: jaegertracing/jaeger-collector - command: ["--es.num-shards=1", "--es.num-replicas=0", "--es.server-urls=http://elasticsearch:9200", "--collector.zipkin.http-port=9411"] + command: ["--es.num-shards=1", "--es.num-replicas=0", "--es.server-urls=http://elasticsearch:9200", "--collector.zipkin.host-port=:9411"] ports: - "14269" - "14268:14268" diff --git a/crossdock/jaeger-opentelemetry-docker-compose.yml b/crossdock/jaeger-opentelemetry-docker-compose.yml index 406fefc8d02..35d16428600 100644 --- a/crossdock/jaeger-opentelemetry-docker-compose.yml +++ b/crossdock/jaeger-opentelemetry-docker-compose.yml @@ -3,7 +3,7 @@ version: '2' services: jaeger-collector: image: jaegertracing/jaeger-opentelemetry-collector - command: ["--es.num-shards=1", "--es.num-replicas=0", "--es.server-urls=http://elasticsearch:9200", "--collector.zipkin.http-port=9411"] + command: ["--es.num-shards=1", "--es.num-replicas=0", "--es.server-urls=http://elasticsearch:9200", "--collector.zipkin.host-port=:9411"] ports: - "14250" - "14268" diff --git a/plugin/sampling/strategystore/static/options.go b/plugin/sampling/strategystore/static/options.go index ffc55ba870c..0ef18fbf2ea 100644 --- a/plugin/sampling/strategystore/static/options.go +++ b/plugin/sampling/strategystore/static/options.go @@ -37,8 +37,13 @@ type Options struct { // AddFlags adds flags for Options func AddFlags(flagSet *flag.FlagSet) { - flagSet.String(SamplingStrategiesFile, "", "The path for the sampling strategies file in JSON format. See sampling documentation to see format of the file") flagSet.Duration(samplingStrategiesReloadInterval, 0, "Reload interval to check and reload sampling strategies file. Zero value means no reloading") + AddOTELFlags(flagSet) +} + +// AddOTELFlags adds flags that are exposed by OTEL collector +func AddOTELFlags(flagSet *flag.FlagSet) { + flagSet.String(SamplingStrategiesFile, "", "The path for the sampling strategies file in JSON format. See sampling documentation to see format of the file") } // InitFromViper initializes Options with properties from viper