diff --git a/.chloggen/add_integration_test_for_clickhous_exporter.yaml b/.chloggen/add_integration_test_for_clickhous_exporter.yaml new file mode 100644 index 000000000000..231361f1e16e --- /dev/null +++ b/.chloggen/add_integration_test_for_clickhous_exporter.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: clickhouseexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add integration test for clickhouse exporter + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29626] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index 8d1a525592be..c404b14e8201 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -1049,6 +1049,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index b4c58803c4e4..9e47feb697d4 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -1045,6 +1045,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= diff --git a/exporter/clickhouseexporter/README.md b/exporter/clickhouseexporter/README.md index 207f3c1640cb..2293a57b4948 100644 --- a/exporter/clickhouseexporter/README.md +++ b/exporter/clickhouseexporter/README.md @@ -342,3 +342,7 @@ service: processors: [ batch ] exporters: [ clickhouse ] ``` + +## Developer tips + +- Make sure integration tests pass after any change of sql \ No newline at end of file diff --git a/exporter/clickhouseexporter/exporter_logs_test.go b/exporter/clickhouseexporter/exporter_logs_test.go index fc04402702f9..417cda22ec7c 100644 --- a/exporter/clickhouseexporter/exporter_logs_test.go +++ b/exporter/clickhouseexporter/exporter_logs_test.go @@ -121,6 +121,7 @@ func TestExporter_pushLogsData(t *testing.T) { }) } +// nolint:unparam // not need to check this func func newTestLogsExporter(t *testing.T, dsn string, fns ...func(*Config)) *logsExporter { exporter, err := newLogsExporter(zaptest.NewLogger(t), withTestExporterConfig(fns...)(dsn)) require.NoError(t, err) @@ -151,10 +152,18 @@ func simpleLogs(count int) plog.Logs { sl.Scope().SetName("io.opentelemetry.contrib.clickhouse") sl.Scope().SetVersion("1.0.0") sl.Scope().Attributes().PutStr("lib", "clickhouse") + timestamp := time.Unix(1703498029, 0) for i := 0; i < count; i++ { r := sl.LogRecords().AppendEmpty() - r.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) - r.Attributes().PutStr(conventions.AttributeServiceName, "v") + r.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) + r.SetObservedTimestamp(pcommon.NewTimestampFromTime(timestamp)) + r.SetSeverityNumber(plog.SeverityNumberError2) + r.SetSeverityText("error") + r.Body().SetStr("error message") + r.Attributes().PutStr(conventions.AttributeServiceNamespace, "default") + r.SetFlags(plog.DefaultLogRecordFlags) + r.SetTraceID([16]byte{1, 2, 3, byte(i)}) + r.SetSpanID([8]byte{1, 2, 3, byte(i)}) } return logs } diff --git a/exporter/clickhouseexporter/exporter_metrics_test.go b/exporter/clickhouseexporter/exporter_metrics_test.go index 4d407131e257..ee9ad9bb6fd7 100644 --- a/exporter/clickhouseexporter/exporter_metrics_test.go +++ b/exporter/clickhouseexporter/exporter_metrics_test.go @@ -29,7 +29,7 @@ func TestExporter_pushMetricsData(t *testing.T) { } return nil }) - exporter := newTestMetricsExporter(t) + exporter := newTestMetricsExporter(t, defaultEndpoint) mustPushMetricsData(t, exporter, simpleMetrics(1)) require.Equal(t, int32(15), items.Load()) @@ -41,7 +41,7 @@ func TestExporter_pushMetricsData(t *testing.T) { } return nil }) - exporter := newTestMetricsExporter(t) + exporter := newTestMetricsExporter(t, defaultEndpoint) err := exporter.pushMetricsData(context.TODO(), simpleMetrics(2)) require.Error(t, err) }) @@ -93,7 +93,7 @@ func TestExporter_pushMetricsData(t *testing.T) { } return nil }) - exporter := newTestMetricsExporter(t) + exporter := newTestMetricsExporter(t, defaultEndpoint) mustPushMetricsData(t, exporter, simpleMetrics(1)) require.Equal(t, int32(15), items.Load()) @@ -118,14 +118,14 @@ func TestExporter_pushMetricsData(t *testing.T) { } return nil }) - exporter := newTestMetricsExporter(t) + exporter := newTestMetricsExporter(t, defaultEndpoint) mustPushMetricsData(t, exporter, simpleMetrics(1)) }) } func Benchmark_pushMetricsData(b *testing.B) { pm := simpleMetrics(1) - exporter := newTestMetricsExporter(&testing.T{}) + exporter := newTestMetricsExporter(&testing.T{}, defaultEndpoint) b.ReportAllocs() b.ResetTimer() for n := 0; n < b.N; n++ { @@ -148,6 +148,7 @@ func simpleMetrics(count int) pmetric.Metrics { sm.Scope().SetDroppedAttributesCount(10) sm.Scope().SetName("Scope name 1") sm.Scope().SetVersion("Scope version 1") + timestamp := time.Unix(1703498029, 0) for i := 0; i < count; i++ { // gauge m := sm.Metrics().AppendEmpty() @@ -156,10 +157,12 @@ func simpleMetrics(count int) pmetric.Metrics { m.SetDescription("This is a gauge metrics") dp := m.SetEmptyGauge().DataPoints().AppendEmpty() dp.SetIntValue(int64(i)) + dp.SetFlags(pmetric.DefaultDataPointFlags) dp.Attributes().PutStr("gauge_label_1", "1") - dp.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + dp.SetStartTimestamp(pcommon.NewTimestampFromTime(timestamp)) + dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) exemplars := dp.Exemplars().AppendEmpty() + exemplars.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) exemplars.SetIntValue(54) exemplars.FilteredAttributes().PutStr("key", "value") exemplars.FilteredAttributes().PutStr("key2", "value2") @@ -173,10 +176,12 @@ func simpleMetrics(count int) pmetric.Metrics { m.SetDescription("This is a sum metrics") dp = m.SetEmptySum().DataPoints().AppendEmpty() dp.SetDoubleValue(11.234) + dp.SetFlags(pmetric.DefaultDataPointFlags) dp.Attributes().PutStr("sum_label_1", "1") - dp.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + dp.SetStartTimestamp(pcommon.NewTimestampFromTime(timestamp)) + dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) exemplars = dp.Exemplars().AppendEmpty() + exemplars.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) exemplars.SetIntValue(54) exemplars.FilteredAttributes().PutStr("key", "value") exemplars.FilteredAttributes().PutStr("key2", "value2") @@ -189,17 +194,18 @@ func simpleMetrics(count int) pmetric.Metrics { m.SetUnit("ms") m.SetDescription("This is a histogram metrics") dpHisto := m.SetEmptyHistogram().DataPoints().AppendEmpty() - dpHisto.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - dpHisto.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + dpHisto.SetStartTimestamp(pcommon.NewTimestampFromTime(timestamp)) + dpHisto.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) dpHisto.SetCount(1) dpHisto.SetSum(1) dpHisto.Attributes().PutStr("key", "value") - dpHisto.Attributes().PutStr("key", "value") + dpHisto.Attributes().PutStr("key2", "value") dpHisto.ExplicitBounds().FromRaw([]float64{0, 0, 0, 0, 0}) dpHisto.BucketCounts().FromRaw([]uint64{0, 0, 0, 1, 0}) dpHisto.SetMin(0) dpHisto.SetMax(1) exemplars = dpHisto.Exemplars().AppendEmpty() + exemplars.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) exemplars.SetDoubleValue(55.22) exemplars.FilteredAttributes().PutStr("key", "value") exemplars.FilteredAttributes().PutStr("key2", "value2") @@ -212,21 +218,22 @@ func simpleMetrics(count int) pmetric.Metrics { m.SetUnit("ms") m.SetDescription("This is a exp histogram metrics") dpExpHisto := m.SetEmptyExponentialHistogram().DataPoints().AppendEmpty() - dpExpHisto.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - dpExpHisto.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + dpExpHisto.SetStartTimestamp(pcommon.NewTimestampFromTime(timestamp)) + dpExpHisto.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) dpExpHisto.SetSum(1) dpExpHisto.SetMin(0) dpExpHisto.SetMax(1) dpExpHisto.SetZeroCount(0) dpExpHisto.SetCount(1) dpExpHisto.Attributes().PutStr("key", "value") - dpExpHisto.Attributes().PutStr("key", "value") + dpExpHisto.Attributes().PutStr("key2", "value") dpExpHisto.Negative().SetOffset(1) dpExpHisto.Negative().BucketCounts().FromRaw([]uint64{0, 0, 0, 1, 0}) dpExpHisto.Positive().SetOffset(1) dpExpHisto.Positive().BucketCounts().FromRaw([]uint64{0, 0, 0, 1, 0}) exemplars = dpExpHisto.Exemplars().AppendEmpty() + exemplars.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) exemplars.SetIntValue(54) exemplars.FilteredAttributes().PutStr("key", "value") exemplars.FilteredAttributes().PutStr("key2", "value2") @@ -239,10 +246,10 @@ func simpleMetrics(count int) pmetric.Metrics { m.SetUnit("ms") m.SetDescription("This is a summary metrics") summary := m.SetEmptySummary().DataPoints().AppendEmpty() - summary.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - summary.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + summary.SetStartTimestamp(pcommon.NewTimestampFromTime(timestamp)) + summary.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) summary.Attributes().PutStr("key", "value") - summary.Attributes().PutStr("key2", "value2") + summary.Attributes().PutStr("key2", "value") summary.SetCount(1) summary.SetSum(1) quantileValues := summary.QuantileValues().AppendEmpty() @@ -475,8 +482,9 @@ func mustPushMetricsData(t *testing.T, exporter *metricsExporter, md pmetric.Met require.NoError(t, err) } -func newTestMetricsExporter(t *testing.T) *metricsExporter { - exporter, err := newMetricsExporter(zaptest.NewLogger(t), withTestExporterConfig()(defaultEndpoint)) +// nolint:unparam // not need to check this func +func newTestMetricsExporter(t *testing.T, dsn string, fns ...func(*Config)) *metricsExporter { + exporter, err := newMetricsExporter(zaptest.NewLogger(t), withTestExporterConfig(fns...)(dsn)) require.NoError(t, err) require.NoError(t, exporter.start(context.TODO(), nil)) diff --git a/exporter/clickhouseexporter/exporter_traces_test.go b/exporter/clickhouseexporter/exporter_traces_test.go index 2bff1fcdc2b2..d8d6bdf268a2 100644 --- a/exporter/clickhouseexporter/exporter_traces_test.go +++ b/exporter/clickhouseexporter/exporter_traces_test.go @@ -69,15 +69,28 @@ func simpleTraces(count int) ptrace.Traces { ss.SetSchemaUrl("https://opentelemetry.io/schemas/1.7.0") ss.Scope().SetDroppedAttributesCount(20) ss.Scope().Attributes().PutStr("lib", "clickhouse") + timestamp := time.Unix(1703498029, 0) for i := 0; i < count; i++ { s := ss.Spans().AppendEmpty() - s.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - s.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + s.SetTraceID([16]byte{1, 2, 3, byte(i)}) + s.SetSpanID([8]byte{1, 2, 3, byte(i)}) + s.TraceState().FromRaw("trace state") + s.SetParentSpanID([8]byte{1, 2, 4, byte(i)}) + s.SetName("call db") + s.SetKind(ptrace.SpanKindInternal) + s.SetStartTimestamp(pcommon.NewTimestampFromTime(timestamp)) + s.SetEndTimestamp(pcommon.NewTimestampFromTime(timestamp.Add(time.Minute))) s.Attributes().PutStr(conventions.AttributeServiceName, "v") + s.Status().SetMessage("error") + s.Status().SetCode(ptrace.StatusCodeError) event := s.Events().AppendEmpty() event.SetName("event1") - event.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + event.SetTimestamp(pcommon.NewTimestampFromTime(timestamp)) + event.Attributes().PutStr("level", "info") link := s.Links().AppendEmpty() + link.SetTraceID([16]byte{1, 2, 5, byte(i)}) + link.SetSpanID([8]byte{1, 2, 5, byte(i)}) + link.TraceState().FromRaw("error") link.Attributes().PutStr("k", "v") } return traces diff --git a/exporter/clickhouseexporter/go.mod b/exporter/clickhouseexporter/go.mod index 4172b4633436..41b45cef1285 100644 --- a/exporter/clickhouseexporter/go.mod +++ b/exporter/clickhouseexporter/go.mod @@ -5,8 +5,10 @@ go 1.21 require ( github.com/ClickHouse/clickhouse-go/v2 v2.17.1 github.com/cenkalti/backoff/v4 v4.2.1 + github.com/jmoiron/sqlx v1.3.5 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.96.0 github.com/stretchr/testify v1.9.0 + github.com/testcontainers/testcontainers-go v0.27.0 go.opentelemetry.io/collector/component v0.96.1-0.20240306115632-b2693620eff6 go.opentelemetry.io/collector/config/configopaque v1.3.1-0.20240306115632-b2693620eff6 go.opentelemetry.io/collector/config/configretry v0.96.1-0.20240306115632-b2693620eff6 @@ -21,15 +23,27 @@ require ( ) require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/ClickHouse/ch-go v0.58.2 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.11.4 // indirect github.com/andybalholm/brotli v1.0.6 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/containerd/containerd v1.7.11 // indirect + github.com/containerd/log v0.1.0 // indirect + github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/docker/docker v24.0.7+incompatible // indirect + github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/go-faster/city v1.0.1 // indirect github.com/go-faster/errors v0.6.1 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect @@ -39,20 +53,36 @@ require ( github.com/knadh/koanf/maps v0.1.1 // indirect github.com/knadh/koanf/providers/confmap v0.1.0 // indirect github.com/knadh/koanf/v2 v2.1.0 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/moby/patternmatcher v0.6.0 // indirect + github.com/moby/sys/sequential v0.5.0 // indirect + github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/morikuni/aec v1.0.0 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc5 // indirect + github.com/opencontainers/runc v1.1.12 // indirect github.com/paulmach/orb v0.10.0 // indirect github.com/pierrec/lz4/v4 v4.1.18 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect github.com/prometheus/common v0.48.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/segmentio/asm v1.2.0 // indirect + github.com/shirou/gopsutil/v3 v3.24.1 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/shopspring/decimal v1.3.1 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect go.opentelemetry.io/collector v0.96.1-0.20240306115632-b2693620eff6 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.96.1-0.20240306115632-b2693620eff6 // indirect go.opentelemetry.io/collector/consumer v0.96.1-0.20240306115632-b2693620eff6 // indirect @@ -63,9 +93,12 @@ require ( go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect + golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect + golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.15.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/grpc v1.62.1 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/exporter/clickhouseexporter/go.sum b/exporter/clickhouseexporter/go.sum index bf1dcc1c62a0..2d73885fd718 100644 --- a/exporter/clickhouseexporter/go.sum +++ b/exporter/clickhouseexporter/go.sum @@ -1,7 +1,17 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/ClickHouse/ch-go v0.58.2 h1:jSm2szHbT9MCAB1rJ3WuCJqmGLi5UTjlNu+f530UTS0= github.com/ClickHouse/ch-go v0.58.2/go.mod h1:Ap/0bEmiLa14gYjCiRkYGbXvbe8vwdrfTYWhsuQ99aw= github.com/ClickHouse/clickhouse-go/v2 v2.17.1 h1:ZCmAYWpu75IyEi7+Yrs/uaAjiCGY5wfW5kXo64exkX4= github.com/ClickHouse/clickhouse-go/v2 v2.17.1/go.mod h1:rkGTvFDTLqLIm0ma+13xmcCfr/08Gvs7KmFt1tgiWHQ= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= +github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -10,9 +20,25 @@ github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqy github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/containerd/containerd v1.7.11 h1:lfGKw3eU35sjV0aG2eYZTiwFEY1pCzxdzicHP3SZILw= +github.com/containerd/containerd v1.7.11/go.mod h1:5UluHxHTX2rdvYuZ5OJTC5m/KJNs0Zs9wVoJm9zf5ZE= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= +github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= +github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw= github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw= github.com/go-faster/errors v0.6.1 h1:nNIPOBkprlKzkThvS/0YaX8Zs9KewLCOSFQS5BU06FI= @@ -22,6 +48,10 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 h1:TQcrn6Wq+sKGkpyPvppOz99zsMBaUOKXq6HSv655U1c= github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -32,11 +62,15 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -57,16 +91,38 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= +github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= +github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= +github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss= +github.com/opencontainers/runc v1.1.12/go.mod h1:S+lQwSfncpBha7XTy/5lBwWgm5+y5Ma/O44Ekby9FK8= github.com/paulmach/orb v0.10.0 h1:guVYVqzxHE/CQ1KpfGO077TR0ATHSNjp4s6XGLn3W9s= github.com/paulmach/orb v0.10.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= @@ -76,6 +132,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= @@ -88,20 +146,42 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= +github.com/shirou/gopsutil/v3 v3.24.1 h1:R3t6ondCEvmARp3wxODhXMTLC/klMa87h2PHUw5m7QI= +github.com/shirou/gopsutil/v3 v3.24.1/go.mod h1:UU7a2MSBQa+kW1uuDq8DeEBS8kmrnQwsv2b5O513rwU= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/testcontainers/testcontainers-go v0.27.0 h1:IeIrJN4twonTDuMuBNQdKZ+K97yd7VrmNGu+lDpYcDk= +github.com/testcontainers/testcontainers-go v0.27.0/go.mod h1:+HgYZcd17GshBUZv9b+jKFJ198heWPQq3KQIp2+N+7U= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= go.opentelemetry.io/collector v0.96.1-0.20240306115632-b2693620eff6 h1:yaLqn47nYskiYqvIz+ixF4WgJCNmZYmvYgT1N79q2fc= go.opentelemetry.io/collector v0.96.1-0.20240306115632-b2693620eff6/go.mod h1:lNnB7h6qHClzeyZKauJdXB6wLhTq5sFvt1G70zTYmTs= @@ -149,8 +229,12 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= +golang.org/x/exp v0.0.0-20230711023510-fffb14384f22/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -162,12 +246,21 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -177,10 +270,14 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -201,3 +298,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= diff --git a/exporter/clickhouseexporter/integration_test.go b/exporter/clickhouseexporter/integration_test.go new file mode 100644 index 000000000000..968b46247545 --- /dev/null +++ b/exporter/clickhouseexporter/integration_test.go @@ -0,0 +1,593 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +//go:build integration +// +build integration + +package clickhouseexporter + +import ( + "context" + "fmt" + "math/rand" + "strconv" + "testing" + "time" + + "github.com/jmoiron/sqlx" + "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" + "go.opentelemetry.io/collector/pdata/pmetric" +) + +func TestIntegration(t *testing.T) { + testCase := []struct { + name string + image string + }{ + { + name: "test clickhouse 23-alpine", + image: "clickhouse/clickhouse-server:23-alpine", + }, + { + name: "test clickhouse 22-alpine", + image: "clickhouse/clickhouse-server:22-alpine", + }, + } + + for _, c := range testCase { + t.Run(c.name, func(t *testing.T) { + port := randPort() + req := testcontainers.ContainerRequest{ + Image: c.image, + ExposedPorts: []string{fmt.Sprintf("%s:9000", port)}, + WaitingFor: wait.ForListeningPort("9000"). + WithStartupTimeout(2 * time.Minute), + } + c := getContainer(t, req) + defer func() { + err := c.Terminate(context.Background()) + require.NoError(t, err) + }() + + host, err := c.Host(context.Background()) + require.NoError(t, err) + endpoint := fmt.Sprintf("tcp://%s:%s", host, port) + + logExporter := newTestLogsExporter(t, endpoint) + verifyExportLog(t, logExporter) + + traceExporter := newTestTracesExporter(t, endpoint) + require.NoError(t, err) + verifyExporterTrace(t, traceExporter) + + metricExporter := newTestMetricsExporter(t, endpoint) + require.NoError(t, err) + verifyExporterMetric(t, metricExporter) + }) + } +} + +func getContainer(t *testing.T, req testcontainers.ContainerRequest) testcontainers.Container { + require.NoError(t, req.Validate()) + container, err := testcontainers.GenericContainer( + context.Background(), + testcontainers.GenericContainerRequest{ + ContainerRequest: req, + Started: true, + }) + require.NoError(t, err) + + err = container.Start(context.Background()) + require.NoError(t, err) + return container +} + +func verifyExportLog(t *testing.T, logExporter *logsExporter) { + mustPushLogsData(t, logExporter, simpleLogs(1)) + db := sqlx.NewDb(logExporter.client, driverName) + + type log struct { + Timestamp string `db:"Timestamp"` + TraceID string `db:"TraceId"` + SpanID string `db:"SpanId"` + TraceFlags uint32 `db:"TraceFlags"` + SeverityText string `db:"SeverityText"` + SeverityNumber int32 `db:"SeverityNumber"` + ServiceName string `db:"ServiceName"` + Body string `db:"Body"` + ResourceSchemaURL string `db:"ResourceSchemaUrl"` + ResourceAttributes map[string]string `db:"ResourceAttributes"` + ScopeSchemaURL string `db:"ScopeSchemaUrl"` + ScopeName string `db:"ScopeName"` + ScopeVersion string `db:"ScopeVersion"` + ScopeAttributes map[string]string `db:"ScopeAttributes"` + LogAttributes map[string]string `db:"LogAttributes"` + } + + var actualLog log + + expectLog := log{ + Timestamp: "2023-12-25T09:53:49Z", + TraceID: "01020300000000000000000000000000", + SpanID: "0102030000000000", + SeverityText: "error", + SeverityNumber: 18, + ServiceName: "test-service", + Body: "error message", + ResourceSchemaURL: "https://opentelemetry.io/schemas/1.4.0", + ResourceAttributes: map[string]string{ + "service.name": "test-service", + }, + ScopeSchemaURL: "https://opentelemetry.io/schemas/1.7.0", + ScopeName: "io.opentelemetry.contrib.clickhouse", + ScopeVersion: "1.0.0", + ScopeAttributes: map[string]string{ + "lib": "clickhouse", + }, + LogAttributes: map[string]string{ + "service.namespace": "default", + }, + } + + err := db.Get(&actualLog, "select * from default.otel_logs") + require.NoError(t, err) + require.Equal(t, expectLog, actualLog) +} + +func verifyExporterTrace(t *testing.T, traceExporter *tracesExporter) { + mustPushTracesData(t, traceExporter, simpleTraces(1)) + db := sqlx.NewDb(traceExporter.client, driverName) + + type trace struct { + Timestamp string `db:"Timestamp"` + TraceID string `db:"TraceId"` + SpanID string `db:"SpanId"` + ParentSpanID string `db:"ParentSpanId"` + TraceState string `db:"TraceState"` + SpanName string `db:"SpanName"` + SpanKind string `db:"SpanKind"` + ServiceName string `db:"ServiceName"` + ResourceAttributes map[string]string `db:"ResourceAttributes"` + ScopeName string `db:"ScopeName"` + ScopeVersion string `db:"ScopeVersion"` + SpanAttributes map[string]string `db:"SpanAttributes"` + Duration int64 `db:"Duration"` + StatusCode string `db:"StatusCode"` + StatusMessage string `db:"StatusMessage"` + EventsTimestamp []time.Time `db:"Events.Timestamp"` + EventsName []string `db:"Events.Name"` + EventsAttributes []map[string]string `db:"Events.Attributes"` + LinksTraceID []string `db:"Links.TraceId"` + LinksSpanID []string `db:"Links.SpanId"` + LinksTraceState []string `db:"Links.TraceState"` + LinksAttributes []map[string]string `db:"Links.Attributes"` + } + + var actualTrace trace + + expectTrace := trace{ + Timestamp: "2023-12-25T09:53:49Z", + TraceID: "01020300000000000000000000000000", + SpanID: "0102030000000000", + ParentSpanID: "0102040000000000", + TraceState: "trace state", + SpanName: "call db", + SpanKind: "SPAN_KIND_INTERNAL", + ServiceName: "test-service", + ResourceAttributes: map[string]string{ + "service.name": "test-service", + }, + ScopeName: "io.opentelemetry.contrib.clickhouse", + ScopeVersion: "1.0.0", + SpanAttributes: map[string]string{ + "service.name": "v", + }, + Duration: 60000000000, + StatusCode: "STATUS_CODE_ERROR", + StatusMessage: "error", + EventsTimestamp: []time.Time{ + time.Unix(1703498029, 0).UTC(), + }, + EventsName: []string{"event1"}, + EventsAttributes: []map[string]string{ + { + "level": "info", + }, + }, + LinksTraceID: []string{ + "01020500000000000000000000000000", + }, + LinksSpanID: []string{ + "0102050000000000", + }, + LinksTraceState: []string{ + "error", + }, + LinksAttributes: []map[string]string{ + { + "k": "v", + }, + }, + } + + err := db.Get(&actualTrace, "select * from default.otel_traces") + require.NoError(t, err) + require.Equal(t, expectTrace, actualTrace) +} + +func verifyExporterMetric(t *testing.T, metricExporter *metricsExporter) { + metric := pmetric.NewMetrics() + rm := metric.ResourceMetrics().AppendEmpty() + simpleMetrics(1).ResourceMetrics().At(0).CopyTo(rm) + + mustPushMetricsData(t, metricExporter, metric) + db := sqlx.NewDb(metricExporter.client, driverName) + + verifyGaugeMetric(t, db) + verifySumMetric(t, db) + verifyHistogramMetric(t, db) + verifyExphistogramMetric(t, db) + verifySummaryMetric(t, db) +} + +func verifyGaugeMetric(t *testing.T, db *sqlx.DB) { + type gauge struct { + ResourceAttributes map[string]string `db:"ResourceAttributes"` + ResourceSchemaURL string `db:"ResourceSchemaUrl"` + ScopeName string `db:"ScopeName"` + ScopeVersion string `db:"ScopeVersion"` + ScopeAttributes map[string]string `db:"ScopeAttributes"` + ScopeDroppedAttrCount uint32 `db:"ScopeDroppedAttrCount"` + ScopeSchemaURL string `db:"ScopeSchemaUrl"` + MetricName string `db:"MetricName"` + MetricDescription string `db:"MetricDescription"` + MetricUnit string `db:"MetricUnit"` + Attributes map[string]string `db:"Attributes"` + StartTimeUnix string `db:"StartTimeUnix"` + TimeUnix string `db:"TimeUnix"` + Value float64 `db:"Value"` + Flags uint32 `db:"Flags"` + ExemplarsFilteredAttributes []map[string]string `db:"Exemplars.FilteredAttributes"` + ExemplarsTimeUnix []time.Time `db:"Exemplars.TimeUnix"` + ExemplarsValue []float64 `db:"Exemplars.Value"` + ExemplarsSpanID []string `db:"Exemplars.SpanId"` + ExemplarsTraceID []string `db:"Exemplars.TraceId"` + } + + var actualGauge gauge + + expectGauge := gauge{ + ResourceAttributes: map[string]string{ + "service.name": "demo 1", + "Resource Attributes 1": "value1", + }, + ResourceSchemaURL: "Resource SchemaUrl 1", + ScopeName: "Scope name 1", + ScopeVersion: "Scope version 1", + ScopeDroppedAttrCount: 10, + ScopeSchemaURL: "Scope SchemaUrl 1", + ScopeAttributes: map[string]string{ + "Scope Attributes 1": "value1", + }, + MetricName: "gauge metrics", + MetricDescription: "This is a gauge metrics", + MetricUnit: "count", + Attributes: map[string]string{ + "gauge_label_1": "1", + }, + StartTimeUnix: "2023-12-25T09:53:49Z", + TimeUnix: "2023-12-25T09:53:49Z", + Value: 0, + Flags: 0, + ExemplarsFilteredAttributes: []map[string]string{ + { + "key": "value", + "key2": "value2", + }, + }, + ExemplarsTimeUnix: []time.Time{time.Unix(1703498029, 0).UTC()}, + ExemplarsTraceID: []string{"01020300000000000000000000000000"}, + ExemplarsSpanID: []string{"0102030000000000"}, + ExemplarsValue: []float64{54}, + } + + err := db.Get(&actualGauge, "select * from default.otel_metrics_gauge") + require.NoError(t, err) + require.Equal(t, expectGauge, actualGauge) +} + +func verifySumMetric(t *testing.T, db *sqlx.DB) { + type sum struct { + ResourceAttributes map[string]string `db:"ResourceAttributes"` + ResourceSchemaURL string `db:"ResourceSchemaUrl"` + ScopeName string `db:"ScopeName"` + ScopeVersion string `db:"ScopeVersion"` + ScopeAttributes map[string]string `db:"ScopeAttributes"` + ScopeDroppedAttrCount uint32 `db:"ScopeDroppedAttrCount"` + ScopeSchemaURL string `db:"ScopeSchemaUrl"` + MetricName string `db:"MetricName"` + MetricDescription string `db:"MetricDescription"` + MetricUnit string `db:"MetricUnit"` + Attributes map[string]string `db:"Attributes"` + StartTimeUnix string `db:"StartTimeUnix"` + TimeUnix string `db:"TimeUnix"` + Value float64 `db:"Value"` + Flags uint32 `db:"Flags"` + ExemplarsFilteredAttributes []map[string]string `db:"Exemplars.FilteredAttributes"` + ExemplarsTimeUnix []time.Time `db:"Exemplars.TimeUnix"` + ExemplarsValue []float64 `db:"Exemplars.Value"` + ExemplarsSpanID []string `db:"Exemplars.SpanId"` + ExemplarsTraceID []string `db:"Exemplars.TraceId"` + AggTemp int32 `db:"AggTemp"` + IsMonotonic bool `db:"IsMonotonic"` + } + + var actualSum sum + + expectSum := sum{ + ResourceAttributes: map[string]string{ + "service.name": "demo 1", + "Resource Attributes 1": "value1", + }, + ResourceSchemaURL: "Resource SchemaUrl 1", + ScopeName: "Scope name 1", + ScopeVersion: "Scope version 1", + ScopeDroppedAttrCount: 10, + ScopeSchemaURL: "Scope SchemaUrl 1", + ScopeAttributes: map[string]string{ + "Scope Attributes 1": "value1", + }, + MetricName: "sum metrics", + MetricDescription: "This is a sum metrics", + MetricUnit: "count", + Attributes: map[string]string{ + "sum_label_1": "1", + }, + StartTimeUnix: "2023-12-25T09:53:49Z", + TimeUnix: "2023-12-25T09:53:49Z", + Value: 11.234, + Flags: 0, + ExemplarsFilteredAttributes: []map[string]string{ + { + "key": "value", + "key2": "value2", + }, + }, + ExemplarsTimeUnix: []time.Time{time.Unix(1703498029, 0).UTC()}, + ExemplarsTraceID: []string{"01020300000000000000000000000000"}, + ExemplarsSpanID: []string{"0102030000000000"}, + ExemplarsValue: []float64{54}, + } + + err := db.Get(&actualSum, "select * from default.otel_metrics_sum") + require.NoError(t, err) + require.Equal(t, expectSum, actualSum) +} + +func verifyHistogramMetric(t *testing.T, db *sqlx.DB) { + type sum struct { + ResourceAttributes map[string]string `db:"ResourceAttributes"` + ResourceSchemaURL string `db:"ResourceSchemaUrl"` + ScopeName string `db:"ScopeName"` + ScopeVersion string `db:"ScopeVersion"` + ScopeAttributes map[string]string `db:"ScopeAttributes"` + ScopeDroppedAttrCount uint32 `db:"ScopeDroppedAttrCount"` + ScopeSchemaURL string `db:"ScopeSchemaUrl"` + MetricName string `db:"MetricName"` + MetricDescription string `db:"MetricDescription"` + MetricUnit string `db:"MetricUnit"` + Attributes map[string]string `db:"Attributes"` + StartTimeUnix string `db:"StartTimeUnix"` + TimeUnix string `db:"TimeUnix"` + Count float64 `db:"Count"` + Sum float64 `db:"Sum"` + BucketCounts []uint64 `db:"BucketCounts"` + ExplicitBounds []float64 `db:"ExplicitBounds"` + ExemplarsFilteredAttributes []map[string]string `db:"Exemplars.FilteredAttributes"` + ExemplarsTimeUnix []time.Time `db:"Exemplars.TimeUnix"` + ExemplarsValue []float64 `db:"Exemplars.Value"` + ExemplarsSpanID []string `db:"Exemplars.SpanId"` + ExemplarsTraceID []string `db:"Exemplars.TraceId"` + Flags uint32 `db:"Flags"` + Min float64 `db:"Min"` + Max float64 `db:"Max"` + } + + var actualSum sum + + expectSum := sum{ + ResourceAttributes: map[string]string{ + "service.name": "demo 1", + "Resource Attributes 1": "value1", + }, + ResourceSchemaURL: "Resource SchemaUrl 1", + ScopeName: "Scope name 1", + ScopeVersion: "Scope version 1", + ScopeDroppedAttrCount: 10, + ScopeSchemaURL: "Scope SchemaUrl 1", + ScopeAttributes: map[string]string{ + "Scope Attributes 1": "value1", + }, + MetricName: "histogram metrics", + MetricDescription: "This is a histogram metrics", + MetricUnit: "ms", + Attributes: map[string]string{ + "key": "value", + "key2": "value", + }, + StartTimeUnix: "2023-12-25T09:53:49Z", + TimeUnix: "2023-12-25T09:53:49Z", + Count: 1, + Sum: 1, + BucketCounts: []uint64{0, 0, 0, 1, 0}, + ExplicitBounds: []float64{0, 0, 0, 0, 0}, + Flags: 0, + Min: 0, + Max: 1, + ExemplarsFilteredAttributes: []map[string]string{ + { + "key": "value", + "key2": "value2", + }, + }, + ExemplarsTimeUnix: []time.Time{time.Unix(1703498029, 0).UTC()}, + ExemplarsTraceID: []string{"01020300000000000000000000000000"}, + ExemplarsSpanID: []string{"0102030000000000"}, + ExemplarsValue: []float64{55.22}, + } + + err := db.Get(&actualSum, "select * from default.otel_metrics_histogram") + require.NoError(t, err) + require.Equal(t, expectSum, actualSum) +} + +func verifyExphistogramMetric(t *testing.T, db *sqlx.DB) { + type sum struct { + ResourceAttributes map[string]string `db:"ResourceAttributes"` + ResourceSchemaURL string `db:"ResourceSchemaUrl"` + ScopeName string `db:"ScopeName"` + ScopeVersion string `db:"ScopeVersion"` + ScopeAttributes map[string]string `db:"ScopeAttributes"` + ScopeDroppedAttrCount uint32 `db:"ScopeDroppedAttrCount"` + ScopeSchemaURL string `db:"ScopeSchemaUrl"` + MetricName string `db:"MetricName"` + MetricDescription string `db:"MetricDescription"` + MetricUnit string `db:"MetricUnit"` + Attributes map[string]string `db:"Attributes"` + StartTimeUnix string `db:"StartTimeUnix"` + TimeUnix string `db:"TimeUnix"` + Count float64 `db:"Count"` + Sum float64 `db:"Sum"` + Scale int32 `db:"Scale"` + ZeroCount uint64 `db:"ZeroCount"` + PositiveOffset int32 `db:"PositiveOffset"` + PositiveBucketCounts []uint64 `db:"PositiveBucketCounts"` + NegativeOffset int32 `db:"NegativeOffset"` + NegativeBucketCounts []uint64 `db:"NegativeBucketCounts"` + ExemplarsFilteredAttributes []map[string]string `db:"Exemplars.FilteredAttributes"` + ExemplarsTimeUnix []time.Time `db:"Exemplars.TimeUnix"` + ExemplarsValue []float64 `db:"Exemplars.Value"` + ExemplarsSpanID []string `db:"Exemplars.SpanId"` + ExemplarsTraceID []string `db:"Exemplars.TraceId"` + Flags uint32 `db:"Flags"` + Min float64 `db:"Min"` + Max float64 `db:"Max"` + } + + var actualSum sum + + expectSum := sum{ + ResourceAttributes: map[string]string{ + "service.name": "demo 1", + "Resource Attributes 1": "value1", + }, + ResourceSchemaURL: "Resource SchemaUrl 1", + ScopeName: "Scope name 1", + ScopeVersion: "Scope version 1", + ScopeDroppedAttrCount: 10, + ScopeSchemaURL: "Scope SchemaUrl 1", + ScopeAttributes: map[string]string{ + "Scope Attributes 1": "value1", + }, + MetricName: "exp histogram metrics", + MetricDescription: "This is a exp histogram metrics", + MetricUnit: "ms", + Attributes: map[string]string{ + "key": "value", + "key2": "value", + }, + StartTimeUnix: "2023-12-25T09:53:49Z", + TimeUnix: "2023-12-25T09:53:49Z", + Count: 1, + Sum: 1, + Scale: 0, + ZeroCount: 0, + PositiveOffset: 1, + PositiveBucketCounts: []uint64{0, 0, 0, 1, 0}, + NegativeOffset: 1, + NegativeBucketCounts: []uint64{0, 0, 0, 1, 0}, + Flags: 0, + Min: 0, + Max: 1, + ExemplarsFilteredAttributes: []map[string]string{ + { + "key": "value", + "key2": "value2", + }, + }, + ExemplarsTimeUnix: []time.Time{time.Unix(1703498029, 0).UTC()}, + ExemplarsTraceID: []string{"01020300000000000000000000000000"}, + ExemplarsSpanID: []string{"0102030000000000"}, + ExemplarsValue: []float64{54}, + } + + err := db.Get(&actualSum, "select * from default.otel_metrics_exponential_histogram") + require.NoError(t, err) + require.Equal(t, expectSum, actualSum) +} + +func verifySummaryMetric(t *testing.T, db *sqlx.DB) { + type sum struct { + ResourceAttributes map[string]string `db:"ResourceAttributes"` + ResourceSchemaURL string `db:"ResourceSchemaUrl"` + ScopeName string `db:"ScopeName"` + ScopeVersion string `db:"ScopeVersion"` + ScopeAttributes map[string]string `db:"ScopeAttributes"` + ScopeDroppedAttrCount uint32 `db:"ScopeDroppedAttrCount"` + ScopeSchemaURL string `db:"ScopeSchemaUrl"` + MetricName string `db:"MetricName"` + MetricDescription string `db:"MetricDescription"` + MetricUnit string `db:"MetricUnit"` + Attributes map[string]string `db:"Attributes"` + StartTimeUnix string `db:"StartTimeUnix"` + TimeUnix string `db:"TimeUnix"` + Count float64 `db:"Count"` + Sum float64 `db:"Sum"` + Quantile []float64 `db:"ValueAtQuantiles.Quantile"` + QuantilesValue []float64 `db:"ValueAtQuantiles.Value"` + Flags uint32 `db:"Flags"` + } + + var actualSum sum + + expectSum := sum{ + ResourceAttributes: map[string]string{ + "service.name": "demo 1", + "Resource Attributes 1": "value1", + }, + ResourceSchemaURL: "Resource SchemaUrl 1", + ScopeName: "Scope name 1", + ScopeVersion: "Scope version 1", + ScopeDroppedAttrCount: 10, + ScopeSchemaURL: "Scope SchemaUrl 1", + ScopeAttributes: map[string]string{ + "Scope Attributes 1": "value1", + }, + MetricName: "summary metrics", + MetricDescription: "This is a summary metrics", + MetricUnit: "ms", + Attributes: map[string]string{ + "key": "value", + "key2": "value", + }, + StartTimeUnix: "2023-12-25T09:53:49Z", + TimeUnix: "2023-12-25T09:53:49Z", + Count: 1, + Sum: 1, + Quantile: []float64{1}, + QuantilesValue: []float64{1}, + Flags: 0, + } + + err := db.Get(&actualSum, "select * from default.otel_metrics_summary") + require.NoError(t, err) + require.Equal(t, expectSum, actualSum) +} + +func randPort() string { + rs := rand.NewSource(time.Now().Unix()) + r := rand.New(rs) + return strconv.Itoa(r.Intn(999) + 9000) +} diff --git a/go.sum b/go.sum index 679c4aaed988..6b58e8f4312e 100644 --- a/go.sum +++ b/go.sum @@ -1050,6 +1050,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=