diff --git a/exporter/instanaexporter/exporter.go b/exporter/instanaexporter/exporter.go index 88b44208ddc6..3ec7c0dd9e03 100644 --- a/exporter/instanaexporter/exporter.go +++ b/exporter/instanaexporter/exporter.go @@ -29,20 +29,17 @@ import ( "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" - "go.uber.org/zap/zapcore" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/instanaexporter/internal/backend" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/instanaexporter/internal/converter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/instanaexporter/internal/converter/model" - "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/instanaexporter/internal/otlptext" ) type instanaExporter struct { - config *Config - client *http.Client - tracesMarshaler ptrace.Marshaler - settings component.TelemetrySettings - userAgent string + config *Config + client *http.Client + settings component.TelemetrySettings + userAgent string } func (e *instanaExporter) start(_ context.Context, host component.Host) error { @@ -55,17 +52,6 @@ func (e *instanaExporter) start(_ context.Context, host component.Host) error { } func (e *instanaExporter) pushConvertedTraces(ctx context.Context, td ptrace.Traces) error { - e.settings.Logger.Info("TracesExporter", zap.Int("#spans", td.SpanCount())) - if !e.settings.Logger.Core().Enabled(zapcore.DebugLevel) { - return nil - } - - buf, err := e.tracesMarshaler.MarshalTraces(td) - if err != nil { - return err - } - e.settings.Logger.Debug(string(buf)) - converter := converter.NewConvertAllConverter(e.settings.Logger) spans := make([]model.Span, 0) @@ -97,9 +83,6 @@ func (e *instanaExporter) pushConvertedTraces(ctx context.Context, td ptrace.Tra } req, err := bundle.Marshal() - - e.settings.Logger.Debug(string(req)) - if err != nil { return consumererror.NewPermanent(err) } @@ -126,18 +109,15 @@ func newInstanaExporter(cfg config.Exporter, set component.ExporterCreateSetting userAgent := fmt.Sprintf("%s/%s (%s/%s)", set.BuildInfo.Description, set.BuildInfo.Version, runtime.GOOS, runtime.GOARCH) return &instanaExporter{ - config: iCfg, - settings: set.TelemetrySettings, - tracesMarshaler: otlptext.NewTextTracesMarshaler(), - userAgent: userAgent, + config: iCfg, + settings: set.TelemetrySettings, + userAgent: userAgent, }, nil } func (e *instanaExporter) export(ctx context.Context, url string, header map[string]string, request []byte) error { url = strings.TrimSuffix(url, "/") + "/bundle" - e.settings.Logger.Debug("Preparing to make HTTP request", zap.String("url", url)) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(request)) if err != nil { return consumererror.NewPermanent(err) @@ -152,7 +132,7 @@ func (e *instanaExporter) export(ctx context.Context, url string, header map[str resp, err := e.client.Do(req) if err != nil { - return fmt.Errorf("failed to make an HTTP request: %w", err) + return fmt.Errorf("failed to make a HTTP request: %w", err) } if resp.StatusCode >= 200 && resp.StatusCode <= 299 { diff --git a/exporter/instanaexporter/exporter_test.go b/exporter/instanaexporter/exporter_test.go index bf7ca05b3c70..b1791dbea95e 100644 --- a/exporter/instanaexporter/exporter_test.go +++ b/exporter/instanaexporter/exporter_test.go @@ -47,7 +47,11 @@ func TestPushConvertedDefaultTraces(t *testing.T) { componenttest.NewNopExporterCreateSettings()) assert.NoError(t, err) - err = instanaExporter.pushConvertedTraces(context.Background(), testutils.TestTraces.Clone()) + ctx := context.Background() + err = instanaExporter.start(ctx, componenttest.NewNopHost()) + assert.NoError(t, err) + + err = instanaExporter.pushConvertedTraces(ctx, testutils.TestTraces.Clone()) assert.NoError(t, err) } @@ -71,7 +75,11 @@ func TestPushConvertedSimpleTraces(t *testing.T) { componenttest.NewNopExporterCreateSettings()) assert.NoError(t, err) - err = instanaExporter.pushConvertedTraces(context.Background(), simpleTraces()) + ctx := context.Background() + err = instanaExporter.start(ctx, componenttest.NewNopHost()) + assert.NoError(t, err) + + err = instanaExporter.pushConvertedTraces(ctx, simpleTraces()) assert.NoError(t, err) } diff --git a/exporter/instanaexporter/internal/converter/all_converter.go b/exporter/instanaexporter/internal/converter/all_converter.go index aa93d604f490..a731906b38e4 100644 --- a/exporter/instanaexporter/internal/converter/all_converter.go +++ b/exporter/instanaexporter/internal/converter/all_converter.go @@ -40,7 +40,7 @@ func (c *ConvertAllConverter) ConvertSpans(attributes pcommon.Map, spanSlice ptr for i := 0; i < len(c.converters); i++ { if !c.converters[i].AcceptsSpans(attributes, spanSlice) { - c.logger.Debug(fmt.Sprintf("Converter %s didnt Accept", c.converters[i].Name())) + c.logger.Warn(fmt.Sprintf("Converter %s didnt Accept", c.converters[i].Name())) continue } diff --git a/exporter/instanaexporter/internal/converter/span_converter.go b/exporter/instanaexporter/internal/converter/span_converter.go index 1c4d81dde585..0a441a33e470 100644 --- a/exporter/instanaexporter/internal/converter/span_converter.go +++ b/exporter/instanaexporter/internal/converter/span_converter.go @@ -72,7 +72,7 @@ func (c *SpanConverter) ConvertSpans(attributes pcommon.Map, spanSlice ptrace.Sp instanaSpan, err := model.ConvertPDataSpanToInstanaSpan(fromS, otelSpan, serviceName, attributes) if err != nil { - c.logger.Debug(fmt.Sprintf("Error converting Open Telemetry span to Instana span: %s", err.Error())) + c.logger.Warn(fmt.Sprintf("Error converting Open Telemetry span to Instana span: %s", err.Error())) continue } diff --git a/exporter/instanaexporter/internal/testutils/test_utils.go b/exporter/instanaexporter/internal/testutils/test_utils.go index 4f6c0711a0f1..cc1bc480b962 100644 --- a/exporter/instanaexporter/internal/testutils/test_utils.go +++ b/exporter/instanaexporter/internal/testutils/test_utils.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testutils +package testutils // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/instanaexporter/internal/testutils" import ( "go.opentelemetry.io/collector/pdata/pcommon"