diff --git a/exporter/stackdriverexporter/factory.go b/exporter/stackdriverexporter/factory.go index 6d0285fc6ae2..0ffed84e67a8 100644 --- a/exporter/stackdriverexporter/factory.go +++ b/exporter/stackdriverexporter/factory.go @@ -15,9 +15,12 @@ package stackdriverexporter import ( + "context" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configerror" "go.opentelemetry.io/collector/config/configmodels" - "go.uber.org/zap" + //"go.uber.org/zap" ) const ( @@ -45,13 +48,20 @@ func (f *Factory) CreateDefaultConfig() configmodels.Exporter { } // CreateTraceExporter creates a trace exporter based on this config. -func (f *Factory) CreateTraceExporter(logger *zap.Logger, cfg configmodels.Exporter) (component.TraceExporter, error) { +func (f *Factory) CreateTraceExporter( + _ context.Context, + _ component.ExporterCreateParams, + cfg configmodels.Exporter) (component.TraceExporter, error) { eCfg := cfg.(*Config) return newStackdriverTraceExporter(eCfg) } // CreateMetricsExporter creates a metrics exporter based on this config. -func (f *Factory) CreateMetricsExporter(logger *zap.Logger, cfg configmodels.Exporter) (component.MetricsExporterOld, error) { - eCfg := cfg.(*Config) - return newStackdriverMetricsExporter(eCfg) +func (f *Factory) CreateMetricsExporter( + _ context.Context, + _ component.ExporterCreateParams, + cfg configmodels.Exporter) (component.MetricsExporter, error) { + // eCfg := cfg.(*Config) + // return newStackdriverMetricsExporter(eCfg) + return nil, configerror.ErrDataTypeIsNotSupported } diff --git a/exporter/stackdriverexporter/spandata.go b/exporter/stackdriverexporter/spandata.go index 37e5e6f8e55b..20b06cda6ce9 100644 --- a/exporter/stackdriverexporter/spandata.go +++ b/exporter/stackdriverexporter/spandata.go @@ -96,6 +96,9 @@ func pdataSpanToOTSpanData( resource pdata.Resource, il pdata.InstrumentationLibrary, ) (*export.SpanData, error) { + if span.IsNil() { + return nil, errNilSpan + } sc := apitrace.SpanContext{} copy(sc.TraceID[:], span.TraceID()) copy(sc.SpanID[:], span.SpanID()) @@ -104,10 +107,7 @@ func pdataSpanToOTSpanData( startTime := time.Unix(0, int64(span.StartTime())) endTime := time.Unix(0, int64(span.EndTime())) status := span.Status() - instrumentationLibrary := instrumentation.Library{ - Name: il.Name(), - Version: il.Version(), - } + sd := &export.SpanData{ SpanContext: sc, ParentSpanID: parentSpanID, @@ -126,7 +126,12 @@ func pdataSpanToOTSpanData( DroppedAttributeCount: int(span.DroppedAttributesCount()), DroppedMessageEventCount: int(span.DroppedEventsCount()), DroppedLinkCount: int(span.DroppedLinksCount()), - InstrumentationLibrary: instrumentationLibrary, + } + if !il.IsNil() { + sd.InstrumentationLibrary = instrumentation.Library{ + Name: il.Name(), + Version: il.Version(), + } } return sd, nil diff --git a/exporter/stackdriverexporter/stackdriver.go b/exporter/stackdriverexporter/stackdriver.go index c9af7c452a10..bb970f52654a 100644 --- a/exporter/stackdriverexporter/stackdriver.go +++ b/exporter/stackdriverexporter/stackdriver.go @@ -192,6 +192,6 @@ func (se *stackdriverExporter) newPushTraceData(ctx context.Context, td pdata.Tr se.texporter.ExportSpan(ctx, span) goodSpans++ } - + fmt.Println("Good spans:", goodSpans) return numSpans - goodSpans, componenterror.CombineErrors(errs) } \ No newline at end of file