From 17509dd8749659c28b9b31393473bf07ad07d9b4 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 20 Aug 2024 20:26:15 +0200 Subject: [PATCH 01/20] Import of template processor and receiver --- .../elastic-components/manifest.yaml | 11 +- extension/filetemplateextension/Makefile | 1 + extension/filetemplateextension/config.go | 43 +++ extension/filetemplateextension/extension.go | 79 +++++ extension/filetemplateextension/factory.go | 53 ++++ extension/filetemplateextension/go.mod | 43 +++ extension/filetemplateextension/go.sum | 130 +++++++++ pkg/templates/Makefile | 1 + pkg/templates/go.mod | 35 +++ pkg/templates/go.sum | 104 +++++++ pkg/templates/templates.go | 109 +++++++ processor/templateprocessor/Makefile | 1 + processor/templateprocessor/config.go | 39 +++ processor/templateprocessor/confmap.go | 64 ++++ processor/templateprocessor/factory.go | 56 ++++ processor/templateprocessor/go.mod | 44 +++ processor/templateprocessor/go.sum | 141 +++++++++ processor/templateprocessor/processor.go | 260 +++++++++++++++++ receiver/templatereceiver/Makefile | 1 + receiver/templatereceiver/config.go | 39 +++ receiver/templatereceiver/confmap.go | 62 ++++ receiver/templatereceiver/factory.go | 56 ++++ receiver/templatereceiver/go.mod | 45 +++ receiver/templatereceiver/go.sum | 143 +++++++++ receiver/templatereceiver/receiver.go | 275 ++++++++++++++++++ 25 files changed, 1834 insertions(+), 1 deletion(-) create mode 100644 extension/filetemplateextension/Makefile create mode 100644 extension/filetemplateextension/config.go create mode 100644 extension/filetemplateextension/extension.go create mode 100644 extension/filetemplateextension/factory.go create mode 100644 extension/filetemplateextension/go.mod create mode 100644 extension/filetemplateextension/go.sum create mode 100644 pkg/templates/Makefile create mode 100644 pkg/templates/go.mod create mode 100644 pkg/templates/go.sum create mode 100644 pkg/templates/templates.go create mode 100644 processor/templateprocessor/Makefile create mode 100644 processor/templateprocessor/config.go create mode 100644 processor/templateprocessor/confmap.go create mode 100644 processor/templateprocessor/factory.go create mode 100644 processor/templateprocessor/go.mod create mode 100644 processor/templateprocessor/go.sum create mode 100644 processor/templateprocessor/processor.go create mode 100644 receiver/templatereceiver/Makefile create mode 100644 receiver/templatereceiver/config.go create mode 100644 receiver/templatereceiver/confmap.go create mode 100644 receiver/templatereceiver/factory.go create mode 100644 receiver/templatereceiver/go.mod create mode 100644 receiver/templatereceiver/go.sum create mode 100644 receiver/templatereceiver/receiver.go diff --git a/distributions/elastic-components/manifest.yaml b/distributions/elastic-components/manifest.yaml index b5e9320d..3b33e64a 100644 --- a/distributions/elastic-components/manifest.yaml +++ b/distributions/elastic-components/manifest.yaml @@ -7,6 +7,7 @@ dist: otelcol_version: 0.105.0 extensions: + - gomod: github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension v0.0.0 connectors: - gomod: github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 v0.0.0 @@ -14,16 +15,24 @@ connectors: converters: receivers: + - gomod: github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver v0.0.0 - gomod: go.opentelemetry.io/collector/receiver/nopreceiver v0.105.0 processors: - gomod: github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.0.0 - gomod: github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor v0.0.0 + - gomod: github.com/elastic/opentelemetry-collector-components/processor/templateprocessor v0.0.0 exporters: - gomod: go.opentelemetry.io/collector/exporter/nopexporter v0.105.0 + - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.105.0 replaces: + - github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 => ../connector/spanmetricsconnectorv2 + - github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension => ../extension/filetemplateextension - github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor => ../processor/elasticinframetricsprocessor - github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor => ../processor/elastictraceprocessor - - github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 => ../connector/spanmetricsconnectorv2 + - github.com/elastic/opentelemetry-collector-components/processor/templateprocessor => ../processor/templateprocessor + - github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver => ../receiver/templatereceiver + - github.com/elastic/opentelemetry-collector-components/pkg/templates => ../pkg/templates + diff --git a/extension/filetemplateextension/Makefile b/extension/filetemplateextension/Makefile new file mode 100644 index 00000000..ded7a360 --- /dev/null +++ b/extension/filetemplateextension/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/extension/filetemplateextension/config.go b/extension/filetemplateextension/config.go new file mode 100644 index 00000000..f3f5b1c1 --- /dev/null +++ b/extension/filetemplateextension/config.go @@ -0,0 +1,43 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" + +import ( + "errors" + "fmt" + "os" +) + +type Config struct { + Path string `mapstructure:"path"` +} + +func (c *Config) Validate() error { + if c.Path == "" { + return errors.New("path is required") + } + info, err := os.Stat(c.Path) + if err != nil { + return err + } + if !info.IsDir() { + return fmt.Errorf("path (%s) must be a directory", c.Path) + } + + return nil +} diff --git a/extension/filetemplateextension/extension.go b/extension/filetemplateextension/extension.go new file mode 100644 index 00000000..aa77cd41 --- /dev/null +++ b/extension/filetemplateextension/extension.go @@ -0,0 +1,79 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" + +import ( + "context" + "errors" + "io/fs" + "os" + "path/filepath" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/provider/fileprovider" + + "github.com/elastic/opentelemetry-collector-components/pkg/templates" +) + +type fileTemplateExtension struct { + config *Config +} + +var _ templates.TemplateFinder = &fileTemplateExtension{} + +func newFileTemplateExtension(config *Config) *fileTemplateExtension { + return &fileTemplateExtension{ + config: config, + } +} + +func (e *fileTemplateExtension) FindTemplate(ctx context.Context, name, version string) (templates.Template, error) { + path := filepath.Join(e.config.Path, name+".yml") + _, err := os.Stat(path) + if errors.Is(err, fs.ErrNotExist) { + return nil, templates.ErrNotFound + } + if err != nil { + return nil, err + } + + return &templateFile{ + path: path, + }, nil +} + +func (*fileTemplateExtension) Start(context.Context, component.Host) error { + return nil +} + +func (*fileTemplateExtension) Shutdown(context.Context) error { + return nil +} + +type templateFile struct { + path string +} + +func (t *templateFile) URI() string { + return "file:" + t.path +} + +func (t *templateFile) ProviderFactory() confmap.ProviderFactory { + return fileprovider.NewFactory() +} diff --git a/extension/filetemplateextension/factory.go b/extension/filetemplateextension/factory.go new file mode 100644 index 00000000..bc5b0b29 --- /dev/null +++ b/extension/filetemplateextension/factory.go @@ -0,0 +1,53 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" + +import ( + "context" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/extension" +) + +var ( + extensionType = component.MustNewType("file_templates") +) + +const ( + extensionStability = component.StabilityLevelAlpha +) + +// NewFactory creates a factory for ack extension. +func NewFactory() extension.Factory { + return extension.NewFactory( + extensionType, + createDefaultConfig, + createExtension, + extensionStability, + ) +} + +func createDefaultConfig() component.Config { + return &Config{ + Path: "templates", + } +} + +func createExtension(_ context.Context, _ extension.Settings, cfg component.Config) (extension.Extension, error) { + return newFileTemplateExtension(cfg.(*Config)), nil +} diff --git a/extension/filetemplateextension/go.mod b/extension/filetemplateextension/go.mod new file mode 100644 index 00000000..194011ea --- /dev/null +++ b/extension/filetemplateextension/go.mod @@ -0,0 +1,43 @@ +module github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension + +go 1.22.1 + +require ( + github.com/elastic/opentelemetry-collector-components/pkg/templates v0.0.0 + go.opentelemetry.io/collector/component v0.105.0 + go.opentelemetry.io/collector/confmap v0.105.0 + go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 + go.opentelemetry.io/collector/extension v0.105.0 +) + +require ( + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/knadh/koanf/maps v0.1.1 // indirect + github.com/knadh/koanf/providers/confmap v0.1.0 // indirect + github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/featuregate v1.13.0 // indirect + go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata v1.13.0 // indirect + go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver => ../../receiver/templatereceiver + +replace github.com/elastic/opentelemetry-collector-components/pkg/templates => ../../pkg/templates diff --git a/extension/filetemplateextension/go.sum b/extension/filetemplateextension/go.sum new file mode 100644 index 00000000..820a2201 --- /dev/null +++ b/extension/filetemplateextension/go.sum @@ -0,0 +1,130 @@ +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/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +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/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= +github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= +github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= +github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= +github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= +github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +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/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= +go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= +go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= +go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= +go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 h1:RgQwEbJgx+BihDt8yhiqmEi8IjQYFwbzsYRcTzvM7E4= +go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0/go.mod h1:P7oT+6eaMv+ZyPSu6SEKalfR/UALdQgE3hq36b0Iww4= +go.opentelemetry.io/collector/extension v0.105.0 h1:R8i4HMvuSm20Nt3onyrLk19KKhjCNAsgS8FGh60rcZU= +go.opentelemetry.io/collector/extension v0.105.0/go.mod h1:oyX960URG27esNKitf3o2rqcBj0ajcx+dxkCxwRz34U= +go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= +go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= +go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= +go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= +go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= +go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +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/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/templates/Makefile b/pkg/templates/Makefile new file mode 100644 index 00000000..ded7a360 --- /dev/null +++ b/pkg/templates/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/pkg/templates/go.mod b/pkg/templates/go.mod new file mode 100644 index 00000000..fccf03b6 --- /dev/null +++ b/pkg/templates/go.mod @@ -0,0 +1,35 @@ +module github.com/elastic/opentelemetry-collector-components/pkg/templates + +go 1.22.1 + +require ( + go.opentelemetry.io/collector/component v0.105.0 + go.opentelemetry.io/collector/confmap v0.105.0 + go.uber.org/zap v1.27.0 +) + +require ( + github.com/go-viper/mapstructure/v2 v2.0.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/knadh/koanf/maps v0.1.1 // indirect + github.com/knadh/koanf/providers/confmap v0.1.0 // indirect + github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/featuregate v1.13.0 // indirect + go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata v1.13.0 // indirect + go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/pkg/templates/go.sum b/pkg/templates/go.sum new file mode 100644 index 00000000..e7bef9d5 --- /dev/null +++ b/pkg/templates/go.sum @@ -0,0 +1,104 @@ +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/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.0.0 h1:dhn8MZ1gZ0mzeodTG3jt5Vj/o87xZKuNAprG2mQfMfc= +github.com/go-viper/mapstructure/v2 v2.0.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +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/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= +github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= +github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= +github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= +github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= +github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= +go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= +go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= +go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= +go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= +go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= +go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= +go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= +go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= +go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +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/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/templates/templates.go b/pkg/templates/templates.go new file mode 100644 index 00000000..cf876523 --- /dev/null +++ b/pkg/templates/templates.go @@ -0,0 +1,109 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templates // import "github.com/elastic/opentelemetry-collector-components/pkg/templates" + +import ( + "context" + "errors" + "fmt" + + "go.uber.org/zap" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap" +) + +var ErrNotFound = errors.New("not found") + +type Template interface { + URI() string + ProviderFactory() confmap.ProviderFactory +} + +type TemplateFinder interface { + FindTemplate(ctx context.Context, name, version string) (Template, error) +} + +func Find(ctx context.Context, logger *zap.Logger, host component.Host, name string, version string) (Template, error) { + anyExtension := false + for eid, extension := range host.GetExtensions() { + finder, ok := extension.(TemplateFinder) + if !ok { + continue + } + anyExtension = true + + template, err := finder.FindTemplate(ctx, name, version) + if errors.Is(ErrNotFound, err) { + continue + } + if err != nil { + logger.Error("template finder failed", + zap.String("component", eid.String()), + zap.Error(err)) + return nil, err + } + + return template, nil + } + if !anyExtension { + return nil, errors.New("no template finder extension found") + } + + return nil, ErrNotFound +} + +type Config struct { + Receivers map[component.ID]map[string]any `mapstructure:"receivers"` + Processors map[component.ID]map[string]any `mapstructure:"processors"` + Pipelines map[component.ID]PipelineConfig `mapstructure:"pipelines"` +} + +func (c *Config) Validate() error { + for id, pipeline := range c.Pipelines { + if err := pipeline.Validate(); err != nil { + return fmt.Errorf("invalid pipeline %q: %w", id, err) + } + + if _, found := c.Receivers[pipeline.Receiver]; !found { + return fmt.Errorf("receiver %s not defined", pipeline.Receiver.String()) + } + + for _, processor := range pipeline.Processors { + if _, found := c.Processors[processor]; !found { + return fmt.Errorf("processor %q not defined", processor.String()) + } + + } + } + + return nil +} + +type PipelineConfig struct { + Receiver component.ID `mapstructure:"receiver"` + Processors []component.ID `mapstructure:"processors"` +} + +func (p *PipelineConfig) Validate() error { + if len(p.Receiver.Type().String()) == 0 { + return fmt.Errorf("pipeline without receiver") + } + + return nil +} diff --git a/processor/templateprocessor/Makefile b/processor/templateprocessor/Makefile new file mode 100644 index 00000000..ded7a360 --- /dev/null +++ b/processor/templateprocessor/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/processor/templateprocessor/config.go b/processor/templateprocessor/config.go new file mode 100644 index 00000000..71658d97 --- /dev/null +++ b/processor/templateprocessor/config.go @@ -0,0 +1,39 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" + +import ( + "errors" + + "go.opentelemetry.io/collector/component" +) + +type Config struct { + Name string `mapstructure:"name"` + Pipeline *component.ID `mapstructure:"pipeline"` + Version string `mapstructure:"version"` + Parameters map[string]any `mapstructure:"parameters"` +} + +func (cfg *Config) Validate() error { + if cfg.Name == "" { + return errors.New("name is required") + } + + return nil +} diff --git a/processor/templateprocessor/confmap.go b/processor/templateprocessor/confmap.go new file mode 100644 index 00000000..7f5a3240 --- /dev/null +++ b/processor/templateprocessor/confmap.go @@ -0,0 +1,64 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" + +import ( + "context" + "strings" + + "go.opentelemetry.io/collector/confmap" +) + +const ( + varProviderScheme = "var" +) + +func newVariablesProviderFactory(variables map[string]any) confmap.ProviderFactory { + return confmap.NewProviderFactory(createVariablesProvider(variables)) +} + +func createVariablesProvider(variables map[string]any) confmap.CreateProviderFunc { + return func(_ confmap.ProviderSettings) confmap.Provider { + return &variablesProvider{variables: variables} + } +} + +type variablesProvider struct { + variables map[string]any +} + +func (p *variablesProvider) Retrieve(ctx context.Context, uri string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) { + key := strings.TrimLeft(uri, varProviderScheme+":") + value, found := p.variables[key] + if !found { + // FIXME: Resolve relevant configuration only instead of the whole template, so we don't need to ignore + // variables not found in unrelevant parts. + //return nil, fmt.Errorf("variable %q not found", key) + return confmap.NewRetrieved("") + } + + return confmap.NewRetrieved(value) +} + +func (p *variablesProvider) Scheme() string { + return varProviderScheme +} + +func (p *variablesProvider) Shutdown(ctx context.Context) error { + return nil +} diff --git a/processor/templateprocessor/factory.go b/processor/templateprocessor/factory.go new file mode 100644 index 00000000..a5334fef --- /dev/null +++ b/processor/templateprocessor/factory.go @@ -0,0 +1,56 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" + +import ( + "context" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/processor" +) + +var ( + typeStr = component.MustNewType("template") +) + +func NewFactory() processor.Factory { + return processor.NewFactory( + typeStr, + createDefaultConfig, + processor.WithLogs(createLogsProcessor, component.StabilityLevelAlpha), + processor.WithMetrics(createMetricsProcessor, component.StabilityLevelAlpha), + processor.WithTraces(createTracesProcessor, component.StabilityLevelAlpha), + ) +} + +func createDefaultConfig() component.Config { + return &Config{} +} + +func createLogsProcessor(_ context.Context, params processor.Settings, cfg component.Config, consumer consumer.Logs) (processor.Logs, error) { + return newTemplateLogsProcessor(params, cfg.(*Config), consumer), nil +} + +func createMetricsProcessor(_ context.Context, params processor.Settings, cfg component.Config, consumer consumer.Metrics) (processor.Metrics, error) { + return newTemplateMetricsProcessor(params, cfg.(*Config), consumer), nil +} + +func createTracesProcessor(_ context.Context, params processor.Settings, cfg component.Config, consumer consumer.Traces) (processor.Traces, error) { + return newTemplateTracesProcessor(params, cfg.(*Config), consumer), nil +} diff --git a/processor/templateprocessor/go.mod b/processor/templateprocessor/go.mod new file mode 100644 index 00000000..8144a745 --- /dev/null +++ b/processor/templateprocessor/go.mod @@ -0,0 +1,44 @@ +module github.com/elastic/opentelemetry-collector-components/processor/templateprocessor + +go 1.22.1 + +require ( + github.com/elastic/opentelemetry-collector-components/pkg/templates v0.0.0 + go.opentelemetry.io/collector/component v0.105.0 + go.opentelemetry.io/collector/confmap v0.105.0 + go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/pdata v1.13.0 + go.opentelemetry.io/collector/processor v0.105.0 + go.uber.org/zap v1.27.0 +) + +require ( + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/knadh/koanf/maps v0.1.1 // indirect + github.com/knadh/koanf/providers/confmap v0.1.0 // indirect + github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/mitchellh/copystructure v1.2.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/rogpeppe/go-internal v1.12.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/featuregate v1.13.0 // indirect + go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/elastic/opentelemetry-collector-components/pkg/templates => ../../pkg/templates diff --git a/processor/templateprocessor/go.sum b/processor/templateprocessor/go.sum new file mode 100644 index 00000000..b5a2b139 --- /dev/null +++ b/processor/templateprocessor/go.sum @@ -0,0 +1,141 @@ +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/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= +github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= +github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= +github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= +github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= +github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +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/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= +go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= +go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= +go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= +go.opentelemetry.io/collector/consumer v0.105.0 h1:pO5Tspoz7yvEs81+904HfDjByP8Z7uuNk+7pOr3lRHM= +go.opentelemetry.io/collector/consumer v0.105.0/go.mod h1:tnaPDHUfKBJ01OnsJNRecniG9iciE+xHYLqamYwFQOQ= +go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= +go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= +go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= +go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= +go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= +go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/collector/processor v0.105.0 h1:LE6wEMWNa3h7eOJLMBm2lA0v6sc2j6Geqv1e3pIWS8Y= +go.opentelemetry.io/collector/processor v0.105.0/go.mod h1:QAvMEtd3k+YhRrnaEgs/8e0UueYonuT8Hg4udQOht60= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +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/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/processor/templateprocessor/processor.go b/processor/templateprocessor/processor.go new file mode 100644 index 00000000..5e2492d7 --- /dev/null +++ b/processor/templateprocessor/processor.go @@ -0,0 +1,260 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" + +import ( + "context" + "errors" + "fmt" + "slices" + + "go.uber.org/zap" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/processor" + + "github.com/elastic/opentelemetry-collector-components/pkg/templates" +) + +type templateProcessor struct { + params processor.Settings + config *Config + components []component.Component + capabilities consumer.Capabilities + nextMetricsConsumer consumer.Metrics + nextLogsConsumer consumer.Logs + nextTracesConsumer consumer.Traces + + metrics consumer.Metrics + logs consumer.Logs + traces consumer.Traces +} + +func newTemplateLogsProcessor(params processor.Settings, config *Config, consumer consumer.Logs) *templateProcessor { + return &templateProcessor{ + params: params, + config: config, + nextLogsConsumer: consumer, + } +} + +func newTemplateMetricsProcessor(params processor.Settings, config *Config, consumer consumer.Metrics) *templateProcessor { + return &templateProcessor{ + params: params, + config: config, + nextMetricsConsumer: consumer, + } +} + +func newTemplateTracesProcessor(params processor.Settings, config *Config, consumer consumer.Traces) *templateProcessor { + return &templateProcessor{ + params: params, + config: config, + nextTracesConsumer: consumer, + } +} + +// factoryGetter is an interface that the component.Host passed to processorcreator's Start function must implement +// GetFactory is optional in hosts since 107.0, but we require it. +type factoryGetter interface { + component.Host + GetFactory(component.Kind, component.Type) component.Factory +} + +func (r *templateProcessor) Start(ctx context.Context, ch component.Host) error { + host, ok := ch.(factoryGetter) + if !ok { + return fmt.Errorf("templateprocessor is not compatible with the provided component.Host") + } + + template, err := templates.Find(ctx, r.params.Logger, host, r.config.Name, r.config.Version) + if err != nil { + return fmt.Errorf("failed to find template %q: %w", r.config.Name, err) + } + + resolver, err := newResolver(template, r.config.Parameters) + if err != nil { + return fmt.Errorf("failed to create configuration resolver: %w", err) + } + conf, err := resolver.Resolve(ctx) + if err != nil { + return fmt.Errorf("failed to resolve template %q: %w", r.config.Name, err) + } + + var templateConfig templates.Config + err = conf.Unmarshal(&templateConfig) + if err != nil { + return fmt.Errorf("failed to decode template %q: %w", r.config.Name, err) + } + + selectedPipelines := []component.ID{} + if r.config.Pipeline != nil { + selectedPipelines = append(selectedPipelines, *r.config.Pipeline) + } + pipelines, err := selectComponents(templateConfig.Pipelines, selectedPipelines) + if err != nil { + return fmt.Errorf("failed to select component: %w", err) + } + if len(pipelines) > 1 { + return errors.New("multiple pipelines selected, select only one") + } + for id, pipeline := range pipelines { + err := r.startPipeline(ctx, host, templateConfig, id, pipeline) + if err != nil { + // Shutdown components that had been already started for cleanup. + if err := r.Shutdown(ctx); err != nil { + r.params.Logger.Warn("Failed to shutdown all components on error while starting", + zap.String("error", err.Error())) + } + return fmt.Errorf("failed to start pipeline %q: %w", id, err) + } + } + + return nil +} + +func (r *templateProcessor) startPipeline(ctx context.Context, host factoryGetter, config templates.Config, pipelineID component.ID, pipeline templates.PipelineConfig) error { + r.logs = r.nextLogsConsumer + r.metrics = r.nextMetricsConsumer + r.traces = r.nextTracesConsumer + + processors := slices.Clone(pipeline.Processors) + slices.Reverse(processors) + for i, id := range processors { + processorConfig, found := config.Processors[id] + if !found { + return fmt.Errorf("processor %q not found", id) + } + + factory, ok := host.GetFactory(component.KindProcessor, id.Type()).(processor.Factory) + if !ok { + return fmt.Errorf("could not find processor factory for %q", id.Type()) + } + + config, err := prepareComponentConfig(factory.CreateDefaultConfig, processorConfig) + if err != nil { + return fmt.Errorf("could not compose processor config for %s: %w", id.String(), err) + } + + params := processor.Settings(r.params) + params.ID = component.NewIDWithName(factory.Type(), fmt.Sprintf("%s-%s-%d", r.params.ID, pipelineID, i)) + params.Logger = params.Logger.With(zap.String("name", params.ID.String())) + if r.logs != nil { + logs, err := factory.CreateLogsProcessor(ctx, params, config, r.logs) + if err != nil { + return fmt.Errorf("failed to create logs processor %s: %w", params.ID, err) + } + r.logs = logs + r.components = append(r.components, logs) + } + if r.metrics != nil { + metrics, err := factory.CreateMetricsProcessor(ctx, params, config, r.metrics) + if err != nil { + return fmt.Errorf("failed to create metrics processor %s: %w", params.ID, err) + } + r.metrics = metrics + r.components = append(r.components, metrics) + } + if r.traces != nil { + traces, err := factory.CreateTracesProcessor(ctx, params, config, r.traces) + if err != nil { + return fmt.Errorf("failed to create traces processor %s: %w", params.ID, err) + } + r.traces = traces + r.components = append(r.components, traces) + } + } + + for _, component := range r.components { + err := component.Start(ctx, host) + if err != nil { + return fmt.Errorf("failed to start component %q: %w", component, err) + } + } + + return nil +} + +func (r *templateProcessor) Shutdown(ctx context.Context) error { + // Shutdown them in reverse order as they were created. + components := slices.Clone(r.components) + slices.Reverse(r.components) + for _, c := range components { + err := c.Shutdown(ctx) + if err != nil { + return fmt.Errorf("failed to shutdown component %s: %w", c, err) + } + } + + return nil +} + +func (r *templateProcessor) Capabilities() consumer.Capabilities { + return r.capabilities +} + +func (r *templateProcessor) ConsumeLogs(ctx context.Context, logs plog.Logs) error { + return r.logs.ConsumeLogs(ctx, logs) +} + +func (r *templateProcessor) ConsumeMetrics(ctx context.Context, metrics pmetric.Metrics) error { + return r.metrics.ConsumeMetrics(ctx, metrics) +} + +func (r *templateProcessor) ConsumeTraces(ctx context.Context, traces ptrace.Traces) error { + return r.traces.ConsumeTraces(ctx, traces) +} + +func newResolver(template templates.Template, variables map[string]any) (*confmap.Resolver, error) { + settings := confmap.ResolverSettings{ + URIs: []string{template.URI()}, + ProviderFactories: []confmap.ProviderFactory{ + template.ProviderFactory(), + newVariablesProviderFactory(variables), + }, + } + return confmap.NewResolver(settings) +} + +func selectComponents[C any](from map[component.ID]C, selection []component.ID) (map[component.ID]C, error) { + if len(selection) == 0 { + // If no selection, select all. + return from, nil + } + selected := make(map[component.ID]C) + for _, id := range selection { + component, found := from[id] + if !found { + return nil, fmt.Errorf("component %s not found", id.String()) + } + selected[id] = component + } + return selected, nil +} + +func prepareComponentConfig(create func() component.Config, config map[string]any) (component.Config, error) { + prepared := create() + received := confmap.NewFromStringMap(config) + err := received.Unmarshal(prepared) + return prepared, err +} diff --git a/receiver/templatereceiver/Makefile b/receiver/templatereceiver/Makefile new file mode 100644 index 00000000..ded7a360 --- /dev/null +++ b/receiver/templatereceiver/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/receiver/templatereceiver/config.go b/receiver/templatereceiver/config.go new file mode 100644 index 00000000..93a4a9d5 --- /dev/null +++ b/receiver/templatereceiver/config.go @@ -0,0 +1,39 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" + +import ( + "errors" + + "go.opentelemetry.io/collector/component" +) + +type Config struct { + Name string `mapstructure:"name"` + Pipelines []component.ID `mapstructure:"pipelines"` + Version string `mapstructure:"version"` + Parameters map[string]any `mapstructure:"parameters"` +} + +func (cfg *Config) Validate() error { + if cfg.Name == "" { + return errors.New("name is required") + } + + return nil +} diff --git a/receiver/templatereceiver/confmap.go b/receiver/templatereceiver/confmap.go new file mode 100644 index 00000000..4e710471 --- /dev/null +++ b/receiver/templatereceiver/confmap.go @@ -0,0 +1,62 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" + +import ( + "context" + "fmt" + "strings" + + "go.opentelemetry.io/collector/confmap" +) + +const ( + varProviderScheme = "var" +) + +func newVariablesProviderFactory(variables map[string]any) confmap.ProviderFactory { + return confmap.NewProviderFactory(createVariablesProvider(variables)) +} + +func createVariablesProvider(variables map[string]any) confmap.CreateProviderFunc { + return func(_ confmap.ProviderSettings) confmap.Provider { + return &variablesProvider{variables: variables} + } +} + +type variablesProvider struct { + variables map[string]any +} + +func (p *variablesProvider) Retrieve(ctx context.Context, uri string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) { + key := strings.TrimLeft(uri, varProviderScheme+":") + value, found := p.variables[key] + if !found { + return nil, fmt.Errorf("variable %q not found", key) + } + + return confmap.NewRetrieved(value) +} + +func (p *variablesProvider) Scheme() string { + return varProviderScheme +} + +func (p *variablesProvider) Shutdown(ctx context.Context) error { + return nil +} diff --git a/receiver/templatereceiver/factory.go b/receiver/templatereceiver/factory.go new file mode 100644 index 00000000..1f6f6b7e --- /dev/null +++ b/receiver/templatereceiver/factory.go @@ -0,0 +1,56 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" + +import ( + "context" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/receiver" +) + +var ( + typeStr = component.MustNewType("template") +) + +func NewFactory() receiver.Factory { + return receiver.NewFactory( + typeStr, + createDefaultConfig, + receiver.WithLogs(createLogsReceiver, component.StabilityLevelAlpha), + receiver.WithMetrics(createMetricsReceiver, component.StabilityLevelAlpha), + receiver.WithTraces(createTracesReceiver, component.StabilityLevelAlpha), + ) +} + +func createDefaultConfig() component.Config { + return &Config{} +} + +func createLogsReceiver(_ context.Context, params receiver.Settings, cfg component.Config, consumer consumer.Logs) (receiver.Logs, error) { + return newTemplateLogsReceiver(params, cfg.(*Config), consumer), nil +} + +func createMetricsReceiver(_ context.Context, params receiver.Settings, cfg component.Config, consumer consumer.Metrics) (receiver.Metrics, error) { + return newTemplateMetricsReceiver(params, cfg.(*Config), consumer), nil +} + +func createTracesReceiver(_ context.Context, params receiver.Settings, cfg component.Config, consumer consumer.Traces) (receiver.Traces, error) { + return newTemplateTracesReceiver(params, cfg.(*Config), consumer), nil +} diff --git a/receiver/templatereceiver/go.mod b/receiver/templatereceiver/go.mod new file mode 100644 index 00000000..ee3c9d0b --- /dev/null +++ b/receiver/templatereceiver/go.mod @@ -0,0 +1,45 @@ +module github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver + +go 1.22.1 + +require ( + github.com/elastic/opentelemetry-collector-components/pkg/templates v0.0.0 + go.opentelemetry.io/collector/component v0.105.0 + go.opentelemetry.io/collector/confmap v0.105.0 + go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/processor v0.105.0 + go.opentelemetry.io/collector/receiver v0.105.0 + go.uber.org/zap v1.27.0 +) + +require ( + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/knadh/koanf/maps v0.1.1 // indirect + github.com/knadh/koanf/providers/confmap v0.1.0 // indirect + github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/mitchellh/copystructure v1.2.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/rogpeppe/go-internal v1.12.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/featuregate v1.13.0 // indirect + go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata v1.13.0 // indirect + go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/elastic/opentelemetry-collector-components/pkg/templates => ../../pkg/templates diff --git a/receiver/templatereceiver/go.sum b/receiver/templatereceiver/go.sum new file mode 100644 index 00000000..bbb1ef67 --- /dev/null +++ b/receiver/templatereceiver/go.sum @@ -0,0 +1,143 @@ +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/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= +github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= +github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= +github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= +github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= +github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +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/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= +go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= +go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= +go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= +go.opentelemetry.io/collector/consumer v0.105.0 h1:pO5Tspoz7yvEs81+904HfDjByP8Z7uuNk+7pOr3lRHM= +go.opentelemetry.io/collector/consumer v0.105.0/go.mod h1:tnaPDHUfKBJ01OnsJNRecniG9iciE+xHYLqamYwFQOQ= +go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= +go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= +go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= +go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= +go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= +go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/collector/processor v0.105.0 h1:LE6wEMWNa3h7eOJLMBm2lA0v6sc2j6Geqv1e3pIWS8Y= +go.opentelemetry.io/collector/processor v0.105.0/go.mod h1:QAvMEtd3k+YhRrnaEgs/8e0UueYonuT8Hg4udQOht60= +go.opentelemetry.io/collector/receiver v0.105.0 h1:eZF97kMUnKJ20Uc4PaDlgLIGmaA8kyLqhH+vMXjh92U= +go.opentelemetry.io/collector/receiver v0.105.0/go.mod h1:nGKDXLUGVHxMBJ5QLfsJ/bIhGvoMGqsN0pZtD5SC8sE= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +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/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/receiver/templatereceiver/receiver.go b/receiver/templatereceiver/receiver.go new file mode 100644 index 00000000..e604cc6f --- /dev/null +++ b/receiver/templatereceiver/receiver.go @@ -0,0 +1,275 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" + +import ( + "context" + "fmt" + "slices" + + "go.uber.org/zap" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/receiver" + + "github.com/elastic/opentelemetry-collector-components/pkg/templates" +) + +type templateReceiver struct { + params receiver.Settings + config *Config + components []component.Component + nextMetricsConsumer consumer.Metrics + nextLogsConsumer consumer.Logs + nextTracesConsumer consumer.Traces +} + +func newTemplateLogsReceiver(params receiver.Settings, config *Config, consumer consumer.Logs) *templateReceiver { + return &templateReceiver{ + params: params, + config: config, + nextLogsConsumer: consumer, + } +} + +func newTemplateMetricsReceiver(params receiver.Settings, config *Config, consumer consumer.Metrics) *templateReceiver { + return &templateReceiver{ + params: params, + config: config, + nextMetricsConsumer: consumer, + } +} + +func newTemplateTracesReceiver(params receiver.Settings, config *Config, consumer consumer.Traces) *templateReceiver { + return &templateReceiver{ + params: params, + config: config, + nextTracesConsumer: consumer, + } +} + +// factoryGetter is an interface that the component.Host passed to receivercreator's Start function must implement +// GetFactory is optional in hosts since 107.0, but we require it. +type factoryGetter interface { + component.Host + GetFactory(component.Kind, component.Type) component.Factory +} + +func (r *templateReceiver) Start(ctx context.Context, ch component.Host) error { + host, ok := ch.(factoryGetter) + if !ok { + return fmt.Errorf("templatereceiver is not compatible with the provided component.Host") + } + + template, err := templates.Find(ctx, r.params.Logger, host, r.config.Name, r.config.Version) + if err != nil { + return fmt.Errorf("failed to find template %q: %w", r.config.Name, err) + } + + resolver, err := newResolver(template, r.config.Parameters) + if err != nil { + return fmt.Errorf("failed to create configuration resolver: %w", err) + } + conf, err := resolver.Resolve(ctx) + if err != nil { + return fmt.Errorf("failed to resolve template %q: %w", r.config.Name, err) + } + + var templateConfig templates.Config + err = conf.Unmarshal(&templateConfig) + if err != nil { + return fmt.Errorf("failed to decode template %q: %w", r.config.Name, err) + } + + pipelines, err := selectComponents(templateConfig.Pipelines, r.config.Pipelines) + if err != nil { + return fmt.Errorf("failed to select component: %w", err) + } + for id, pipeline := range pipelines { + err := r.startPipeline(ctx, host, templateConfig, id, pipeline) + if err != nil { + // Shutdown components that had been already started for cleanup. + if err := r.Shutdown(ctx); err != nil { + r.params.Logger.Warn("Failed to shutdown all components on error while starting", + zap.String("error", err.Error())) + } + return fmt.Errorf("failed to start pipeline %q: %w", id, err) + } + } + + return nil +} + +func (r *templateReceiver) startPipeline(ctx context.Context, host factoryGetter, config templates.Config, pipelineID component.ID, pipeline templates.PipelineConfig) error { + consumerChain := struct { + logs consumer.Logs + metrics consumer.Metrics + traces consumer.Traces + }{ + logs: r.nextLogsConsumer, + metrics: r.nextMetricsConsumer, + traces: r.nextTracesConsumer, + } + + receiverConfig, found := config.Receivers[pipeline.Receiver] + if !found { + return fmt.Errorf("receiver %q not found", pipeline.Receiver) + } + + receiverFactory, ok := host.GetFactory(component.KindReceiver, pipeline.Receiver.Type()).(receiver.Factory) + if !ok { + return fmt.Errorf("could not find receiver factory for %q", pipeline.Receiver.Type()) + } + + preparedConfig, err := prepareComponentConfig(receiverFactory.CreateDefaultConfig, receiverConfig) + if err != nil { + return fmt.Errorf("could not compose receiver config for %s: %w", pipeline.Receiver.String(), err) + } + + processors := slices.Clone(pipeline.Processors) + slices.Reverse(processors) + for i, id := range processors { + processorConfig, found := config.Processors[id] + if !found { + return fmt.Errorf("processor %q not found", id) + } + + factory, ok := host.GetFactory(component.KindProcessor, id.Type()).(processor.Factory) + if !ok { + return fmt.Errorf("could not find processor factory for %q", id.Type()) + } + + config, err := prepareComponentConfig(factory.CreateDefaultConfig, processorConfig) + if err != nil { + return fmt.Errorf("could not compose processor config for %s: %w", id.String(), err) + } + + params := processor.Settings(r.params) + params.ID = component.NewIDWithName(factory.Type(), fmt.Sprintf("%s-%s-%d", r.params.ID, pipelineID, i)) + params.Logger = params.Logger.With(zap.String("name", params.ID.String())) + if consumerChain.logs != nil { + logs, err := factory.CreateLogsProcessor(ctx, params, config, consumerChain.logs) + if err != nil { + return fmt.Errorf("failed to create logs processor %s: %w", params.ID, err) + } + consumerChain.logs = logs + r.components = append(r.components, logs) + } + if consumerChain.metrics != nil { + metrics, err := factory.CreateMetricsProcessor(ctx, params, config, consumerChain.metrics) + if err != nil { + return fmt.Errorf("failed to create metrics processor %s: %w", params.ID, err) + } + consumerChain.metrics = metrics + r.components = append(r.components, metrics) + } + if consumerChain.traces != nil { + traces, err := factory.CreateTracesProcessor(ctx, params, config, consumerChain.traces) + if err != nil { + return fmt.Errorf("failed to create traces processor %s: %w", params.ID, err) + } + consumerChain.traces = traces + r.components = append(r.components, traces) + } + } + + params := r.params + params.ID = component.NewIDWithName(receiverFactory.Type(), fmt.Sprintf("%s-receiver", pipelineID)) + params.Logger = params.Logger.With(zap.String("name", params.ID.String())) + if consumerChain.logs != nil { + logs, err := receiverFactory.CreateLogsReceiver(ctx, params, preparedConfig, consumerChain.logs) + if err != nil { + return fmt.Errorf("failed to create logs processor %s: %w", params.ID, err) + } + r.components = append(r.components, logs) + } + if consumerChain.metrics != nil { + metrics, err := receiverFactory.CreateMetricsReceiver(ctx, params, preparedConfig, consumerChain.metrics) + if err != nil { + return fmt.Errorf("failed to create metrics processor %s: %w", params.ID, err) + } + r.components = append(r.components, metrics) + } + if consumerChain.traces != nil { + traces, err := receiverFactory.CreateTracesReceiver(ctx, params, preparedConfig, consumerChain.traces) + if err != nil { + return fmt.Errorf("failed to create traces processor %s: %w", params.ID, err) + } + r.components = append(r.components, traces) + } + + for _, component := range r.components { + err := component.Start(ctx, host) + if err != nil { + return fmt.Errorf("failed to start component %q: %w", component, err) + } + } + + return nil +} + +func (r *templateReceiver) Shutdown(ctx context.Context) error { + // Shutdown them in reverse order as they were created. + components := slices.Clone(r.components) + slices.Reverse(r.components) + for _, c := range components { + err := c.Shutdown(ctx) + if err != nil { + return fmt.Errorf("failed to shutdown component %s: %w", c, err) + } + } + + return nil +} + +func newResolver(template templates.Template, variables map[string]any) (*confmap.Resolver, error) { + settings := confmap.ResolverSettings{ + URIs: []string{template.URI()}, + ProviderFactories: []confmap.ProviderFactory{ + template.ProviderFactory(), + newVariablesProviderFactory(variables), + }, + } + return confmap.NewResolver(settings) +} + +func selectComponents[C any](from map[component.ID]C, selection []component.ID) (map[component.ID]C, error) { + if len(selection) == 0 { + // If no selection, select all. + return from, nil + } + selected := make(map[component.ID]C) + for _, id := range selection { + component, found := from[id] + if !found { + return nil, fmt.Errorf("component %s not found", id.String()) + } + selected[id] = component + } + return selected, nil +} + +func prepareComponentConfig(create func() component.Config, config map[string]any) (component.Config, error) { + prepared := create() + received := confmap.NewFromStringMap(config) + err := received.Unmarshal(prepared) + return prepared, err +} From 1d347563bbb650a5ebbb2f9701e1173f03356892 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 21 Aug 2024 11:09:56 +0200 Subject: [PATCH 02/20] Add metadata files --- extension/filetemplateextension/metadata.yml | 8 ++++++++ processor/templateprocessor/metadata.yml | 8 ++++++++ receiver/templatereceiver/metadata.yml | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 extension/filetemplateextension/metadata.yml create mode 100644 processor/templateprocessor/metadata.yml create mode 100644 receiver/templatereceiver/metadata.yml diff --git a/extension/filetemplateextension/metadata.yml b/extension/filetemplateextension/metadata.yml new file mode 100644 index 00000000..98ec3342 --- /dev/null +++ b/extension/filetemplateextension/metadata.yml @@ -0,0 +1,8 @@ +type: file_templates + +status: + class: extension + stability: + development: [logs, metrics, traces] + codeowners: + active: [jsoriano] diff --git a/processor/templateprocessor/metadata.yml b/processor/templateprocessor/metadata.yml new file mode 100644 index 00000000..0204e437 --- /dev/null +++ b/processor/templateprocessor/metadata.yml @@ -0,0 +1,8 @@ +type: templateprocessor + +status: + class: processor + stability: + development: [logs, metrics, traces] + codeowners: + active: [jsoriano] diff --git a/receiver/templatereceiver/metadata.yml b/receiver/templatereceiver/metadata.yml new file mode 100644 index 00000000..1fa824ba --- /dev/null +++ b/receiver/templatereceiver/metadata.yml @@ -0,0 +1,8 @@ +type: elasticinframetrics + +status: + class: receiver + stability: + development: [logs, metrics, traces] + codeowners: + active: [jsoriano] From 4349db02521dee9175f13247c474161ed6526d2f Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 21 Aug 2024 11:14:33 +0200 Subject: [PATCH 03/20] Change stability level --- extension/filetemplateextension/factory.go | 2 +- processor/templateprocessor/factory.go | 6 +++--- receiver/templatereceiver/factory.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extension/filetemplateextension/factory.go b/extension/filetemplateextension/factory.go index bc5b0b29..13a0e91a 100644 --- a/extension/filetemplateextension/factory.go +++ b/extension/filetemplateextension/factory.go @@ -29,7 +29,7 @@ var ( ) const ( - extensionStability = component.StabilityLevelAlpha + extensionStability = component.StabilityLevelDevelopment ) // NewFactory creates a factory for ack extension. diff --git a/processor/templateprocessor/factory.go b/processor/templateprocessor/factory.go index a5334fef..a88aaf4c 100644 --- a/processor/templateprocessor/factory.go +++ b/processor/templateprocessor/factory.go @@ -33,9 +33,9 @@ func NewFactory() processor.Factory { return processor.NewFactory( typeStr, createDefaultConfig, - processor.WithLogs(createLogsProcessor, component.StabilityLevelAlpha), - processor.WithMetrics(createMetricsProcessor, component.StabilityLevelAlpha), - processor.WithTraces(createTracesProcessor, component.StabilityLevelAlpha), + processor.WithLogs(createLogsProcessor, component.StabilityLevelDevelopment), + processor.WithMetrics(createMetricsProcessor, component.StabilityLevelDevelopment), + processor.WithTraces(createTracesProcessor, component.StabilityLevelDevelopment), ) } diff --git a/receiver/templatereceiver/factory.go b/receiver/templatereceiver/factory.go index 1f6f6b7e..ff1e0eed 100644 --- a/receiver/templatereceiver/factory.go +++ b/receiver/templatereceiver/factory.go @@ -33,9 +33,9 @@ func NewFactory() receiver.Factory { return receiver.NewFactory( typeStr, createDefaultConfig, - receiver.WithLogs(createLogsReceiver, component.StabilityLevelAlpha), - receiver.WithMetrics(createMetricsReceiver, component.StabilityLevelAlpha), - receiver.WithTraces(createTracesReceiver, component.StabilityLevelAlpha), + receiver.WithLogs(createLogsReceiver, component.StabilityLevelDevelopment), + receiver.WithMetrics(createMetricsReceiver, component.StabilityLevelDevelopment), + receiver.WithTraces(createTracesReceiver, component.StabilityLevelDevelopment), ) } From 58df09173caae623e400c026580d5a0d976f11c6 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 21 Aug 2024 11:16:46 +0200 Subject: [PATCH 04/20] Move templates package to internal --- distributions/elastic-components/manifest.yaml | 2 +- extension/filetemplateextension/extension.go | 2 +- extension/filetemplateextension/go.mod | 4 ++-- {pkg => internal}/templates/Makefile | 0 {pkg => internal}/templates/go.mod | 2 +- {pkg => internal}/templates/go.sum | 0 {pkg => internal}/templates/templates.go | 2 +- processor/templateprocessor/go.mod | 4 ++-- processor/templateprocessor/processor.go | 2 +- receiver/templatereceiver/go.mod | 4 ++-- receiver/templatereceiver/receiver.go | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) rename {pkg => internal}/templates/Makefile (100%) rename {pkg => internal}/templates/go.mod (94%) rename {pkg => internal}/templates/go.sum (100%) rename {pkg => internal}/templates/templates.go (98%) diff --git a/distributions/elastic-components/manifest.yaml b/distributions/elastic-components/manifest.yaml index 3b33e64a..a78d07ab 100644 --- a/distributions/elastic-components/manifest.yaml +++ b/distributions/elastic-components/manifest.yaml @@ -34,5 +34,5 @@ replaces: - github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor => ../processor/elastictraceprocessor - github.com/elastic/opentelemetry-collector-components/processor/templateprocessor => ../processor/templateprocessor - github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver => ../receiver/templatereceiver - - github.com/elastic/opentelemetry-collector-components/pkg/templates => ../pkg/templates + - github.com/elastic/opentelemetry-collector-components/internal/templates => ../internal/templates diff --git a/extension/filetemplateextension/extension.go b/extension/filetemplateextension/extension.go index aa77cd41..1740350c 100644 --- a/extension/filetemplateextension/extension.go +++ b/extension/filetemplateextension/extension.go @@ -28,7 +28,7 @@ import ( "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/provider/fileprovider" - "github.com/elastic/opentelemetry-collector-components/pkg/templates" + "github.com/elastic/opentelemetry-collector-components/internal/templates" ) type fileTemplateExtension struct { diff --git a/extension/filetemplateextension/go.mod b/extension/filetemplateextension/go.mod index 194011ea..9eb183a2 100644 --- a/extension/filetemplateextension/go.mod +++ b/extension/filetemplateextension/go.mod @@ -3,7 +3,7 @@ module github.com/elastic/opentelemetry-collector-components/extension/filetempl go 1.22.1 require ( - github.com/elastic/opentelemetry-collector-components/pkg/templates v0.0.0 + github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 @@ -40,4 +40,4 @@ require ( replace github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver => ../../receiver/templatereceiver -replace github.com/elastic/opentelemetry-collector-components/pkg/templates => ../../pkg/templates +replace github.com/elastic/opentelemetry-collector-components/internal/templates => ../../internal/templates diff --git a/pkg/templates/Makefile b/internal/templates/Makefile similarity index 100% rename from pkg/templates/Makefile rename to internal/templates/Makefile diff --git a/pkg/templates/go.mod b/internal/templates/go.mod similarity index 94% rename from pkg/templates/go.mod rename to internal/templates/go.mod index fccf03b6..026d2afe 100644 --- a/pkg/templates/go.mod +++ b/internal/templates/go.mod @@ -1,4 +1,4 @@ -module github.com/elastic/opentelemetry-collector-components/pkg/templates +module github.com/elastic/opentelemetry-collector-components/internal/templates go 1.22.1 diff --git a/pkg/templates/go.sum b/internal/templates/go.sum similarity index 100% rename from pkg/templates/go.sum rename to internal/templates/go.sum diff --git a/pkg/templates/templates.go b/internal/templates/templates.go similarity index 98% rename from pkg/templates/templates.go rename to internal/templates/templates.go index cf876523..7e38402c 100644 --- a/pkg/templates/templates.go +++ b/internal/templates/templates.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templates // import "github.com/elastic/opentelemetry-collector-components/pkg/templates" +package templates // import "github.com/elastic/opentelemetry-collector-components/internal/templates" import ( "context" diff --git a/processor/templateprocessor/go.mod b/processor/templateprocessor/go.mod index 8144a745..a27ee999 100644 --- a/processor/templateprocessor/go.mod +++ b/processor/templateprocessor/go.mod @@ -3,7 +3,7 @@ module github.com/elastic/opentelemetry-collector-components/processor/templatep go 1.22.1 require ( - github.com/elastic/opentelemetry-collector-components/pkg/templates v0.0.0 + github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 @@ -41,4 +41,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/elastic/opentelemetry-collector-components/pkg/templates => ../../pkg/templates +replace github.com/elastic/opentelemetry-collector-components/internal/templates => ../../internal/templates diff --git a/processor/templateprocessor/processor.go b/processor/templateprocessor/processor.go index 5e2492d7..5eadf7bd 100644 --- a/processor/templateprocessor/processor.go +++ b/processor/templateprocessor/processor.go @@ -33,7 +33,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/processor" - "github.com/elastic/opentelemetry-collector-components/pkg/templates" + "github.com/elastic/opentelemetry-collector-components/internal/templates" ) type templateProcessor struct { diff --git a/receiver/templatereceiver/go.mod b/receiver/templatereceiver/go.mod index ee3c9d0b..522b6949 100644 --- a/receiver/templatereceiver/go.mod +++ b/receiver/templatereceiver/go.mod @@ -3,7 +3,7 @@ module github.com/elastic/opentelemetry-collector-components/receiver/templatere go 1.22.1 require ( - github.com/elastic/opentelemetry-collector-components/pkg/templates v0.0.0 + github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 @@ -42,4 +42,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/elastic/opentelemetry-collector-components/pkg/templates => ../../pkg/templates +replace github.com/elastic/opentelemetry-collector-components/internal/templates => ../../internal/templates diff --git a/receiver/templatereceiver/receiver.go b/receiver/templatereceiver/receiver.go index e604cc6f..9ba752dc 100644 --- a/receiver/templatereceiver/receiver.go +++ b/receiver/templatereceiver/receiver.go @@ -30,7 +30,7 @@ import ( "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/receiver" - "github.com/elastic/opentelemetry-collector-components/pkg/templates" + "github.com/elastic/opentelemetry-collector-components/internal/templates" ) type templateReceiver struct { From cf3d5a9301fbd78d7c2c7f527d9fc880e3a696de Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 21 Aug 2024 12:07:16 +0200 Subject: [PATCH 05/20] Use mdatagen --- .../elastic-components/manifest.yaml | 1 - extension/filetemplateextension/doc.go | 21 +++ extension/filetemplateextension/factory.go | 12 +- .../generated_component_test.go | 49 ++++++ .../generated_package_test.go | 12 ++ extension/filetemplateextension/go.mod | 17 ++ extension/filetemplateextension/go.sum | 1 + .../internal/metadata/generated_status.go | 16 ++ .../{metadata.yml => metadata.yaml} | 3 +- processor/templateprocessor/doc.go | 21 +++ processor/templateprocessor/factory.go | 12 +- .../generated_component_test.go | 149 ++++++++++++++++++ .../generated_package_test.go | 12 ++ processor/templateprocessor/go.mod | 19 +++ processor/templateprocessor/go.sum | 5 + .../internal/metadata/generated_status.go | 18 +++ .../{metadata.yml => metadata.yaml} | 2 +- receiver/templatereceiver/doc.go | 21 +++ receiver/templatereceiver/factory.go | 12 +- .../generated_component_test.go | 83 ++++++++++ .../generated_package_test.go | 12 ++ receiver/templatereceiver/go.mod | 17 ++ receiver/templatereceiver/go.sum | 6 + .../internal/metadata/generated_status.go | 18 +++ .../{metadata.yml => metadata.yaml} | 0 25 files changed, 512 insertions(+), 27 deletions(-) create mode 100644 extension/filetemplateextension/doc.go create mode 100644 extension/filetemplateextension/generated_component_test.go create mode 100644 extension/filetemplateextension/generated_package_test.go create mode 100644 extension/filetemplateextension/internal/metadata/generated_status.go rename extension/filetemplateextension/{metadata.yml => metadata.yaml} (70%) create mode 100644 processor/templateprocessor/doc.go create mode 100644 processor/templateprocessor/generated_component_test.go create mode 100644 processor/templateprocessor/generated_package_test.go create mode 100644 processor/templateprocessor/internal/metadata/generated_status.go rename processor/templateprocessor/{metadata.yml => metadata.yaml} (83%) create mode 100644 receiver/templatereceiver/doc.go create mode 100644 receiver/templatereceiver/generated_component_test.go create mode 100644 receiver/templatereceiver/generated_package_test.go create mode 100644 receiver/templatereceiver/internal/metadata/generated_status.go rename receiver/templatereceiver/{metadata.yml => metadata.yaml} (100%) diff --git a/distributions/elastic-components/manifest.yaml b/distributions/elastic-components/manifest.yaml index a78d07ab..e31ca0a8 100644 --- a/distributions/elastic-components/manifest.yaml +++ b/distributions/elastic-components/manifest.yaml @@ -35,4 +35,3 @@ replaces: - github.com/elastic/opentelemetry-collector-components/processor/templateprocessor => ../processor/templateprocessor - github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver => ../receiver/templatereceiver - github.com/elastic/opentelemetry-collector-components/internal/templates => ../internal/templates - diff --git a/extension/filetemplateextension/doc.go b/extension/filetemplateextension/doc.go new file mode 100644 index 00000000..b0c4d34e --- /dev/null +++ b/extension/filetemplateextension/doc.go @@ -0,0 +1,21 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:generate mdatagen metadata.yaml + +// Package filetemplateextension provides a source of templates that obtain them from a local directory. +package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" diff --git a/extension/filetemplateextension/factory.go b/extension/filetemplateextension/factory.go index 13a0e91a..3afe2b87 100644 --- a/extension/filetemplateextension/factory.go +++ b/extension/filetemplateextension/factory.go @@ -22,23 +22,17 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension" -) - -var ( - extensionType = component.MustNewType("file_templates") -) -const ( - extensionStability = component.StabilityLevelDevelopment + "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension/internal/metadata" ) // NewFactory creates a factory for ack extension. func NewFactory() extension.Factory { return extension.NewFactory( - extensionType, + metadata.Type, createDefaultConfig, createExtension, - extensionStability, + metadata.ExtensionStability, ) } diff --git a/extension/filetemplateextension/generated_component_test.go b/extension/filetemplateextension/generated_component_test.go new file mode 100644 index 00000000..017a8f41 --- /dev/null +++ b/extension/filetemplateextension/generated_component_test.go @@ -0,0 +1,49 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package filetemplateextension + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" + "go.opentelemetry.io/collector/extension/extensiontest" +) + +func TestComponentFactoryType(t *testing.T) { + require.Equal(t, "file_templates", NewFactory().Type().String()) +} + +func TestComponentConfigStruct(t *testing.T) { + require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig())) +} + +func TestComponentLifecycle(t *testing.T) { + factory := NewFactory() + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(&cfg)) + t.Run("shutdown", func(t *testing.T) { + e, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + require.NoError(t, err) + err = e.Shutdown(context.Background()) + require.NoError(t, err) + }) + t.Run("lifecycle", func(t *testing.T) { + firstExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + require.NoError(t, err) + require.NoError(t, firstExt.Start(context.Background(), componenttest.NewNopHost())) + require.NoError(t, firstExt.Shutdown(context.Background())) + + secondExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondExt.Start(context.Background(), componenttest.NewNopHost())) + require.NoError(t, secondExt.Shutdown(context.Background())) + }) +} diff --git a/extension/filetemplateextension/generated_package_test.go b/extension/filetemplateextension/generated_package_test.go new file mode 100644 index 00000000..ea816ab1 --- /dev/null +++ b/extension/filetemplateextension/generated_package_test.go @@ -0,0 +1,12 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package filetemplateextension + +import ( + "go.uber.org/goleak" + "testing" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/extension/filetemplateextension/go.mod b/extension/filetemplateextension/go.mod index 9eb183a2..6b09d787 100644 --- a/extension/filetemplateextension/go.mod +++ b/extension/filetemplateextension/go.mod @@ -4,28 +4,45 @@ go 1.22.1 require ( github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 + github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 go.opentelemetry.io/collector/extension v0.105.0 + go.uber.org/goleak v1.3.0 ) require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect github.com/knadh/koanf/providers/confmap v0.1.0 // indirect github.com/knadh/koanf/v2 v2.1.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.13.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata v1.13.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect diff --git a/extension/filetemplateextension/go.sum b/extension/filetemplateextension/go.sum index 820a2201..cd15f84b 100644 --- a/extension/filetemplateextension/go.sum +++ b/extension/filetemplateextension/go.sum @@ -4,6 +4,7 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= diff --git a/extension/filetemplateextension/internal/metadata/generated_status.go b/extension/filetemplateextension/internal/metadata/generated_status.go new file mode 100644 index 00000000..6de7fcba --- /dev/null +++ b/extension/filetemplateextension/internal/metadata/generated_status.go @@ -0,0 +1,16 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +var ( + Type = component.MustNewType("file_templates") + ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" +) + +const ( + ExtensionStability = component.StabilityLevelDevelopment +) diff --git a/extension/filetemplateextension/metadata.yml b/extension/filetemplateextension/metadata.yaml similarity index 70% rename from extension/filetemplateextension/metadata.yml rename to extension/filetemplateextension/metadata.yaml index 98ec3342..105db8f8 100644 --- a/extension/filetemplateextension/metadata.yml +++ b/extension/filetemplateextension/metadata.yaml @@ -1,8 +1,7 @@ type: file_templates - status: class: extension stability: - development: [logs, metrics, traces] + development: [extension] codeowners: active: [jsoriano] diff --git a/processor/templateprocessor/doc.go b/processor/templateprocessor/doc.go new file mode 100644 index 00000000..e5d3d52a --- /dev/null +++ b/processor/templateprocessor/doc.go @@ -0,0 +1,21 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:generate mdatagen metadata.yaml + +// Package templateprocessor provides a processor that creates processors from templates. +package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" diff --git a/processor/templateprocessor/factory.go b/processor/templateprocessor/factory.go index a88aaf4c..60e2a37d 100644 --- a/processor/templateprocessor/factory.go +++ b/processor/templateprocessor/factory.go @@ -23,19 +23,17 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/processor" -) -var ( - typeStr = component.MustNewType("template") + "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor/internal/metadata" ) func NewFactory() processor.Factory { return processor.NewFactory( - typeStr, + metadata.Type, createDefaultConfig, - processor.WithLogs(createLogsProcessor, component.StabilityLevelDevelopment), - processor.WithMetrics(createMetricsProcessor, component.StabilityLevelDevelopment), - processor.WithTraces(createTracesProcessor, component.StabilityLevelDevelopment), + processor.WithLogs(createLogsProcessor, metadata.LogsStability), + processor.WithMetrics(createMetricsProcessor, metadata.MetricsStability), + processor.WithTraces(createTracesProcessor, metadata.TracesStability), ) } diff --git a/processor/templateprocessor/generated_component_test.go b/processor/templateprocessor/generated_component_test.go new file mode 100644 index 00000000..868bdbe0 --- /dev/null +++ b/processor/templateprocessor/generated_component_test.go @@ -0,0 +1,149 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package templateprocessor + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" +) + +func TestComponentFactoryType(t *testing.T) { + require.Equal(t, "template", NewFactory().Type().String()) +} + +func TestComponentConfigStruct(t *testing.T) { + require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig())) +} + +func TestComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(&cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + t.Run(test.name+"-lifecycle", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg) + require.NoError(t, err) + host := componenttest.NewNopHost() + err = c.Start(context.Background(), host) + require.NoError(t, err) + require.NotPanics(t, func() { + switch test.name { + case "logs": + e, ok := c.(processor.Logs) + require.True(t, ok) + logs := generateLifecycleTestLogs() + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case "metrics": + e, ok := c.(processor.Metrics) + require.True(t, ok) + metrics := generateLifecycleTestMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case "traces": + e, ok := c.(processor.Traces) + require.True(t, ok) + traces := generateLifecycleTestTraces() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} + +func generateLifecycleTestLogs() plog.Logs { + logs := plog.NewLogs() + rl := logs.ResourceLogs().AppendEmpty() + rl.Resource().Attributes().PutStr("resource", "R1") + l := rl.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty() + l.Body().SetStr("test log message") + l.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return logs +} + +func generateLifecycleTestMetrics() pmetric.Metrics { + metrics := pmetric.NewMetrics() + rm := metrics.ResourceMetrics().AppendEmpty() + rm.Resource().Attributes().PutStr("resource", "R1") + m := rm.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty() + m.SetName("test_metric") + dp := m.SetEmptyGauge().DataPoints().AppendEmpty() + dp.Attributes().PutStr("test_attr", "value_1") + dp.SetIntValue(123) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return metrics +} + +func generateLifecycleTestTraces() ptrace.Traces { + traces := ptrace.NewTraces() + rs := traces.ResourceSpans().AppendEmpty() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/templateprocessor/generated_package_test.go b/processor/templateprocessor/generated_package_test.go new file mode 100644 index 00000000..f7fb2309 --- /dev/null +++ b/processor/templateprocessor/generated_package_test.go @@ -0,0 +1,12 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package templateprocessor + +import ( + "go.uber.org/goleak" + "testing" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/processor/templateprocessor/go.mod b/processor/templateprocessor/go.mod index a27ee999..17a8270a 100644 --- a/processor/templateprocessor/go.mod +++ b/processor/templateprocessor/go.mod @@ -4,17 +4,25 @@ go 1.22.1 require ( github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 + github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 go.opentelemetry.io/collector/pdata v1.13.0 go.opentelemetry.io/collector/processor v0.105.0 + go.uber.org/goleak v1.3.0 go.uber.org/zap v1.27.0 ) require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect @@ -24,12 +32,23 @@ require ( 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/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.13.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/testdata v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.28.0 // indirect diff --git a/processor/templateprocessor/go.sum b/processor/templateprocessor/go.sum index b5a2b139..50c0298d 100644 --- a/processor/templateprocessor/go.sum +++ b/processor/templateprocessor/go.sum @@ -5,6 +5,7 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -77,6 +78,10 @@ go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6 go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/collector/pdata/pprofile v0.105.0 h1:C+Hd7CNcepL/364OBV9f4lHzJil2jQSOxcEM1PFXGDg= +go.opentelemetry.io/collector/pdata/pprofile v0.105.0/go.mod h1:chr7lMJIzyXkccnPRkIPhyXtqLZLSReZYhwsggOGEfg= +go.opentelemetry.io/collector/pdata/testdata v0.105.0 h1:5sPZzanR4nJR3sNQk3MTdArdEZCK0NRAfC29t0Dtf60= +go.opentelemetry.io/collector/pdata/testdata v0.105.0/go.mod h1:NIfgaclQp/M1BZhgyc/7hDWD+/DumC/OMBQVI2KW+N0= go.opentelemetry.io/collector/processor v0.105.0 h1:LE6wEMWNa3h7eOJLMBm2lA0v6sc2j6Geqv1e3pIWS8Y= go.opentelemetry.io/collector/processor v0.105.0/go.mod h1:QAvMEtd3k+YhRrnaEgs/8e0UueYonuT8Hg4udQOht60= go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= diff --git a/processor/templateprocessor/internal/metadata/generated_status.go b/processor/templateprocessor/internal/metadata/generated_status.go new file mode 100644 index 00000000..48b8766d --- /dev/null +++ b/processor/templateprocessor/internal/metadata/generated_status.go @@ -0,0 +1,18 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +var ( + Type = component.MustNewType("template") + ScopeName = "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" +) + +const ( + LogsStability = component.StabilityLevelDevelopment + MetricsStability = component.StabilityLevelDevelopment + TracesStability = component.StabilityLevelDevelopment +) diff --git a/processor/templateprocessor/metadata.yml b/processor/templateprocessor/metadata.yaml similarity index 83% rename from processor/templateprocessor/metadata.yml rename to processor/templateprocessor/metadata.yaml index 0204e437..0a7b5ea4 100644 --- a/processor/templateprocessor/metadata.yml +++ b/processor/templateprocessor/metadata.yaml @@ -1,4 +1,4 @@ -type: templateprocessor +type: template status: class: processor diff --git a/receiver/templatereceiver/doc.go b/receiver/templatereceiver/doc.go new file mode 100644 index 00000000..afd3b707 --- /dev/null +++ b/receiver/templatereceiver/doc.go @@ -0,0 +1,21 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:generate mdatagen metadata.yaml + +// Package templatereceiver provides a stateless span metrics connector similar to the upstream span metrics connector. +package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" diff --git a/receiver/templatereceiver/factory.go b/receiver/templatereceiver/factory.go index ff1e0eed..0cd63c7d 100644 --- a/receiver/templatereceiver/factory.go +++ b/receiver/templatereceiver/factory.go @@ -23,19 +23,17 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/receiver" -) -var ( - typeStr = component.MustNewType("template") + "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver/internal/metadata" ) func NewFactory() receiver.Factory { return receiver.NewFactory( - typeStr, + metadata.Type, createDefaultConfig, - receiver.WithLogs(createLogsReceiver, component.StabilityLevelDevelopment), - receiver.WithMetrics(createMetricsReceiver, component.StabilityLevelDevelopment), - receiver.WithTraces(createTracesReceiver, component.StabilityLevelDevelopment), + receiver.WithLogs(createLogsReceiver, metadata.LogsStability), + receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability), + receiver.WithTraces(createTracesReceiver, metadata.TracesStability), ) } diff --git a/receiver/templatereceiver/generated_component_test.go b/receiver/templatereceiver/generated_component_test.go new file mode 100644 index 00000000..ce1cd84a --- /dev/null +++ b/receiver/templatereceiver/generated_component_test.go @@ -0,0 +1,83 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package templatereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" +) + +func TestComponentFactoryType(t *testing.T) { + require.Equal(t, "elasticinframetrics", NewFactory().Type().String()) +} + +func TestComponentConfigStruct(t *testing.T) { + require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig())) +} + +func TestComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(&cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + t.Run(test.name+"-lifecycle", func(t *testing.T) { + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopSettings(), cfg) + require.NoError(t, err) + host := componenttest.NewNopHost() + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/templatereceiver/generated_package_test.go b/receiver/templatereceiver/generated_package_test.go new file mode 100644 index 00000000..e8de0937 --- /dev/null +++ b/receiver/templatereceiver/generated_package_test.go @@ -0,0 +1,12 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package templatereceiver + +import ( + "go.uber.org/goleak" + "testing" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/receiver/templatereceiver/go.mod b/receiver/templatereceiver/go.mod index 522b6949..424a300b 100644 --- a/receiver/templatereceiver/go.mod +++ b/receiver/templatereceiver/go.mod @@ -4,17 +4,25 @@ go 1.22.1 require ( github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 + github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 go.opentelemetry.io/collector/processor v0.105.0 go.opentelemetry.io/collector/receiver v0.105.0 + go.uber.org/goleak v1.3.0 go.uber.org/zap v1.27.0 ) require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect @@ -24,13 +32,22 @@ require ( 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/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.13.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata v1.13.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.28.0 // indirect diff --git a/receiver/templatereceiver/go.sum b/receiver/templatereceiver/go.sum index bbb1ef67..ce320558 100644 --- a/receiver/templatereceiver/go.sum +++ b/receiver/templatereceiver/go.sum @@ -5,6 +5,7 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -63,6 +64,7 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector v0.105.0 h1:Qw/ONVMPT3aD8HjdDRcXCGoZrtSWH3jx4BkwAN1yrEM= go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= @@ -77,6 +79,10 @@ go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6 go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/collector/pdata/pprofile v0.105.0 h1:C+Hd7CNcepL/364OBV9f4lHzJil2jQSOxcEM1PFXGDg= +go.opentelemetry.io/collector/pdata/pprofile v0.105.0/go.mod h1:chr7lMJIzyXkccnPRkIPhyXtqLZLSReZYhwsggOGEfg= +go.opentelemetry.io/collector/pdata/testdata v0.105.0 h1:5sPZzanR4nJR3sNQk3MTdArdEZCK0NRAfC29t0Dtf60= +go.opentelemetry.io/collector/pdata/testdata v0.105.0/go.mod h1:NIfgaclQp/M1BZhgyc/7hDWD+/DumC/OMBQVI2KW+N0= go.opentelemetry.io/collector/processor v0.105.0 h1:LE6wEMWNa3h7eOJLMBm2lA0v6sc2j6Geqv1e3pIWS8Y= go.opentelemetry.io/collector/processor v0.105.0/go.mod h1:QAvMEtd3k+YhRrnaEgs/8e0UueYonuT8Hg4udQOht60= go.opentelemetry.io/collector/receiver v0.105.0 h1:eZF97kMUnKJ20Uc4PaDlgLIGmaA8kyLqhH+vMXjh92U= diff --git a/receiver/templatereceiver/internal/metadata/generated_status.go b/receiver/templatereceiver/internal/metadata/generated_status.go new file mode 100644 index 00000000..84f482c0 --- /dev/null +++ b/receiver/templatereceiver/internal/metadata/generated_status.go @@ -0,0 +1,18 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +var ( + Type = component.MustNewType("elasticinframetrics") + ScopeName = "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" +) + +const ( + LogsStability = component.StabilityLevelDevelopment + MetricsStability = component.StabilityLevelDevelopment + TracesStability = component.StabilityLevelDevelopment +) diff --git a/receiver/templatereceiver/metadata.yml b/receiver/templatereceiver/metadata.yaml similarity index 100% rename from receiver/templatereceiver/metadata.yml rename to receiver/templatereceiver/metadata.yaml From e99d8463d0d0152de6f917be537d243bd4d15c14 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 21 Aug 2024 17:53:43 +0200 Subject: [PATCH 06/20] Fix template receiver type --- receiver/templatereceiver/generated_component_test.go | 2 +- receiver/templatereceiver/internal/metadata/generated_status.go | 2 +- receiver/templatereceiver/metadata.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/receiver/templatereceiver/generated_component_test.go b/receiver/templatereceiver/generated_component_test.go index ce1cd84a..982306db 100644 --- a/receiver/templatereceiver/generated_component_test.go +++ b/receiver/templatereceiver/generated_component_test.go @@ -16,7 +16,7 @@ import ( ) func TestComponentFactoryType(t *testing.T) { - require.Equal(t, "elasticinframetrics", NewFactory().Type().String()) + require.Equal(t, "template", NewFactory().Type().String()) } func TestComponentConfigStruct(t *testing.T) { diff --git a/receiver/templatereceiver/internal/metadata/generated_status.go b/receiver/templatereceiver/internal/metadata/generated_status.go index 84f482c0..da2874e5 100644 --- a/receiver/templatereceiver/internal/metadata/generated_status.go +++ b/receiver/templatereceiver/internal/metadata/generated_status.go @@ -7,7 +7,7 @@ import ( ) var ( - Type = component.MustNewType("elasticinframetrics") + Type = component.MustNewType("template") ScopeName = "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" ) diff --git a/receiver/templatereceiver/metadata.yaml b/receiver/templatereceiver/metadata.yaml index 1fa824ba..a91e2a2d 100644 --- a/receiver/templatereceiver/metadata.yaml +++ b/receiver/templatereceiver/metadata.yaml @@ -1,4 +1,4 @@ -type: elasticinframetrics +type: template status: class: receiver From 43ceb9c3dd93cb429c9f9e78911cabc4c8f0eb3e Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 17 Sep 2024 15:11:44 +0200 Subject: [PATCH 07/20] Rename template to integration --- .../elastic-components/manifest.yaml | 14 ++--- .../Makefile | 0 .../config.go | 2 +- .../doc.go | 4 +- .../extension.go | 18 +++--- .../factory.go | 6 +- .../generated_component_test.go | 4 +- .../generated_package_test.go | 2 +- .../go.mod | 8 +-- .../go.sum | 0 .../internal/metadata/generated_status.go | 4 +- .../metadata.yaml | 2 +- internal/{templates => integrations}/Makefile | 0 internal/{templates => integrations}/go.mod | 2 +- internal/{templates => integrations}/go.sum | 0 .../integrations.go} | 10 ++-- .../Makefile | 0 .../config.go | 2 +- .../confmap.go | 4 +- .../doc.go | 4 +- .../factory.go | 4 +- .../generated_component_test.go | 4 +- .../generated_package_test.go | 2 +- .../go.mod | 6 +- .../go.sum | 0 .../internal/metadata/generated_status.go | 4 +- .../metadata.yaml | 2 +- .../processor.go | 58 +++++++++---------- .../Makefile | 0 .../config.go | 2 +- .../confmap.go | 2 +- .../doc.go | 4 +- .../factory.go | 4 +- .../generated_component_test.go | 4 +- .../generated_package_test.go | 2 +- .../go.mod | 6 +- .../go.sum | 0 .../internal/metadata/generated_status.go | 4 +- .../metadata.yaml | 2 +- .../receiver.go | 50 ++++++++-------- 40 files changed, 123 insertions(+), 123 deletions(-) rename extension/{filetemplateextension => fileintegrationextension}/Makefile (100%) rename extension/{filetemplateextension => fileintegrationextension}/config.go (89%) rename extension/{filetemplateextension => fileintegrationextension}/doc.go (77%) rename extension/{filetemplateextension => fileintegrationextension}/extension.go (78%) rename extension/{filetemplateextension => fileintegrationextension}/factory.go (87%) rename extension/{filetemplateextension => fileintegrationextension}/generated_component_test.go (94%) rename extension/{filetemplateextension => fileintegrationextension}/generated_package_test.go (81%) rename extension/{filetemplateextension => fileintegrationextension}/go.mod (94%) rename extension/{filetemplateextension => fileintegrationextension}/go.sum (100%) rename extension/{filetemplateextension => fileintegrationextension}/internal/metadata/generated_status.go (72%) rename extension/{filetemplateextension => fileintegrationextension}/metadata.yaml (81%) rename internal/{templates => integrations}/Makefile (100%) rename internal/{templates => integrations}/go.mod (98%) rename internal/{templates => integrations}/go.sum (100%) rename internal/{templates/templates.go => integrations/integrations.go} (89%) rename processor/{templateprocessor => integrationprocessor}/Makefile (100%) rename processor/{templateprocessor => integrationprocessor}/config.go (90%) rename processor/{templateprocessor => integrationprocessor}/confmap.go (91%) rename processor/{templateprocessor => integrationprocessor}/doc.go (78%) rename processor/{templateprocessor => integrationprocessor}/factory.go (92%) rename processor/{templateprocessor => integrationprocessor}/generated_component_test.go (98%) rename {receiver/templatereceiver => processor/integrationprocessor}/generated_package_test.go (83%) rename processor/{templateprocessor => integrationprocessor}/go.mod (96%) rename processor/{templateprocessor => integrationprocessor}/go.sum (100%) rename {receiver/templatereceiver => processor/integrationprocessor}/internal/metadata/generated_status.go (81%) rename processor/{templateprocessor => integrationprocessor}/metadata.yaml (86%) rename processor/{templateprocessor => integrationprocessor}/processor.go (76%) rename receiver/{templatereceiver => integrationreceiver}/Makefile (100%) rename receiver/{templatereceiver => integrationreceiver}/config.go (90%) rename receiver/{templatereceiver => integrationreceiver}/confmap.go (93%) rename receiver/{templatereceiver => integrationreceiver}/doc.go (77%) rename receiver/{templatereceiver => integrationreceiver}/factory.go (92%) rename receiver/{templatereceiver => integrationreceiver}/generated_component_test.go (96%) rename {processor/templateprocessor => receiver/integrationreceiver}/generated_package_test.go (84%) rename receiver/{templatereceiver => integrationreceiver}/go.mod (96%) rename receiver/{templatereceiver => integrationreceiver}/go.sum (100%) rename {processor/templateprocessor => receiver/integrationreceiver}/internal/metadata/generated_status.go (81%) rename receiver/{templatereceiver => integrationreceiver}/metadata.yaml (86%) rename receiver/{templatereceiver => integrationreceiver}/receiver.go (82%) diff --git a/distributions/elastic-components/manifest.yaml b/distributions/elastic-components/manifest.yaml index 18404e12..e622196a 100644 --- a/distributions/elastic-components/manifest.yaml +++ b/distributions/elastic-components/manifest.yaml @@ -7,7 +7,7 @@ dist: otelcol_version: 0.109.0 extensions: - - gomod: github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension v0.0.0 + - gomod: github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension v0.0.0 connectors: - gomod: github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 v0.0.0 @@ -15,14 +15,14 @@ connectors: converters: receivers: - - gomod: github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver v0.0.0 + - gomod: github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver v0.0.0 - gomod: go.opentelemetry.io/collector/receiver/nopreceiver v0.109.0 processors: - gomod: github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.0.0 - gomod: github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor v0.0.0 - gomod: github.com/elastic/opentelemetry-collector-components/processor/lsmintervalprocessor v0.0.0 - - gomod: github.com/elastic/opentelemetry-collector-components/processor/templateprocessor v0.0.0 + - gomod: github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor v0.0.0 exporters: - gomod: go.opentelemetry.io/collector/exporter/nopexporter v0.109.0 @@ -38,10 +38,10 @@ providers: replaces: - github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 => ../connector/spanmetricsconnectorv2 - - github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension => ../extension/filetemplateextension - - github.com/elastic/opentelemetry-collector-components/internal/templates => ../internal/templates + - github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension => ../extension/fileintegrationextension + - github.com/elastic/opentelemetry-collector-components/internal/integrations => ../internal/integrations - github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor => ../processor/elasticinframetricsprocessor - github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor => ../processor/elastictraceprocessor - github.com/elastic/opentelemetry-collector-components/processor/lsmintervalprocessor => ../processor/lsmintervalprocessor - - github.com/elastic/opentelemetry-collector-components/processor/templateprocessor => ../processor/templateprocessor - - github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver => ../receiver/templatereceiver + - github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor => ../processor/integrationprocessor + - github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver => ../receiver/integrationreceiver diff --git a/extension/filetemplateextension/Makefile b/extension/fileintegrationextension/Makefile similarity index 100% rename from extension/filetemplateextension/Makefile rename to extension/fileintegrationextension/Makefile diff --git a/extension/filetemplateextension/config.go b/extension/fileintegrationextension/config.go similarity index 89% rename from extension/filetemplateextension/config.go rename to extension/fileintegrationextension/config.go index f3f5b1c1..4278ba30 100644 --- a/extension/filetemplateextension/config.go +++ b/extension/fileintegrationextension/config.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "errors" diff --git a/extension/filetemplateextension/doc.go b/extension/fileintegrationextension/doc.go similarity index 77% rename from extension/filetemplateextension/doc.go rename to extension/fileintegrationextension/doc.go index b0c4d34e..d29492b8 100644 --- a/extension/filetemplateextension/doc.go +++ b/extension/fileintegrationextension/doc.go @@ -17,5 +17,5 @@ //go:generate mdatagen metadata.yaml -// Package filetemplateextension provides a source of templates that obtain them from a local directory. -package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" +// Package fileintegrationextension provides a source of integrations that obtain them from a local directory. +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" diff --git a/extension/filetemplateextension/extension.go b/extension/fileintegrationextension/extension.go similarity index 78% rename from extension/filetemplateextension/extension.go rename to extension/fileintegrationextension/extension.go index 1740350c..0628f49a 100644 --- a/extension/filetemplateextension/extension.go +++ b/extension/fileintegrationextension/extension.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "context" @@ -28,14 +28,14 @@ import ( "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/provider/fileprovider" - "github.com/elastic/opentelemetry-collector-components/internal/templates" + "github.com/elastic/opentelemetry-collector-components/internal/integrations" ) type fileTemplateExtension struct { config *Config } -var _ templates.TemplateFinder = &fileTemplateExtension{} +var _ integrations.TemplateFinder = &fileTemplateExtension{} func newFileTemplateExtension(config *Config) *fileTemplateExtension { return &fileTemplateExtension{ @@ -43,17 +43,17 @@ func newFileTemplateExtension(config *Config) *fileTemplateExtension { } } -func (e *fileTemplateExtension) FindTemplate(ctx context.Context, name, version string) (templates.Template, error) { +func (e *fileTemplateExtension) FindTemplate(ctx context.Context, name, version string) (integrations.Template, error) { path := filepath.Join(e.config.Path, name+".yml") _, err := os.Stat(path) if errors.Is(err, fs.ErrNotExist) { - return nil, templates.ErrNotFound + return nil, integrations.ErrNotFound } if err != nil { return nil, err } - return &templateFile{ + return &integrationFile{ path: path, }, nil } @@ -66,14 +66,14 @@ func (*fileTemplateExtension) Shutdown(context.Context) error { return nil } -type templateFile struct { +type integrationFile struct { path string } -func (t *templateFile) URI() string { +func (t *integrationFile) URI() string { return "file:" + t.path } -func (t *templateFile) ProviderFactory() confmap.ProviderFactory { +func (t *integrationFile) ProviderFactory() confmap.ProviderFactory { return fileprovider.NewFactory() } diff --git a/extension/filetemplateextension/factory.go b/extension/fileintegrationextension/factory.go similarity index 87% rename from extension/filetemplateextension/factory.go rename to extension/fileintegrationextension/factory.go index 3afe2b87..dd21e813 100644 --- a/extension/filetemplateextension/factory.go +++ b/extension/fileintegrationextension/factory.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package filetemplateextension // import "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "context" @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension" - "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension/internal/metadata" + "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension/internal/metadata" ) // NewFactory creates a factory for ack extension. @@ -38,7 +38,7 @@ func NewFactory() extension.Factory { func createDefaultConfig() component.Config { return &Config{ - Path: "templates", + Path: "integrations", } } diff --git a/extension/filetemplateextension/generated_component_test.go b/extension/fileintegrationextension/generated_component_test.go similarity index 94% rename from extension/filetemplateextension/generated_component_test.go rename to extension/fileintegrationextension/generated_component_test.go index 017a8f41..05c61f0d 100644 --- a/extension/filetemplateextension/generated_component_test.go +++ b/extension/fileintegrationextension/generated_component_test.go @@ -1,6 +1,6 @@ // Code generated by mdatagen. DO NOT EDIT. -package filetemplateextension +package fileintegrationextension import ( "context" @@ -13,7 +13,7 @@ import ( ) func TestComponentFactoryType(t *testing.T) { - require.Equal(t, "file_templates", NewFactory().Type().String()) + require.Equal(t, "file_integrations", NewFactory().Type().String()) } func TestComponentConfigStruct(t *testing.T) { diff --git a/extension/filetemplateextension/generated_package_test.go b/extension/fileintegrationextension/generated_package_test.go similarity index 81% rename from extension/filetemplateextension/generated_package_test.go rename to extension/fileintegrationextension/generated_package_test.go index ea816ab1..c02d29ab 100644 --- a/extension/filetemplateextension/generated_package_test.go +++ b/extension/fileintegrationextension/generated_package_test.go @@ -1,6 +1,6 @@ // Code generated by mdatagen. DO NOT EDIT. -package filetemplateextension +package fileintegrationextension import ( "go.uber.org/goleak" diff --git a/extension/filetemplateextension/go.mod b/extension/fileintegrationextension/go.mod similarity index 94% rename from extension/filetemplateextension/go.mod rename to extension/fileintegrationextension/go.mod index 6b09d787..2ae0150a 100644 --- a/extension/filetemplateextension/go.mod +++ b/extension/fileintegrationextension/go.mod @@ -1,9 +1,9 @@ -module github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension +module github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension go 1.22.1 require ( - github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 + github.com/elastic/opentelemetry-collector-components/internal/integrations v0.0.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 @@ -55,6 +55,6 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver => ../../receiver/templatereceiver +replace github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver => ../../receiver/integrationreceiver -replace github.com/elastic/opentelemetry-collector-components/internal/templates => ../../internal/templates +replace github.com/elastic/opentelemetry-collector-components/internal/integrations => ../../internal/integrations diff --git a/extension/filetemplateextension/go.sum b/extension/fileintegrationextension/go.sum similarity index 100% rename from extension/filetemplateextension/go.sum rename to extension/fileintegrationextension/go.sum diff --git a/extension/filetemplateextension/internal/metadata/generated_status.go b/extension/fileintegrationextension/internal/metadata/generated_status.go similarity index 72% rename from extension/filetemplateextension/internal/metadata/generated_status.go rename to extension/fileintegrationextension/internal/metadata/generated_status.go index 6de7fcba..6dad870e 100644 --- a/extension/filetemplateextension/internal/metadata/generated_status.go +++ b/extension/fileintegrationextension/internal/metadata/generated_status.go @@ -7,8 +7,8 @@ import ( ) var ( - Type = component.MustNewType("file_templates") - ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/filetemplateextension" + Type = component.MustNewType("file_integrations") + ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" ) const ( diff --git a/extension/filetemplateextension/metadata.yaml b/extension/fileintegrationextension/metadata.yaml similarity index 81% rename from extension/filetemplateextension/metadata.yaml rename to extension/fileintegrationextension/metadata.yaml index 105db8f8..03d05f0f 100644 --- a/extension/filetemplateextension/metadata.yaml +++ b/extension/fileintegrationextension/metadata.yaml @@ -1,4 +1,4 @@ -type: file_templates +type: file_integrations status: class: extension stability: diff --git a/internal/templates/Makefile b/internal/integrations/Makefile similarity index 100% rename from internal/templates/Makefile rename to internal/integrations/Makefile diff --git a/internal/templates/go.mod b/internal/integrations/go.mod similarity index 98% rename from internal/templates/go.mod rename to internal/integrations/go.mod index 026d2afe..27d852a5 100644 --- a/internal/templates/go.mod +++ b/internal/integrations/go.mod @@ -1,4 +1,4 @@ -module github.com/elastic/opentelemetry-collector-components/internal/templates +module github.com/elastic/opentelemetry-collector-components/internal/integrations go 1.22.1 diff --git a/internal/templates/go.sum b/internal/integrations/go.sum similarity index 100% rename from internal/templates/go.sum rename to internal/integrations/go.sum diff --git a/internal/templates/templates.go b/internal/integrations/integrations.go similarity index 89% rename from internal/templates/templates.go rename to internal/integrations/integrations.go index 7e38402c..142fbd0e 100644 --- a/internal/templates/templates.go +++ b/internal/integrations/integrations.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templates // import "github.com/elastic/opentelemetry-collector-components/internal/templates" +package integrations // import "github.com/elastic/opentelemetry-collector-components/internal/integrations" import ( "context" @@ -48,21 +48,21 @@ func Find(ctx context.Context, logger *zap.Logger, host component.Host, name str } anyExtension = true - template, err := finder.FindTemplate(ctx, name, version) + integration, err := finder.FindTemplate(ctx, name, version) if errors.Is(ErrNotFound, err) { continue } if err != nil { - logger.Error("template finder failed", + logger.Error("integration finder failed", zap.String("component", eid.String()), zap.Error(err)) return nil, err } - return template, nil + return integration, nil } if !anyExtension { - return nil, errors.New("no template finder extension found") + return nil, errors.New("no integration finder extension found") } return nil, ErrNotFound diff --git a/processor/templateprocessor/Makefile b/processor/integrationprocessor/Makefile similarity index 100% rename from processor/templateprocessor/Makefile rename to processor/integrationprocessor/Makefile diff --git a/processor/templateprocessor/config.go b/processor/integrationprocessor/config.go similarity index 90% rename from processor/templateprocessor/config.go rename to processor/integrationprocessor/config.go index 71658d97..a146b8f5 100644 --- a/processor/templateprocessor/config.go +++ b/processor/integrationprocessor/config.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" +package integrationprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor" import ( "errors" diff --git a/processor/templateprocessor/confmap.go b/processor/integrationprocessor/confmap.go similarity index 91% rename from processor/templateprocessor/confmap.go rename to processor/integrationprocessor/confmap.go index 7f5a3240..77b70411 100644 --- a/processor/templateprocessor/confmap.go +++ b/processor/integrationprocessor/confmap.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" +package integrationprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor" import ( "context" @@ -46,7 +46,7 @@ func (p *variablesProvider) Retrieve(ctx context.Context, uri string, _ confmap. key := strings.TrimLeft(uri, varProviderScheme+":") value, found := p.variables[key] if !found { - // FIXME: Resolve relevant configuration only instead of the whole template, so we don't need to ignore + // FIXME: Resolve relevant configuration only instead of the whole integration, so we don't need to ignore // variables not found in unrelevant parts. //return nil, fmt.Errorf("variable %q not found", key) return confmap.NewRetrieved("") diff --git a/processor/templateprocessor/doc.go b/processor/integrationprocessor/doc.go similarity index 78% rename from processor/templateprocessor/doc.go rename to processor/integrationprocessor/doc.go index e5d3d52a..6ac6cdac 100644 --- a/processor/templateprocessor/doc.go +++ b/processor/integrationprocessor/doc.go @@ -17,5 +17,5 @@ //go:generate mdatagen metadata.yaml -// Package templateprocessor provides a processor that creates processors from templates. -package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" +// Package integrationprocessor provides a processor that creates processors from integrations. +package integrationprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor" diff --git a/processor/templateprocessor/factory.go b/processor/integrationprocessor/factory.go similarity index 92% rename from processor/templateprocessor/factory.go rename to processor/integrationprocessor/factory.go index 60e2a37d..754531b7 100644 --- a/processor/templateprocessor/factory.go +++ b/processor/integrationprocessor/factory.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" +package integrationprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor" import ( "context" @@ -24,7 +24,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/processor" - "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor/internal/metadata" + "github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor/internal/metadata" ) func NewFactory() processor.Factory { diff --git a/processor/templateprocessor/generated_component_test.go b/processor/integrationprocessor/generated_component_test.go similarity index 98% rename from processor/templateprocessor/generated_component_test.go rename to processor/integrationprocessor/generated_component_test.go index 868bdbe0..603a8896 100644 --- a/processor/templateprocessor/generated_component_test.go +++ b/processor/integrationprocessor/generated_component_test.go @@ -1,6 +1,6 @@ // Code generated by mdatagen. DO NOT EDIT. -package templateprocessor +package integrationprocessor import ( "context" @@ -21,7 +21,7 @@ import ( ) func TestComponentFactoryType(t *testing.T) { - require.Equal(t, "template", NewFactory().Type().String()) + require.Equal(t, "integration", NewFactory().Type().String()) } func TestComponentConfigStruct(t *testing.T) { diff --git a/receiver/templatereceiver/generated_package_test.go b/processor/integrationprocessor/generated_package_test.go similarity index 83% rename from receiver/templatereceiver/generated_package_test.go rename to processor/integrationprocessor/generated_package_test.go index e8de0937..0e459134 100644 --- a/receiver/templatereceiver/generated_package_test.go +++ b/processor/integrationprocessor/generated_package_test.go @@ -1,6 +1,6 @@ // Code generated by mdatagen. DO NOT EDIT. -package templatereceiver +package integrationprocessor import ( "go.uber.org/goleak" diff --git a/processor/templateprocessor/go.mod b/processor/integrationprocessor/go.mod similarity index 96% rename from processor/templateprocessor/go.mod rename to processor/integrationprocessor/go.mod index 17a8270a..30372b1f 100644 --- a/processor/templateprocessor/go.mod +++ b/processor/integrationprocessor/go.mod @@ -1,9 +1,9 @@ -module github.com/elastic/opentelemetry-collector-components/processor/templateprocessor +module github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor go 1.22.1 require ( - github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 + github.com/elastic/opentelemetry-collector-components/internal/integrations v0.0.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 @@ -60,4 +60,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/elastic/opentelemetry-collector-components/internal/templates => ../../internal/templates +replace github.com/elastic/opentelemetry-collector-components/internal/integrations => ../../internal/integrations diff --git a/processor/templateprocessor/go.sum b/processor/integrationprocessor/go.sum similarity index 100% rename from processor/templateprocessor/go.sum rename to processor/integrationprocessor/go.sum diff --git a/receiver/templatereceiver/internal/metadata/generated_status.go b/processor/integrationprocessor/internal/metadata/generated_status.go similarity index 81% rename from receiver/templatereceiver/internal/metadata/generated_status.go rename to processor/integrationprocessor/internal/metadata/generated_status.go index da2874e5..c7e02580 100644 --- a/receiver/templatereceiver/internal/metadata/generated_status.go +++ b/processor/integrationprocessor/internal/metadata/generated_status.go @@ -7,8 +7,8 @@ import ( ) var ( - Type = component.MustNewType("template") - ScopeName = "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" + Type = component.MustNewType("integration") + ScopeName = "github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor" ) const ( diff --git a/processor/templateprocessor/metadata.yaml b/processor/integrationprocessor/metadata.yaml similarity index 86% rename from processor/templateprocessor/metadata.yaml rename to processor/integrationprocessor/metadata.yaml index 0a7b5ea4..4f9ac992 100644 --- a/processor/templateprocessor/metadata.yaml +++ b/processor/integrationprocessor/metadata.yaml @@ -1,4 +1,4 @@ -type: template +type: integration status: class: processor diff --git a/processor/templateprocessor/processor.go b/processor/integrationprocessor/processor.go similarity index 76% rename from processor/templateprocessor/processor.go rename to processor/integrationprocessor/processor.go index 5eadf7bd..2a14637a 100644 --- a/processor/templateprocessor/processor.go +++ b/processor/integrationprocessor/processor.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templateprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" +package integrationprocessor // import "github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor" import ( "context" @@ -33,10 +33,10 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/processor" - "github.com/elastic/opentelemetry-collector-components/internal/templates" + "github.com/elastic/opentelemetry-collector-components/internal/integrations" ) -type templateProcessor struct { +type integrationProcessor struct { params processor.Settings config *Config components []component.Component @@ -50,24 +50,24 @@ type templateProcessor struct { traces consumer.Traces } -func newTemplateLogsProcessor(params processor.Settings, config *Config, consumer consumer.Logs) *templateProcessor { - return &templateProcessor{ +func newTemplateLogsProcessor(params processor.Settings, config *Config, consumer consumer.Logs) *integrationProcessor { + return &integrationProcessor{ params: params, config: config, nextLogsConsumer: consumer, } } -func newTemplateMetricsProcessor(params processor.Settings, config *Config, consumer consumer.Metrics) *templateProcessor { - return &templateProcessor{ +func newTemplateMetricsProcessor(params processor.Settings, config *Config, consumer consumer.Metrics) *integrationProcessor { + return &integrationProcessor{ params: params, config: config, nextMetricsConsumer: consumer, } } -func newTemplateTracesProcessor(params processor.Settings, config *Config, consumer consumer.Traces) *templateProcessor { - return &templateProcessor{ +func newTemplateTracesProcessor(params processor.Settings, config *Config, consumer consumer.Traces) *integrationProcessor { + return &integrationProcessor{ params: params, config: config, nextTracesConsumer: consumer, @@ -81,37 +81,37 @@ type factoryGetter interface { GetFactory(component.Kind, component.Type) component.Factory } -func (r *templateProcessor) Start(ctx context.Context, ch component.Host) error { +func (r *integrationProcessor) Start(ctx context.Context, ch component.Host) error { host, ok := ch.(factoryGetter) if !ok { - return fmt.Errorf("templateprocessor is not compatible with the provided component.Host") + return fmt.Errorf("integrationprocessor is not compatible with the provided component.Host") } - template, err := templates.Find(ctx, r.params.Logger, host, r.config.Name, r.config.Version) + integration, err := integrations.Find(ctx, r.params.Logger, host, r.config.Name, r.config.Version) if err != nil { - return fmt.Errorf("failed to find template %q: %w", r.config.Name, err) + return fmt.Errorf("failed to find integration %q: %w", r.config.Name, err) } - resolver, err := newResolver(template, r.config.Parameters) + resolver, err := newResolver(integration, r.config.Parameters) if err != nil { return fmt.Errorf("failed to create configuration resolver: %w", err) } conf, err := resolver.Resolve(ctx) if err != nil { - return fmt.Errorf("failed to resolve template %q: %w", r.config.Name, err) + return fmt.Errorf("failed to resolve integration %q: %w", r.config.Name, err) } - var templateConfig templates.Config - err = conf.Unmarshal(&templateConfig) + var integrationConfig integrations.Config + err = conf.Unmarshal(&integrationConfig) if err != nil { - return fmt.Errorf("failed to decode template %q: %w", r.config.Name, err) + return fmt.Errorf("failed to decode integration %q: %w", r.config.Name, err) } selectedPipelines := []component.ID{} if r.config.Pipeline != nil { selectedPipelines = append(selectedPipelines, *r.config.Pipeline) } - pipelines, err := selectComponents(templateConfig.Pipelines, selectedPipelines) + pipelines, err := selectComponents(integrationConfig.Pipelines, selectedPipelines) if err != nil { return fmt.Errorf("failed to select component: %w", err) } @@ -119,7 +119,7 @@ func (r *templateProcessor) Start(ctx context.Context, ch component.Host) error return errors.New("multiple pipelines selected, select only one") } for id, pipeline := range pipelines { - err := r.startPipeline(ctx, host, templateConfig, id, pipeline) + err := r.startPipeline(ctx, host, integrationConfig, id, pipeline) if err != nil { // Shutdown components that had been already started for cleanup. if err := r.Shutdown(ctx); err != nil { @@ -133,7 +133,7 @@ func (r *templateProcessor) Start(ctx context.Context, ch component.Host) error return nil } -func (r *templateProcessor) startPipeline(ctx context.Context, host factoryGetter, config templates.Config, pipelineID component.ID, pipeline templates.PipelineConfig) error { +func (r *integrationProcessor) startPipeline(ctx context.Context, host factoryGetter, config integrations.Config, pipelineID component.ID, pipeline integrations.PipelineConfig) error { r.logs = r.nextLogsConsumer r.metrics = r.nextMetricsConsumer r.traces = r.nextTracesConsumer @@ -195,7 +195,7 @@ func (r *templateProcessor) startPipeline(ctx context.Context, host factoryGette return nil } -func (r *templateProcessor) Shutdown(ctx context.Context) error { +func (r *integrationProcessor) Shutdown(ctx context.Context) error { // Shutdown them in reverse order as they were created. components := slices.Clone(r.components) slices.Reverse(r.components) @@ -209,27 +209,27 @@ func (r *templateProcessor) Shutdown(ctx context.Context) error { return nil } -func (r *templateProcessor) Capabilities() consumer.Capabilities { +func (r *integrationProcessor) Capabilities() consumer.Capabilities { return r.capabilities } -func (r *templateProcessor) ConsumeLogs(ctx context.Context, logs plog.Logs) error { +func (r *integrationProcessor) ConsumeLogs(ctx context.Context, logs plog.Logs) error { return r.logs.ConsumeLogs(ctx, logs) } -func (r *templateProcessor) ConsumeMetrics(ctx context.Context, metrics pmetric.Metrics) error { +func (r *integrationProcessor) ConsumeMetrics(ctx context.Context, metrics pmetric.Metrics) error { return r.metrics.ConsumeMetrics(ctx, metrics) } -func (r *templateProcessor) ConsumeTraces(ctx context.Context, traces ptrace.Traces) error { +func (r *integrationProcessor) ConsumeTraces(ctx context.Context, traces ptrace.Traces) error { return r.traces.ConsumeTraces(ctx, traces) } -func newResolver(template templates.Template, variables map[string]any) (*confmap.Resolver, error) { +func newResolver(integration integrations.Template, variables map[string]any) (*confmap.Resolver, error) { settings := confmap.ResolverSettings{ - URIs: []string{template.URI()}, + URIs: []string{integration.URI()}, ProviderFactories: []confmap.ProviderFactory{ - template.ProviderFactory(), + integration.ProviderFactory(), newVariablesProviderFactory(variables), }, } diff --git a/receiver/templatereceiver/Makefile b/receiver/integrationreceiver/Makefile similarity index 100% rename from receiver/templatereceiver/Makefile rename to receiver/integrationreceiver/Makefile diff --git a/receiver/templatereceiver/config.go b/receiver/integrationreceiver/config.go similarity index 90% rename from receiver/templatereceiver/config.go rename to receiver/integrationreceiver/config.go index 93a4a9d5..666f7a58 100644 --- a/receiver/templatereceiver/config.go +++ b/receiver/integrationreceiver/config.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" +package integrationreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver" import ( "errors" diff --git a/receiver/templatereceiver/confmap.go b/receiver/integrationreceiver/confmap.go similarity index 93% rename from receiver/templatereceiver/confmap.go rename to receiver/integrationreceiver/confmap.go index 4e710471..4bda4145 100644 --- a/receiver/templatereceiver/confmap.go +++ b/receiver/integrationreceiver/confmap.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" +package integrationreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver" import ( "context" diff --git a/receiver/templatereceiver/doc.go b/receiver/integrationreceiver/doc.go similarity index 77% rename from receiver/templatereceiver/doc.go rename to receiver/integrationreceiver/doc.go index afd3b707..57f4d7cf 100644 --- a/receiver/templatereceiver/doc.go +++ b/receiver/integrationreceiver/doc.go @@ -17,5 +17,5 @@ //go:generate mdatagen metadata.yaml -// Package templatereceiver provides a stateless span metrics connector similar to the upstream span metrics connector. -package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" +// Package integrationreceiver provides a stateless span metrics connector similar to the upstream span metrics connector. +package integrationreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver" diff --git a/receiver/templatereceiver/factory.go b/receiver/integrationreceiver/factory.go similarity index 92% rename from receiver/templatereceiver/factory.go rename to receiver/integrationreceiver/factory.go index 0cd63c7d..b780104c 100644 --- a/receiver/templatereceiver/factory.go +++ b/receiver/integrationreceiver/factory.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" +package integrationreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver" import ( "context" @@ -24,7 +24,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/receiver" - "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver/internal/metadata" + "github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver/internal/metadata" ) func NewFactory() receiver.Factory { diff --git a/receiver/templatereceiver/generated_component_test.go b/receiver/integrationreceiver/generated_component_test.go similarity index 96% rename from receiver/templatereceiver/generated_component_test.go rename to receiver/integrationreceiver/generated_component_test.go index 982306db..9543498a 100644 --- a/receiver/templatereceiver/generated_component_test.go +++ b/receiver/integrationreceiver/generated_component_test.go @@ -1,6 +1,6 @@ // Code generated by mdatagen. DO NOT EDIT. -package templatereceiver +package integrationreceiver import ( "context" @@ -16,7 +16,7 @@ import ( ) func TestComponentFactoryType(t *testing.T) { - require.Equal(t, "template", NewFactory().Type().String()) + require.Equal(t, "integration", NewFactory().Type().String()) } func TestComponentConfigStruct(t *testing.T) { diff --git a/processor/templateprocessor/generated_package_test.go b/receiver/integrationreceiver/generated_package_test.go similarity index 84% rename from processor/templateprocessor/generated_package_test.go rename to receiver/integrationreceiver/generated_package_test.go index f7fb2309..c94240d1 100644 --- a/processor/templateprocessor/generated_package_test.go +++ b/receiver/integrationreceiver/generated_package_test.go @@ -1,6 +1,6 @@ // Code generated by mdatagen. DO NOT EDIT. -package templateprocessor +package integrationreceiver import ( "go.uber.org/goleak" diff --git a/receiver/templatereceiver/go.mod b/receiver/integrationreceiver/go.mod similarity index 96% rename from receiver/templatereceiver/go.mod rename to receiver/integrationreceiver/go.mod index 424a300b..3ade221e 100644 --- a/receiver/templatereceiver/go.mod +++ b/receiver/integrationreceiver/go.mod @@ -1,9 +1,9 @@ -module github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver +module github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver go 1.22.1 require ( - github.com/elastic/opentelemetry-collector-components/internal/templates v0.0.0 + github.com/elastic/opentelemetry-collector-components/internal/integrations v0.0.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 @@ -59,4 +59,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/elastic/opentelemetry-collector-components/internal/templates => ../../internal/templates +replace github.com/elastic/opentelemetry-collector-components/internal/integrations => ../../internal/integrations diff --git a/receiver/templatereceiver/go.sum b/receiver/integrationreceiver/go.sum similarity index 100% rename from receiver/templatereceiver/go.sum rename to receiver/integrationreceiver/go.sum diff --git a/processor/templateprocessor/internal/metadata/generated_status.go b/receiver/integrationreceiver/internal/metadata/generated_status.go similarity index 81% rename from processor/templateprocessor/internal/metadata/generated_status.go rename to receiver/integrationreceiver/internal/metadata/generated_status.go index 48b8766d..ffb1a465 100644 --- a/processor/templateprocessor/internal/metadata/generated_status.go +++ b/receiver/integrationreceiver/internal/metadata/generated_status.go @@ -7,8 +7,8 @@ import ( ) var ( - Type = component.MustNewType("template") - ScopeName = "github.com/elastic/opentelemetry-collector-components/processor/templateprocessor" + Type = component.MustNewType("integration") + ScopeName = "github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver" ) const ( diff --git a/receiver/templatereceiver/metadata.yaml b/receiver/integrationreceiver/metadata.yaml similarity index 86% rename from receiver/templatereceiver/metadata.yaml rename to receiver/integrationreceiver/metadata.yaml index a91e2a2d..ffde530b 100644 --- a/receiver/templatereceiver/metadata.yaml +++ b/receiver/integrationreceiver/metadata.yaml @@ -1,4 +1,4 @@ -type: template +type: integration status: class: receiver diff --git a/receiver/templatereceiver/receiver.go b/receiver/integrationreceiver/receiver.go similarity index 82% rename from receiver/templatereceiver/receiver.go rename to receiver/integrationreceiver/receiver.go index 9ba752dc..33b455ef 100644 --- a/receiver/templatereceiver/receiver.go +++ b/receiver/integrationreceiver/receiver.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package templatereceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/templatereceiver" +package integrationreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver" import ( "context" @@ -30,10 +30,10 @@ import ( "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/receiver" - "github.com/elastic/opentelemetry-collector-components/internal/templates" + "github.com/elastic/opentelemetry-collector-components/internal/integrations" ) -type templateReceiver struct { +type integrationReceiver struct { params receiver.Settings config *Config components []component.Component @@ -42,24 +42,24 @@ type templateReceiver struct { nextTracesConsumer consumer.Traces } -func newTemplateLogsReceiver(params receiver.Settings, config *Config, consumer consumer.Logs) *templateReceiver { - return &templateReceiver{ +func newTemplateLogsReceiver(params receiver.Settings, config *Config, consumer consumer.Logs) *integrationReceiver { + return &integrationReceiver{ params: params, config: config, nextLogsConsumer: consumer, } } -func newTemplateMetricsReceiver(params receiver.Settings, config *Config, consumer consumer.Metrics) *templateReceiver { - return &templateReceiver{ +func newTemplateMetricsReceiver(params receiver.Settings, config *Config, consumer consumer.Metrics) *integrationReceiver { + return &integrationReceiver{ params: params, config: config, nextMetricsConsumer: consumer, } } -func newTemplateTracesReceiver(params receiver.Settings, config *Config, consumer consumer.Traces) *templateReceiver { - return &templateReceiver{ +func newTemplateTracesReceiver(params receiver.Settings, config *Config, consumer consumer.Traces) *integrationReceiver { + return &integrationReceiver{ params: params, config: config, nextTracesConsumer: consumer, @@ -73,38 +73,38 @@ type factoryGetter interface { GetFactory(component.Kind, component.Type) component.Factory } -func (r *templateReceiver) Start(ctx context.Context, ch component.Host) error { +func (r *integrationReceiver) Start(ctx context.Context, ch component.Host) error { host, ok := ch.(factoryGetter) if !ok { - return fmt.Errorf("templatereceiver is not compatible with the provided component.Host") + return fmt.Errorf("integrationreceiver is not compatible with the provided component.Host") } - template, err := templates.Find(ctx, r.params.Logger, host, r.config.Name, r.config.Version) + integration, err := integrations.Find(ctx, r.params.Logger, host, r.config.Name, r.config.Version) if err != nil { - return fmt.Errorf("failed to find template %q: %w", r.config.Name, err) + return fmt.Errorf("failed to find integration %q: %w", r.config.Name, err) } - resolver, err := newResolver(template, r.config.Parameters) + resolver, err := newResolver(integration, r.config.Parameters) if err != nil { return fmt.Errorf("failed to create configuration resolver: %w", err) } conf, err := resolver.Resolve(ctx) if err != nil { - return fmt.Errorf("failed to resolve template %q: %w", r.config.Name, err) + return fmt.Errorf("failed to resolve integration %q: %w", r.config.Name, err) } - var templateConfig templates.Config - err = conf.Unmarshal(&templateConfig) + var integrationConfig integrations.Config + err = conf.Unmarshal(&integrationConfig) if err != nil { - return fmt.Errorf("failed to decode template %q: %w", r.config.Name, err) + return fmt.Errorf("failed to decode integration %q: %w", r.config.Name, err) } - pipelines, err := selectComponents(templateConfig.Pipelines, r.config.Pipelines) + pipelines, err := selectComponents(integrationConfig.Pipelines, r.config.Pipelines) if err != nil { return fmt.Errorf("failed to select component: %w", err) } for id, pipeline := range pipelines { - err := r.startPipeline(ctx, host, templateConfig, id, pipeline) + err := r.startPipeline(ctx, host, integrationConfig, id, pipeline) if err != nil { // Shutdown components that had been already started for cleanup. if err := r.Shutdown(ctx); err != nil { @@ -118,7 +118,7 @@ func (r *templateReceiver) Start(ctx context.Context, ch component.Host) error { return nil } -func (r *templateReceiver) startPipeline(ctx context.Context, host factoryGetter, config templates.Config, pipelineID component.ID, pipeline templates.PipelineConfig) error { +func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGetter, config integrations.Config, pipelineID component.ID, pipeline integrations.PipelineConfig) error { consumerChain := struct { logs consumer.Logs metrics consumer.Metrics @@ -226,7 +226,7 @@ func (r *templateReceiver) startPipeline(ctx context.Context, host factoryGetter return nil } -func (r *templateReceiver) Shutdown(ctx context.Context) error { +func (r *integrationReceiver) Shutdown(ctx context.Context) error { // Shutdown them in reverse order as they were created. components := slices.Clone(r.components) slices.Reverse(r.components) @@ -240,11 +240,11 @@ func (r *templateReceiver) Shutdown(ctx context.Context) error { return nil } -func newResolver(template templates.Template, variables map[string]any) (*confmap.Resolver, error) { +func newResolver(integration integrations.Template, variables map[string]any) (*confmap.Resolver, error) { settings := confmap.ResolverSettings{ - URIs: []string{template.URI()}, + URIs: []string{integration.URI()}, ProviderFactories: []confmap.ProviderFactory{ - template.ProviderFactory(), + integration.ProviderFactory(), newVariablesProviderFactory(variables), }, } From cfc7369ff71fb60103f392f2f1241542b3208dec Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 17 Sep 2024 15:17:24 +0200 Subject: [PATCH 08/20] Add license headers to generated files --- .../generated_component_test.go | 17 +++++++++++++++++ .../generated_package_test.go | 17 +++++++++++++++++ .../internal/metadata/generated_status.go | 17 +++++++++++++++++ .../generated_component_test.go | 17 +++++++++++++++++ .../generated_package_test.go | 17 +++++++++++++++++ .../internal/metadata/generated_status.go | 17 +++++++++++++++++ .../generated_component_test.go | 17 +++++++++++++++++ .../generated_package_test.go | 17 +++++++++++++++++ .../internal/metadata/generated_status.go | 17 +++++++++++++++++ 9 files changed, 153 insertions(+) diff --git a/extension/fileintegrationextension/generated_component_test.go b/extension/fileintegrationextension/generated_component_test.go index 05c61f0d..0481d412 100644 --- a/extension/fileintegrationextension/generated_component_test.go +++ b/extension/fileintegrationextension/generated_component_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package fileintegrationextension diff --git a/extension/fileintegrationextension/generated_package_test.go b/extension/fileintegrationextension/generated_package_test.go index c02d29ab..0fa38606 100644 --- a/extension/fileintegrationextension/generated_package_test.go +++ b/extension/fileintegrationextension/generated_package_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package fileintegrationextension diff --git a/extension/fileintegrationextension/internal/metadata/generated_status.go b/extension/fileintegrationextension/internal/metadata/generated_status.go index 6dad870e..eb5b024e 100644 --- a/extension/fileintegrationextension/internal/metadata/generated_status.go +++ b/extension/fileintegrationextension/internal/metadata/generated_status.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package metadata diff --git a/processor/integrationprocessor/generated_component_test.go b/processor/integrationprocessor/generated_component_test.go index 603a8896..88372d25 100644 --- a/processor/integrationprocessor/generated_component_test.go +++ b/processor/integrationprocessor/generated_component_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package integrationprocessor diff --git a/processor/integrationprocessor/generated_package_test.go b/processor/integrationprocessor/generated_package_test.go index 0e459134..9202c4fe 100644 --- a/processor/integrationprocessor/generated_package_test.go +++ b/processor/integrationprocessor/generated_package_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package integrationprocessor diff --git a/processor/integrationprocessor/internal/metadata/generated_status.go b/processor/integrationprocessor/internal/metadata/generated_status.go index c7e02580..1466a78d 100644 --- a/processor/integrationprocessor/internal/metadata/generated_status.go +++ b/processor/integrationprocessor/internal/metadata/generated_status.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package metadata diff --git a/receiver/integrationreceiver/generated_component_test.go b/receiver/integrationreceiver/generated_component_test.go index 9543498a..5dd4d437 100644 --- a/receiver/integrationreceiver/generated_component_test.go +++ b/receiver/integrationreceiver/generated_component_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package integrationreceiver diff --git a/receiver/integrationreceiver/generated_package_test.go b/receiver/integrationreceiver/generated_package_test.go index c94240d1..1b0bf835 100644 --- a/receiver/integrationreceiver/generated_package_test.go +++ b/receiver/integrationreceiver/generated_package_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package integrationreceiver diff --git a/receiver/integrationreceiver/internal/metadata/generated_status.go b/receiver/integrationreceiver/internal/metadata/generated_status.go index ffb1a465..f1bbc66d 100644 --- a/receiver/integrationreceiver/internal/metadata/generated_status.go +++ b/receiver/integrationreceiver/internal/metadata/generated_status.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by mdatagen. DO NOT EDIT. package metadata From faa1035c6d670da6b912b89fab1bf517aa53a59e Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 18 Sep 2024 14:43:14 +0200 Subject: [PATCH 09/20] Remove lifecycle tests by now --- .../generated_component_test.go | 38 ------------------- processor/integrationprocessor/metadata.yaml | 3 ++ .../generated_component_test.go | 12 ------ receiver/integrationreceiver/metadata.yaml | 3 ++ 4 files changed, 6 insertions(+), 50 deletions(-) diff --git a/processor/integrationprocessor/generated_component_test.go b/processor/integrationprocessor/generated_component_test.go index 88372d25..61bf82a9 100644 --- a/processor/integrationprocessor/generated_component_test.go +++ b/processor/integrationprocessor/generated_component_test.go @@ -89,44 +89,6 @@ func TestComponentLifecycle(t *testing.T) { err = c.Shutdown(context.Background()) require.NoError(t, err) }) - t.Run(test.name+"-lifecycle", func(t *testing.T) { - c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg) - require.NoError(t, err) - host := componenttest.NewNopHost() - err = c.Start(context.Background(), host) - require.NoError(t, err) - require.NotPanics(t, func() { - switch test.name { - case "logs": - e, ok := c.(processor.Logs) - require.True(t, ok) - logs := generateLifecycleTestLogs() - if !e.Capabilities().MutatesData { - logs.MarkReadOnly() - } - err = e.ConsumeLogs(context.Background(), logs) - case "metrics": - e, ok := c.(processor.Metrics) - require.True(t, ok) - metrics := generateLifecycleTestMetrics() - if !e.Capabilities().MutatesData { - metrics.MarkReadOnly() - } - err = e.ConsumeMetrics(context.Background(), metrics) - case "traces": - e, ok := c.(processor.Traces) - require.True(t, ok) - traces := generateLifecycleTestTraces() - if !e.Capabilities().MutatesData { - traces.MarkReadOnly() - } - err = e.ConsumeTraces(context.Background(), traces) - } - }) - require.NoError(t, err) - err = c.Shutdown(context.Background()) - require.NoError(t, err) - }) } } diff --git a/processor/integrationprocessor/metadata.yaml b/processor/integrationprocessor/metadata.yaml index 4f9ac992..b371f64e 100644 --- a/processor/integrationprocessor/metadata.yaml +++ b/processor/integrationprocessor/metadata.yaml @@ -6,3 +6,6 @@ status: development: [logs, metrics, traces] codeowners: active: [jsoriano] + +tests: + skip_lifecycle: true # It depends on other processors to be available. diff --git a/receiver/integrationreceiver/generated_component_test.go b/receiver/integrationreceiver/generated_component_test.go index 5dd4d437..7e07c43b 100644 --- a/receiver/integrationreceiver/generated_component_test.go +++ b/receiver/integrationreceiver/generated_component_test.go @@ -84,17 +84,5 @@ func TestComponentLifecycle(t *testing.T) { err = c.Shutdown(context.Background()) require.NoError(t, err) }) - t.Run(test.name+"-lifecycle", func(t *testing.T) { - firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopSettings(), cfg) - require.NoError(t, err) - host := componenttest.NewNopHost() - require.NoError(t, err) - require.NoError(t, firstRcvr.Start(context.Background(), host)) - require.NoError(t, firstRcvr.Shutdown(context.Background())) - secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopSettings(), cfg) - require.NoError(t, err) - require.NoError(t, secondRcvr.Start(context.Background(), host)) - require.NoError(t, secondRcvr.Shutdown(context.Background())) - }) } } diff --git a/receiver/integrationreceiver/metadata.yaml b/receiver/integrationreceiver/metadata.yaml index ffde530b..5fd96a55 100644 --- a/receiver/integrationreceiver/metadata.yaml +++ b/receiver/integrationreceiver/metadata.yaml @@ -6,3 +6,6 @@ status: development: [logs, metrics, traces] codeowners: active: [jsoriano] + +tests: + skip_lifecycle: true # It depends on other receivers to be available. From 9a202e839a722e9e128bfb5eb14fe3e3e5ca8898 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Mon, 23 Sep 2024 17:14:22 +0200 Subject: [PATCH 10/20] Add a new provider for integrations as raw configuration --- .../elastic-components/manifest.yaml | 6 +- extension/configintegrationextension/Makefile | 1 + .../configintegrationextension/config.go | 26 ++++ extension/configintegrationextension/doc.go | 21 +++ .../configintegrationextension/extension.go | 89 ++++++++++++ .../configintegrationextension/factory.go | 45 ++++++ .../generated_component_test.go | 66 +++++++++ .../generated_package_test.go | 29 ++++ extension/configintegrationextension/go.mod | 60 ++++++++ extension/configintegrationextension/go.sum | 131 ++++++++++++++++++ .../internal/metadata/generated_status.go | 33 +++++ .../configintegrationextension/metadata.yaml | 7 + extension/fileintegrationextension/config.go | 2 +- extension/fileintegrationextension/doc.go | 4 +- .../fileintegrationextension/extension.go | 2 +- extension/fileintegrationextension/factory.go | 4 +- .../generated_component_test.go | 2 +- .../generated_package_test.go | 2 +- extension/fileintegrationextension/go.mod | 2 +- .../internal/metadata/generated_status.go | 2 +- 20 files changed, 522 insertions(+), 12 deletions(-) create mode 100644 extension/configintegrationextension/Makefile create mode 100644 extension/configintegrationextension/config.go create mode 100644 extension/configintegrationextension/doc.go create mode 100644 extension/configintegrationextension/extension.go create mode 100644 extension/configintegrationextension/factory.go create mode 100644 extension/configintegrationextension/generated_component_test.go create mode 100644 extension/configintegrationextension/generated_package_test.go create mode 100644 extension/configintegrationextension/go.mod create mode 100644 extension/configintegrationextension/go.sum create mode 100644 extension/configintegrationextension/internal/metadata/generated_status.go create mode 100644 extension/configintegrationextension/metadata.yaml diff --git a/distributions/elastic-components/manifest.yaml b/distributions/elastic-components/manifest.yaml index e622196a..780155b7 100644 --- a/distributions/elastic-components/manifest.yaml +++ b/distributions/elastic-components/manifest.yaml @@ -7,7 +7,8 @@ dist: otelcol_version: 0.109.0 extensions: - - gomod: github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension v0.0.0 + - gomod: github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension v0.0.0 + - gomod: github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension v0.0.0 connectors: - gomod: github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 v0.0.0 @@ -38,7 +39,8 @@ providers: replaces: - github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 => ../connector/spanmetricsconnectorv2 - - github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension => ../extension/fileintegrationextension + - github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension => ../extension/configintegrationextension + - github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension => ../extension/fileintegrationextension - github.com/elastic/opentelemetry-collector-components/internal/integrations => ../internal/integrations - github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor => ../processor/elasticinframetricsprocessor - github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor => ../processor/elastictraceprocessor diff --git a/extension/configintegrationextension/Makefile b/extension/configintegrationextension/Makefile new file mode 100644 index 00000000..ded7a360 --- /dev/null +++ b/extension/configintegrationextension/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/extension/configintegrationextension/config.go b/extension/configintegrationextension/config.go new file mode 100644 index 00000000..b806b911 --- /dev/null +++ b/extension/configintegrationextension/config.go @@ -0,0 +1,26 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" + +type Config struct { + Integrations map[string]string `mapstructure:"integrations"` +} + +func (c *Config) Validate() error { + return nil +} diff --git a/extension/configintegrationextension/doc.go b/extension/configintegrationextension/doc.go new file mode 100644 index 00000000..b0a6af7a --- /dev/null +++ b/extension/configintegrationextension/doc.go @@ -0,0 +1,21 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:generate mdatagen metadata.yaml + +// Package configintegrationextension provides a source of integrations that obtain them from a local directory. +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" diff --git a/extension/configintegrationextension/extension.go b/extension/configintegrationextension/extension.go new file mode 100644 index 00000000..6b999ce6 --- /dev/null +++ b/extension/configintegrationextension/extension.go @@ -0,0 +1,89 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" + +import ( + "context" + "strings" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap" + + "github.com/elastic/opentelemetry-collector-components/internal/integrations" +) + +type configTemplateExtension struct { + config *Config +} + +var _ integrations.TemplateFinder = &configTemplateExtension{} + +func newConfigTemplateExtension(config *Config) *configTemplateExtension { + return &configTemplateExtension{ + config: config, + } +} + +func (e *configTemplateExtension) FindTemplate(ctx context.Context, name, version string) (integrations.Template, error) { + integration, found := e.config.Integrations[name] + if !found { + return nil, integrations.ErrNotFound + } + + return &integrationConfig{ + name: name, + integration: strings.ReplaceAll(integration, `$$`, `$`), + }, nil +} + +func (*configTemplateExtension) Start(context.Context, component.Host) error { + return nil +} + +func (*configTemplateExtension) Shutdown(context.Context) error { + return nil +} + +type integrationConfig struct { + name string + integration string +} + +func (t *integrationConfig) URI() string { + return t.Scheme() + ":" + t.name +} + +func (t *integrationConfig) ProviderFactory() confmap.ProviderFactory { + return t +} + +func (t *integrationConfig) Create(_ confmap.ProviderSettings) confmap.Provider { + return t +} + +func (t *integrationConfig) Retrieve(ctx context.Context, _ string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) { + return confmap.NewRetrievedFromYAML([]byte(t.integration)) +} + +func (t *integrationConfig) Scheme() string { + return "config" +} + +func (t *integrationConfig) Shutdown(ctx context.Context) error { + return nil +} diff --git a/extension/configintegrationextension/factory.go b/extension/configintegrationextension/factory.go new file mode 100644 index 00000000..5a022dd7 --- /dev/null +++ b/extension/configintegrationextension/factory.go @@ -0,0 +1,45 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" + +import ( + "context" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/extension" + + "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension/internal/metadata" +) + +// NewFactory creates a factory for ack extension. +func NewFactory() extension.Factory { + return extension.NewFactory( + metadata.Type, + createDefaultConfig, + createExtension, + metadata.ExtensionStability, + ) +} + +func createDefaultConfig() component.Config { + return &Config{} +} + +func createExtension(_ context.Context, _ extension.Settings, cfg component.Config) (extension.Extension, error) { + return newConfigTemplateExtension(cfg.(*Config)), nil +} diff --git a/extension/configintegrationextension/generated_component_test.go b/extension/configintegrationextension/generated_component_test.go new file mode 100644 index 00000000..9dfe4d00 --- /dev/null +++ b/extension/configintegrationextension/generated_component_test.go @@ -0,0 +1,66 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by mdatagen. DO NOT EDIT. + +package configintegrationextension + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" + "go.opentelemetry.io/collector/extension/extensiontest" +) + +func TestComponentFactoryType(t *testing.T) { + require.Equal(t, "config_integrations", NewFactory().Type().String()) +} + +func TestComponentConfigStruct(t *testing.T) { + require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig())) +} + +func TestComponentLifecycle(t *testing.T) { + factory := NewFactory() + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(&cfg)) + t.Run("shutdown", func(t *testing.T) { + e, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + require.NoError(t, err) + err = e.Shutdown(context.Background()) + require.NoError(t, err) + }) + t.Run("lifecycle", func(t *testing.T) { + firstExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + require.NoError(t, err) + require.NoError(t, firstExt.Start(context.Background(), componenttest.NewNopHost())) + require.NoError(t, firstExt.Shutdown(context.Background())) + + secondExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondExt.Start(context.Background(), componenttest.NewNopHost())) + require.NoError(t, secondExt.Shutdown(context.Background())) + }) +} diff --git a/extension/configintegrationextension/generated_package_test.go b/extension/configintegrationextension/generated_package_test.go new file mode 100644 index 00000000..9dbdf80d --- /dev/null +++ b/extension/configintegrationextension/generated_package_test.go @@ -0,0 +1,29 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by mdatagen. DO NOT EDIT. + +package configintegrationextension + +import ( + "go.uber.org/goleak" + "testing" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/extension/configintegrationextension/go.mod b/extension/configintegrationextension/go.mod new file mode 100644 index 00000000..5f837f1c --- /dev/null +++ b/extension/configintegrationextension/go.mod @@ -0,0 +1,60 @@ +module github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension + +go 1.22.1 + +require ( + github.com/elastic/opentelemetry-collector-components/internal/integrations v0.0.0 + github.com/stretchr/testify v1.9.0 + go.opentelemetry.io/collector/component v0.105.0 + go.opentelemetry.io/collector/confmap v0.105.0 + go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 + go.opentelemetry.io/collector/extension v0.105.0 + go.uber.org/goleak v1.3.0 +) + +require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/knadh/koanf/maps v0.1.1 // indirect + github.com/knadh/koanf/providers/confmap v0.1.0 // indirect + github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/featuregate v1.13.0 // indirect + go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata v1.13.0 // indirect + go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver => ../../receiver/integrationreceiver + +replace github.com/elastic/opentelemetry-collector-components/internal/integrations => ../../internal/integrations diff --git a/extension/configintegrationextension/go.sum b/extension/configintegrationextension/go.sum new file mode 100644 index 00000000..cd15f84b --- /dev/null +++ b/extension/configintegrationextension/go.sum @@ -0,0 +1,131 @@ +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/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +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/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= +github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= +github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= +github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= +github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= +github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +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/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= +go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= +go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= +go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= +go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= +go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 h1:RgQwEbJgx+BihDt8yhiqmEi8IjQYFwbzsYRcTzvM7E4= +go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0/go.mod h1:P7oT+6eaMv+ZyPSu6SEKalfR/UALdQgE3hq36b0Iww4= +go.opentelemetry.io/collector/extension v0.105.0 h1:R8i4HMvuSm20Nt3onyrLk19KKhjCNAsgS8FGh60rcZU= +go.opentelemetry.io/collector/extension v0.105.0/go.mod h1:oyX960URG27esNKitf3o2rqcBj0ajcx+dxkCxwRz34U= +go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= +go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= +go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= +go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= +go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= +go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +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/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/extension/configintegrationextension/internal/metadata/generated_status.go b/extension/configintegrationextension/internal/metadata/generated_status.go new file mode 100644 index 00000000..931a8c1a --- /dev/null +++ b/extension/configintegrationextension/internal/metadata/generated_status.go @@ -0,0 +1,33 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +var ( + Type = component.MustNewType("config_integrations") + ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" +) + +const ( + ExtensionStability = component.StabilityLevelDevelopment +) diff --git a/extension/configintegrationextension/metadata.yaml b/extension/configintegrationextension/metadata.yaml new file mode 100644 index 00000000..b80e81d7 --- /dev/null +++ b/extension/configintegrationextension/metadata.yaml @@ -0,0 +1,7 @@ +type: config_integrations +status: + class: extension + stability: + development: [extension] + codeowners: + active: [jsoriano] diff --git a/extension/fileintegrationextension/config.go b/extension/fileintegrationextension/config.go index 4278ba30..20f59541 100644 --- a/extension/fileintegrationextension/config.go +++ b/extension/fileintegrationextension/config.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "errors" diff --git a/extension/fileintegrationextension/doc.go b/extension/fileintegrationextension/doc.go index d29492b8..69b4a111 100644 --- a/extension/fileintegrationextension/doc.go +++ b/extension/fileintegrationextension/doc.go @@ -17,5 +17,5 @@ //go:generate mdatagen metadata.yaml -// Package fileintegrationextension provides a source of integrations that obtain them from a local directory. -package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +// Package configintegrationextension provides a source of integrations that obtain them from a local directory. +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" diff --git a/extension/fileintegrationextension/extension.go b/extension/fileintegrationextension/extension.go index 0628f49a..8cd5d150 100644 --- a/extension/fileintegrationextension/extension.go +++ b/extension/fileintegrationextension/extension.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "context" diff --git a/extension/fileintegrationextension/factory.go b/extension/fileintegrationextension/factory.go index dd21e813..158b5536 100644 --- a/extension/fileintegrationextension/factory.go +++ b/extension/fileintegrationextension/factory.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "context" @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension" - "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension/internal/metadata" + "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension/internal/metadata" ) // NewFactory creates a factory for ack extension. diff --git a/extension/fileintegrationextension/generated_component_test.go b/extension/fileintegrationextension/generated_component_test.go index 0481d412..c75c947b 100644 --- a/extension/fileintegrationextension/generated_component_test.go +++ b/extension/fileintegrationextension/generated_component_test.go @@ -17,7 +17,7 @@ // Code generated by mdatagen. DO NOT EDIT. -package fileintegrationextension +package configintegrationextension import ( "context" diff --git a/extension/fileintegrationextension/generated_package_test.go b/extension/fileintegrationextension/generated_package_test.go index 0fa38606..9dbdf80d 100644 --- a/extension/fileintegrationextension/generated_package_test.go +++ b/extension/fileintegrationextension/generated_package_test.go @@ -17,7 +17,7 @@ // Code generated by mdatagen. DO NOT EDIT. -package fileintegrationextension +package configintegrationextension import ( "go.uber.org/goleak" diff --git a/extension/fileintegrationextension/go.mod b/extension/fileintegrationextension/go.mod index 2ae0150a..5f837f1c 100644 --- a/extension/fileintegrationextension/go.mod +++ b/extension/fileintegrationextension/go.mod @@ -1,4 +1,4 @@ -module github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension +module github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension go 1.22.1 diff --git a/extension/fileintegrationextension/internal/metadata/generated_status.go b/extension/fileintegrationextension/internal/metadata/generated_status.go index eb5b024e..8e09bcca 100644 --- a/extension/fileintegrationextension/internal/metadata/generated_status.go +++ b/extension/fileintegrationextension/internal/metadata/generated_status.go @@ -25,7 +25,7 @@ import ( var ( Type = component.MustNewType("file_integrations") - ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" + ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" ) const ( From 49324a563b49af5c6f6c6c836402ae42971636eb Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 24 Sep 2024 10:41:51 +0200 Subject: [PATCH 11/20] Fix imports --- Makefile | 4 ++-- extension/fileintegrationextension/config.go | 2 +- extension/fileintegrationextension/doc.go | 2 +- extension/fileintegrationextension/extension.go | 2 +- extension/fileintegrationextension/factory.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 61c80134..7db9d4d3 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ include ./Makefile.Common ALL_DOC := $(shell find . \( -name "*.md" -o -name "*.yaml" \) \ -type f | sort) -# ALL_MODULES includes ./* dirs (excludes . dir) -ALL_MODULES := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort | grep -E '^./' ) +# ALL_MODULES includes ./* dirs (excludes . and ./_build dirs) +ALL_MODULES := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort | grep -E '^./' | grep -v '^./_build') GROUP ?= all FOR_GROUP_TARGET=for-$(GROUP)-target diff --git a/extension/fileintegrationextension/config.go b/extension/fileintegrationextension/config.go index 20f59541..73e41019 100644 --- a/extension/fileintegrationextension/config.go +++ b/extension/fileintegrationextension/config.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" import ( "errors" diff --git a/extension/fileintegrationextension/doc.go b/extension/fileintegrationextension/doc.go index 69b4a111..b0a6af7a 100644 --- a/extension/fileintegrationextension/doc.go +++ b/extension/fileintegrationextension/doc.go @@ -18,4 +18,4 @@ //go:generate mdatagen metadata.yaml // Package configintegrationextension provides a source of integrations that obtain them from a local directory. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" diff --git a/extension/fileintegrationextension/extension.go b/extension/fileintegrationextension/extension.go index 8cd5d150..c3ba92f3 100644 --- a/extension/fileintegrationextension/extension.go +++ b/extension/fileintegrationextension/extension.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" import ( "context" diff --git a/extension/fileintegrationextension/factory.go b/extension/fileintegrationextension/factory.go index 158b5536..05c79f0b 100644 --- a/extension/fileintegrationextension/factory.go +++ b/extension/fileintegrationextension/factory.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" +package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" import ( "context" From 860419df31cc1a4b86bad2c2e57312a37949bf3a Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 24 Sep 2024 10:48:25 +0200 Subject: [PATCH 12/20] Fix wrong replaces --- extension/fileintegrationextension/config.go | 2 +- extension/fileintegrationextension/doc.go | 4 ++-- extension/fileintegrationextension/extension.go | 2 +- extension/fileintegrationextension/factory.go | 4 ++-- .../fileintegrationextension/generated_component_test.go | 2 +- extension/fileintegrationextension/generated_package_test.go | 2 +- extension/fileintegrationextension/go.mod | 2 +- .../internal/metadata/generated_status.go | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/extension/fileintegrationextension/config.go b/extension/fileintegrationextension/config.go index 73e41019..4278ba30 100644 --- a/extension/fileintegrationextension/config.go +++ b/extension/fileintegrationextension/config.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "errors" diff --git a/extension/fileintegrationextension/doc.go b/extension/fileintegrationextension/doc.go index b0a6af7a..d29492b8 100644 --- a/extension/fileintegrationextension/doc.go +++ b/extension/fileintegrationextension/doc.go @@ -17,5 +17,5 @@ //go:generate mdatagen metadata.yaml -// Package configintegrationextension provides a source of integrations that obtain them from a local directory. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" +// Package fileintegrationextension provides a source of integrations that obtain them from a local directory. +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" diff --git a/extension/fileintegrationextension/extension.go b/extension/fileintegrationextension/extension.go index c3ba92f3..0628f49a 100644 --- a/extension/fileintegrationextension/extension.go +++ b/extension/fileintegrationextension/extension.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "context" diff --git a/extension/fileintegrationextension/factory.go b/extension/fileintegrationextension/factory.go index 05c79f0b..dd21e813 100644 --- a/extension/fileintegrationextension/factory.go +++ b/extension/fileintegrationextension/factory.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" +package fileintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" import ( "context" @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension" - "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension/internal/metadata" + "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension/internal/metadata" ) // NewFactory creates a factory for ack extension. diff --git a/extension/fileintegrationextension/generated_component_test.go b/extension/fileintegrationextension/generated_component_test.go index c75c947b..0481d412 100644 --- a/extension/fileintegrationextension/generated_component_test.go +++ b/extension/fileintegrationextension/generated_component_test.go @@ -17,7 +17,7 @@ // Code generated by mdatagen. DO NOT EDIT. -package configintegrationextension +package fileintegrationextension import ( "context" diff --git a/extension/fileintegrationextension/generated_package_test.go b/extension/fileintegrationextension/generated_package_test.go index 9dbdf80d..0fa38606 100644 --- a/extension/fileintegrationextension/generated_package_test.go +++ b/extension/fileintegrationextension/generated_package_test.go @@ -17,7 +17,7 @@ // Code generated by mdatagen. DO NOT EDIT. -package configintegrationextension +package fileintegrationextension import ( "go.uber.org/goleak" diff --git a/extension/fileintegrationextension/go.mod b/extension/fileintegrationextension/go.mod index 5f837f1c..2ae0150a 100644 --- a/extension/fileintegrationextension/go.mod +++ b/extension/fileintegrationextension/go.mod @@ -1,4 +1,4 @@ -module github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension +module github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension go 1.22.1 diff --git a/extension/fileintegrationextension/internal/metadata/generated_status.go b/extension/fileintegrationextension/internal/metadata/generated_status.go index 8e09bcca..eb5b024e 100644 --- a/extension/fileintegrationextension/internal/metadata/generated_status.go +++ b/extension/fileintegrationextension/internal/metadata/generated_status.go @@ -25,7 +25,7 @@ import ( var ( Type = component.MustNewType("file_integrations") - ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension" + ScopeName = "github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension" ) const ( From 781f96f7476408768666794a18b66ff4d463dc3d Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 24 Sep 2024 10:54:05 +0200 Subject: [PATCH 13/20] Go mod tidy --- distributions/elastic-components/manifest.yaml | 4 ++-- extension/configintegrationextension/go.mod | 1 - extension/configintegrationextension/go.sum | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/distributions/elastic-components/manifest.yaml b/distributions/elastic-components/manifest.yaml index 780155b7..b3103557 100644 --- a/distributions/elastic-components/manifest.yaml +++ b/distributions/elastic-components/manifest.yaml @@ -8,7 +8,7 @@ dist: extensions: - gomod: github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension v0.0.0 - - gomod: github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension v0.0.0 + - gomod: github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension v0.0.0 connectors: - gomod: github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 v0.0.0 @@ -40,7 +40,7 @@ providers: replaces: - github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 => ../connector/spanmetricsconnectorv2 - github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension => ../extension/configintegrationextension - - github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension => ../extension/fileintegrationextension + - github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension => ../extension/fileintegrationextension - github.com/elastic/opentelemetry-collector-components/internal/integrations => ../internal/integrations - github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor => ../processor/elasticinframetricsprocessor - github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor => ../processor/elastictraceprocessor diff --git a/extension/configintegrationextension/go.mod b/extension/configintegrationextension/go.mod index 5f837f1c..0d2643d9 100644 --- a/extension/configintegrationextension/go.mod +++ b/extension/configintegrationextension/go.mod @@ -7,7 +7,6 @@ require ( github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 - go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 go.opentelemetry.io/collector/extension v0.105.0 go.uber.org/goleak v1.3.0 ) diff --git a/extension/configintegrationextension/go.sum b/extension/configintegrationextension/go.sum index cd15f84b..0032d7c5 100644 --- a/extension/configintegrationextension/go.sum +++ b/extension/configintegrationextension/go.sum @@ -59,8 +59,6 @@ go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aL go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= -go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 h1:RgQwEbJgx+BihDt8yhiqmEi8IjQYFwbzsYRcTzvM7E4= -go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0/go.mod h1:P7oT+6eaMv+ZyPSu6SEKalfR/UALdQgE3hq36b0Iww4= go.opentelemetry.io/collector/extension v0.105.0 h1:R8i4HMvuSm20Nt3onyrLk19KKhjCNAsgS8FGh60rcZU= go.opentelemetry.io/collector/extension v0.105.0/go.mod h1:oyX960URG27esNKitf3o2rqcBj0ajcx+dxkCxwRz34U= go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= From 5a6213a3eb3c0b81e19f9ef26cbee4b95920f0f9 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 25 Sep 2024 19:15:07 +0200 Subject: [PATCH 14/20] Fix prefix trimming --- receiver/integrationreceiver/confmap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/integrationreceiver/confmap.go b/receiver/integrationreceiver/confmap.go index 4bda4145..4362d3d2 100644 --- a/receiver/integrationreceiver/confmap.go +++ b/receiver/integrationreceiver/confmap.go @@ -44,7 +44,7 @@ type variablesProvider struct { } func (p *variablesProvider) Retrieve(ctx context.Context, uri string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) { - key := strings.TrimLeft(uri, varProviderScheme+":") + key := strings.TrimPrefix(uri, varProviderScheme+":") value, found := p.variables[key] if !found { return nil, fmt.Errorf("variable %q not found", key) From 6ece9624601e9c2fc4a1a3edced269451c71e3bf Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 26 Sep 2024 10:33:32 +0200 Subject: [PATCH 15/20] Ignore errors on unsupported signal types --- receiver/integrationreceiver/receiver.go | 38 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/receiver/integrationreceiver/receiver.go b/receiver/integrationreceiver/receiver.go index 33b455ef..7cab4e1e 100644 --- a/receiver/integrationreceiver/receiver.go +++ b/receiver/integrationreceiver/receiver.go @@ -19,6 +19,7 @@ package integrationreceiver // import "github.com/elastic/opentelemetry-collecto import ( "context" + "errors" "fmt" "slices" @@ -27,6 +28,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/consumer" + otelpipeline "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/receiver" @@ -196,24 +198,42 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet params.Logger = params.Logger.With(zap.String("name", params.ID.String())) if consumerChain.logs != nil { logs, err := receiverFactory.CreateLogsReceiver(ctx, params, preparedConfig, consumerChain.logs) - if err != nil { - return fmt.Errorf("failed to create logs processor %s: %w", params.ID, err) + switch { + case err == nil: + r.components = append(r.components, logs) + case errors.Is(err, otelpipeline.ErrSignalNotSupported): + r.params.Logger.Debug("receiver does not support logs telemetry type", + zap.String("integration", r.params.ID.String()), + zap.String("receiver", params.ID.String())) + default: + return fmt.Errorf("failed to create logs receiver %s: %w", params.ID, err) } - r.components = append(r.components, logs) } if consumerChain.metrics != nil { metrics, err := receiverFactory.CreateMetricsReceiver(ctx, params, preparedConfig, consumerChain.metrics) - if err != nil { - return fmt.Errorf("failed to create metrics processor %s: %w", params.ID, err) + switch { + case err == nil: + r.components = append(r.components, metrics) + case errors.Is(err, otelpipeline.ErrSignalNotSupported): + r.params.Logger.Debug("receiver does not support metrics telemetry type", + zap.String("integration", r.params.ID.String()), + zap.String("receiver", params.ID.String())) + default: + return fmt.Errorf("failed to create metrics receiver %s: %w", params.ID, err) } - r.components = append(r.components, metrics) } if consumerChain.traces != nil { traces, err := receiverFactory.CreateTracesReceiver(ctx, params, preparedConfig, consumerChain.traces) - if err != nil { - return fmt.Errorf("failed to create traces processor %s: %w", params.ID, err) + switch { + case err == nil: + r.components = append(r.components, traces) + case errors.Is(err, otelpipeline.ErrSignalNotSupported): + r.params.Logger.Debug("receiver does not support traces telemetry type", + zap.String("integration", r.params.ID.String()), + zap.String("receiver", params.ID.String())) + default: + return fmt.Errorf("failed to create traces receiver %s: %w", params.ID, err) } - r.components = append(r.components, traces) } for _, component := range r.components { From 2fa10130896a8b6aa30abdce68f33a21df0803b8 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 26 Sep 2024 10:52:42 +0200 Subject: [PATCH 16/20] Some fixes on component cleanup --- receiver/integrationreceiver/go.mod | 2 ++ receiver/integrationreceiver/go.sum | 4 +++ receiver/integrationreceiver/receiver.go | 39 ++++++++++++++++++------ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/receiver/integrationreceiver/go.mod b/receiver/integrationreceiver/go.mod index 3ade221e..2b8f78ca 100644 --- a/receiver/integrationreceiver/go.mod +++ b/receiver/integrationreceiver/go.mod @@ -8,6 +8,7 @@ require ( go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/pipeline v0.110.0 go.opentelemetry.io/collector/processor v0.105.0 go.opentelemetry.io/collector/receiver v0.105.0 go.uber.org/goleak v1.3.0 @@ -42,6 +43,7 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.13.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect go.opentelemetry.io/collector/pdata v1.13.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect diff --git a/receiver/integrationreceiver/go.sum b/receiver/integrationreceiver/go.sum index ce320558..d2d8b18a 100644 --- a/receiver/integrationreceiver/go.sum +++ b/receiver/integrationreceiver/go.sum @@ -77,12 +77,16 @@ go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthb go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= +go.opentelemetry.io/collector/internal/globalsignal v0.110.0 h1:S6bfFEiek8vJeXAbciWS7W8UR6ZrVJB3ftNyFTMHQaY= +go.opentelemetry.io/collector/internal/globalsignal v0.110.0/go.mod h1:GqMXodPWOxK5uqpX8MaMXC2389y2XJTa5nPwf8FYDK8= go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= go.opentelemetry.io/collector/pdata/pprofile v0.105.0 h1:C+Hd7CNcepL/364OBV9f4lHzJil2jQSOxcEM1PFXGDg= go.opentelemetry.io/collector/pdata/pprofile v0.105.0/go.mod h1:chr7lMJIzyXkccnPRkIPhyXtqLZLSReZYhwsggOGEfg= go.opentelemetry.io/collector/pdata/testdata v0.105.0 h1:5sPZzanR4nJR3sNQk3MTdArdEZCK0NRAfC29t0Dtf60= go.opentelemetry.io/collector/pdata/testdata v0.105.0/go.mod h1:NIfgaclQp/M1BZhgyc/7hDWD+/DumC/OMBQVI2KW+N0= +go.opentelemetry.io/collector/pipeline v0.110.0 h1:nArQj8lt2R6ajbbmZ0f7JqkzAzvIOSwxsxDEv9HGKHw= +go.opentelemetry.io/collector/pipeline v0.110.0/go.mod h1:qWk90kohDYBgI/1Kw4DQaQU82+y9GJY8MDse7H2JTWg= go.opentelemetry.io/collector/processor v0.105.0 h1:LE6wEMWNa3h7eOJLMBm2lA0v6sc2j6Geqv1e3pIWS8Y= go.opentelemetry.io/collector/processor v0.105.0/go.mod h1:QAvMEtd3k+YhRrnaEgs/8e0UueYonuT8Hg4udQOht60= go.opentelemetry.io/collector/receiver v0.105.0 h1:eZF97kMUnKJ20Uc4PaDlgLIGmaA8kyLqhH+vMXjh92U= diff --git a/receiver/integrationreceiver/receiver.go b/receiver/integrationreceiver/receiver.go index 7cab4e1e..b1f928e1 100644 --- a/receiver/integrationreceiver/receiver.go +++ b/receiver/integrationreceiver/receiver.go @@ -146,6 +146,7 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet return fmt.Errorf("could not compose receiver config for %s: %w", pipeline.Receiver.String(), err) } + var components []component.Component processors := slices.Clone(pipeline.Processors) slices.Reverse(processors) for i, id := range processors { @@ -173,7 +174,7 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet return fmt.Errorf("failed to create logs processor %s: %w", params.ID, err) } consumerChain.logs = logs - r.components = append(r.components, logs) + components = append(components, logs) } if consumerChain.metrics != nil { metrics, err := factory.CreateMetricsProcessor(ctx, params, config, consumerChain.metrics) @@ -181,7 +182,7 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet return fmt.Errorf("failed to create metrics processor %s: %w", params.ID, err) } consumerChain.metrics = metrics - r.components = append(r.components, metrics) + components = append(components, metrics) } if consumerChain.traces != nil { traces, err := factory.CreateTracesProcessor(ctx, params, config, consumerChain.traces) @@ -189,18 +190,20 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet return fmt.Errorf("failed to create traces processor %s: %w", params.ID, err) } consumerChain.traces = traces - r.components = append(r.components, traces) + components = append(components, traces) } } params := r.params params.ID = component.NewIDWithName(receiverFactory.Type(), fmt.Sprintf("%s-receiver", pipelineID)) params.Logger = params.Logger.With(zap.String("name", params.ID.String())) + receiversCreated := 0 if consumerChain.logs != nil { logs, err := receiverFactory.CreateLogsReceiver(ctx, params, preparedConfig, consumerChain.logs) switch { case err == nil: - r.components = append(r.components, logs) + components = append(components, logs) + receiversCreated += 1 case errors.Is(err, otelpipeline.ErrSignalNotSupported): r.params.Logger.Debug("receiver does not support logs telemetry type", zap.String("integration", r.params.ID.String()), @@ -213,7 +216,8 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet metrics, err := receiverFactory.CreateMetricsReceiver(ctx, params, preparedConfig, consumerChain.metrics) switch { case err == nil: - r.components = append(r.components, metrics) + components = append(components, metrics) + receiversCreated += 1 case errors.Is(err, otelpipeline.ErrSignalNotSupported): r.params.Logger.Debug("receiver does not support metrics telemetry type", zap.String("integration", r.params.ID.String()), @@ -226,7 +230,8 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet traces, err := receiverFactory.CreateTracesReceiver(ctx, params, preparedConfig, consumerChain.traces) switch { case err == nil: - r.components = append(r.components, traces) + components = append(components, traces) + receiversCreated += 1 case errors.Is(err, otelpipeline.ErrSignalNotSupported): r.params.Logger.Debug("receiver does not support traces telemetry type", zap.String("integration", r.params.ID.String()), @@ -236,20 +241,36 @@ func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGet } } - for _, component := range r.components { + // If no receiver has been created the rest of the pipeline won't be used, so don't keep it. + if receiversCreated == 0 { + // Shutting down created components out of kindness, because they haven't been started yet. + if err := shutdownComponents(ctx, components); err != nil { + r.params.Logger.Error("failed to cleanup processors after receiver was not created", + zap.String("integration", r.params.ID.String()), + zap.String("receiver", params.ID.String())) + } + return nil + } + + for _, component := range components { err := component.Start(ctx, host) if err != nil { return fmt.Errorf("failed to start component %q: %w", component, err) } } + r.components = append(r.components, components...) return nil } func (r *integrationReceiver) Shutdown(ctx context.Context) error { + return shutdownComponents(ctx, r.components) +} + +func shutdownComponents(ctx context.Context, components []component.Component) error { // Shutdown them in reverse order as they were created. - components := slices.Clone(r.components) - slices.Reverse(r.components) + components = slices.Clone(components) + slices.Reverse(components) for _, c := range components { err := c.Shutdown(ctx) if err != nil { From b2c14dbba7789cb78f8959ac14bb14230a1e5ab5 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 23 Oct 2024 20:44:01 +0200 Subject: [PATCH 17/20] Each receiver instance creates pipelines only for the supported types --- receiver/integrationreceiver/receiver.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/receiver/integrationreceiver/receiver.go b/receiver/integrationreceiver/receiver.go index b1f928e1..9e9188cb 100644 --- a/receiver/integrationreceiver/receiver.go +++ b/receiver/integrationreceiver/receiver.go @@ -106,6 +106,9 @@ func (r *integrationReceiver) Start(ctx context.Context, ch component.Host) erro return fmt.Errorf("failed to select component: %w", err) } for id, pipeline := range pipelines { + if !r.hasConsumerForPipelineType(id) { + continue + } err := r.startPipeline(ctx, host, integrationConfig, id, pipeline) if err != nil { // Shutdown components that had been already started for cleanup. @@ -120,6 +123,20 @@ func (r *integrationReceiver) Start(ctx context.Context, ch component.Host) erro return nil } +func (r *integrationReceiver) hasConsumerForPipelineType(id component.ID) bool { + switch id.Type().String() { + case "logs": + return r.nextLogsConsumer != nil + case "metrics": + return r.nextMetricsConsumer != nil + case "traces": + return r.nextTracesConsumer != nil + default: + r.params.Logger.Warn("unexpected pipeline type in integration", zap.String("id", id.String())) + return false + } +} + func (r *integrationReceiver) startPipeline(ctx context.Context, host factoryGetter, config integrations.Config, pipelineID component.ID, pipeline integrations.PipelineConfig) error { consumerChain := struct { logs consumer.Logs From c3096f4b6c6afb317cf28a2a798f303367e5c1b9 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 29 Nov 2024 11:27:56 +0100 Subject: [PATCH 18/20] Fix tests --- processor/integrationprocessor/generated_component_test.go | 6 +++--- receiver/integrationreceiver/generated_component_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/processor/integrationprocessor/generated_component_test.go b/processor/integrationprocessor/generated_component_test.go index 61bf82a9..3cf2d342 100644 --- a/processor/integrationprocessor/generated_component_test.go +++ b/processor/integrationprocessor/generated_component_test.go @@ -56,21 +56,21 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs", createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "metrics", createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateMetrics(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "traces", createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateTraces(ctx, set, cfg, consumertest.NewNop()) }, }, } diff --git a/receiver/integrationreceiver/generated_component_test.go b/receiver/integrationreceiver/generated_component_test.go index 7e07c43b..20beb205 100644 --- a/receiver/integrationreceiver/generated_component_test.go +++ b/receiver/integrationreceiver/generated_component_test.go @@ -51,21 +51,21 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "metrics", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateMetrics(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "traces", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateTraces(ctx, set, cfg, consumertest.NewNop()) }, }, } From 62b5f2d25e70deb8e120aa0d0fb19703a3b53b3f Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 29 Nov 2024 11:47:23 +0100 Subject: [PATCH 19/20] Generate --- .../configintegrationextension/generated_component_test.go | 6 +++--- .../fileintegrationextension/generated_component_test.go | 6 +++--- processor/integrationprocessor/generated_component_test.go | 6 +++--- receiver/integrationreceiver/generated_component_test.go | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/extension/configintegrationextension/generated_component_test.go b/extension/configintegrationextension/generated_component_test.go index 9dfe4d00..09ac6014 100644 --- a/extension/configintegrationextension/generated_component_test.go +++ b/extension/configintegrationextension/generated_component_test.go @@ -47,18 +47,18 @@ func TestComponentLifecycle(t *testing.T) { require.NoError(t, err) require.NoError(t, sub.Unmarshal(&cfg)) t.Run("shutdown", func(t *testing.T) { - e, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + e, err := factory.Create(context.Background(), extensiontest.NewNopSettings(), cfg) require.NoError(t, err) err = e.Shutdown(context.Background()) require.NoError(t, err) }) t.Run("lifecycle", func(t *testing.T) { - firstExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + firstExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(), cfg) require.NoError(t, err) require.NoError(t, firstExt.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, firstExt.Shutdown(context.Background())) - secondExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + secondExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(), cfg) require.NoError(t, err) require.NoError(t, secondExt.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, secondExt.Shutdown(context.Background())) diff --git a/extension/fileintegrationextension/generated_component_test.go b/extension/fileintegrationextension/generated_component_test.go index 0481d412..4583d69b 100644 --- a/extension/fileintegrationextension/generated_component_test.go +++ b/extension/fileintegrationextension/generated_component_test.go @@ -47,18 +47,18 @@ func TestComponentLifecycle(t *testing.T) { require.NoError(t, err) require.NoError(t, sub.Unmarshal(&cfg)) t.Run("shutdown", func(t *testing.T) { - e, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + e, err := factory.Create(context.Background(), extensiontest.NewNopSettings(), cfg) require.NoError(t, err) err = e.Shutdown(context.Background()) require.NoError(t, err) }) t.Run("lifecycle", func(t *testing.T) { - firstExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + firstExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(), cfg) require.NoError(t, err) require.NoError(t, firstExt.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, firstExt.Shutdown(context.Background())) - secondExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopSettings(), cfg) + secondExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(), cfg) require.NoError(t, err) require.NoError(t, secondExt.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, secondExt.Shutdown(context.Background())) diff --git a/processor/integrationprocessor/generated_component_test.go b/processor/integrationprocessor/generated_component_test.go index 3cf2d342..906788e0 100644 --- a/processor/integrationprocessor/generated_component_test.go +++ b/processor/integrationprocessor/generated_component_test.go @@ -82,9 +82,9 @@ func TestComponentLifecycle(t *testing.T) { require.NoError(t, err) require.NoError(t, sub.Unmarshal(&cfg)) - for _, test := range tests { - t.Run(test.name+"-shutdown", func(t *testing.T) { - c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg) + for _, tt := range tests { + t.Run(tt.name+"-shutdown", func(t *testing.T) { + c, err := tt.createFn(context.Background(), processortest.NewNopSettings(), cfg) require.NoError(t, err) err = c.Shutdown(context.Background()) require.NoError(t, err) diff --git a/receiver/integrationreceiver/generated_component_test.go b/receiver/integrationreceiver/generated_component_test.go index 20beb205..82312460 100644 --- a/receiver/integrationreceiver/generated_component_test.go +++ b/receiver/integrationreceiver/generated_component_test.go @@ -77,9 +77,9 @@ func TestComponentLifecycle(t *testing.T) { require.NoError(t, err) require.NoError(t, sub.Unmarshal(&cfg)) - for _, test := range tests { - t.Run(test.name+"-shutdown", func(t *testing.T) { - c, err := test.createFn(context.Background(), receivertest.NewNopSettings(), cfg) + for _, tt := range tests { + t.Run(tt.name+"-shutdown", func(t *testing.T) { + c, err := tt.createFn(context.Background(), receivertest.NewNopSettings(), cfg) require.NoError(t, err) err = c.Shutdown(context.Background()) require.NoError(t, err) From e89da4af47d1ec095f647df4d4027bcec5753448 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 29 Nov 2024 11:52:44 +0100 Subject: [PATCH 20/20] More linting --- extension/configintegrationextension/go.mod | 53 +++++----- extension/configintegrationextension/go.sum | 100 ++++++++----------- extension/fileintegrationextension/go.mod | 55 +++++------ extension/fileintegrationextension/go.sum | 104 +++++++++----------- 4 files changed, 133 insertions(+), 179 deletions(-) diff --git a/extension/configintegrationextension/go.mod b/extension/configintegrationextension/go.mod index 0d2643d9..027b52b3 100644 --- a/extension/configintegrationextension/go.mod +++ b/extension/configintegrationextension/go.mod @@ -1,56 +1,49 @@ module github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension -go 1.22.1 +go 1.22.7 + +toolchain go1.23.1 require ( github.com/elastic/opentelemetry-collector-components/internal/integrations v0.0.0 github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/collector/component v0.105.0 - go.opentelemetry.io/collector/confmap v0.105.0 - go.opentelemetry.io/collector/extension v0.105.0 + go.opentelemetry.io/collector/component v0.114.0 + go.opentelemetry.io/collector/component/componenttest v0.114.0 + go.opentelemetry.io/collector/confmap v1.20.0 + go.opentelemetry.io/collector/extension v0.114.0 + go.opentelemetry.io/collector/extension/extensiontest v0.114.0 go.uber.org/goleak v1.3.0 ) require ( - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/hashicorp/go-version v1.7.0 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect github.com/knadh/koanf/providers/confmap v0.1.0 // indirect - github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/knadh/koanf/v2 v2.1.2 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.19.1 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect - go.opentelemetry.io/collector/featuregate v1.13.0 // indirect - go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect - go.opentelemetry.io/collector/pdata v1.13.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect - go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.114.0 // indirect + go.opentelemetry.io/collector/pdata v1.20.0 // indirect + go.opentelemetry.io/otel v1.32.0 // indirect + go.opentelemetry.io/otel/metric v1.32.0 // indirect + go.opentelemetry.io/otel/sdk v1.32.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect + go.opentelemetry.io/otel/trace v1.32.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect - google.golang.org/grpc v1.65.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect + google.golang.org/grpc v1.68.0 // indirect + google.golang.org/protobuf v1.35.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/extension/configintegrationextension/go.sum b/extension/configintegrationextension/go.sum index 0032d7c5..a889e7f8 100644 --- a/extension/configintegrationextension/go.sum +++ b/extension/configintegrationextension/go.sum @@ -1,7 +1,3 @@ -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/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -9,24 +5,24 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= -github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= +github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= -github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 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/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= -github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= -github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/knadh/koanf/v2 v2.1.2 h1:I2rtLRqXRy1p01m/utEtpZSSA6dcJbgGVuE27kW2PzQ= +github.com/knadh/koanf/v2 v2.1.2/go.mod h1:Gphfaen0q1Fc1HTgJgSTC4oRX9R2R5ErYMZJy8fLJBo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -35,50 +31,38 @@ github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa1 github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 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/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= -github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= -github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= -github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= -github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= -go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= -go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= -go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= -go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= -go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= -go.opentelemetry.io/collector/extension v0.105.0 h1:R8i4HMvuSm20Nt3onyrLk19KKhjCNAsgS8FGh60rcZU= -go.opentelemetry.io/collector/extension v0.105.0/go.mod h1:oyX960URG27esNKitf3o2rqcBj0ajcx+dxkCxwRz34U= -go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= -go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= -go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= -go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= -go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= -go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= -go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= -go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= -go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= -go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= -go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= -go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/collector/component v0.114.0 h1:SVGbm5LvHGSTEDv7p92oPuBgK5tuiWR82I9+LL4TtBE= +go.opentelemetry.io/collector/component v0.114.0/go.mod h1:MLxtjZ6UVHjDxSdhGLuJfHBHvfl1iT/Y7IaQPD24Eww= +go.opentelemetry.io/collector/component/componenttest v0.114.0 h1:GM4FTTlfeXoVm6sZYBHImwlRN8ayh2oAfUhvaFj7Zo8= +go.opentelemetry.io/collector/component/componenttest v0.114.0/go.mod h1:ZZEJMtbJtoVC/3/9R1HzERq+cYQRxuMFQrPCpfZ4Xos= +go.opentelemetry.io/collector/config/configtelemetry v0.114.0 h1:kjLeyrumge6wsX6ZIkicdNOlBXaEyW2PI2ZdVXz/rzY= +go.opentelemetry.io/collector/config/configtelemetry v0.114.0/go.mod h1:R0MBUxjSMVMIhljuDHWIygzzJWQyZHXXWIgQNxcFwhc= +go.opentelemetry.io/collector/confmap v1.20.0 h1:ARfOwmkKxFOud1njl03yAHQ30+uenlzqCO6LBYamDTE= +go.opentelemetry.io/collector/confmap v1.20.0/go.mod h1:DMpd9Ay/ffls3JoQBQ73vWeRsz1rNuLbwjo6WtjSQus= +go.opentelemetry.io/collector/extension v0.114.0 h1:9Qb92y8hD2WDC5aMDoj4JNQN+/5BQYJWPUPzLXX+iGw= +go.opentelemetry.io/collector/extension v0.114.0/go.mod h1:Yk2/1ptVgfTr12t+22v93nYJpioP14pURv2YercSzU0= +go.opentelemetry.io/collector/extension/extensiontest v0.114.0 h1:ibXDms1qrswlvlR6b3d2BeyI8sXUXoFV11yOi9Sop8o= +go.opentelemetry.io/collector/extension/extensiontest v0.114.0/go.mod h1:/bOYmqu5yTDfI1bJZUxFqm8ZtmcodpquebiSxiQxtDY= +go.opentelemetry.io/collector/pdata v1.20.0 h1:ePcwt4bdtISP0loHaE+C9xYoU2ZkIvWv89Fob16o9SM= +go.opentelemetry.io/collector/pdata v1.20.0/go.mod h1:Ox1YVLe87cZDB/TL30i4SUz1cA5s6AM6SpFMfY61ICs= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -94,20 +78,20 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= 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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -116,12 +100,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= +google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= +google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/extension/fileintegrationextension/go.mod b/extension/fileintegrationextension/go.mod index 2ae0150a..2baa149c 100644 --- a/extension/fileintegrationextension/go.mod +++ b/extension/fileintegrationextension/go.mod @@ -1,57 +1,50 @@ module github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension -go 1.22.1 +go 1.22.7 + +toolchain go1.23.1 require ( github.com/elastic/opentelemetry-collector-components/internal/integrations v0.0.0 github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/collector/component v0.105.0 - go.opentelemetry.io/collector/confmap v0.105.0 - go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 - go.opentelemetry.io/collector/extension v0.105.0 + go.opentelemetry.io/collector/component v0.114.0 + go.opentelemetry.io/collector/component/componenttest v0.114.0 + go.opentelemetry.io/collector/confmap v1.20.0 + go.opentelemetry.io/collector/confmap/provider/fileprovider v1.20.0 + go.opentelemetry.io/collector/extension v0.114.0 + go.opentelemetry.io/collector/extension/extensiontest v0.114.0 go.uber.org/goleak v1.3.0 ) require ( - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/hashicorp/go-version v1.7.0 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect github.com/knadh/koanf/providers/confmap v0.1.0 // indirect - github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/knadh/koanf/v2 v2.1.2 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.19.1 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect - go.opentelemetry.io/collector/featuregate v1.13.0 // indirect - go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect - go.opentelemetry.io/collector/pdata v1.13.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect - go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.114.0 // indirect + go.opentelemetry.io/collector/pdata v1.20.0 // indirect + go.opentelemetry.io/otel v1.32.0 // indirect + go.opentelemetry.io/otel/metric v1.32.0 // indirect + go.opentelemetry.io/otel/sdk v1.32.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect + go.opentelemetry.io/otel/trace v1.32.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect - google.golang.org/grpc v1.65.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect + google.golang.org/grpc v1.68.0 // indirect + google.golang.org/protobuf v1.35.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/extension/fileintegrationextension/go.sum b/extension/fileintegrationextension/go.sum index cd15f84b..8822e59e 100644 --- a/extension/fileintegrationextension/go.sum +++ b/extension/fileintegrationextension/go.sum @@ -1,7 +1,3 @@ -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/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -9,24 +5,24 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= -github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= +github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= -github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 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/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= -github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= -github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/knadh/koanf/v2 v2.1.2 h1:I2rtLRqXRy1p01m/utEtpZSSA6dcJbgGVuE27kW2PzQ= +github.com/knadh/koanf/v2 v2.1.2/go.mod h1:Gphfaen0q1Fc1HTgJgSTC4oRX9R2R5ErYMZJy8fLJBo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -35,52 +31,40 @@ github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa1 github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 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/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= -github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= -github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= -github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= -github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector/component v0.105.0 h1:/OdkWHd1xTNX7JRq9iW3AFoJAnYUOGZZyOprNQkGoTI= -go.opentelemetry.io/collector/component v0.105.0/go.mod h1:s8KoxOrhNIBzetkb0LHmzX1OI67DyZbaaUPOWIXS1mg= -go.opentelemetry.io/collector/config/configtelemetry v0.105.0 h1:wEfUxAjjstp47aLr2s1cMZiH0dt+k42m6VC6HigqgJA= -go.opentelemetry.io/collector/config/configtelemetry v0.105.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= -go.opentelemetry.io/collector/confmap v0.105.0 h1:3NP2BbUju42rjeQvRbmpCJGJGvbiV3WnGyXsVmocimo= -go.opentelemetry.io/collector/confmap v0.105.0/go.mod h1:Oj1xUBRvAuL8OWWMj9sSYf1uQpB+AErpj+FKGUQLBI0= -go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 h1:RgQwEbJgx+BihDt8yhiqmEi8IjQYFwbzsYRcTzvM7E4= -go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0/go.mod h1:P7oT+6eaMv+ZyPSu6SEKalfR/UALdQgE3hq36b0Iww4= -go.opentelemetry.io/collector/extension v0.105.0 h1:R8i4HMvuSm20Nt3onyrLk19KKhjCNAsgS8FGh60rcZU= -go.opentelemetry.io/collector/extension v0.105.0/go.mod h1:oyX960URG27esNKitf3o2rqcBj0ajcx+dxkCxwRz34U= -go.opentelemetry.io/collector/featuregate v1.13.0 h1:rc84eCf5hesXQ8/bP6Zc15wqthbomfLBHmox5tT7AwM= -go.opentelemetry.io/collector/featuregate v1.13.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= -go.opentelemetry.io/collector/internal/globalgates v0.105.0 h1:U/CwnTUXtrblD1sZ6ri7KWfYoTNjQd7GjJKrX/phRik= -go.opentelemetry.io/collector/internal/globalgates v0.105.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= -go.opentelemetry.io/collector/pdata v1.13.0 h1:eV3NQt2f1UcaibkziMvGTQI34LlpiYBUGp1yP0G/Cxw= -go.opentelemetry.io/collector/pdata v1.13.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= -go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= -go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= -go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= -go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= -go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= -go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/collector/component v0.114.0 h1:SVGbm5LvHGSTEDv7p92oPuBgK5tuiWR82I9+LL4TtBE= +go.opentelemetry.io/collector/component v0.114.0/go.mod h1:MLxtjZ6UVHjDxSdhGLuJfHBHvfl1iT/Y7IaQPD24Eww= +go.opentelemetry.io/collector/component/componenttest v0.114.0 h1:GM4FTTlfeXoVm6sZYBHImwlRN8ayh2oAfUhvaFj7Zo8= +go.opentelemetry.io/collector/component/componenttest v0.114.0/go.mod h1:ZZEJMtbJtoVC/3/9R1HzERq+cYQRxuMFQrPCpfZ4Xos= +go.opentelemetry.io/collector/config/configtelemetry v0.114.0 h1:kjLeyrumge6wsX6ZIkicdNOlBXaEyW2PI2ZdVXz/rzY= +go.opentelemetry.io/collector/config/configtelemetry v0.114.0/go.mod h1:R0MBUxjSMVMIhljuDHWIygzzJWQyZHXXWIgQNxcFwhc= +go.opentelemetry.io/collector/confmap v1.20.0 h1:ARfOwmkKxFOud1njl03yAHQ30+uenlzqCO6LBYamDTE= +go.opentelemetry.io/collector/confmap v1.20.0/go.mod h1:DMpd9Ay/ffls3JoQBQ73vWeRsz1rNuLbwjo6WtjSQus= +go.opentelemetry.io/collector/confmap/provider/fileprovider v1.20.0 h1:wWxvQ7wj+1O9yDGM5m1HPEz8FJewAHAUWadAAi0KVbM= +go.opentelemetry.io/collector/confmap/provider/fileprovider v1.20.0/go.mod h1:/5HWIPjGYk8IUurs1CZUSjGaSsaQyJsfR8+Zs5rGJ6Y= +go.opentelemetry.io/collector/extension v0.114.0 h1:9Qb92y8hD2WDC5aMDoj4JNQN+/5BQYJWPUPzLXX+iGw= +go.opentelemetry.io/collector/extension v0.114.0/go.mod h1:Yk2/1ptVgfTr12t+22v93nYJpioP14pURv2YercSzU0= +go.opentelemetry.io/collector/extension/extensiontest v0.114.0 h1:ibXDms1qrswlvlR6b3d2BeyI8sXUXoFV11yOi9Sop8o= +go.opentelemetry.io/collector/extension/extensiontest v0.114.0/go.mod h1:/bOYmqu5yTDfI1bJZUxFqm8ZtmcodpquebiSxiQxtDY= +go.opentelemetry.io/collector/pdata v1.20.0 h1:ePcwt4bdtISP0loHaE+C9xYoU2ZkIvWv89Fob16o9SM= +go.opentelemetry.io/collector/pdata v1.20.0/go.mod h1:Ox1YVLe87cZDB/TL30i4SUz1cA5s6AM6SpFMfY61ICs= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -96,20 +80,20 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= 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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -118,12 +102,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= +google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= +google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=