Skip to content

Commit

Permalink
bump opentelemetry-collector to v0.14.0
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Kositsyn <[email protected]>
  • Loading branch information
pkositsyn committed Nov 6, 2020
1 parent 740264b commit 64633e1
Show file tree
Hide file tree
Showing 29 changed files with 133 additions and 92 deletions.
6 changes: 3 additions & 3 deletions cmd/opentelemetry/app/exporter/badgerexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ func (f Factory) CreateDefaultConfig() configmodels.Exporter {

// CreateTraceExporter creates Jaeger Cassandra trace exporter.
// This function implements OTEL component.ExporterFactory interface.
func (f Factory) CreateTraceExporter(
func (f Factory) CreateTracesExporter(
_ context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.TraceExporter, error) {
) (component.TracesExporter, error) {
config := cfg.(*Config)
factory, err := f.createStorageFactory(params, config)
if err != nil {
return nil, err
}
return exporter.NewSpanWriterExporter(cfg, factory,
return exporter.NewSpanWriterExporter(cfg, params, factory,
exporterhelper.WithTimeout(config.TimeoutSettings),
exporterhelper.WithQueue(config.QueueSettings),
exporterhelper.WithRetry(config.RetrySettings))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestCreateTraceExporter(t *testing.T) {
factory := NewFactory(func() *badger.Options {
return opts
})
exporter, err := factory.CreateTraceExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, factory.CreateDefaultConfig())
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, factory.CreateDefaultConfig())
require.NoError(t, err)
assert.NotNil(t, exporter)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/opentelemetry/app/exporter/cassandraexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
)

// new creates Cassandra exporter/storage
func new(config *Config, params component.ExporterCreateParams) (component.TraceExporter, error) {
func new(config *Config, params component.ExporterCreateParams) (component.TracesExporter, error) {
f := cassandra.NewFactory()
f.InitFromOptions(&config.Options)

err := f.Initialize(metrics.NullFactory, params.Logger)
if err != nil {
return nil, err
}
return exporter.NewSpanWriterExporter(config, f,
return exporter.NewSpanWriterExporter(config, params, f,
exporterhelper.WithTimeout(config.TimeoutSettings),
exporterhelper.WithQueue(config.QueueSettings),
exporterhelper.WithRetry(config.RetrySettings))
Expand Down
4 changes: 2 additions & 2 deletions cmd/opentelemetry/app/exporter/cassandraexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func (f Factory) CreateDefaultConfig() configmodels.Exporter {

// CreateTraceExporter creates Jaeger Cassandra trace exporter.
// This function implements OTEL component.ExporterFactory interface.
func (f Factory) CreateTraceExporter(
func (f Factory) CreateTracesExporter(
_ context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.TraceExporter, error) {
) (component.TracesExporter, error) {
config := cfg.(*Config)
return new(config, params)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestCreateTraceExporter(t *testing.T) {
factory := Factory{OptionsFactory: func() *cassandra.Options {
return opts
}}
exporter, err := factory.CreateTraceExporter(context.Background(), component.ExporterCreateParams{}, factory.CreateDefaultConfig())
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{}, factory.CreateDefaultConfig())
require.Nil(t, exporter)
assert.Contains(t, err.Error(), "gocql: unable to create session")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,15 @@ func references(links pdata.SpanLinkSlice, parentSpanID pdata.SpanID, traceID db
}

func convertSpanID(spanID pdata.SpanID) (dbmodel.SpanID, error) {
spanIDInt, err := tracetranslator.BytesToUInt64SpanID(spanID.Bytes())
if err != nil {
return "", err
}
spanIDInt := tracetranslator.BytesToUInt64SpanID(spanID.Bytes())
if spanIDInt == 0 {
return "", errZeroSpanID
}
return dbmodel.SpanID(fmt.Sprintf("%016x", spanIDInt)), nil
}

func convertTraceID(traceID pdata.TraceID) (dbmodel.TraceID, error) {
high, low, err := tracetranslator.BytesToUInt64TraceID(traceID.Bytes())
if err != nil {
return "", err
}
high, low := tracetranslator.BytesToUInt64TraceID(traceID.Bytes())
if low == 0 && high == 0 {
return "", errZeroTraceID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package esmodeltranslator

import (
"encoding/binary"
"fmt"
"testing"
"time"
Expand All @@ -30,8 +29,8 @@ import (
)

var (
traceID = pdata.NewTraceID([]byte("0123456789abcdef"))
spanID = pdata.NewSpanID([]byte("01234567"))
traceID = pdata.NewTraceID(Byte16ArrayFromString("0123456789abcdef"))
spanID = pdata.NewSpanID(Byte8ArrayFromString("01234567"))
)

func TestAttributeToKeyValue(t *testing.T) {
Expand Down Expand Up @@ -151,7 +150,7 @@ func TestConvertSpan(t *testing.T) {
StartTimeMillis: 1,
Tags: []dbmodel.KeyValue{
{Key: "span.kind", Type: dbmodel.StringType, Value: "client"},
{Key: "status.code", Type: dbmodel.StringType, Value: "STATUS_CODE_CANCELLED"},
{Key: "status.code", Type: dbmodel.StringType, Value: "STATUS_CODE_OK"},
{Key: "error", Type: dbmodel.BoolType, Value: "true"},
{Key: "status.message", Type: dbmodel.StringType, Value: "messagetext"},
{Key: "foo", Type: dbmodel.BoolType, Value: "true"},
Expand Down Expand Up @@ -196,9 +195,15 @@ func TestSpanEmptyRef(t *testing.T) {
Duration: 1000,
OperationName: "root",
StartTimeMillis: 1,
Tags: []dbmodel.KeyValue{}, // should not be nil
Logs: []dbmodel.Log{}, // should not be nil
References: []dbmodel.Reference{}, // should not be nil
Tags: []dbmodel.KeyValue{}, // should not be nil
Logs: []dbmodel.Log{}, // should not be nil
References: []dbmodel.Reference{
{
RefType: "CHILD_OF",
TraceID: "30313233343536373839616263646566",
SpanID: "3031323334353637",
},
},
Process: dbmodel.Process{
ServiceName: "myservice",
Tags: nil,
Expand All @@ -215,26 +220,16 @@ func TestEmpty(t *testing.T) {
}

func TestErrorIDs(t *testing.T) {
zero64Bytes := make([]byte, 16)
binary.LittleEndian.PutUint64(zero64Bytes, 0)
binary.LittleEndian.PutUint64(zero64Bytes, 0)
var zero64Bytes [16]byte
var zero32Bytes [8]byte
tests := []struct {
spanID pdata.SpanID
traceID pdata.TraceID
err string
}{
{
traceID: pdata.NewTraceID([]byte("invalid-%")),
err: "TraceID does not have 16 bytes",
},
{
traceID: traceID,
spanID: pdata.NewSpanID([]byte("invalid-%")),
err: "SpanID does not have 8 bytes",
},
{
traceID: traceID,
spanID: pdata.NewSpanID(zero64Bytes[:8]),
spanID: pdata.NewSpanID(zero32Bytes),
err: errZeroSpanID.Error(),
},
{
Expand Down Expand Up @@ -274,7 +269,18 @@ func addSpan(traces pdata.Traces, name string, traceID pdata.TraceID, spanID pda
span.SetName(name)
span.SetTraceID(traceID)
span.SetSpanID(spanID)
span.SetParentSpanID(spanID)
span.SetStartTime(pdata.TimestampUnixNano(time.Now().UnixNano()))
span.SetEndTime(pdata.TimestampUnixNano(time.Now().UnixNano()))
return span
}

func Byte16ArrayFromString(s string) (result [16]byte) {
copy(result[:], s)
return
}

func Byte8ArrayFromString(s string) (result [8]byte) {
copy(result[:], s)
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

// newExporter creates Elasticsearch exporter/storage.
func newExporter(ctx context.Context, config *Config, params component.ExporterCreateParams) (component.TraceExporter, error) {
func newExporter(ctx context.Context, config *Config, params component.ExporterCreateParams) (component.TracesExporter, error) {
esCfg := config.GetPrimary()
w, err := newEsSpanWriter(*esCfg, params.Logger, false, config.Name())
if err != nil {
Expand All @@ -38,6 +38,7 @@ func newExporter(ctx context.Context, config *Config, params component.ExporterC
}
return exporterhelper.NewTraceExporter(
config,
params.Logger,
w.WriteTraces,
exporterhelper.WithTimeout(config.TimeoutSettings),
exporterhelper.WithQueue(config.QueueSettings),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ func (f Factory) CreateDefaultConfig() configmodels.Exporter {

// CreateTraceExporter creates Jaeger Elasticsearch trace exporter.
// This function implements OTEL component.ExporterFactory interface.
func (Factory) CreateTraceExporter(
func (Factory) CreateTracesExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.TraceExporter, error) {
) (component.TracesExporter, error) {
esCfg, ok := cfg.(*Config)
if !ok {
return nil, fmt.Errorf("could not cast configuration to %s", TypeStr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func TestCreateTraceExporter(t *testing.T) {
}}
config := factory.CreateDefaultConfig().(*Config)
config.Primary.Servers = []string{"http://foobardoesnotexists.test"}
exporter, err := factory.CreateTraceExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, config)
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, config)
require.Nil(t, exporter)
assert.Contains(t, err.Error(), "no such host")
}

func TestCreateTraceExporter_nilConfig(t *testing.T) {
factory := &Factory{}
exporter, err := factory.CreateTraceExporter(context.Background(), component.ExporterCreateParams{}, nil)
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{}, nil)
require.Nil(t, exporter)
assert.Contains(t, err.Error(), "could not cast configuration to jaeger_elasticsearch")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const (
serviceIndexBaseName = "jaeger-service"
spanTypeName = "span"
serviceTypeName = "service"
indexDateFormat = "2006-01-02" // date format for index e.g. 2020-01-20
)

// esSpanWriter holds components required for ES span writer
Expand Down Expand Up @@ -245,7 +244,7 @@ func bulkItemsToTraces(bulkItems []bulkItem) pdata.Traces {
rss := traces.ResourceSpans().At(i)
if !spanData.Resource.IsNil() {
rss.Resource().InitEmpty()
rss.Resource().Attributes().InitFromAttributeMap(spanData.Resource.Attributes())
spanData.Resource.Attributes().CopyTo(rss.Resource().Attributes())
}
rss.InstrumentationLibrarySpans().Resize(1)
ispans := rss.InstrumentationLibrarySpans().At(0)
Expand Down
4 changes: 2 additions & 2 deletions cmd/opentelemetry/app/exporter/grpcpluginexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import (
)

// new creates gRPC exporter/storage.
func new(config *Config, params component.ExporterCreateParams) (component.TraceExporter, error) {
func new(config *Config, params component.ExporterCreateParams) (component.TracesExporter, error) {
factory := storageGrpc.NewFactory()
factory.InitFromOptions(config.Options)
err := factory.Initialize(metrics.NullFactory, params.Logger)
if err != nil {
return nil, err
}
return storageOtelExporter.NewSpanWriterExporter(&config.ExporterSettings, factory,
return storageOtelExporter.NewSpanWriterExporter(&config.ExporterSettings, params, factory,
exporterhelper.WithTimeout(config.TimeoutSettings),
exporterhelper.WithQueue(config.QueueSettings),
exporterhelper.WithRetry(config.RetrySettings))
Expand Down
4 changes: 2 additions & 2 deletions cmd/opentelemetry/app/exporter/grpcpluginexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ func (f Factory) CreateDefaultConfig() configmodels.Exporter {

// CreateTraceExporter creates Jaeger gRPC trace exporter.
// This function implements OTEL component.ExporterFactory interface.
func (f Factory) CreateTraceExporter(
func (f Factory) CreateTracesExporter(
_ context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.TraceExporter, error) {
) (component.TracesExporter, error) {
grpcCfg := cfg.(*Config)
return new(grpcCfg, params)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestCreateTraceExporter(t *testing.T) {
factory := &Factory{OptionsFactory: func() *storageGrpc.Options {
return opts
}}
exporter, err := factory.CreateTraceExporter(context.Background(), component.ExporterCreateParams{}, factory.CreateDefaultConfig())
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{}, factory.CreateDefaultConfig())
require.Nil(t, exporter)
assert.Contains(t, err.Error(), "error attempting to connect to plugin rpc client: fork/exec : no such file or directory")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ func (f Factory) CreateDefaultConfig() configmodels.Exporter {

// CreateTraceExporter creates Jaeger trace exporter.
// This function implements OTEL component.ExporterFactory interface.
func (f Factory) CreateTraceExporter(
func (f Factory) CreateTracesExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.TraceExporter, error) {
return f.Wrapped.CreateTraceExporter(ctx, params, cfg)
) (component.TracesExporter, error) {
return f.Wrapped.CreateTracesExporter(ctx, params, cfg)
}

// CreateMetricsExporter creates a metrics exporter based on provided config.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func TestDefaultValueFromViper(t *testing.T) {
cfg := f.CreateDefaultConfig().(*jaegerexporter.Config)

qs := exporterhelper.CreateDefaultQueueSettings()
qs.Enabled = false
assert.Equal(t, &jaegerexporter.Config{
ExporterSettings: configmodels.ExporterSettings{
TypeVal: "jaeger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ func (f Factory) CreateDefaultConfig() configmodels.Exporter {

// CreateTraceExporter creates Jaeger trace exporter.
// This function implements OTEL component.ExporterFactory interface.
func (f Factory) CreateTraceExporter(
func (f Factory) CreateTracesExporter(
ctx context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.TraceExporter, error) {
return f.Wrapped.CreateTraceExporter(ctx, params, cfg)
) (component.TracesExporter, error) {
return f.Wrapped.CreateTracesExporter(ctx, params, cfg)
}

// CreateMetricsExporter creates a metrics exporter based on provided config.
Expand Down
6 changes: 3 additions & 3 deletions cmd/opentelemetry/app/exporter/memoryexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ func (f Factory) CreateDefaultConfig() configmodels.Exporter {

// CreateTraceExporter creates Jaeger Kafka trace exporter.
// This function implements OTEL component.ExporterFactory interface.
func (f Factory) CreateTraceExporter(
func (f Factory) CreateTracesExporter(
_ context.Context,
params component.ExporterCreateParams,
cfg configmodels.Exporter,
) (component.TraceExporter, error) {
) (component.TracesExporter, error) {
factory, err := f.createStorageFactory(params, cfg)
if err != nil {
return nil, err
}
return exporter.NewSpanWriterExporter(cfg, factory)
return exporter.NewSpanWriterExporter(cfg, params, factory)
}

// CreateMetricsExporter is not implemented.
Expand Down
8 changes: 4 additions & 4 deletions cmd/opentelemetry/app/exporter/memoryexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestCreateTraceExporter(t *testing.T) {

v, _ := jConfig.Viperize(AddFlags)
factory := NewFactory(v)
exporter, err := factory.CreateTraceExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, factory.CreateDefaultConfig())
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, factory.CreateDefaultConfig())
require.NoError(t, err)
require.NotNil(t, exporter)
}
Expand All @@ -48,7 +48,7 @@ func TestCreateTraceExporter_nilConfig(t *testing.T) {
defer cleanup()

factory := &Factory{}
exporter, err := factory.CreateTraceExporter(context.Background(), component.ExporterCreateParams{}, nil)
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{}, nil)
require.Nil(t, exporter)
assert.Contains(t, err.Error(), "could not cast configuration to jaeger_memory")
}
Expand Down Expand Up @@ -84,11 +84,11 @@ func TestSingleton(t *testing.T) {
f := NewFactory(viper.New())
logger := zap.NewNop()
assert.Nil(t, instance)
exp, err := f.CreateTraceExporter(context.Background(), component.ExporterCreateParams{Logger: logger}, &Config{})
exp, err := f.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: logger}, &Config{})
require.NoError(t, err)
require.NotNil(t, exp)
previousInstance := instance
exp, err = f.CreateTraceExporter(context.Background(), component.ExporterCreateParams{Logger: logger}, &Config{})
exp, err = f.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: logger}, &Config{})
require.NoError(t, err)
require.NotNil(t, exp)
assert.Equal(t, previousInstance, instance)
Expand Down
Loading

0 comments on commit 64633e1

Please sign in to comment.