-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config sources to support full remote config and value substitution #4468
Changes from all commits
b7c405d
9c893c0
c3fc435
d4a178e
6363a1c
8e2b979
30b13dd
9f91092
b6cb36e
7959de4
521b875
ef946dc
05047ee
aca583e
87415b0
f05015f
3d7fb51
3fb2e33
011c1d4
86b69e4
1788c26
e8aeed2
50915c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed 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 component // import "go.opentelemetry.io/collector/component" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/config/configmapprovider" | ||
) | ||
|
||
// ConfigSource is a component that provides a configuration map or value. | ||
type ConfigSource interface { | ||
configmapprovider.Provider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need a ConfigSource and a Provider if they are the same? This is what I was suggesting #3924. I think we should have only one concept. |
||
} | ||
|
||
// ConfigSourceCreateSettings is passed to CreateConfigSource functions. | ||
type ConfigSourceCreateSettings struct { | ||
} | ||
|
||
type ConfigSourceFactory interface { | ||
Factory | ||
CreateDefaultConfig() config.ConfigSource | ||
CreateConfigSource(ctx context.Context, set ConfigSourceCreateSettings, cfg config.ConfigSource) (configmapprovider.Provider, error) | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,18 +22,18 @@ import ( | |
"go.opentelemetry.io/collector/config" | ||
) | ||
|
||
type fileMapProvider struct { | ||
type FileMapProvider struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This provides both so probably FileProvider is better name |
||
fileName string | ||
} | ||
|
||
// NewFile returns a new Provider that reads the configuration from the given file. | ||
func NewFile(fileName string) Provider { | ||
return &fileMapProvider{ | ||
// NewFile returns a new MapProvider that reads the configuration from the given file. | ||
func NewFile(fileName string) *FileMapProvider { | ||
return &FileMapProvider{ | ||
fileName: fileName, | ||
} | ||
} | ||
|
||
func (fmp *fileMapProvider) Retrieve(_ context.Context, _ func(*ChangeEvent)) (Retrieved, error) { | ||
func (fmp *FileMapProvider) Retrieve(_ context.Context, _ func(*ChangeEvent)) (RetrievedMap, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this if the other call can retrieve a map? That was my whole concern that we don't need 2 concepts we just need to find the "middle ground" between the full flexibility ConfigSource have and restricted scope of MapProvider. The reality is that the "ConfigSources" for example do not use params except for the "template" case for example, so we need to answer is that a reasonable use-case so we need to support params? |
||
if fmp.fileName == "" { | ||
return nil, errors.New("config file not specified") | ||
} | ||
|
@@ -46,6 +46,21 @@ func (fmp *fileMapProvider) Retrieve(_ context.Context, _ func(*ChangeEvent)) (R | |
return &simpleRetrieved{confMap: cp}, nil | ||
} | ||
|
||
func (*fileMapProvider) Shutdown(context.Context) error { | ||
func (fmp *FileMapProvider) RetrieveValue(_ context.Context, _ func(*ChangeEvent), selector string, paramsConfigMap *config.Map) (RetrievedValue, error) { | ||
if selector == "" { | ||
return nil, errors.New("config file not specified") | ||
} | ||
|
||
// TODO: support multiple file paths in selector (use some sort of delimiter). | ||
|
||
cp, err := config.NewMapFromFile(selector) | ||
if err != nil { | ||
return nil, fmt.Errorf("error loading config file %q: %w", fmp.fileName, err) | ||
} | ||
|
||
return &simpleRetrievedValue{value: cp}, nil | ||
} | ||
|
||
func (*FileMapProvider) Shutdown(context.Context) error { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see https://github.com/open-telemetry/opentelemetry-collector/tree/main/config/internal/configsource and https://github.com/open-telemetry/opentelemetry-collector/tree/main/component/experimental/component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I saw it. It will be all deleted since it is no longer needed. I deleted some parts of it already in this PR (the Manager).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this feature can be achieved through helm chart