From ce10c395f8d80076745eea84543b5f707a493dc1 Mon Sep 17 00:00:00 2001 From: Murphy Chen Date: Mon, 18 Mar 2024 11:46:57 +0800 Subject: [PATCH] [exporter/clickhouse] Add integration test (#30209) **Description:** as https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/29626#issuecomment-1839884566 mentioned, this PR adds an integration test for clickhouse exporter and it brings those benefits: - Verify tables are properly created in clickhouse after any breaking change(filter out bug like [this](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/29573) before merge) - Verify if any bugs occur during data insertion like missed data or insert into an error column([30210](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/30210)) .etc. - Compatibility testing for `clickhouse-server:23-alpine` and `clickhouse-server:22-alpine` close https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/29626 --------- Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> --- ...tegration_test_for_clickhous_exporter.yaml | 27 + cmd/configschema/go.sum | 2 + cmd/otelcontribcol/go.sum | 2 + exporter/clickhouseexporter/README.md | 4 + .../clickhouseexporter/exporter_logs_test.go | 13 +- .../exporter_metrics_test.go | 48 +- .../exporter_traces_test.go | 19 +- exporter/clickhouseexporter/go.mod | 35 ++ exporter/clickhouseexporter/go.sum | 114 ++++ .../clickhouseexporter/integration_test.go | 593 ++++++++++++++++++ go.sum | 2 + 11 files changed, 834 insertions(+), 25 deletions(-) create mode 100644 .chloggen/add_integration_test_for_clickhous_exporter.yaml create mode 100644 exporter/clickhouseexporter/integration_test.go 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 55110e9c591a..1e184ee56e50 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -1053,6 +1053,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 66985354bcc3..e8cf17034e19 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/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/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 73fe6714f9d0..de00160dd7ca 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.21.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.28.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,28 @@ 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.61.5 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.11.4 // indirect github.com/andybalholm/brotli v1.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/containerd/containerd v1.7.12 // 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/distribution/reference v0.5.0 // indirect + github.com/docker/docker v25.0.3+incompatible // indirect + github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/felixge/httpsnoop v1.0.3 // indirect github.com/go-faster/city v1.0.1 // indirect github.com/go-faster/errors v0.7.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,33 +54,53 @@ 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/sys/user v0.1.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/paulmach/orb v0.11.1 // indirect github.com/pierrec/lz4/v4 v4.1.21 // 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 go.opentelemetry.io/collector/extension v0.96.1-0.20240306115632-b2693620eff6 // indirect go.opentelemetry.io/collector/receiver v0.96.1-0.20240306115632-b2693620eff6 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.46.0 // indirect 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.22.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 4911dd5b6c6b..7b142174afaa 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.61.5 h1:zwR8QbYI0tsMiEcze/uIMK+Tz1D3XZXLdNrlaOpeEI4= github.com/ClickHouse/ch-go v0.61.5/go.mod h1:s1LJW/F/LcFs5HJnuogFMta50kKDO0lf9zzfrbl0RQg= github.com/ClickHouse/clickhouse-go/v2 v2.21.1 h1:x8wZEMOHDh4K8kLQBtGMeIIguejiaj8/bUiF2VzG6n4= github.com/ClickHouse/clickhouse-go/v2 v2.21.1/go.mod h1:hTWNkV9mkQwiQ/df0rbN17VXF05UTResY4krnjbzVZA= +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.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -10,9 +20,27 @@ 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.12 h1:+KQsnv4VnzyxWcfO9mlxxELaoztsDEjOuCMPAuPqgU0= +github.com/containerd/containerd v1.7.12/go.mod h1:/5OMpE1p0ylxtEUGY8kuCYkDRzJm9NO1TFMWjUpdevk= +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/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= +github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v25.0.3+incompatible h1:D5fy/lYmY7bvZa0XTZ5/UJPljor41F+vdyJG5luQLfQ= +github.com/docker/docker v25.0.3+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/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= +github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= 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.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg= @@ -22,6 +50,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 +64,17 @@ 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/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= +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 +95,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/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= +github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= +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/paulmach/orb v0.11.1 h1:3koVegMC4X/WeiXYz9iswopaTwMem53NzTJuTF20JzU= github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= @@ -76,6 +136,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 +150,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.28.0 h1:1HLm9qm+J5VikzFDYhOd+Zw12NtOl+8drH2E8nTY1r8= +github.com/testcontainers/testcontainers-go v0.28.0/go.mod h1:COlDpUXbwW3owtpMkEB1zo9gwb1CoKVKlyrVPejF4AU= 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= @@ -127,8 +211,14 @@ go.opentelemetry.io/collector/receiver v0.96.1-0.20240306115632-b2693620eff6 h1: go.opentelemetry.io/collector/receiver v0.96.1-0.20240306115632-b2693620eff6/go.mod h1:Kj14Vn5nJE2T9PdH+p1skvrlbqTfrHoPOUfsCs2M+TU= go.opentelemetry.io/collector/semconv v0.96.1-0.20240306115632-b2693620eff6 h1:wLnFcJSimh5/axOIYGssu09e/9m4oy8dkj9nfFS3QP8= go.opentelemetry.io/collector/semconv v0.96.1-0.20240306115632-b2693620eff6/go.mod h1:8ElcRZ8Cdw5JnvhTOQOdYizkJaQ10Z2fS+R6djOnj6A= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= go.opentelemetry.io/otel/exporters/prometheus v0.46.0 h1:I8WIFXR351FoLJYuloU4EgXbtNX2URfU/85pUPheIEQ= go.opentelemetry.io/otel/exporters/prometheus v0.46.0/go.mod h1:ztwVUHe5DTR/1v7PeuGRnU5Bbd4QKYwApWmuutKsJSs= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= @@ -139,6 +229,8 @@ go.opentelemetry.io/otel/sdk/metric v1.24.0 h1:yyMQrPzF+k88/DbH7o4FMAs80puqd+9os go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6Ek5IIrmwTLqMrrOE0= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= +go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -149,8 +241,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 +258,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,14 +282,21 @@ 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= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 h1:KAeGQVN3M9nD0/bQXnr/ClcEMJ968gUXJQ9pwfSynuQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 h1:Lj5rbfG876hIAYFjqiJnPHfhXbv+nzTWfm04Fg/XSVU= +google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= @@ -201,3 +313,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 1fde5d48ccb5..2423f31f1fed 100644 --- a/go.sum +++ b/go.sum @@ -1054,6 +1054,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=