Skip to content

Commit

Permalink
[chore][exporter/elasticsearch]Log errror logs on bench and fix EOF (#…
Browse files Browse the repository at this point in the history
…33554)

**Description:** Benchmark didn't log errors before and issues would not
surface if something was failing during bench. Since benchmarks don't
assert the situation is made worse.
  • Loading branch information
lahsivjar authored Jun 18, 2024
1 parent fc36398 commit ef36268
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (es *mockESReceiver) Start(ctx context.Context, host component.Host) error
})
r.HandleFunc("/_bulk", func(w http.ResponseWriter, r *http.Request) {
if !es.config.DecodeBulkRequests {
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, "{}")
return
}
_, response := docappendertest.DecodeBulkRequest(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed"
Expand Down Expand Up @@ -52,9 +54,11 @@ func benchmarkLogs(b *testing.B, batchSize int, mappingMode string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

exporterSettings := exportertest.NewNopSettings()
exporterSettings.TelemetrySettings.Logger = zaptest.NewLogger(b, zaptest.Level(zap.WarnLevel))
runnerCfg := prepareBenchmark(b, batchSize, mappingMode)
exporter, err := runnerCfg.factory.CreateLogsExporter(
ctx, exportertest.NewNopSettings(), runnerCfg.esCfg,
ctx, exporterSettings, runnerCfg.esCfg,
)
require.NoError(b, err)
require.NoError(b, exporter.Start(ctx, componenttest.NewNopHost()))
Expand All @@ -79,9 +83,11 @@ func benchmarkTraces(b *testing.B, batchSize int, mappingMode string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

exporterSettings := exportertest.NewNopSettings()
exporterSettings.TelemetrySettings.Logger = zaptest.NewLogger(b, zaptest.Level(zap.WarnLevel))
runnerCfg := prepareBenchmark(b, batchSize, mappingMode)
exporter, err := runnerCfg.factory.CreateTracesExporter(
ctx, exportertest.NewNopSettings(), runnerCfg.esCfg,
ctx, exporterSettings, runnerCfg.esCfg,
)
require.NoError(b, err)
require.NoError(b, exporter.Start(ctx, componenttest.NewNopHost()))
Expand Down

0 comments on commit ef36268

Please sign in to comment.