diff --git a/.chloggen/opensearch-exporter.yaml b/.chloggen/opensearch-exporter.yaml new file mode 100755 index 000000000000..4c9c664d137a --- /dev/null +++ b/.chloggen/opensearch-exporter.yaml @@ -0,0 +1,11 @@ + +change_type: new_component + +component: opensearchexporter + +note: exports OpenTelemetry signals to [OpenSearch](https://opensearch.org/). + +issues: [7905] + +subtext: + diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e3d9fbc9a183..4028bad0ce5f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -66,6 +66,7 @@ exporter/logzioexporter/ @open-telemetry/collect exporter/lokiexporter/ @open-telemetry/collector-contrib-approvers @gramidt @gouthamve @jpkrohling @kovrus @mar4uk exporter/mezmoexporter/ @open-telemetry/collector-contrib-approvers @dashpole @billmeyer @gjanco exporter/opencensusexporter/ @open-telemetry/collector-contrib-approvers @open-telemetry/collector-approvers +exporter/opensearchexporter/ @open-telemetry/collector-contrib-approvers @open-telemetry/collector-approvers @MaxKsyunz exporter/parquetexporter/ @open-telemetry/collector-contrib-approvers @atoulme exporter/prometheusexporter/ @open-telemetry/collector-contrib-approvers @Aneurysm9 exporter/prometheusremotewriteexporter/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @rapphil diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 4107accc67e5..dda8d8061454 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -60,6 +60,7 @@ body: - exporter/loki - exporter/mezmo - exporter/opencensus + - exporter/opensearch - exporter/parquet - exporter/prometheus - exporter/prometheusremotewrite diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index 9680ffa19da9..9dffc11cd7cd 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -54,6 +54,7 @@ body: - exporter/loki - exporter/mezmo - exporter/opencensus + - exporter/opensearch - exporter/parquet - exporter/prometheus - exporter/prometheusremotewrite diff --git a/.github/ISSUE_TEMPLATE/other.yaml b/.github/ISSUE_TEMPLATE/other.yaml index 1746a9f0c376..918a0af0c7c6 100644 --- a/.github/ISSUE_TEMPLATE/other.yaml +++ b/.github/ISSUE_TEMPLATE/other.yaml @@ -54,6 +54,7 @@ body: - exporter/loki - exporter/mezmo - exporter/opencensus + - exporter/opensearch - exporter/parquet - exporter/prometheus - exporter/prometheusremotewrite diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3d76b7033704..0f26665b1361 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -222,6 +222,11 @@ updates: schedule: interval: "weekly" day: "wednesday" + - package-ecosystem: "gomod" + directory: "/exporter/opensearchexporter" + schedule: + interval: "weekly" + day: "wednesday" - package-ecosystem: "gomod" directory: "/exporter/parquetexporter" schedule: diff --git a/.golangci.yml b/.golangci.yml index 587940ff4988..c3f036a932d7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -272,6 +272,9 @@ issues: - path: elasticsearchexporter linters: - exhaustive + - path: opensearchexporter + linters: + - exhaustive - path: datadogexporter linters: - exhaustive diff --git a/cmd/otelcontribcol/builder-config.yaml b/cmd/otelcontribcol/builder-config.yaml index adacf180f2ae..f6c332aee0d5 100644 --- a/cmd/otelcontribcol/builder-config.yaml +++ b/cmd/otelcontribcol/builder-config.yaml @@ -66,6 +66,7 @@ exporters: - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lokiexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/mezmoexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.79.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/parquetexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.79.0 @@ -354,6 +355,7 @@ replaces: - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter => ../../exporter/fileexporter - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry => ../../pkg/resourcetotelemetry - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter => ../../exporter/opencensusexporter + - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter => ../../exporter/opensearchexporter - github.com/open-telemetry/opentelemetry-collector-contrib/internal/metadataproviders => ../../internal/metadataproviders - github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy => ../../internal/aws/proxy - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snmpreceiver => ../../receiver/snmpreceiver diff --git a/cmd/otelcontribcol/components.go b/cmd/otelcontribcol/components.go index 44c6e6343f71..0d013652cfb8 100644 --- a/cmd/otelcontribcol/components.go +++ b/cmd/otelcontribcol/components.go @@ -54,6 +54,7 @@ import ( lokiexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lokiexporter" mezmoexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/mezmoexporter" opencensusexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter" + opensearchexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter" parquetexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/parquetexporter" prometheusexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter" prometheusremotewriteexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter" @@ -356,6 +357,7 @@ func components() (otelcol.Factories, error) { lokiexporter.NewFactory(), mezmoexporter.NewFactory(), opencensusexporter.NewFactory(), + opensearchexporter.NewFactory(), parquetexporter.NewFactory(), prometheusexporter.NewFactory(), prometheusremotewriteexporter.NewFactory(), diff --git a/cmd/otelcontribcol/exporters_test.go b/cmd/otelcontribcol/exporters_test.go index 6b6d24d4cfde..6805633670a6 100644 --- a/cmd/otelcontribcol/exporters_test.go +++ b/cmd/otelcontribcol/exporters_test.go @@ -51,6 +51,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lokiexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/mezmoexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter" + "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/parquetexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/pulsarexporter" @@ -136,6 +137,14 @@ func TestDefaultExporters(t *testing.T) { return cfg }, }, + { + exporter: "opensearch", + getConfigFn: func() component.Config { + cfg := expFactories["opensearch"].CreateDefaultConfig().(*opensearchexporter.Config) + cfg.Endpoints = []string{"http://" + endpoint} + return cfg + }, + }, { exporter: "otlp", getConfigFn: func() component.Config { diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index 54d2d06acb66..1a2b0814decc 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -40,6 +40,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lokiexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/mezmoexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.79.0 + github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/parquetexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.79.0 @@ -535,6 +536,7 @@ require ( github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78 // indirect github.com/opencontainers/selinux v1.10.1 // indirect + github.com/opensearch-project/opensearch-go/v2 v2.3.0 // indirect github.com/openshift/api v3.9.0+incompatible // indirect github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect @@ -985,6 +987,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourceto replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter => ../../exporter/opencensusexporter +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter => ../../exporter/opensearchexporter + replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/metadataproviders => ../../internal/metadataproviders replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy => ../../internal/aws/proxy diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index 996c30982bd4..99242bc4863a 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -870,6 +870,8 @@ github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/antchfx/jsonquery v1.3.2 h1:/BgHv1le9CCkqDe7t1x5BRlCg6DQmXTsztnMQFG5Hoc= +github.com/antchfx/xpath v1.2.3 h1:CCZWOzv5bAqjVv0offZ2LVgVYFbeldKQVuLNbViZdes= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antonmedv/expr v1.12.5 h1:Fq4okale9swwL3OeLLs9WD9H6GbgBLJyN/NUHRv+n0E= @@ -916,6 +918,7 @@ github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU github.com/aws/aws-sdk-go v1.35.24/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= +github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.277 h1:YHmyzBPARTJ7LLYV1fxbfEbQOaUh3kh52hb7nBvX3BQ= github.com/aws/aws-sdk-go v1.44.277/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= @@ -2524,6 +2527,8 @@ github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xA github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/opencontainers/selinux v1.10.1 h1:09LIPVRP3uuZGQvgR+SgMSNBd1Eb3vlRbGqQpoHsF8w= github.com/opencontainers/selinux v1.10.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= +github.com/opensearch-project/opensearch-go/v2 v2.3.0 h1:nQIEMr+A92CkhHrZgUhcfsrZjibvB3APXf2a1VwCmMQ= +github.com/opensearch-project/opensearch-go/v2 v2.3.0/go.mod h1:8LDr9FCgUTVoT+5ESjc2+iaZuldqE+23Iq0r1XeNue8= github.com/openshift/api v0.0.0-20180801171038-322a19404e37 h1:05irGU4HK4IauGGDbsk+ZHrm1wOzMLYjMlfaiqMrBYc= github.com/openshift/api v0.0.0-20180801171038-322a19404e37/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY= github.com/openshift/api v0.0.0-20210521075222-e273a339932a/go.mod h1:izBmoXbUu3z5kUa4FjZhvekTsyzIWiOoaIgJiZBBMQs= diff --git a/cmd/oteltestbedcol/builder-config.yaml b/cmd/oteltestbedcol/builder-config.yaml index cc88353dc95c..d2de952a43fc 100644 --- a/cmd/oteltestbedcol/builder-config.yaml +++ b/cmd/oteltestbedcol/builder-config.yaml @@ -19,6 +19,7 @@ exporters: - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.79.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter v0.79.0 @@ -83,6 +84,7 @@ replaces: - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter => ../../exporter/signalfxexporter - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry => ../../pkg/resourcetotelemetry - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter => ../../exporter/opencensusexporter + - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter => ../../exporter/opensearchexporter - github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent => ../../internal/sharedcomponent - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => ../../receiver/prometheusreceiver - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter => ../../exporter/sapmexporter diff --git a/cmd/oteltestbedcol/components.go b/cmd/oteltestbedcol/components.go index 61778854e289..aa64ad1022f4 100644 --- a/cmd/oteltestbedcol/components.go +++ b/cmd/oteltestbedcol/components.go @@ -21,6 +21,7 @@ import ( carbonexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter" jaegerexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter" opencensusexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter" + opensearchexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter" prometheusexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter" sapmexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter" signalfxexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter" @@ -86,6 +87,7 @@ func components() (otelcol.Factories, error) { carbonexporter.NewFactory(), jaegerexporter.NewFactory(), opencensusexporter.NewFactory(), + opensearchexporter.NewFactory(), prometheusexporter.NewFactory(), sapmexporter.NewFactory(), signalfxexporter.NewFactory(), diff --git a/cmd/oteltestbedcol/go.mod b/cmd/oteltestbedcol/go.mod index b21969342e48..dc5e95649a26 100644 --- a/cmd/oteltestbedcol/go.mod +++ b/cmd/oteltestbedcol/go.mod @@ -8,6 +8,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.79.0 + github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter v0.79.0 @@ -81,6 +82,7 @@ require ( github.com/docker/docker v24.0.2+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/elastic/go-structform v0.0.10 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/envoyproxy/go-control-plane v0.11.0 // indirect github.com/envoyproxy/protoc-gen-validate v0.10.0 // indirect @@ -181,6 +183,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.79.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect + github.com/opensearch-project/opensearch-go/v2 v2.3.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/openzipkin/zipkin-go v0.4.1 // indirect github.com/ovh/go-ovh v1.3.0 // indirect @@ -338,6 +341,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourceto replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter => ../../exporter/opencensusexporter +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter => ../../exporter/opensearchexporter + replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent => ../../internal/sharedcomponent replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => ../../receiver/prometheusreceiver diff --git a/cmd/oteltestbedcol/go.sum b/cmd/oteltestbedcol/go.sum index 56e2080f50d7..e5d3410c1d16 100644 --- a/cmd/oteltestbedcol/go.sum +++ b/cmd/oteltestbedcol/go.sum @@ -762,21 +762,34 @@ github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZo github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= +github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.277 h1:YHmyzBPARTJ7LLYV1fxbfEbQOaUh3kh52hb7nBvX3BQ= github.com/aws/aws-sdk-go v1.44.277/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= +github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= +github.com/aws/aws-sdk-go-v2/config v1.18.25/go.mod h1:dZnYpD5wTW/dQF0rRNLVypB396zWCcPiBIvdvSWHEg4= github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3/go.mod h1:4Q0UFP0YJf0NrsEuEYHpM9fTSEVnD16Z3uyEF7J9JGM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33/go.mod h1:7i0PF1ME/2eUPFcjkVIwq+DOygHEoK92t5cDqNgYbIw= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27/go.mod h1:UrHnn3QV/d0pBZ6QBAEQcqFLf8FAzLmoUfPVIueOvoM= github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34/go.mod h1:Etz2dj6UHYuw+Xw830KfzCfWGMzqvUTCjUj5b76GVDc= github.com/aws/aws-sdk-go-v2/service/appconfig v1.4.2/go.mod h1:FZ3HkCe+b10uFZZkFdvf98LHW21k49W8o8J366lqVKY= github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27/go.mod h1:EOwBD4J4S5qYszS5/3DpkejfuK+Z5/1uzICfPaZLtqw= github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= +github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= @@ -1062,6 +1075,8 @@ github.com/eapache/go-resiliency v1.3.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/elastic/go-structform v0.0.10 h1:oy08o/Ih2hHTkNcRY/1HhaYvIp5z6t8si8gnCJPDo1w= +github.com/elastic/go-structform v0.0.10/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= @@ -2035,6 +2050,8 @@ github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3 github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/opencontainers/selinux v1.10.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= +github.com/opensearch-project/opensearch-go/v2 v2.3.0 h1:nQIEMr+A92CkhHrZgUhcfsrZjibvB3APXf2a1VwCmMQ= +github.com/opensearch-project/opensearch-go/v2 v2.3.0/go.mod h1:8LDr9FCgUTVoT+5ESjc2+iaZuldqE+23Iq0r1XeNue8= github.com/opentracing-contrib/go-grpc v0.0.0-20191001143057-db30781987df/go.mod h1:DYR5Eij8rJl8h7gblRrOZ8g0kW1umSpKqYIBTgeDtLo= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9/go.mod h1:PLldrQSroqzH70Xl+1DQcGnefIbqsKR7UDaiux3zV+w= diff --git a/exporter/opensearchexporter/Makefile b/exporter/opensearchexporter/Makefile new file mode 100644 index 000000000000..c1496226e590 --- /dev/null +++ b/exporter/opensearchexporter/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common \ No newline at end of file diff --git a/exporter/opensearchexporter/README.md b/exporter/opensearchexporter/README.md new file mode 100644 index 000000000000..fb97847984ea --- /dev/null +++ b/exporter/opensearchexporter/README.md @@ -0,0 +1,66 @@ +# OpenSearch Exporter + +| Status | | +| ------------------------ |-----------| +| Stability | [devel] | +| Supported pipeline types | traces | +| Distributions | [contrib] | + +This exporter supports sending OpenTelemetry signals as documents to [OpenSearch](https://www.opensearch.org). + +The documents are sent using [observability catalog](https://github.com/opensearch-project/opensearch-catalog/tree/main/schema/observability) schema. + +## Configuration options + +- `endpoints`: List of OpenSearch URLs. If endpoints is missing, the + OPENSEARCH_URL environment variable will be used. +- `num_workers` (optional): Number of workers publishing bulk requests concurrently. +- `dataset` (default=`default`) a user-provided label. It is used to construct the name of the destination index or data stream. +- `namespace` (default=`namespace`)a user-provided label. It is used to construct the name of the destination index or data stream. +- `flush`: Event bulk buffer flush settings + - `bytes` (default=5242880): Write buffer flush limit. + - `interval` (default=30s): Write buffer time limit. +- `retry`: Event retry settings + - `enabled` (default=true): Enable/Disable event retry on error. Retry + support is enabled by default. + - `max_requests` (default=3): Number of HTTP request retries. + - `initial_interval` (default=100ms): Initial waiting time if a HTTP request failed. + - `max_interval` (default=1m): Max waiting time if a HTTP request failed. + +### HTTP settings + +- `read_buffer_size` (default=0): Read buffer size. +- `write_buffer_size` (default=0): Write buffer size used when. +- `timeout` (default=90s): HTTP request time limit. +- `headers` (optional): Headers to be send with each HTTP request. + +### Security and Authentication settings + +- `user` (optional): Username used for HTTP Basic Authentication. +- `password` (optional): Password used for HTTP Basic Authentication. + +### TLS settings +- `ca_file` (optional): Root Certificate Authority (CA) certificate, for + verifying the server's identity, if TLS is enabled. +- `cert_file` (optional): Client TLS certificate. +- `key_file` (optional): Client TLS key. +- `insecure` (optional): In gRPC when set to true, this is used to disable the client transport security. In HTTP, this disables verifying the server's certificate chain and host name. +- `insecure_skip_verify` (optional): Will enable TLS but not verify the certificate. + is enabled. + +## Example + +```yaml +exporters: + opensearch/trace: + endpoints: [https://opensearch.example.com:9200] +# ······ +service: + pipelines: + traces: + receivers: [otlp] + exporters: [opensearch/trace] + processors: [batch] +``` +[devel]:https://github.com/open-telemetry/opentelemetry-collector#development +[contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib \ No newline at end of file diff --git a/exporter/opensearchexporter/config.go b/exporter/opensearchexporter/config.go new file mode 100644 index 000000000000..fbdcba140060 --- /dev/null +++ b/exporter/opensearchexporter/config.go @@ -0,0 +1,122 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter // Package opensearchexporter + +import ( + "errors" + "os" + "time" + + "go.opentelemetry.io/collector/config/configopaque" + "go.opentelemetry.io/collector/config/configtls" +) + +const ( + defaultOpenSearchEnvName = "OPENSEARCH_URL" +) + +// Config defines configuration for OpenSearch exporter. +type Config struct { + + // Endpoints holds the OpenSearch URLs the exporter should send events to. + // + // OPENSEARCH_URL environment variable is not set. + Endpoints []string `mapstructure:"endpoints"` + + // NumWorkers configures the number of workers publishing bulk requests. + NumWorkers int `mapstructure:"num_workers"` + + HTTPClientSettings `mapstructure:",squash"` + Retry RetrySettings `mapstructure:"retry"` + Flush FlushSettings `mapstructure:"flush"` + Namespace string `mapstructure:"namespace"` + Dataset string `mapstructure:"dataset"` +} + +type HTTPClientSettings struct { + Authentication AuthenticationSettings `mapstructure:",squash"` + + // ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize. + ReadBufferSize int `mapstructure:"read_buffer_size"` + + // WriteBufferSize for HTTP client. See http.Transport.WriteBufferSize. + WriteBufferSize int `mapstructure:"write_buffer_size"` + + // Timeout configures the HTTP request timeout. + Timeout time.Duration `mapstructure:"timeout"` + + // Headers allows users to configure optional HTTP headers that + // will be sent with each HTTP request. + Headers map[string]string `mapstructure:"headers,omitempty"` + + configtls.TLSClientSetting `mapstructure:"tls,omitempty"` +} + +// AuthenticationSettings defines user authentication related settings. +type AuthenticationSettings struct { + // User is used to configure HTTP Basic Authentication. + User string `mapstructure:"user"` + + // Password is used to configure HTTP Basic Authentication. + Password configopaque.String `mapstructure:"password"` +} + +// FlushSettings defines settings for configuring the write buffer flushing +// policy in the OpenSearch exporter. The exporter sends a bulk request with +// all events already serialized into the send-buffer. +type FlushSettings struct { + // Bytes sets the send buffer flushing limit. + Bytes int `mapstructure:"bytes"` + + // Interval configures the max age of a document in the send buffer. + Interval time.Duration `mapstructure:"interval"` +} + +// RetrySettings defines settings for the HTTP request retries in the OpenSearch exporter. +// Failed sends are retried with exponential backoff. +type RetrySettings struct { + // Enabled allows users to disable retry without having to comment out all settings. + Enabled bool `mapstructure:"enabled"` + + // MaxRequests configures how often an HTTP request is retried before it is assumed to be failed. + MaxRequests int `mapstructure:"max_requests"` + + // InitialInterval configures the initial waiting time if a request failed. + InitialInterval time.Duration `mapstructure:"initial_interval"` + + // MaxInterval configures the max waiting time if consecutive requests failed. + MaxInterval time.Duration `mapstructure:"max_interval"` +} + +type MappingsSettings struct { + // Mode configures the field mappings. + Mode string `mapstructure:"mode"` + + // Try to find and remove duplicate fields + Dedup bool `mapstructure:"dedup"` + + Dedot bool `mapstructure:"dedot"` +} + +var ( + errConfigNoEndpoint = errors.New("endpoints must be specified") + errConfigEmptyEndpoint = errors.New("endpoints must not include empty entries") +) + +// Validate validates the opensearch server configuration. +func (cfg *Config) Validate() error { + if len(cfg.Endpoints) == 0 { + if os.Getenv(defaultOpenSearchEnvName) == "" { + return errConfigNoEndpoint + } + } + + for _, endpoint := range cfg.Endpoints { + if endpoint == "" { + return errConfigEmptyEndpoint + } + } + + return nil +} diff --git a/exporter/opensearchexporter/config_test.go b/exporter/opensearchexporter/config_test.go new file mode 100644 index 000000000000..daaacf992781 --- /dev/null +++ b/exporter/opensearchexporter/config_test.go @@ -0,0 +1,88 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter + +import ( + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +func TestLoadConfig(t *testing.T) { + t.Parallel() + + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) + require.NoError(t, err) + + defaultCfg := createDefaultConfig() + defaultCfg.(*Config).Endpoints = []string{"https://opensearch.example.com:9200"} + + tests := []struct { + id component.ID + expected component.Config + configValidateAssert assert.ErrorAssertionFunc + }{ + { + id: component.NewIDWithName(typeStr, ""), + expected: defaultCfg, + configValidateAssert: assert.NoError, + }, + { + id: component.NewIDWithName(typeStr, "trace"), + expected: &Config{ + Endpoints: []string{"https://opensearch.example.com:9200"}, + Namespace: "", + Dataset: "", + HTTPClientSettings: HTTPClientSettings{ + Authentication: AuthenticationSettings{ + User: "open", + Password: "search", + }, + Timeout: 2 * time.Minute, + Headers: map[string]string{ + "myheader": "test", + }, + }, + Flush: FlushSettings{ + Bytes: 10485760, + }, + Retry: RetrySettings{ + Enabled: true, + MaxRequests: 5, + InitialInterval: 100 * time.Millisecond, + MaxInterval: 1 * time.Minute, + }, + }, + configValidateAssert: assert.NoError, + }, + } + + for _, tt := range tests { + t.Run(tt.id.String(), func(t *testing.T) { + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + + sub, err := cm.Sub(tt.id.String()) + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + vv := component.ValidateConfig(cfg) + tt.configValidateAssert(t, vv) + assert.Equal(t, tt.expected, cfg) + }) + } +} + +func withDefaultConfig(fns ...func(*Config)) *Config { + cfg := createDefaultConfig().(*Config) + for _, fn := range fns { + fn(cfg) + } + return cfg +} diff --git a/exporter/opensearchexporter/factory.go b/exporter/opensearchexporter/factory.go new file mode 100644 index 000000000000..26394b2ee1a7 --- /dev/null +++ b/exporter/opensearchexporter/factory.go @@ -0,0 +1,58 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter" + +import ( + "context" + "fmt" + "time" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/exporter" + "go.opentelemetry.io/collector/exporter/exporterhelper" +) + +const ( + // The value of "type" key in configuration. + typeStr = "opensearch" + // The stability level of the exporter. + stability = component.StabilityLevelDevelopment +) + +// NewFactory creates a factory for OpenSearch exporter. +func NewFactory() exporter.Factory { + return exporter.NewFactory( + typeStr, + createDefaultConfig, + exporter.WithTraces(createTracesExporter, stability), + ) +} + +func createDefaultConfig() component.Config { + return &Config{ + HTTPClientSettings: HTTPClientSettings{ + Timeout: 90 * time.Second, + }, + Namespace: "", + Dataset: "", + Retry: RetrySettings{ + Enabled: true, + MaxRequests: 3, + InitialInterval: 100 * time.Millisecond, + MaxInterval: 1 * time.Minute, + }, + } +} + +func createTracesExporter(ctx context.Context, + set exporter.CreateSettings, + cfg component.Config) (exporter.Traces, error) { + + tracesExporter, err := newTracesExporter(set.Logger, cfg.(*Config)) + if err != nil { + return nil, fmt.Errorf("cannot configure OpenSearch traces tracesExporter: %w", err) + } + return exporterhelper.NewTracesExporter(ctx, set, cfg, tracesExporter.pushTraceData, + exporterhelper.WithShutdown(tracesExporter.Shutdown)) +} diff --git a/exporter/opensearchexporter/factory_test.go b/exporter/opensearchexporter/factory_test.go new file mode 100644 index 000000000000..c4d478acb028 --- /dev/null +++ b/exporter/opensearchexporter/factory_test.go @@ -0,0 +1,50 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/exporter/exportertest" +) + +func TestCreateDefaultConfig(t *testing.T) { + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NotNil(t, cfg, "failed to create default config") + assert.NoError(t, componenttest.CheckConfigStruct(cfg)) +} + +func TestFactory_CreateMetricsExporter_Fail(t *testing.T) { + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + params := exportertest.NewNopCreateSettings() + _, err := factory.CreateMetricsExporter(context.Background(), params, cfg) + require.Error(t, err, "expected an error when creating a traces exporter") +} + +func TestFactory_CreateTracesExporter_Fail(t *testing.T) { + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + params := exportertest.NewNopCreateSettings() + _, err := factory.CreateTracesExporter(context.Background(), params, cfg) + require.Error(t, err, "expected an error when creating a traces exporter") +} + +func TestFactory_CreateTracesExporter(t *testing.T) { + factory := NewFactory() + cfg := withDefaultConfig(func(cfg *Config) { + cfg.Endpoints = []string{"https://opensearch.example.com:9200"} + }) + params := exportertest.NewNopCreateSettings() + exporter, err := factory.CreateTracesExporter(context.Background(), params, cfg) + require.NoError(t, err) + require.NotNil(t, exporter) + + require.NoError(t, exporter.Shutdown(context.TODO())) +} diff --git a/exporter/opensearchexporter/go.mod b/exporter/opensearchexporter/go.mod new file mode 100644 index 000000000000..2c4499dd2ebf --- /dev/null +++ b/exporter/opensearchexporter/go.mod @@ -0,0 +1,64 @@ +module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter + +go 1.19 + +require ( + github.com/antchfx/jsonquery v1.3.2 + github.com/cenkalti/backoff/v4 v4.2.1 + github.com/elastic/go-structform v0.0.10 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.78.0 + github.com/opensearch-project/opensearch-go/v2 v2.3.0 + github.com/stretchr/testify v1.8.4 + go.opentelemetry.io/collector v0.79.1-0.20230609201858-ed8547a8e5d6 + go.opentelemetry.io/collector/component v0.79.1-0.20230609201858-ed8547a8e5d6 + go.opentelemetry.io/collector/confmap v0.79.1-0.20230609201858-ed8547a8e5d6 + go.opentelemetry.io/collector/exporter v0.79.0 + go.opentelemetry.io/collector/pdata v1.0.0-rcv0012.0.20230609201858-ed8547a8e5d6 + go.uber.org/multierr v1.11.0 + go.uber.org/zap v1.24.0 +) + +require ( + github.com/antchfx/xpath v1.2.3 // indirect + github.com/benbjohnson/clock v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/knadh/koanf v1.5.0 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/collector/consumer v0.79.1-0.20230609201858-ed8547a8e5d6 // indirect + go.opentelemetry.io/collector/extension v0.0.0-20230609200026-525adf4a682a // indirect + go.opentelemetry.io/collector/featuregate v1.0.0-rcv0012.0.20230609201858-ed8547a8e5d6 // indirect + go.opentelemetry.io/collector/processor v0.0.0-20230609193203-89d1060c7606 // indirect + go.opentelemetry.io/collector/receiver v0.79.1-0.20230609201858-ed8547a8e5d6 // indirect + go.opentelemetry.io/otel v1.16.0 // indirect + go.opentelemetry.io/otel/metric v1.16.0 // indirect + go.opentelemetry.io/otel/trace v1.16.0 // indirect + go.uber.org/atomic v1.10.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/grpc v1.55.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +retract v0.65.0 + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil diff --git a/exporter/opensearchexporter/go.sum b/exporter/opensearchexporter/go.sum new file mode 100644 index 000000000000..e84d67a38cb9 --- /dev/null +++ b/exporter/opensearchexporter/go.sum @@ -0,0 +1,520 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/antchfx/jsonquery v1.3.2 h1:/BgHv1le9CCkqDe7t1x5BRlCg6DQmXTsztnMQFG5Hoc= +github.com/antchfx/jsonquery v1.3.2/go.mod h1:VsW9O/sNgHoUVvhoMEjR+opjIOjKOViNFTpAlxcI4Ws= +github.com/antchfx/xpath v1.2.3 h1:CCZWOzv5bAqjVv0offZ2LVgVYFbeldKQVuLNbViZdes= +github.com/antchfx/xpath v1.2.3/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= +github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= +github.com/aws/aws-sdk-go-v2/config v1.18.25/go.mod h1:dZnYpD5wTW/dQF0rRNLVypB396zWCcPiBIvdvSWHEg4= +github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3/go.mod h1:4Q0UFP0YJf0NrsEuEYHpM9fTSEVnD16Z3uyEF7J9JGM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33/go.mod h1:7i0PF1ME/2eUPFcjkVIwq+DOygHEoK92t5cDqNgYbIw= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27/go.mod h1:UrHnn3QV/d0pBZ6QBAEQcqFLf8FAzLmoUfPVIueOvoM= +github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34/go.mod h1:Etz2dj6UHYuw+Xw830KfzCfWGMzqvUTCjUj5b76GVDc= +github.com/aws/aws-sdk-go-v2/service/appconfig v1.4.2/go.mod h1:FZ3HkCe+b10uFZZkFdvf98LHW21k49W8o8J366lqVKY= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27/go.mod h1:EOwBD4J4S5qYszS5/3DpkejfuK+Z5/1uzICfPaZLtqw= +github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= +github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= +github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= +github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +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/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/elastic/go-structform v0.0.10 h1:oy08o/Ih2hHTkNcRY/1HhaYvIp5z6t8si8gnCJPDo1w= +github.com/elastic/go-structform v0.0.10/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/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.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/hashicorp/consul/api v1.13.0/go.mod h1:ZlVrynguJKcYr54zGaDbaL3fOvKC9m72FhPvA8T35KQ= +github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= +github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= +github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= +github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= +github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= +github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= +github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hjson/hjson-go/v4 v4.0.0 h1:wlm6IYYqHjOdXH1gHev4VoXCaW20HdQAGCxdOEEg2cs= +github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +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/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +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/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf v1.5.0 h1:q2TSd/3Pyc/5yP9ldIrSdIz26MCcyNQzW0pEAugLPNs= +github.com/knadh/koanf v1.5.0/go.mod h1:Hgyjp4y8v44hpZtPzs7JZfRAW5AhN7KfZcwv1RYggDs= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +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/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +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/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +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 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/opensearch-project/opensearch-go/v2 v2.3.0 h1:nQIEMr+A92CkhHrZgUhcfsrZjibvB3APXf2a1VwCmMQ= +github.com/opensearch-project/opensearch-go/v2 v2.3.0/go.mod h1:8LDr9FCgUTVoT+5ESjc2+iaZuldqE+23Iq0r1XeNue8= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT1pX2CziuyQR0= +github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +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.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= +go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/collector v0.79.1-0.20230609201858-ed8547a8e5d6 h1:o56cLasMc9AUmddgNfFcIbXJx2ZXSKMmfuKLrmubBoc= +go.opentelemetry.io/collector v0.79.1-0.20230609201858-ed8547a8e5d6/go.mod h1:8PZ5zhR4M8v7jetOr+vdjKOyoANnL+xHqqHdqpJlq9A= +go.opentelemetry.io/collector/component v0.79.1-0.20230609201858-ed8547a8e5d6 h1:rcKDmVykPrMy4wQtbV98xsM0zEa4AJz5wogLDjt7b28= +go.opentelemetry.io/collector/component v0.79.1-0.20230609201858-ed8547a8e5d6/go.mod h1:013c6CnhIU/d/Z1X4kvHpRpELPfNoO+HRBeZh+MJxeo= +go.opentelemetry.io/collector/confmap v0.79.1-0.20230609201858-ed8547a8e5d6 h1:NVbYg6oL99z7QCAzjfNNDByBsdnGHIaXM0FvxnhsQ3c= +go.opentelemetry.io/collector/confmap v0.79.1-0.20230609201858-ed8547a8e5d6/go.mod h1:cKr2c7lVtEJCuMOncUPlcROJBbTFaHiPjYp1Y8RbL+Q= +go.opentelemetry.io/collector/consumer v0.79.1-0.20230609201858-ed8547a8e5d6 h1:ENjWsqFjxbylWXQG5Y3kQFkGkOmpst3s50hVihgs3pQ= +go.opentelemetry.io/collector/consumer v0.79.1-0.20230609201858-ed8547a8e5d6/go.mod h1:mgVk2Eaf5E+nxN9dAsGMMkfA8Imt/FzVUZ91dc6dQDo= +go.opentelemetry.io/collector/exporter v0.79.0 h1:PxhKgWf1AkZvN1PjiJT5xiO+pKZA9Y4fyuMs5aNFuEA= +go.opentelemetry.io/collector/exporter v0.79.0/go.mod h1:qlXiqnOUeHelpAwk03f8nB5+91UIqlA7udSBsj9bJ3M= +go.opentelemetry.io/collector/extension v0.0.0-20230609200026-525adf4a682a h1:I8WVnt7cj/JweYOaaiu+Zzx8szYwVR5jBVxBgzkFxaA= +go.opentelemetry.io/collector/extension v0.0.0-20230609200026-525adf4a682a/go.mod h1:7vkZTU69L7UBMLhIPWeIl/vQZHpwVLiu0AW6lhojfDw= +go.opentelemetry.io/collector/featuregate v1.0.0-rcv0012.0.20230609201858-ed8547a8e5d6 h1:q/bCQl8udc8eZvfM1ReHLd7MVEngrK7rHit1kMDPAsQ= +go.opentelemetry.io/collector/featuregate v1.0.0-rcv0012.0.20230609201858-ed8547a8e5d6/go.mod h1:0mE3mDLmUrOXVoNsuvj+7dV14h/9HFl/Fy9YTLoLObo= +go.opentelemetry.io/collector/pdata v1.0.0-rcv0012.0.20230609201858-ed8547a8e5d6 h1:5owemI2Qf9djArnnA/l83hn/Un7cMeSEaDWI0LPlQ9k= +go.opentelemetry.io/collector/pdata v1.0.0-rcv0012.0.20230609201858-ed8547a8e5d6/go.mod h1:0J5SebctoOSo+5fdRWc7TKu0wc7nDbZ6I603WKY24sg= +go.opentelemetry.io/collector/processor v0.0.0-20230609193203-89d1060c7606 h1:K2ULUkyOHHj+06EhQpLPTOBY8mDCEv2s2ZcK+CMU+bQ= +go.opentelemetry.io/collector/processor v0.0.0-20230609193203-89d1060c7606/go.mod h1:8+isoLVhFkBwPaFl8jkWe1h2fjs9lgmhY0zPzLQ5WuM= +go.opentelemetry.io/collector/receiver v0.79.1-0.20230609201858-ed8547a8e5d6 h1:h7Mdww7QeZUFt4dvv9cdsnbR+5TOg7IwiUvTZmTgfrI= +go.opentelemetry.io/collector/receiver v0.79.1-0.20230609201858-ed8547a8e5d6/go.mod h1:3owfLpZ4d6m8YxYaOFQ1gknZtMkMsH0IA/2Uo28tWOk= +go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= +go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= +go.opentelemetry.io/otel/exporters/prometheus v0.39.0 h1:whAaiHxOatgtKd+w0dOi//1KUxj3KoPINZdtDaDj3IA= +go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= +go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= +go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= +go.opentelemetry.io/otel/sdk/metric v0.39.0 h1:Kun8i1eYf48kHH83RucG93ffz0zGV1sh46FAScOTuDI= +go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= +go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= +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-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +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.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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-20201207232520-09787c993a3a/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.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/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-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +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.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +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.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +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/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/exporter/opensearchexporter/internal/objmodel/objmodel.go b/exporter/opensearchexporter/internal/objmodel/objmodel.go new file mode 100644 index 000000000000..0928e1adbafa --- /dev/null +++ b/exporter/opensearchexporter/internal/objmodel/objmodel.go @@ -0,0 +1,544 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// The objmodel package provides tools for converting OpenTelemetry Log records into +// JSON documents. +// +// The JSON parsing in OpenSearch does not support parsing JSON documents +// with duplicate fields. The fields in the docuemt can be sort and duplicate entries +// can be removed before serializing. Deduplication ensures that ambigious +// events can still be indexed. +// +// With attributes map encoded as a list of key value +// pairs, we might find some structured loggers that create log records with +// duplicate fields. Although the AttributeMap wrapper tries to give a +// dictionary like view into the list, it is not 'complete'. When iterating the map +// for encoding, we still will encounter the duplicates. +// The AttributeMap helpers treat the first occurrence as the actual field. +// For high-performance structured loggers (e.g. zap) the AttributeMap +// semantics are not necessarily correct. Most often the last occurrence will be +// what we want to export, as the last occurrence represents the last overwrite +// within a context/dictionary (the leaf-logger its context). +// Some Loggers might even allow users to create a mix of dotted and dedotted fields. +// The Document type also tries to combine these into a proper structure, such that these mixed +// representations have a unique encoding only, which allows us to properly remove duplicates. +// +// The `.` is special to OpenSearch. In order to handle common prefixes and attributes +// being a mix of key value pairs with dots and complex objects, we flatten the document first +// before we deduplicate. Final dedotting is optional and only required when +// Ingest Node is used. But either way, we try to present only well-formed +// document to OpenSearch. + +package objmodel // Package objmodel + +import ( + "encoding/hex" + "io" + "math" + "sort" + "strings" + "time" + + "github.com/elastic/go-structform" + "github.com/elastic/go-structform/json" + "go.opentelemetry.io/collector/pdata/pcommon" +) + +// Document is an intermediate representation for converting open telemetry records with arbitrary attributes +// into a JSON document that can be processed by OpenSearch. +type Document struct { + fields []field +} + +type field struct { + key string + value Value +} + +// Value type that can be added to a Document. +type Value struct { + kind Kind + primitive uint64 + dbl float64 + str string + arr []Value + doc Document + ts time.Time +} + +// Kind represent the internal kind of a value stored in a Document. +type Kind uint8 + +// Enum values for Kind. +const ( + KindNil Kind = iota + KindBool + KindInt + KindDouble + KindString + KindArr + KindObject + KindTimestamp + KindIgnore +) + +const tsLayout = "2006-01-02T15:04:05.000000000Z" + +var nilValue = Value{kind: KindNil} +var ignoreValue = Value{kind: KindIgnore} + +// DocumentFromAttributes creates a document from a OpenTelemetry attribute +// map. All nested maps will be flattened, with keys being joined using a `.` symbol. +func DocumentFromAttributes(am pcommon.Map) Document { + return DocumentFromAttributesWithPath("", am) +} + +// DocumentFromAttributesWithPath creates a document from a OpenTelemetry attribute +// map. All nested maps will be flattened, with keys being joined using a `.` symbol. +// +// All keys in the map will be prefixed with path. +func DocumentFromAttributesWithPath(path string, am pcommon.Map) Document { + if am.Len() == 0 { + return Document{} + } + + fields := make([]field, 0, am.Len()) + fields = appendAttributeFields(fields, path, am) + return Document{fields} +} + +// AddTimestamp adds a raw timestamp value to the Document. +func (doc *Document) AddTimestamp(key string, ts pcommon.Timestamp) { + doc.Add(key, TimestampValue(ts.AsTime())) +} + +// Add adds a converted value to the document. +func (doc *Document) Add(key string, v Value) { + doc.fields = append(doc.fields, field{key: key, value: v}) +} + +// AddString adds a string to the document. +func (doc *Document) AddString(key string, v string) { + if v != "" { + doc.Add(key, StringValue(v)) + } +} + +// AddSpanID adds the hex presentation of a SpanID to the document. If the SpanID +// is empty, no value will be added. +func (doc *Document) AddSpanID(key string, id pcommon.SpanID) { + if !id.IsEmpty() { + doc.AddString(key, hex.EncodeToString(id[:])) + } +} + +// AddTraceID adds the hex presentation of a TraceID value to the document. If the TraceID +// is empty, no value will be added. +func (doc *Document) AddTraceID(key string, id pcommon.TraceID) { + if !id.IsEmpty() { + doc.AddString(key, hex.EncodeToString(id[:])) + } +} + +// AddInt adds an integer value to the document. +func (doc *Document) AddInt(key string, value int64) { + doc.Add(key, IntValue(value)) +} + +// AddAttributes expands and flattens all key-value pairs from the input attribute map into +// the document. +func (doc *Document) AddAttributes(key string, attributes pcommon.Map) { + doc.fields = appendAttributeFields(doc.fields, key, attributes) +} + +// AddAttribute converts and adds a AttributeValue to the document. If the attribute represents a map, +// the fields will be flattened. +func (doc *Document) AddAttribute(key string, attribute pcommon.Value) { + switch attribute.Type() { + case pcommon.ValueTypeEmpty: + // do not add 'null' + case pcommon.ValueTypeMap: + doc.AddAttributes(key, attribute.Map()) + default: + doc.Add(key, ValueFromAttribute(attribute)) + } +} + +// Sort sorts all fields in the document by key name. +func (doc *Document) Sort() { + sort.SliceStable(doc.fields, func(i, j int) bool { + return doc.fields[i].key < doc.fields[j].key + }) + + for i := range doc.fields { + fld := &doc.fields[i] + fld.value.Sort() + } +} + +// Dedup removes fields from the document, that have duplicate keys. +// The filtering only keeps the last value for a key. +// +// Dedup ensure that keys are sorted. +func (doc *Document) Dedup() { + // 1. Always ensure the fields are sorted, Dedup support requires + // Fields to be sorted. + doc.Sort() + + // 2. rename fields if a primitive value is overwritten by an object. + // For example the pair (path.x=1, path.x.a="test") becomes: + // (path.x.value=1, path.x.a="test"). + // + // NOTE: We do the renaming, in order to preserve the original value + // in case of conflicts after dedotting, which would lead to the removal of the field. + // For example docker/k8s labels tend to use `.`, which need to be handled in case + // The collector does pass us these kind of labels as an AttributeMap. + // + // NOTE: If the embedded document already has a field name `value`, we will remove the renamed + // field in favor of the `value` field in the document. + // + // This step removes potential conflicts when dedotting and serializing fields. + var renamed bool + for i := 0; i < len(doc.fields)-1; i++ { + key, nextKey := doc.fields[i].key, doc.fields[i+1].key + if len(key) < len(nextKey) && strings.HasPrefix(nextKey, key) && nextKey[len(key)] == '.' { + renamed = true + doc.fields[i].key = key + ".value" + } + } + if renamed { + doc.Sort() + } + + // 3. mark duplicates as 'ignore' + // + // This step ensures that we do not have duplicate fields names when serializing. + // OpenSearch JSON parser will fail otherwise. + for i := 0; i < len(doc.fields)-1; i++ { + if doc.fields[i].key == doc.fields[i+1].key { + doc.fields[i].value = ignoreValue + } + } + + // 4. fix objects that might be stored in arrays + for i := range doc.fields { + doc.fields[i].value.Dedup() + } +} + +// Serialize writes the document to the given writer. The serializer will create nested objects if dedot is true. +// +// NOTE: The documented MUST be sorted if dedot is true. +func (doc *Document) Serialize(w io.Writer, dedot bool) error { + v := json.NewVisitor(w) + return doc.iterJSON(v, dedot) +} + +func (doc *Document) iterJSON(v *json.Visitor, dedot bool) error { + if dedot { + return doc.iterJSONDedot(v) + } + return doc.iterJSONFlat(v) +} + +func (doc *Document) iterJSONFlat(w *json.Visitor) error { + err := w.OnObjectStart(-1, structform.AnyType) + if err != nil { + return err + } + defer func() { + _ = w.OnObjectFinished() + }() + + for i := range doc.fields { + fld := &doc.fields[i] + if fld.value.IsEmpty() { + continue + } + + if err := w.OnKey(fld.key); err != nil { + return err + } + + if err := fld.value.iterJSON(w, true); err != nil { + return err + } + } + + return nil +} + +func (doc *Document) iterJSONDedot(w *json.Visitor) error { + objPrefix := "" + level := 0 + + if err := w.OnObjectStart(-1, structform.AnyType); err != nil { + return err + } + defer func() { + _ = w.OnObjectFinished() + }() + + for i := range doc.fields { + fld := &doc.fields[i] + if fld.value.IsEmpty() { + continue + } + + key := fld.key + // decrease object level until last reported and current key have the same path prefix + for L := commonObjPrefix(key, objPrefix); L < len(objPrefix); { + for L > 0 && key[L-1] != '.' { + L-- + } + + // remove levels and append write list of outstanding '}' into the writer + if L > 0 { + for delta := objPrefix[L:]; len(delta) > 0; { + idx := strings.IndexByte(delta, '.') + if idx < 0 { + break + } + + delta = delta[idx+1:] + level-- + if err := w.OnObjectFinished(); err != nil { + return err + } + } + + objPrefix = key[:L] + } else { // no common prefix, close all objects we reported so far. + for ; level > 0; level-- { + if err := w.OnObjectFinished(); err != nil { + return err + } + } + objPrefix = "" + } + } + + // increase object level up to current field + for { + start := len(objPrefix) + idx := strings.IndexByte(key[start:], '.') + if idx < 0 { + break + } + + level++ + objPrefix = key[:len(objPrefix)+idx+1] + fieldName := key[start : start+idx] + if err := w.OnKey(fieldName); err != nil { + return err + } + if err := w.OnObjectStart(-1, structform.AnyType); err != nil { + return err + } + } + + // report value + fieldName := key[len(objPrefix):] + if err := w.OnKey(fieldName); err != nil { + return err + } + if err := fld.value.iterJSON(w, true); err != nil { + return err + } + } + + // close all pending object levels + for ; level > 0; level-- { + if err := w.OnObjectFinished(); err != nil { + return err + } + } + + return nil +} + +// StringValue create a new value from a string. +func StringValue(str string) Value { return Value{kind: KindString, str: str} } + +// IntValue creates a new value from an integer. +func IntValue(i int64) Value { return Value{kind: KindInt, primitive: uint64(i)} } + +// DoubleValue creates a new value from a double value.. +func DoubleValue(d float64) Value { return Value{kind: KindDouble, dbl: d} } + +// BoolValue creates a new value from a double value.. +func BoolValue(b bool) Value { + var v uint64 + if b { + v = 1 + } + return Value{kind: KindBool, primitive: v} +} + +// ArrValue combines multiple values into an array value. +func ArrValue(values ...Value) Value { + return Value{kind: KindArr, arr: values} +} + +// TimestampValue create a new value from a time.Time. +func TimestampValue(ts time.Time) Value { + return Value{kind: KindTimestamp, ts: ts} +} + +// ValueFromAttribute converts a AttributeValue into a value. +func ValueFromAttribute(attr pcommon.Value) Value { + switch attr.Type() { + case pcommon.ValueTypeInt: + return IntValue(attr.Int()) + case pcommon.ValueTypeDouble: + return DoubleValue(attr.Double()) + case pcommon.ValueTypeStr: + return StringValue(attr.Str()) + case pcommon.ValueTypeBool: + return BoolValue(attr.Bool()) + case pcommon.ValueTypeSlice: + sub := arrFromAttributes(attr.Slice()) + return ArrValue(sub...) + case pcommon.ValueTypeMap: + sub := DocumentFromAttributes(attr.Map()) + return Value{kind: KindObject, doc: sub} + default: + return nilValue + } +} + +// Sort recursively sorts all keys in docuemts held by the value. +func (v *Value) Sort() { + switch v.kind { + case KindObject: + v.doc.Sort() + case KindArr: + for i := range v.arr { + v.arr[i].Sort() + } + } +} + +// Dedup recursively dedups keys in stored documents. +// +// NOTE: The value MUST be sorted. +func (v *Value) Dedup() { + switch v.kind { + case KindObject: + v.doc.Dedup() + case KindArr: + for i := range v.arr { + v.arr[i].Dedup() + } + } +} + +func (v *Value) IsEmpty() bool { + switch v.kind { + case KindNil, KindIgnore: + return true + case KindArr: + return len(v.arr) == 0 + case KindObject: + return len(v.doc.fields) == 0 + default: + return false + } +} + +func (v *Value) iterJSON(w *json.Visitor, dedot bool) error { + switch v.kind { + case KindNil: + return w.OnNil() + case KindBool: + return w.OnBool(v.primitive == 1) + case KindInt: + return w.OnInt64(int64(v.primitive)) + case KindDouble: + if math.IsNaN(v.dbl) || math.IsInf(v.dbl, 0) { + // NaN and Inf are undefined for JSON. Let's serialize to "null" + return w.OnNil() + } + return w.OnFloat64(v.dbl) + case KindString: + return w.OnString(v.str) + case KindTimestamp: + str := v.ts.UTC().Format(tsLayout) + return w.OnString(str) + case KindObject: + if len(v.doc.fields) == 0 { + return w.OnNil() + } + return v.doc.iterJSON(w, dedot) + case KindArr: + if err := w.OnArrayStart(-1, structform.AnyType); err != nil { + return err + } + for i := range v.arr { + if err := v.arr[i].iterJSON(w, dedot); err != nil { + return err + } + } + if err := w.OnArrayFinished(); err != nil { + return err + } + } + + return nil +} + +func arrFromAttributes(aa pcommon.Slice) []Value { + if aa.Len() == 0 { + return nil + } + + values := make([]Value, aa.Len()) + for i := 0; i < aa.Len(); i++ { + values[i] = ValueFromAttribute(aa.At(i)) + } + return values +} + +func appendAttributeFields(fields []field, path string, am pcommon.Map) []field { + am.Range(func(k string, val pcommon.Value) bool { + fields = appendAttributeValue(fields, path, k, val) + return true + }) + return fields +} + +func appendAttributeValue(fields []field, path string, key string, attr pcommon.Value) []field { + if attr.Type() == pcommon.ValueTypeEmpty { + return fields + } + + if attr.Type() == pcommon.ValueTypeMap { + return appendAttributeFields(fields, flattenKey(path, key), attr.Map()) + } + + return append(fields, field{ + key: flattenKey(path, key), + value: ValueFromAttribute(attr), + }) +} + +func flattenKey(path, key string) string { + if path == "" { + return key + } + return path + "." + key +} + +func commonObjPrefix(a, b string) int { + end := len(a) + if alt := len(b); alt < end { + end = alt + } + + for i := 0; i < end; i++ { + if a[i] != b[i] { + return i + } + } + return end +} diff --git a/exporter/opensearchexporter/internal/objmodel/objmodel_test.go b/exporter/opensearchexporter/internal/objmodel/objmodel_test.go new file mode 100644 index 000000000000..f33aaa740754 --- /dev/null +++ b/exporter/opensearchexporter/internal/objmodel/objmodel_test.go @@ -0,0 +1,435 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package objmodel + +import ( + "math" + "strings" + "testing" + "time" + + "github.com/elastic/go-structform/json" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/pdata/pcommon" +) + +var dijkstra = time.Date(1930, 5, 11, 16, 33, 11, 123456789, time.UTC) + +func TestObjectModel_CreateMap(t *testing.T) { + tests := map[string]struct { + build func() Document + want Document + }{ + "from empty map": { + build: func() Document { + return DocumentFromAttributes(pcommon.NewMap()) + }, + }, + "from map": { + build: func() Document { + m := pcommon.NewMap() + m.PutInt("i", 42) + m.PutStr("str", "test") + return DocumentFromAttributes(m) + }, + want: Document{[]field{{"i", IntValue(42)}, {"str", StringValue("test")}}}, + }, + "ignores nil values": { + build: func() Document { + m := pcommon.NewMap() + m.PutEmpty("null") + m.PutStr("str", "test") + return DocumentFromAttributes(m) + }, + want: Document{[]field{{"str", StringValue("test")}}}, + }, + "from map with prefix": { + build: func() Document { + m := pcommon.NewMap() + m.PutInt("i", 42) + m.PutStr("str", "test") + return DocumentFromAttributesWithPath("prefix", m) + }, + want: Document{[]field{{"prefix.i", IntValue(42)}, {"prefix.str", StringValue("test")}}}, + }, + "add attributes with key": { + build: func() (doc Document) { + m := pcommon.NewMap() + m.PutInt("i", 42) + m.PutStr("str", "test") + doc.AddAttributes("prefix", m) + return doc + }, + want: Document{[]field{{"prefix.i", IntValue(42)}, {"prefix.str", StringValue("test")}}}, + }, + "add attribute flattens a map value": { + build: func() (doc Document) { + mapVal := pcommon.NewValueMap() + m := mapVal.Map() + m.PutInt("i", 42) + m.PutStr("str", "test") + doc.AddAttribute("prefix", mapVal) + return doc + }, + want: Document{[]field{{"prefix.i", IntValue(42)}, {"prefix.str", StringValue("test")}}}, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + doc := test.build() + doc.Sort() + assert.Equal(t, test.want, doc) + }) + } +} + +func TestDocument_Sort(t *testing.T) { + tests := map[string]struct { + build func() Document + want Document + }{ + "keys are sorted": { + build: func() (doc Document) { + doc.AddInt("z", 26) + doc.AddInt("a", 1) + return doc + }, + want: Document{[]field{{"a", IntValue(1)}, {"z", IntValue(26)}}}, + }, + "sorting is stable": { + build: func() (doc Document) { + doc.AddInt("a", 1) + doc.AddInt("c", 3) + doc.AddInt("a", 2) + return doc + }, + want: Document{[]field{{"a", IntValue(1)}, {"a", IntValue(2)}, {"c", IntValue(3)}}}, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + doc := test.build() + doc.Sort() + assert.Equal(t, test.want, doc) + }) + } + +} + +func TestObjectModel_Dedup(t *testing.T) { + tests := map[string]struct { + build func() Document + want Document + }{ + "no duplicates": { + build: func() (doc Document) { + doc.AddInt("a", 1) + doc.AddInt("c", 3) + return doc + }, + want: Document{[]field{{"a", IntValue(1)}, {"c", IntValue(3)}}}, + }, + "duplicate keys": { + build: func() (doc Document) { + doc.AddInt("a", 1) + doc.AddInt("c", 3) + doc.AddInt("a", 2) + return doc + }, + want: Document{[]field{{"a", ignoreValue}, {"a", IntValue(2)}, {"c", IntValue(3)}}}, + }, + "duplicate after flattening from map: namespace object at end": { + build: func() Document { + am := pcommon.NewMap() + am.PutInt("namespace.a", 42) + am.PutStr("toplevel", "test") + am.PutEmptyMap("namespace").PutInt("a", 23) + return DocumentFromAttributes(am) + }, + want: Document{[]field{{"namespace.a", ignoreValue}, {"namespace.a", IntValue(23)}, {"toplevel", StringValue("test")}}}, + }, + "duplicate after flattening from map: namespace object at beginning": { + build: func() Document { + am := pcommon.NewMap() + am.PutEmptyMap("namespace").PutInt("a", 23) + am.PutInt("namespace.a", 42) + am.PutStr("toplevel", "test") + return DocumentFromAttributes(am) + }, + want: Document{[]field{{"namespace.a", ignoreValue}, {"namespace.a", IntValue(42)}, {"toplevel", StringValue("test")}}}, + }, + "dedup in arrays": { + build: func() (doc Document) { + var embedded Document + embedded.AddInt("a", 1) + embedded.AddInt("c", 3) + embedded.AddInt("a", 2) + + doc.Add("arr", ArrValue(Value{kind: KindObject, doc: embedded})) + return doc + }, + want: Document{[]field{{"arr", ArrValue(Value{kind: KindObject, doc: Document{[]field{ + {"a", ignoreValue}, + {"a", IntValue(2)}, + {"c", IntValue(3)}, + }}})}}}, + }, + "dedup mix of primitive and object lifts primitive": { + build: func() (doc Document) { + doc.AddInt("namespace", 1) + doc.AddInt("namespace.a", 2) + return doc + }, + want: Document{[]field{{"namespace.a", IntValue(2)}, {"namespace.value", IntValue(1)}}}, + }, + "dedup removes primitive if value exists": { + build: func() (doc Document) { + doc.AddInt("namespace", 1) + doc.AddInt("namespace.a", 2) + doc.AddInt("namespace.value", 3) + return doc + }, + want: Document{[]field{{"namespace.a", IntValue(2)}, {"namespace.value", ignoreValue}, {"namespace.value", IntValue(3)}}}, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + doc := test.build() + doc.Sort() + doc.Dedup() + assert.Equal(t, test.want, doc) + }) + } +} + +func TestValue_FromAttribute(t *testing.T) { + tests := map[string]struct { + in pcommon.Value + want Value + }{ + "null": { + in: pcommon.NewValueEmpty(), + want: nilValue, + }, + "string": { + in: pcommon.NewValueStr("test"), + want: StringValue("test"), + }, + "int": { + in: pcommon.NewValueInt(23), + want: IntValue(23), + }, + "double": { + in: pcommon.NewValueDouble(3.14), + want: DoubleValue(3.14), + }, + "bool": { + in: pcommon.NewValueBool(true), + want: BoolValue(true), + }, + "empty array": { + in: pcommon.NewValueSlice(), + want: Value{kind: KindArr}, + }, + "non-empty array": { + in: func() pcommon.Value { + v := pcommon.NewValueSlice() + tgt := v.Slice().AppendEmpty() + pcommon.NewValueInt(1).CopyTo(tgt) + return v + }(), + want: ArrValue(IntValue(1)), + }, + "empty map": { + in: pcommon.NewValueMap(), + want: Value{kind: KindObject}, + }, + "non-empty map": { + in: func() pcommon.Value { + v := pcommon.NewValueMap() + v.Map().PutInt("a", 1) + return v + }(), + want: Value{kind: KindObject, doc: Document{[]field{{"a", IntValue(1)}}}}, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + v := ValueFromAttribute(test.in) + assert.Equal(t, test.want, v) + }) + } +} + +func TestDocument_Serialize_Flat(t *testing.T) { + tests := map[string]struct { + attrs map[string]interface{} + want string + }{ + "no nesting with multiple fields": { + attrs: map[string]interface{}{ + "a": "test", + "b": 1, + }, + want: `{"a":"test","b":1}`, + }, + "shared prefix": { + attrs: map[string]interface{}{ + "a.str": "test", + "a.i": 1, + }, + want: `{"a.i":1,"a.str":"test"}`, + }, + "multiple namespaces with dot": { + attrs: map[string]interface{}{ + "a.str": "test", + "b.i": 1, + }, + want: `{"a.str":"test","b.i":1}`, + }, + "nested maps": { + attrs: map[string]interface{}{ + "a": map[string]interface{}{ + "str": "test", + "i": 1, + }, + }, + want: `{"a.i":1,"a.str":"test"}`, + }, + "multi-level nested namespace maps": { + attrs: map[string]interface{}{ + "a": map[string]interface{}{ + "b.str": "test", + "i": 1, + }, + }, + want: `{"a.b.str":"test","a.i":1}`, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + var buf strings.Builder + m := pcommon.NewMap() + assert.NoError(t, m.FromRaw(test.attrs)) + doc := DocumentFromAttributes(m) + doc.Dedup() + err := doc.Serialize(&buf, false) + require.NoError(t, err) + + assert.Equal(t, test.want, buf.String()) + }) + } +} + +func TestDocument_Serialize_Dedot(t *testing.T) { + tests := map[string]struct { + attrs map[string]interface{} + want string + }{ + "no nesting with multiple fields": { + attrs: map[string]interface{}{ + "a": "test", + "b": 1, + }, + want: `{"a":"test","b":1}`, + }, + "shared prefix": { + attrs: map[string]interface{}{ + "a.str": "test", + "a.i": 1, + }, + want: `{"a":{"i":1,"str":"test"}}`, + }, + "multiple namespaces": { + attrs: map[string]interface{}{ + "a.str": "test", + "b.i": 1, + }, + want: `{"a":{"str":"test"},"b":{"i":1}}`, + }, + "nested maps": { + attrs: map[string]interface{}{ + "a": map[string]interface{}{ + "str": "test", + "i": 1, + }, + }, + want: `{"a":{"i":1,"str":"test"}}`, + }, + "multi-level nested namespace maps": { + attrs: map[string]interface{}{ + "a": map[string]interface{}{ + "b.c.str": "test", + "i": 1, + }, + }, + want: `{"a":{"b":{"c":{"str":"test"}},"i":1}}`, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + var buf strings.Builder + m := pcommon.NewMap() + assert.NoError(t, m.FromRaw(test.attrs)) + doc := DocumentFromAttributes(m) + doc.Dedup() + err := doc.Serialize(&buf, true) + require.NoError(t, err) + + assert.Equal(t, test.want, buf.String()) + }) + } +} + +func TestValue_Serialize(t *testing.T) { + tests := map[string]struct { + value Value + want string + }{ + "nil value": {value: nilValue, want: "null"}, + "bool value: true": {value: BoolValue(true), want: "true"}, + "bool value: false": {value: BoolValue(false), want: "false"}, + "int value": {value: IntValue(42), want: "42"}, + "double value": {value: DoubleValue(3.14), want: "3.14"}, + "NaN is undefined": {value: DoubleValue(math.NaN()), want: "null"}, + "Inf is undefined": {value: DoubleValue(math.Inf(0)), want: "null"}, + "string value": {value: StringValue("Hello World!"), want: `"Hello World!"`}, + "timestamp": { + value: TimestampValue(dijkstra), + want: `"1930-05-11T16:33:11.123456789Z"`, + }, + "array": { + value: ArrValue(BoolValue(true), IntValue(23)), + want: `[true,23]`, + }, + "object": { + value: func() Value { + doc := Document{} + doc.AddString("a", "b") + return Value{kind: KindObject, doc: doc} + }(), + want: `{"a":"b"}`, + }, + "empty object": { + value: Value{kind: KindObject, doc: Document{}}, + want: "null", + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + var buf strings.Builder + err := test.value.iterJSON(json.NewVisitor(&buf), false) + require.NoError(t, err) + assert.Equal(t, test.want, buf.String()) + }) + } +} diff --git a/exporter/opensearchexporter/opensearch_bulk.go b/exporter/opensearchexporter/opensearch_bulk.go new file mode 100644 index 000000000000..89988798cc8c --- /dev/null +++ b/exporter/opensearchexporter/opensearch_bulk.go @@ -0,0 +1,217 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Package opensearchexporter contains an opentelemetry-collector exporter +// for OpenSearch. +package opensearchexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter" + +import ( + "bytes" + "context" + "crypto/tls" + "encoding/json" + "fmt" + "io" + "net/http" + "time" + + "github.com/cenkalti/backoff/v4" + "github.com/opensearch-project/opensearch-go/v2" + "github.com/opensearch-project/opensearch-go/v2/opensearchutil" + "go.uber.org/zap" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/sanitize" +) + +type osClientCurrent = opensearch.Client +type osConfigCurrent = opensearch.Config +type osBulkIndexerCurrent = opensearchutil.BulkIndexer +type osBulkIndexerItem = opensearchutil.BulkIndexerItem +type osBulkIndexerResponseItem = opensearchutil.BulkIndexerResponseItem + +var retryOnStatus = []int{500, 502, 503, 504, 429} + +type clientLogger zap.Logger + +// LogRoundTrip should not modify the request or response, except for consuming and closing the body. +// Implementations have to check for nil values in request and response. +func (cl *clientLogger) LogRoundTrip(requ *http.Request, resp *http.Response, err error, _ time.Time, dur time.Duration) error { + zl := (*zap.Logger)(cl) + switch { + case err == nil && resp != nil: + zl.Debug("Request roundtrip completed.", + zap.String("path", sanitize.String(requ.URL.Path)), + zap.String("method", requ.Method), + zap.Duration("duration", dur), + zap.String("status", resp.Status)) + + case err != nil: + zl.Error("Request failed.", zap.NamedError("reason", err)) + } + + return nil +} + +// RequestBodyEnabled makes the client pass a copy of request body to the logger. +func (*clientLogger) RequestBodyEnabled() bool { + // TODO: introduce setting log the bodies for more detailed debug logs + return false +} + +// ResponseBodyEnabled makes the client pass a copy of response body to the logger. +func (*clientLogger) ResponseBodyEnabled() bool { + // TODO: introduce setting log the bodies for more detailed debug logs + return false +} + +func newOpenSearchClient(logger *zap.Logger, config *Config) (*osClientCurrent, error) { + tlsCfg, err := config.TLSClientSetting.LoadTLSConfig() + if err != nil { + return nil, err + } + + transport := newTransport(config, tlsCfg) + + headers := make(http.Header) + for k, v := range config.Headers { + headers.Add(k, v) + } + + // TODO: validate settings: + // - try to parse address and validate scheme (address must be a valid URL) + // - check if cloud ID is valid + + // maxRetries configures the maximum number of event publishing attempts, + // including the first send and additional retries. + maxRetries := config.Retry.MaxRequests - 1 + retryDisabled := !config.Retry.Enabled || maxRetries <= 0 + + if retryDisabled { + maxRetries = 0 + } + + return opensearch.NewClient(osConfigCurrent{ + Transport: transport, + + // configure connection setup + Addresses: config.Endpoints, + Username: config.Authentication.User, + Password: string(config.Authentication.Password), + Header: headers, + + // configure retry behavior + RetryOnStatus: retryOnStatus, + DisableRetry: retryDisabled, + MaxRetries: maxRetries, + RetryBackoff: createBackoffFunction(&config.Retry), + + // configure internal metrics reporting and logging + EnableMetrics: false, // TODO + EnableDebugLogger: false, // TODO + Logger: (*clientLogger)(logger), + }) +} + +func newTransport(config *Config, tlsCfg *tls.Config) *http.Transport { + transport := http.DefaultTransport.(*http.Transport).Clone() + if tlsCfg != nil { + transport.TLSClientConfig = tlsCfg + } + if config.ReadBufferSize > 0 { + transport.ReadBufferSize = config.ReadBufferSize + } + if config.WriteBufferSize > 0 { + transport.WriteBufferSize = config.WriteBufferSize + } + + return transport +} + +func newBulkIndexer(logger *zap.Logger, client *opensearch.Client, config *Config) (osBulkIndexerCurrent, error) { + // TODO: add debug logger + return opensearchutil.NewBulkIndexer(opensearchutil.BulkIndexerConfig{ + NumWorkers: config.NumWorkers, + FlushBytes: config.Flush.Bytes, + FlushInterval: config.Flush.Interval, + Client: client, + Timeout: config.Timeout, + + OnError: func(_ context.Context, err error) { + logger.Error(fmt.Sprintf("Bulk indexer error: %v", err)) + }, + }) +} + +func createBackoffFunction(config *RetrySettings) func(int) time.Duration { + if !config.Enabled { + return nil + } + + expBackoff := backoff.NewExponentialBackOff() + if config.InitialInterval > 0 { + expBackoff.InitialInterval = config.InitialInterval + } + if config.MaxInterval > 0 { + expBackoff.MaxInterval = config.MaxInterval + } + expBackoff.Reset() + + return func(attempts int) time.Duration { + if attempts == 1 { + expBackoff.Reset() + } + + return expBackoff.NextBackOff() + } +} + +func shouldRetryEvent(status int) bool { + for _, retryable := range retryOnStatus { + if status == retryable { + return true + } + } + return false +} + +func pushDocuments(ctx context.Context, logger *zap.Logger, index string, document []byte, bulkIndexer osBulkIndexerCurrent, maxAttempts int) error { + attempts := 1 + body := bytes.NewReader(document) + item := osBulkIndexerItem{Action: "create", Index: index, Body: body} + // Setup error handler. The handler handles the per item response status based on the + // selective ACKing in the bulk response. + item.OnFailure = func(ctx context.Context, item osBulkIndexerItem, resp osBulkIndexerResponseItem, err error) { + switch { + case attempts < maxAttempts && shouldRetryEvent(resp.Status): + logger.Debug("Retrying to index", + zap.String("name", index), + zap.Int("attempt", attempts), + zap.Int("status", resp.Status), + zap.NamedError("reason", err)) + + attempts++ + _, _ = body.Seek(0, io.SeekStart) + _ = bulkIndexer.Add(ctx, item) + + case resp.Status == 0 && err != nil: + // Encoding error. We didn't even attempt to send the event + logger.Error("Drop docs: failed to add docs to the bulk request buffer.", + zap.NamedError("reason", err)) + + case err != nil: + logger.Error("Drop docs: failed to index", + zap.String("name", index), + zap.Int("attempt", attempts), + zap.Int("status", resp.Status), + zap.NamedError("reason", err)) + + default: + erroJson, _ := json.Marshal(resp.Error) + logger.Error(fmt.Sprintf("Drop docs: failed to index: %s", erroJson), + zap.Int("attempt", attempts), + zap.Int("status", resp.Status)) + } + } + + return bulkIndexer.Add(ctx, item) +} diff --git a/exporter/opensearchexporter/opensearch_bulk_test.go b/exporter/opensearchexporter/opensearch_bulk_test.go new file mode 100644 index 000000000000..fff5672cc771 --- /dev/null +++ b/exporter/opensearchexporter/opensearch_bulk_test.go @@ -0,0 +1,76 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "go.uber.org/zap" +) + +func Test_pushDocuments(t *testing.T) { + + type args struct { + index string + document []byte + maxAttempts int + } + tests := []struct { + name string + args args + wantErr assert.ErrorAssertionFunc + }{ + { + name: "simple", + args: args{ + index: "sample-index", + document: []byte(`{"field": "sample"}`), + maxAttempts: 0, + }, + wantErr: assert.NoError, + }, + } + + ctx := context.Background() + logger := zap.L() + config := withDefaultConfig() + client, _ := newOpenSearchClient(zap.L(), config) + bulkIndexer, _ := newBulkIndexer(zap.L(), client, config) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + index := tt.args.index + document := tt.args.document + attempts := tt.args.maxAttempts + tt.wantErr(t, pushDocuments(ctx, logger, index, document, bulkIndexer, attempts), + fmt.Sprintf("pushDocuments(%v, %v, %v, %v, %v, %v)", + ctx, logger, index, document, bulkIndexer, attempts)) + }) + } +} + +func Test_shouldRetryEvent(t *testing.T) { + type args struct { + status int + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "internal server error", + args: args{status: 500}, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equalf(t, tt.want, shouldRetryEvent(tt.args.status), "shouldRetryEvent(%v)", tt.args.status) + }) + } +} diff --git a/exporter/opensearchexporter/sso_model.go b/exporter/opensearchexporter/sso_model.go new file mode 100644 index 000000000000..4b3ab3c1272f --- /dev/null +++ b/exporter/opensearchexporter/sso_model.go @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter + +import ( + "time" +) + +type DataStream struct { + Dataset string `json:"dataset,omitempty"` + Namespace string `json:"namespace,omitempty"` + Type string `json:"type,omitempty"` +} + +type SSOSpanEvent struct { + Attributes map[string]any `json:"attributes"` + DroppedAttributesCount uint32 `json:"droppedAttributesCount"` + Name string `json:"name"` + ObservedTimestamp *time.Time `json:"observedTimestamp,omitempty"` + Timestamp *time.Time `json:"@timestamp,omitempty"` +} + +type SSOSpanLinks struct { + Attributes map[string]any `json:"attributes,omitempty"` + SpanID string `json:"spanId,omitempty"` + TraceID string `json:"traceId,omitempty"` + TraceState string `json:"traceState,omitempty"` + DroppedAttributesCount uint32 `json:"droppedAttributesCount,omitempty"` +} + +type SSOSpan struct { + Attributes map[string]any `json:"attributes,omitempty"` + DroppedAttributesCount uint32 `json:"droppedAttributesCount"` + DroppedEventsCount uint32 `json:"droppedEventsCount"` + DroppedLinksCount uint32 `json:"droppedLinksCount"` + EndTime time.Time `json:"endTime"` + Events []SSOSpanEvent `json:"events,omitempty"` + InstrumentationScope struct { + Attributes map[string]any `json:"attributes,omitempty"` + DroppedAttributesCount uint32 `json:"droppedAttributesCount"` + Name string `json:"name"` + SchemaURL string `json:"schemaUrl"` + Version string `json:"version"` + } `json:"instrumentationScope,omitempty"` + Kind string `json:"kind"` + Links []SSOSpanLinks `json:"links,omitempty"` + Name string `json:"name"` + ParentSpanID string `json:"parentSpanId"` + Resource map[string]any `json:"resource,omitempty"` + SpanID string `json:"spanId"` + StartTime time.Time `json:"startTime"` + Status struct { + Code string `json:"code"` + Message string `json:"message"` + } `json:"status"` + TraceID string `json:"traceId"` + TraceState string `json:"traceState"` +} diff --git a/exporter/opensearchexporter/sso_trace_exporter.go b/exporter/opensearchexporter/sso_trace_exporter.go new file mode 100644 index 000000000000..75650bc25a4d --- /dev/null +++ b/exporter/opensearchexporter/sso_trace_exporter.go @@ -0,0 +1,179 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter + +import ( + "context" + "encoding/json" + "strings" + "time" + + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.uber.org/multierr" + "go.uber.org/zap" +) + +type SSOTracesExporter struct { + logger *zap.Logger + + maxAttempts int + + client *osClientCurrent + bulkIndexer osBulkIndexerCurrent + Namespace string + Dataset string +} + +func (s SSOTracesExporter) Shutdown(ctx context.Context) error { + return s.bulkIndexer.Close(ctx) + +} + +func (s SSOTracesExporter) pushTraceData(ctx context.Context, td ptrace.Traces) error { + var errs []error + resourceSpans := td.ResourceSpans() + for i := 0; i < resourceSpans.Len(); i++ { + il := resourceSpans.At(i) + resource := il.Resource() + scopeSpans := il.ScopeSpans() + for j := 0; j < scopeSpans.Len(); j++ { + spans := scopeSpans.At(j).Spans() + scope := scopeSpans.At(j).Scope() + schemaURL := scopeSpans.At(j).SchemaUrl() + for k := 0; k < spans.Len(); k++ { + if err := s.pushTraceRecord(ctx, resource, scope, schemaURL, spans.At(k)); err != nil { + if cerr := ctx.Err(); cerr != nil { + return cerr + } + errs = append(errs, err) + } + } + } + } + + return multierr.Combine(errs...) +} + +func defaultIfEmpty(value string, def string) string { + if value == "" { + return def + } + return value +} + +func (s SSOTracesExporter) pushTraceRecord( + ctx context.Context, + resource pcommon.Resource, + scope pcommon.InstrumentationScope, + schemaURL string, + span ptrace.Span, +) error { + sso := SSOSpan{} + sso.Attributes = span.Attributes().AsRaw() + sso.DroppedAttributesCount = span.DroppedAttributesCount() + sso.DroppedEventsCount = span.DroppedEventsCount() + sso.DroppedLinksCount = span.DroppedLinksCount() + sso.EndTime = span.EndTimestamp().AsTime() + sso.Kind = span.Kind().String() + sso.Name = span.Name() + sso.ParentSpanID = span.ParentSpanID().String() + sso.Resource = resource.Attributes().AsRaw() + sso.SpanID = span.SpanID().String() + sso.StartTime = span.StartTimestamp().AsTime() + sso.Status.Code = span.Status().Code().String() + sso.Status.Message = span.Status().Message() + sso.TraceID = span.TraceID().String() + sso.TraceState = span.TraceState().AsRaw() + + if span.Events().Len() > 0 { + sso.Events = make([]SSOSpanEvent, span.Events().Len()) + for i := 0; i < span.Events().Len(); i++ { + e := span.Events().At(i) + ssoEvent := &sso.Events[i] + ssoEvent.Attributes = e.Attributes().AsRaw() + ssoEvent.DroppedAttributesCount = e.DroppedAttributesCount() + ssoEvent.Name = e.Name() + ts := e.Timestamp().AsTime() + if ts.Unix() != 0 { + ssoEvent.Timestamp = &ts + } else { + now := time.Now() + ssoEvent.ObservedTimestamp = &now + } + } + } + + dataStream := DataStream{} + if s.Dataset != "" { + dataStream.Dataset = s.Dataset + } + + if s.Namespace != "" { + dataStream.Namespace = s.Namespace + } + + if dataStream != (DataStream{}) { + dataStream.Type = "span" + sso.Attributes["data_stream"] = dataStream + } + + sso.InstrumentationScope.Name = scope.Name() + sso.InstrumentationScope.DroppedAttributesCount = scope.DroppedAttributesCount() + sso.InstrumentationScope.Version = scope.Version() + sso.InstrumentationScope.SchemaURL = schemaURL + sso.InstrumentationScope.Attributes = scope.Attributes().AsRaw() + + if span.Links().Len() > 0 { + sso.Links = make([]SSOSpanLinks, span.Links().Len()) + for i := 0; i < span.Links().Len(); i++ { + link := span.Links().At(i) + ssoLink := &sso.Links[i] + ssoLink.Attributes = link.Attributes().AsRaw() + ssoLink.DroppedAttributesCount = link.DroppedAttributesCount() + ssoLink.TraceID = link.TraceID().String() + ssoLink.TraceState = link.TraceState().AsRaw() + ssoLink.SpanID = link.SpanID().String() + } + } + payload, _ := json.Marshal(sso) + + // construct destination index name by combining Dataset and Namespace options if they are set. + index := strings.Join([]string{"sso_traces", defaultIfEmpty(s.Dataset, "default"), defaultIfEmpty(s.Namespace, "namespace")}, "-") + return pushDocuments(ctx, s.logger, index, payload, s.bulkIndexer, s.maxAttempts) + +} + +func newSSOTracesExporter(logger *zap.Logger, cfg *Config) (*SSOTracesExporter, error) { + if err := cfg.Validate(); err != nil { + return nil, err + } + + client, err := newOpenSearchClient(logger, cfg) + if err != nil { + return nil, err + } + + bulkIndexer, err := newBulkIndexer(logger, client, cfg) + if err != nil { + return nil, err + } + + maxAttempts := getMaxAttempts(cfg) + return &SSOTracesExporter{ + logger: logger, + maxAttempts: maxAttempts, + client: client, + bulkIndexer: bulkIndexer, + Namespace: cfg.Namespace, + Dataset: cfg.Dataset, + }, nil +} + +func getMaxAttempts(cfg *Config) int { + if cfg.Retry.Enabled { + return cfg.Retry.MaxRequests + } + return 1 +} diff --git a/exporter/opensearchexporter/sso_trace_exporter_test.go b/exporter/opensearchexporter/sso_trace_exporter_test.go new file mode 100644 index 000000000000..0cc9719c2fc8 --- /dev/null +++ b/exporter/opensearchexporter/sso_trace_exporter_test.go @@ -0,0 +1,457 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter + +import ( + "bytes" + "context" + "net/http/httptest" + "testing" + "time" + + "github.com/antchfx/jsonquery" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.uber.org/zap" + "go.uber.org/zap/zaptest" +) + +func Test_span_sample(t *testing.T) { + testCase := &singleSpanTestCase{ + name: "sample span", + configMod: func(config *Config) {}, + givenResource: sampleResource(), + givenSpan: sampleSpan(), + givenScope: sampleScope(), + assertNode: func(t *testing.T, doc *jsonquery.Node) { + assertJSONValueEqual(t, "ip_tcp", doc, "/attributes/net.transport") + assertJSONValueEqual(t, float64(3), doc, "/droppedAttributesCount") + assertJSONValueEqual(t, float64(5), doc, "/droppedEventsCount") + assertJSONValueEqual(t, float64(8), doc, "/droppedLinksCount") + assertJSONValueEqual(t, sampleTimeB.Format(time.RFC3339Nano), doc, "/endTime") + assertJSONValueEqual(t, "Internal", doc, "/kind") + assertJSONValueEqual(t, "sample-span", doc, "/name") + assertJSONValueEqual(t, sampleSpanIDB.String(), doc, "/parentSpanId") + assertJSONValueEqual(t, sampleSpanIDA.String(), doc, "/spanId") + assertJSONValueEqual(t, "Error", doc, "/status/code") + assertJSONValueEqual(t, "sample status message", doc, "/status/message") + assertJSONValueEqual(t, sampleTimeA.Format(time.RFC3339Nano), doc, "/startTime") + assertJSONValueEqual(t, rawSampleTraceState, doc, "/traceState") + assertJSONValueEqual(t, sampleTraceIDA.String(), doc, "/traceId") + }, + } + + executeTestCase(t, testCase) +} + +func Test_instrumentation_scope(t *testing.T) { + testCases := []*singleSpanTestCase{ + { + name: "sample scope", + configMod: func(config *Config) {}, + givenResource: sampleResource(), + givenSpan: sampleSpan(), + givenScope: sampleScope(), + assertNode: func(t *testing.T, doc *jsonquery.Node) { + scope := jsonquery.FindOne(doc, "/instrumentationScope") + assert.NotNil(t, scope) + assert.NotNil(t, jsonquery.FindOne(scope, "name")) + assert.NotNil(t, jsonquery.FindOne(scope, "version")) + assertJSONValueEqual(t, sampleSchemaURL, scope, "/schemaUrl") + assertJSONValueEqual(t, "com.example.some-sdk", scope, "/attributes/scope.short_name") + }, + }, + } + + for _, testCase := range testCases { + executeTestCase(t, testCase) + } +} + +func Test_links(t *testing.T) { + testCases := []*singleSpanTestCase{ + { + name: "no links", + configMod: func(config *Config) {}, + givenResource: sampleResource(), + givenSpan: sampleSpan(), + givenScope: sampleScope(), + assertNode: func(t *testing.T, doc *jsonquery.Node) { + links := jsonquery.FindOne(doc, "/links") + assert.Nil(t, links) + }, + }, + + { + name: "sample link", + configMod: func(config *Config) {}, + givenResource: sampleResource(), + givenSpan: withSampleLink(sampleSpan()), + givenScope: sampleScope(), + assertNode: func(t *testing.T, doc *jsonquery.Node) { + links := jsonquery.FindOne(doc, "/links/*") + + assertJSONValueEqual(t, sampleTraceIDB.String(), links, "/traceId") + assertJSONValueEqual(t, sampleSpanIDB.String(), links, "/spanId") + assertJSONValueEqual(t, float64(3), links, "droppedAttributesCount") + assertJSONValueEqual(t, rawSampleTraceState, links, "traceState") + assertJSONValueEqual(t, "remote-link", links, "/attributes/link_attr") + }, + }, + } + + for _, testCase := range testCases { + executeTestCase(t, testCase) + } +} + +// Test_events verifies that events are mapped as expected. +func Test_events(t *testing.T) { + testCases := []*singleSpanTestCase{ + { + name: "no events", + configMod: func(config *Config) {}, + givenResource: sampleResource(), + givenScope: sampleScope(), + givenSpan: sampleSpan(), + assertNode: func(t *testing.T, doc *jsonquery.Node) { + eventsNode := jsonquery.FindOne(doc, "/events") + assert.Nil(t, eventsNode) + }, + }, + { + name: "event with timestamp", + configMod: func(config *Config) {}, + givenResource: sampleResource(), + givenScope: sampleScope(), + givenSpan: withEventWithTimestamp(sampleSpan()), + assertNode: func(t *testing.T, doc *jsonquery.Node) { + eventsNode := jsonquery.FindOne(doc, "/events/*") + assertJSONValueEqual(t, "cloudevent", eventsNode, "name") + // JSON Go encodes all numbers as floats, see https://pkg.go.dev/encoding/json#Marshal + assertJSONValueEqual(t, float64(42), eventsNode, "droppedAttributesCount") + assert.NotNil(t, eventsNode.SelectElement("@timestamp")) + assert.Nil(t, eventsNode.SelectElement("observedTimestamp")) + }, + }, + { + name: "event, no timestamp, observedTimestamp added", + configMod: func(config *Config) {}, + givenResource: sampleResource(), + givenScope: sampleScope(), + givenSpan: withEventNoTimestamp(sampleSpan()), + assertNode: func(t *testing.T, doc *jsonquery.Node) { + eventsNode := jsonquery.FindOne(doc, "/events/*") + assertJSONValueEqual(t, "exception", eventsNode, "name") + assert.NotNil(t, eventsNode.SelectElement("observedTimestamp")) + assert.Nil(t, eventsNode.SelectElement("@timestamp")) + }, + }, + } + + for _, testCase := range testCases { + executeTestCase(t, testCase) + } +} + +// Test_attributes_data_stream verifies that Dataset and Namespace configuration options are +// recorded in the `.attributes.data_stream` object of an exported span +func Test_attributes_data_stream(t *testing.T) { + // validateDataStreamType asserts that /attributes/data_stream/type exists and is equal to "span" + validateDataStreamType := func(t *testing.T, node *jsonquery.Node) { + assert.Equal(t, "span", jsonquery.FindOne(node, "/attributes/data_stream/type").Value()) + } + testCases := []struct { + name string + assertNode func(*testing.T, *jsonquery.Node) + configMod func(*Config) + }{ + { + name: "no data_stream attribute expected", + configMod: func(config *Config) {}, + assertNode: func(t *testing.T, node *jsonquery.Node) { + // no data_stream attribute expected + luckyNode := jsonquery.FindOne(node, "/attributes/data_stream") + assert.Nil(t, luckyNode) + }, + }, + { + name: "datatset is ngnix", + configMod: func(config *Config) { config.Dataset = "ngnix" }, + assertNode: func(t *testing.T, doc *jsonquery.Node) { + assertJSONValueEqual(t, "ngnix", doc, "/attributes/data_stream/dataset") + validateDataStreamType(t, doc) + }, + }, + { + name: "namespace is exceptions", + configMod: func(config *Config) { config.Namespace = "exceptions" }, + assertNode: func(t *testing.T, doc *jsonquery.Node) { + // no attributes property expected + assertJSONValueEqual(t, "exceptions", doc, "/attributes/data_stream/namespace") + validateDataStreamType(t, doc) + }, + }, + { + name: "dataset is mysql, namespace is warnings", + configMod: func(config *Config) { + config.Namespace = "warnings" + config.Dataset = "mysql" + }, + assertNode: func(t *testing.T, doc *jsonquery.Node) { + // no attributes property expected + assertJSONValueEqual(t, "warnings", doc, "/attributes/data_stream/namespace") + assertJSONValueEqual(t, "mysql", doc, "/attributes/data_stream/dataset") + + validateDataStreamType(t, doc) + }, + }, + } + + for _, sampleTestCase := range testCases { + testCase := &singleSpanTestCase{ + name: sampleTestCase.name, + configMod: sampleTestCase.configMod, + givenResource: sampleResource(), + givenScope: sampleScope(), + givenSpan: sampleSpan(), + assertNode: sampleTestCase.assertNode, + } + executeTestCase(t, testCase) + } + +} + +// Test_sso_routing verifies that Dataset and Namespace configuration options determine how export data is routed +func Test_sso_routing(t *testing.T) { + testCases := []struct { + name string + expectedIndex string + configMod func(config *Config) + }{ + { + name: "default routing", + expectedIndex: "sso_traces-default-namespace", + configMod: func(config *Config) {}, + }, + { + name: "dataset is webapp", + configMod: func(config *Config) { + config.Dataset = "webapp" + }, + expectedIndex: "sso_traces-webapp-namespace", + }, + { + name: "namespace is exceptions", + configMod: func(config *Config) { + config.Namespace = "exceptions" + }, + expectedIndex: "sso_traces-default-exceptions", + }, + { + name: "namespace is warnings, dataset is mysql", + configMod: func(config *Config) { + config.Namespace = "warnings" + config.Dataset = "mysql" + }, + expectedIndex: "sso_traces-mysql-warnings", + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + logger := zaptest.NewLogger(t) + rec := newBulkRecorder() + server := newRecTestServer(t, rec) + exporter := newSSOTestTracesExporter(t, logger, server.URL, testCase.configMod) + err := exporter.pushTraceRecord(context.TODO(), *sampleResource(), *sampleScope(), sampleSchemaURL, *sampleSpan()) + require.NoError(t, err) + rec.WaitItems(1) + + // Sanity test + require.Equal(t, 1, rec.NumItems()) + + // Sanity test + require.Len(t, rec.Requests()[0], 1) + + doc, err := jsonquery.Parse(bytes.NewReader(rec.Requests()[0][0].Action)) + + // Sanity test + require.NoError(t, err) + + inx := jsonquery.FindOne(doc, "/create/_index") + assert.Equal(t, testCase.expectedIndex, inx.Value()) + }) + } +} + +// newSSOTestTracesExporter creates a traces exporter that sends data in Simple Schema for Observability schema. +// See https://github.com/opensearch-project/observability for details +func newSSOTestTracesExporter(t *testing.T, logger *zap.Logger, url string, fns ...func(*Config)) *SSOTracesExporter { + exporter, err := newSSOTracesExporter(logger, withTestTracesExporterConfig(fns...)(url)) + require.NoError(t, err) + + t.Cleanup(func() { + require.NoError(t, exporter.Shutdown(context.TODO())) + }) + return exporter +} + +// newRecTestServer creates a http webserver that records all the requests in the provided bulkRecorder +func newRecTestServer(t *testing.T, rec *bulkRecorder) *httptest.Server { + server := newTestServer(t, func(docs []itemRequest) ([]itemResponse, error) { + rec.Record(docs) + return itemsAllOK(docs) + }) + t.Cleanup(func() { + server.Close() + }) + return server +} + +func assertJSONValueEqual(t *testing.T, expected interface{}, node *jsonquery.Node, jq string) { + luckyNode := jsonquery.FindOne(node, jq) + assert.NotNil(t, luckyNode) + assert.Equal(t, expected, luckyNode.Value()) +} + +// singleSpanTestCase represents a test case that configures sso exporter with configMod, +// pushes givenResource and givenSpan and verifies the bulk request that sso exporter generates +// using assertNode +type singleSpanTestCase struct { + name string + configMod func(*Config) + givenResource *pcommon.Resource + givenSpan *ptrace.Span + assertNode func(*testing.T, *jsonquery.Node) + givenScope *pcommon.InstrumentationScope +} + +func executeTestCase(t *testing.T, testCase *singleSpanTestCase) { + t.Run(testCase.name, func(t *testing.T) { + logger := zaptest.NewLogger(t) + + ctx := context.TODO() + rec := newBulkRecorder() + server := newRecTestServer(t, rec) + exporter := newSSOTestTracesExporter(t, logger, server.URL, testCase.configMod) + err := exporter.pushTraceRecord(ctx, *testCase.givenResource, *testCase.givenScope, sampleSchemaURL, *testCase.givenSpan) + + // Verify that push completed successfully + require.NoError(t, err) + + // Wait for HTTP server to capture the bulk request + rec.WaitItems(1) + + // Confirm there was only one bulk request + require.Equal(t, 1, rec.NumItems()) + require.Len(t, rec.Requests()[0], 1) + + // Read the bulk request document + doc, err := jsonquery.Parse(bytes.NewReader(rec.Requests()[0][0].Document)) + + require.NoError(t, err) + + // Verify document matches expectations + testCase.assertNode(t, doc) + }) +} + +func sampleResource() *pcommon.Resource { + r := pcommon.NewResource() + // An attribute of each supported type + r.Attributes().PutStr("service.name", "opensearchexporter") + r.Attributes().PutBool("browser.mobile", false) + r.Attributes().PutInt("process.pid", 300) + return &r +} + +func sampleScope() *pcommon.InstrumentationScope { + sample := pcommon.NewInstrumentationScope() + sample.Attributes().PutStr("scope.short_name", "com.example.some-sdk") + sample.SetDroppedAttributesCount(7) + sample.SetName("some-sdk by Example.com") + sample.SetVersion("semver:2.5.0-SNAPSHOT") + return &sample +} + +func sampleSpan() *ptrace.Span { + sp := ptrace.NewSpan() + + sp.SetDroppedAttributesCount(3) + sp.SetDroppedEventsCount(5) + sp.SetDroppedLinksCount(8) + sp.SetSpanID(sampleSpanIDA) + sp.SetParentSpanID(sampleSpanIDB) + sp.SetTraceID(sampleTraceIDA) + sp.SetKind(ptrace.SpanKindInternal) + sp.TraceState().FromRaw(rawSampleTraceState) + sp.Attributes().PutStr("net.transport", "ip_tcp") + sp.SetStartTimestamp(pcommon.NewTimestampFromTime(sampleTimeA)) + sp.SetEndTimestamp(pcommon.NewTimestampFromTime(sampleTimeB)) + sp.SetName("sample-span") + sp.Status().SetCode(ptrace.StatusCodeError) + sp.Status().SetMessage("sample status message") + return &sp +} + +func withEventNoTimestamp(span *ptrace.Span) *ptrace.Span { + event := span.Events().AppendEmpty() + // This event lacks timestamp + event.Attributes().PutStr("exception.message", "Invalid user input") + event.Attributes().PutStr("exception.type", "ApplicationException") + event.SetDroppedAttributesCount(42) + event.SetName("exception") + return span +} + +func withEventWithTimestamp(span *ptrace.Span) *ptrace.Span { + event := span.Events().AppendEmpty() + event.Attributes().PutStr("cloudevents.event_id", "001") + event.Attributes().PutStr("cloudevents.event_source", "example.com/example-service") + event.Attributes().PutStr("cloudevents.event_type", "com.example.example-service.panic") + event.SetName("cloudevent") + event.SetDroppedAttributesCount(42) + event.SetTimestamp( + pcommon.NewTimestampFromTime(sampleTimeC)) + return span +} + +func withSampleLink(span *ptrace.Span) *ptrace.Span { + link := span.Links().AppendEmpty() + link.SetDroppedAttributesCount(3) + link.SetTraceID(sampleTraceIDB) + link.SetSpanID(sampleSpanIDB) + link.TraceState().FromRaw(rawSampleTraceState) + link.Attributes().PutStr("link_attr", "remote-link") + return span +} + +const sampleSchemaURL string = "https://example.com/schema/1.0" + +var sampleTraceIDA = pcommon.TraceID{1, 0, 0, 0} +var sampleTraceIDB = pcommon.TraceID{1, 1, 0, 0} +var sampleSpanIDA = pcommon.SpanID{1, 0, 0, 0} +var sampleSpanIDB = pcommon.SpanID{1, 1, 0, 0} +var sampleTimeA = time.Date(1990, 1, 1, 1, 1, 1, 1, time.UTC) +var sampleTimeB = time.Date(1995, 1, 1, 1, 1, 1, 1, time.UTC) +var sampleTimeC = time.Date(1998, 1, 1, 1, 1, 1, 1, time.UTC) + +// TraceState is defined by a W3C spec. Sample value take from https://www.w3.org/TR/trace-context/#examples-of-tracestate-http-headers +const rawSampleTraceState = "rojo=00f067aa0ba902b7,congo=t61rcWkgMzE" + +func withTestTracesExporterConfig(fns ...func(*Config)) func(string) *Config { + return func(url string) *Config { + var configMods []func(*Config) + configMods = append(configMods, func(cfg *Config) { + cfg.Endpoints = []string{url} + cfg.NumWorkers = 1 + cfg.Flush.Interval = 10 * time.Millisecond + }) + configMods = append(configMods, fns...) + return withDefaultConfig(configMods...) + } +} diff --git a/exporter/opensearchexporter/testdata/config.yaml b/exporter/opensearchexporter/testdata/config.yaml new file mode 100644 index 000000000000..b57b6d644ce5 --- /dev/null +++ b/exporter/opensearchexporter/testdata/config.yaml @@ -0,0 +1,15 @@ +opensearch: + endpoints: [https://opensearch.example.com:9200] +opensearch/trace: + tls: + insecure: false + endpoints: [https://opensearch.example.com:9200] + timeout: 2m + headers: + myheader: test + user: open + password: search + flush: + bytes: 10485760 + retry: + max_requests: 5 diff --git a/exporter/opensearchexporter/trace_exporter.go b/exporter/opensearchexporter/trace_exporter.go new file mode 100644 index 000000000000..77ad68f0c8f2 --- /dev/null +++ b/exporter/opensearchexporter/trace_exporter.go @@ -0,0 +1,30 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Package opensearchexporter contains an opentelemetry-collector exporter +// for OpenSearch. +package opensearchexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter" + +import ( + "context" + + "go.opentelemetry.io/collector/pdata/ptrace" + "go.uber.org/zap" +) + +type tracesExporter interface { + Shutdown(ctx context.Context) error + pushTraceData( + ctx context.Context, + td ptrace.Traces, + ) error +} + +func newTracesExporter(logger *zap.Logger, cfg *Config) (tracesExporter, error) { + if err := cfg.Validate(); err != nil { + return nil, err + } + + return newSSOTracesExporter(logger, cfg) + +} diff --git a/exporter/opensearchexporter/utils_test.go b/exporter/opensearchexporter/utils_test.go new file mode 100644 index 000000000000..794f08c2e53b --- /dev/null +++ b/exporter/opensearchexporter/utils_test.go @@ -0,0 +1,215 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package opensearchexporter + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "net/http" + "net/http/httptest" + "strings" + "sync" + "testing" + "time" +) + +type itemRequest struct { + Action json.RawMessage + Document json.RawMessage +} + +type itemResponse struct { + Status int `json:"status"` +} + +type bulkResult struct { + Took int `json:"took"` + HasErrors bool `json:"errors"` + Items []itemResponse `json:"items"` +} + +type bulkHandler func([]itemRequest) ([]itemResponse, error) + +type httpTestError struct { + status int + message string + cause error +} + +const opensearchVersion = "2.9.0" + +func (e *httpTestError) Error() string { + return fmt.Sprintf("http request failed (status=%v): %v", e.Status(), e.Message()) +} + +func (e *httpTestError) Status() int { + if e.status == 0 { + return http.StatusInternalServerError + } + return e.status +} + +func (e *httpTestError) Message() string { + var buf strings.Builder + if e.message != "" { + buf.WriteString(e.message) + } + if e.cause != nil { + if buf.Len() > 0 { + buf.WriteString(": ") + } + buf.WriteString(e.cause.Error()) + } + return buf.String() +} + +type bulkRecorder struct { + mu sync.Mutex + cond *sync.Cond + recordings [][]itemRequest +} + +func newBulkRecorder() *bulkRecorder { + r := &bulkRecorder{} + r.cond = sync.NewCond(&r.mu) + return r +} + +func (r *bulkRecorder) Record(bulk []itemRequest) { + r.mu.Lock() + defer r.mu.Unlock() + r.recordings = append(r.recordings, bulk) + r.cond.Broadcast() +} + +func (r *bulkRecorder) WaitItems(n int) { + r.mu.Lock() + defer r.mu.Unlock() + for n > r.countItems() { + r.cond.Wait() + } +} + +func (r *bulkRecorder) Requests() [][]itemRequest { + r.mu.Lock() + defer r.mu.Unlock() + return r.recordings +} + +func (r *bulkRecorder) Items() (docs []itemRequest) { + for _, rec := range r.Requests() { + docs = append(docs, rec...) + } + return docs +} + +func (r *bulkRecorder) NumItems() int { + r.mu.Lock() + defer r.mu.Unlock() + return r.countItems() +} + +func (r *bulkRecorder) countItems() (count int) { + for _, docs := range r.recordings { + count += len(docs) + } + return count +} + +func newTestServer(t *testing.T, bulkHandler bulkHandler) *httptest.Server { + mux := http.NewServeMux() + + mux.HandleFunc("/", handleErr(func(w http.ResponseWriter, req *http.Request) error { + + enc := json.NewEncoder(w) + return enc.Encode(map[string]interface{}{ + "version": map[string]interface{}{ + "number": opensearchVersion, + }, + }) + })) + + mux.HandleFunc("/_bulk", handleErr(func(w http.ResponseWriter, req *http.Request) error { + tsStart := time.Now() + var items []itemRequest + + dec := json.NewDecoder(req.Body) + for dec.More() { + var action, doc json.RawMessage + if err := dec.Decode(&action); err != nil { + return &httpTestError{status: http.StatusBadRequest, cause: err} + } + if !dec.More() { + return &httpTestError{status: http.StatusBadRequest, message: "action without document"} + } + if err := dec.Decode(&doc); err != nil { + return &httpTestError{status: http.StatusBadRequest, cause: err} + } + + items = append(items, itemRequest{Action: action, Document: doc}) + } + + resp, err := bulkHandler(items) + if err != nil { + return err + } + took := int(time.Since(tsStart) / time.Microsecond) + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + + enc := json.NewEncoder(w) + return enc.Encode(bulkResult{Took: took, Items: resp, HasErrors: itemsHasError(resp)}) + })) + + server := httptest.NewServer(mux) + t.Cleanup(server.Close) + return server +} + +func handleErr(fn func(http.ResponseWriter, *http.Request) error) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + err := fn(w, r) + if err != nil { + httpError := &httpTestError{} + if errors.As(err, &httpError) { + http.Error(w, httpError.Message(), httpError.Status()) + } else { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } + } +} + +func (item *itemResponse) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + _, err := fmt.Fprintf(&buf, `{"create": {"status": %v}}`, item.Status) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func itemsAllOK(docs []itemRequest) ([]itemResponse, error) { + return itemsReportStatus(docs, http.StatusOK) +} + +func itemsReportStatus(docs []itemRequest, status int) ([]itemResponse, error) { + responses := make([]itemResponse, len(docs)) + for i := range docs { + responses[i].Status = status + } + return responses, nil +} + +func itemsHasError(resp []itemResponse) bool { + for _, r := range resp { + if r.Status != http.StatusOK { + return true + } + } + return false +} diff --git a/versions.yaml b/versions.yaml index 1b3f9a824697..25917a474299 100644 --- a/versions.yaml +++ b/versions.yaml @@ -47,6 +47,7 @@ module-sets: - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lokiexporter - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/mezmoexporter - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter + - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/parquetexporter - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter