Skip to content
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

Use OTEL Kafka Exporter/Receiver Instead of Jaeger Core #2494

Merged
merged 18 commits into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'master' into kafka-otel
Signed-off-by: Joe Elliott <number101010@gmail.com>
  • Loading branch information
joe-elliott committed Sep 18, 2020
commit 9fe5d38b9dbbdff08ddadfc6b5cf2e7fb80c4532
10 changes: 10 additions & 0 deletions cmd/opentelemetry/app/exporter/badgerexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ func (f Factory) CreateMetricsExporter(
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateLogsExporter creates a metrics exporter based on provided config.
// This function implements component.ExporterFactory.
func (f Factory) CreateLogsExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.LogsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

func (f Factory) createStorageFactory(params component.ExporterCreateParams, cfg *Config) (storage.Factory, error) {
f.mutex.Lock()
defer f.mutex.Unlock()
Expand Down
10 changes: 10 additions & 0 deletions cmd/opentelemetry/app/exporter/cassandraexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,13 @@ func (Factory) CreateMetricsExporter(
) (component.MetricsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateLogsExporter creates a metrics exporter based on provided config.
// This function implements component.ExporterFactory.
func (f Factory) CreateLogsExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.LogsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}
10 changes: 10 additions & 0 deletions cmd/opentelemetry/app/exporter/elasticsearchexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ func (Factory) CreateMetricsExporter(
) (component.MetricsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateLogsExporter creates a metrics exporter based on provided config.
// This function implements component.ExporterFactory.
func (f Factory) CreateLogsExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.LogsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func bulkItemsToTraces(bulkItems []bulkItem) pdata.Traces {
if !spanData.InstrumentationLibrary.IsNil() {
spanData.InstrumentationLibrary.CopyTo(ispans.InstrumentationLibrary())
}
ispans.Spans().Append(&spanData.Span)
ispans.Spans().Append(spanData.Span)
}
return traces
}
10 changes: 10 additions & 0 deletions cmd/opentelemetry/app/exporter/grpcpluginexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,13 @@ func (f Factory) CreateMetricsExporter(
) (component.MetricsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateLogsExporter creates a metrics exporter based on provided config.
// This function implements component.ExporterFactory.
func (f Factory) CreateLogsExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.LogsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}
10 changes: 10 additions & 0 deletions cmd/opentelemetry/app/exporter/jaegerexporter/jaeger_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ func (f Factory) CreateMetricsExporter(
) (component.MetricsExporter, error) {
return f.Wrapped.CreateMetricsExporter(ctx, params, cfg)
}

// CreateLogsExporter creates a metrics exporter based on provided config.
// This function implements component.ExporterFactory.
func (f Factory) CreateLogsExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.LogsExporter, error) {
return f.Wrapped.CreateLogsExporter(ctx, params, cfg)
}
10 changes: 10 additions & 0 deletions cmd/opentelemetry/app/exporter/kafkaexporter/kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,13 @@ func (f Factory) CreateMetricsExporter(
) (component.MetricsExporter, error) {
return f.Wrapped.CreateMetricsExporter(ctx, params, cfg)
}

// CreateLogsExporter creates a metrics exporter based on provided config.
// This function implements component.ExporterFactory.
func (f Factory) CreateLogsExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.LogsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}
10 changes: 10 additions & 0 deletions cmd/opentelemetry/app/exporter/memoryexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ func (Factory) CreateMetricsExporter(
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateLogsExporter creates a metrics exporter based on provided config.
// This function implements component.ExporterFactory.
func (f Factory) CreateLogsExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.LogsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

func (f Factory) createStorageFactory(params component.ExporterCreateParams, cfg configmodels.Exporter) (storage.Factory, error) {
config, ok := cfg.(*Config)
if !ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func (f Factory) GetTags() map[string]string {
func (f Factory) CreateTraceProcessor(
ctx context.Context,
params component.ProcessorCreateParams,
nextConsumer consumer.TraceConsumer,
cfg configmodels.Processor,
nextConsumer consumer.TraceConsumer,
) (component.TraceProcessor, error) {
c := cfg.(*resourceprocessor.Config)
attributeKeys := map[string]bool{}
Expand All @@ -91,16 +91,28 @@ func (f Factory) CreateTraceProcessor(
})
}
}
return f.Wrapped.CreateTraceProcessor(ctx, params, nextConsumer, cfg)
return f.Wrapped.CreateTraceProcessor(ctx, params, cfg, nextConsumer)
}

// CreateMetricsProcessor creates a resource processor.
// This function implements component.ProcessorFactoryOld.
func (f Factory) CreateMetricsProcessor(
ctx context.Context,
params component.ProcessorCreateParams,
nextConsumer consumer.MetricsConsumer,
cfg configmodels.Processor,
nextConsumer consumer.MetricsConsumer,
) (component.MetricsProcessor, error) {
return f.Wrapped.CreateMetricsProcessor(ctx, params, nextConsumer, cfg)
return f.Wrapped.CreateMetricsProcessor(ctx, params, cfg, nextConsumer)
}

// CreateLogsProcessor creates a processor based on the config.
// If the processor type does not support logs or if the config is not valid
// error will be returned instead.
func (f Factory) CreateLogsProcessor(
ctx context.Context,
params component.ProcessorCreateParams,
cfg configmodels.Processor,
nextConsumer consumer.LogsConsumer,
) (component.LogsProcessor, error) {
return f.Wrapped.CreateLogsProcessor(ctx, params, cfg, nextConsumer)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestDefaultValueFromViper(t *testing.T) {
}

cfg := f.CreateDefaultConfig().(*resourceprocessor.Config)
p, err := f.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, &componenttest.ExampleExporterConsumer{}, cfg)
p, err := f.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, &componenttest.ExampleExporterConsumer{})
require.NoError(t, err)
assert.NotNil(t, p)

Expand All @@ -81,7 +81,7 @@ func TestLegacyJaegerTagsOnly(t *testing.T) {
}

cfg := f.CreateDefaultConfig().(*resourceprocessor.Config)
p, err := f.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, &componenttest.ExampleExporterConsumer{}, cfg)
p, err := f.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, &componenttest.ExampleExporterConsumer{})
require.NoError(t, err)
assert.NotNil(t, p)

Expand Down Expand Up @@ -116,7 +116,7 @@ func TestLoadConfigAndFlags(t *testing.T) {
require.NotNil(t, colConfig)

cfg := colConfig.Processors[string(f.Type())].(*resourceprocessor.Config)
p, err := f.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, &componenttest.ExampleExporterConsumer{}, cfg)
p, err := f.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, &componenttest.ExampleExporterConsumer{})
require.NoError(t, err)
assert.NotNil(t, p)
assert.Equal(t, []processorhelper.ActionKeyValue{
Expand All @@ -136,9 +136,9 @@ func TestCreateMetricsProcessor(t *testing.T) {
f := &Factory{
Wrapped: resourceprocessor.NewFactory(),
}
mReceiver, err := f.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, &componenttest.ExampleExporterConsumer{}, &resourceprocessor.Config{
mReceiver, err := f.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, &resourceprocessor.Config{
AttributesActions: []processorhelper.ActionKeyValue{{Key: "foo", Value: "val", Action: processorhelper.UPSERT}},
})
}, &componenttest.ExampleExporterConsumer{})
require.Nil(t, err)
assert.NotNil(t, mReceiver)
}
12 changes: 12 additions & 0 deletions cmd/opentelemetry/app/receiver/jaegerreceiver/jaeger_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,15 @@ func (f *Factory) CreateMetricsReceiver(
) (component.MetricsReceiver, error) {
return f.Wrapped.CreateMetricsReceiver(ctx, params, cfg, nextConsumer)
}

// CreateLogsReceiver creates a receiver based on the config.
// If the receiver type does not support logs or if the config is not valid
// error will be returned instead.
func (f Factory) CreateLogsReceiver(
ctx context.Context,
params component.ReceiverCreateParams,
cfg configmodels.Receiver,
nextConsumer consumer.LogsConsumer,
) (component.LogsReceiver, error) {
return f.Wrapped.CreateLogsReceiver(ctx, params, cfg, nextConsumer)
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,15 @@ func (f Factory) CreateMetricsReceiver(
) (component.MetricsReceiver, error) {
return f.Wrapped.CreateMetricsReceiver(ctx, params, cfg, consumer)
}

// CreateLogsReceiver creates a receiver based on the config.
// If the receiver type does not support logs or if the config is not valid
// error will be returned instead.
func (f Factory) CreateLogsReceiver(
ctx context.Context,
params component.ReceiverCreateParams,
cfg configmodels.Receiver,
nextConsumer consumer.LogsConsumer,
) (component.LogsReceiver, error) {
return f.Wrapped.CreateLogsReceiver(ctx, params, cfg, nextConsumer)
}
4 changes: 2 additions & 2 deletions cmd/opentelemetry/cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
}

ver := version.Get()
info := service.ApplicationStartInfo{
info := component.ApplicationStartInfo{
ExeName: "jaeger-opentelemetry-agent",
LongName: "Jaeger OpenTelemetry Agent",
Version: ver.GitVersion,
Expand Down Expand Up @@ -97,6 +97,6 @@ func main() {
handleErr(fmt.Errorf("could not load Jaeger configuration file %w", err))
}

err = svc.Start()
err = svc.Run()
handleErr(err)
}
4 changes: 2 additions & 2 deletions cmd/opentelemetry/cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
}

ver := version.Get()
info := service.ApplicationStartInfo{
info := component.ApplicationStartInfo{
ExeName: "jaeger-opentelemetry-all-in-one",
LongName: "Jaeger OpenTelemetry all-in-one",
Version: ver.GitVersion,
Expand Down Expand Up @@ -136,7 +136,7 @@ func main() {
}

go func() {
err = svc.Start()
err = svc.Run()
handleErr(err)
}()

Expand Down
4 changes: 2 additions & 2 deletions cmd/opentelemetry/cmd/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func main() {
}

ver := version.Get()
info := service.ApplicationStartInfo{
info := component.ApplicationStartInfo{
ExeName: "jaeger-opentelemetry-collector",
LongName: "Jaeger OpenTelemetry Collector",
Version: ver.GitVersion,
Expand Down Expand Up @@ -115,6 +115,6 @@ func main() {
handleErr(fmt.Errorf("could not load Jaeger configuration file %w", err))
}

err = svc.Start()
err = svc.Run()
handleErr(err)
}
4 changes: 2 additions & 2 deletions cmd/opentelemetry/cmd/ingester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func main() {
}

ver := version.Get()
info := service.ApplicationStartInfo{
info := component.ApplicationStartInfo{
ExeName: "jaeger-opentelemetry-ingester",
LongName: "Jaeger OpenTelemetry Ingester",
Version: ver.GitVersion,
Expand Down Expand Up @@ -114,6 +114,6 @@ func main() {
handleErr(fmt.Errorf("could not load Jaeger configuration file %w", err))
}

err = svc.Start()
err = svc.Run()
handleErr(err)
}
2 changes: 1 addition & 1 deletion cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func NewServer(logger *zap.Logger, querySvc *querysvc.QueryService, options *Que
tracer: tracer,
grpcServer: grpcServer,
httpServer: createHTTPServer(querySvc, options, tracer, logger),
separatePorts: (grpcPort != httpPort),
separatePorts: grpcPort != httpPort,
unavailableChannel: make(chan healthcheck.Status),
}, nil
}
Expand Down
59 changes: 38 additions & 21 deletions cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
opentracing "github.com/opentracing/opentracing-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"

Expand Down Expand Up @@ -73,28 +74,44 @@ func TestServerBadHostPort(t *testing.T) {
}

func TestServerInUseHostPort(t *testing.T) {

for _, hostPort := range [2]string{":8080", ":8081"} {
conn, err := net.Listen("tcp", hostPort)
assert.NoError(t, err)

server, err := NewServer(zap.NewNop(), &querysvc.QueryService{},
&QueryOptions{HTTPHostPort: "127.0.0.1:8080", GRPCHostPort: "127.0.0.1:8081", BearerTokenPropagation: true},
opentracing.NoopTracer{})
assert.NoError(t, err)

err = server.Start()
assert.NotNil(t, err)
conn.Close()
if server.grpcConn != nil {
server.grpcConn.Close()
}
if server.httpConn != nil {
server.httpConn.Close()
}

const availableHostPort = "127.0.0.1:0"
conn, err := net.Listen("tcp", availableHostPort)
require.NoError(t, err)
defer func() { require.NoError(t, conn.Close()) }()

testCases := []struct {
name string
httpHostPort string
grpcHostPort string
}{
{"HTTP host port clash", conn.Addr().String(), availableHostPort},
{"GRPC host port clash", availableHostPort, conn.Addr().String()},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
server, err := NewServer(
zap.NewNop(),
&querysvc.QueryService{},
&QueryOptions{
HTTPHostPort: tc.httpHostPort,
GRPCHostPort: tc.grpcHostPort,
BearerTokenPropagation: true,
},
opentracing.NoopTracer{},
)
assert.NoError(t, err)

err = server.Start()
assert.Error(t, err)

if server.grpcConn != nil {
server.grpcConn.Close()
}
if server.httpConn != nil {
server.httpConn.Close()
}
})
}

}

func TestServer(t *testing.T) {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.