-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new provider for integrations as raw configuration
- Loading branch information
Showing
12 changed files
with
510 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/fileintegrationextension" | ||
|
||
type Config struct { | ||
Integrations map[string]string `mapstructure:"integrations"` | ||
} | ||
|
||
func (c *Config) Validate() error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/fileintegrationextension" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/fileintegrationextension" | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/fileintegrationextension" | ||
|
||
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 | ||
} |
66 changes: 66 additions & 0 deletions
66
extension/configintegrationextension/generated_component_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
extension/configintegrationextension/generated_package_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.