-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Configure Jaeger receiver and exporter by flags #2241
Changes from 6 commits
d236098
786e311
6935b60
8c59cf2
48ae7bd
d3e04e9
1d1b6d6
17c0edf
165a991
6b832b6
b936830
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,103 @@ 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", | ||
"--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", | ||
}, | ||
zipkinHostPort: "localhost:55", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the zipkin host/port being provided separately - couldn't it be taken from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we parse the flag in main and enable the receiver only in the default config. The zipkin receiver is different to Jaeger components, we do not wrap and we enable it only in the default config. I will create a separate issue for this. |
||
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{ | ||
"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 +296,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 +321,65 @@ 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"}, | ||
receivers: configmodels.Receivers{ | ||
"jaeger": &jaegerreceiver.Config{ | ||
TypeVal: "jaeger", | ||
NameVal: "jaeger", | ||
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 | ||
|
This file was deleted.
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.
Might be missing something, but why would these
reporter
flags be defined on the collector? They are normally only supported to an agent.I'm guessing its for when the collector maybe forwarding data to another collector using those reporter (or exporter) details - but think it may need some explanation of why these exporter connection details are being used for the receiver/remote sampling 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.
Collector and agent use OTEL Jaeger receiver. Jaeger receiver exposes HTTP sampling endpoint. It can be configured to get the strategies from a remote server via gRPC. Legacy collector was using the reporter (and its flags) to get the data from the collector.
I can update the test and move the flags to agent test, but it really does not matter in the end.