From 834eb0615a4cd2a8d3a576e34f95740ffc6c6a8f Mon Sep 17 00:00:00 2001 From: Vishal Raj Date: Wed, 5 Jun 2024 11:45:40 +0100 Subject: [PATCH] [chore][exporter/elasticsearch]Extend benchmarks for mapping mode --- .../integrationtest/exporter_bench_test.go | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/exporter/elasticsearchexporter/integrationtest/exporter_bench_test.go b/exporter/elasticsearchexporter/integrationtest/exporter_bench_test.go index 65c8abbbda1a..569d37e19a27 100644 --- a/exporter/elasticsearchexporter/integrationtest/exporter_bench_test.go +++ b/exporter/elasticsearchexporter/integrationtest/exporter_bench_test.go @@ -25,32 +25,34 @@ import ( func BenchmarkExporter(b *testing.B) { for _, eventType := range []string{"logs", "traces"} { - for _, tc := range []struct { - name string - batchSize int - }{ - {name: "small_batch", batchSize: 10}, - {name: "medium_batch", batchSize: 100}, - {name: "large_batch", batchSize: 1000}, - {name: "xlarge_batch", batchSize: 10000}, - } { - b.Run(fmt.Sprintf("%s/%s", eventType, tc.name), func(b *testing.B) { - switch eventType { - case "logs": - benchmarkLogs(b, tc.batchSize) - case "traces": - benchmarkTraces(b, tc.batchSize) - } - }) + for _, mappingMode := range []string{"none", "ecs", "raw"} { + for _, tc := range []struct { + name string + batchSize int + }{ + {name: "small_batch", batchSize: 10}, + {name: "medium_batch", batchSize: 100}, + {name: "large_batch", batchSize: 1000}, + {name: "xlarge_batch", batchSize: 10000}, + } { + b.Run(fmt.Sprintf("%s/%s/%s", eventType, mappingMode, tc.name), func(b *testing.B) { + switch eventType { + case "logs": + benchmarkLogs(b, tc.batchSize, mappingMode) + case "traces": + benchmarkTraces(b, tc.batchSize, mappingMode) + } + }) + } } } } -func benchmarkLogs(b *testing.B, batchSize int) { +func benchmarkLogs(b *testing.B, batchSize int, mappingMode string) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - runnerCfg := prepareBenchmark(b, batchSize) + runnerCfg := prepareBenchmark(b, batchSize, mappingMode) exporter, err := runnerCfg.factory.CreateLogsExporter( ctx, exportertest.NewNopCreateSettings(), runnerCfg.esCfg, ) @@ -73,11 +75,11 @@ func benchmarkLogs(b *testing.B, batchSize int) { require.NoError(b, exporter.Shutdown(ctx)) } -func benchmarkTraces(b *testing.B, batchSize int) { +func benchmarkTraces(b *testing.B, batchSize int, mappingMode string) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - runnerCfg := prepareBenchmark(b, batchSize) + runnerCfg := prepareBenchmark(b, batchSize, mappingMode) exporter, err := runnerCfg.factory.CreateTracesExporter( ctx, exportertest.NewNopCreateSettings(), runnerCfg.esCfg, ) @@ -111,6 +113,7 @@ type benchRunnerCfg struct { func prepareBenchmark( b *testing.B, batchSize int, + mappingMode string, ) *benchRunnerCfg { b.Helper() @@ -122,6 +125,7 @@ func prepareBenchmark( cfg.factory = elasticsearchexporter.NewFactory() cfg.esCfg = cfg.factory.CreateDefaultConfig().(*elasticsearchexporter.Config) + cfg.esCfg.Mapping.Mode = mappingMode cfg.esCfg.Endpoints = []string{receiver.endpoint} cfg.esCfg.LogsIndex = TestLogsIndex cfg.esCfg.TracesIndex = TestTracesIndex