Skip to content

Commit

Permalink
[otelcol] remove deprecated interface ConfmapProvider (open-telemetry…
Browse files Browse the repository at this point in the history
…#10934)

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten authored Aug 20, 2024
1 parent 3c1cf33 commit 26fb7cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 59 deletions.
25 changes: 25 additions & 0 deletions .chloggen/codeboten_remove-deprecated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: otelcol

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove deprecated `ConfmapProvider` interface.

# One or more tracking issues or pull requests related to the change
issues: [10934]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
28 changes: 0 additions & 28 deletions otelcol/configprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@ type ConfigProvider interface {
Shutdown(ctx context.Context) error
}

// ConfmapProvider is an optional interface to be implemented by ConfigProviders
// to provide confmap.Conf objects representing a marshaled version of the
// Collector's configuration.
//
// The purpose of this interface is that otelcol.ConfigProvider structs do not
// necessarily need to use confmap.Conf as their underlying config structure.
//
// Deprecated: [v0.105.0] This interface is deprecated. otelcol.Collector will now obtain
// a confmap.Conf object from the unmarshaled config itself.
type ConfmapProvider interface {
// GetConfmap resolves the Collector's configuration and provides it as a confmap.Conf object.
//
// Should never be called concurrently with itself or any ConfigProvider method.
GetConfmap(ctx context.Context) (*confmap.Conf, error)
}

type configProvider struct {
mapResolver *confmap.Resolver
}
Expand Down Expand Up @@ -117,15 +101,3 @@ func (cm *configProvider) Watch() <-chan error {
func (cm *configProvider) Shutdown(ctx context.Context) error {
return cm.mapResolver.Shutdown(ctx)
}

// Deprecated: [v0.105.0] Call `(*confmap.Conf).Marshal(*otelcol.Config)` to get
// the Collector's configuration instead.
func (cm *configProvider) GetConfmap(ctx context.Context) (*confmap.Conf, error) {
conf, err := cm.mapResolver.Resolve(ctx)

if err != nil {
return nil, fmt.Errorf("cannot resolve the configuration: %w", err)
}

return conf, nil
}
31 changes: 0 additions & 31 deletions otelcol/configprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,3 @@ func TestConfigProviderFile(t *testing.T) {

assert.EqualValues(t, configNop, cfg)
}

func TestGetConfmap(t *testing.T) {
uriLocation := "file:" + filepath.Join("testdata", "otelcol-nop.yaml")
fileProvider := newFakeProvider("file", func(_ context.Context, _ string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {
return confmap.NewRetrieved(newConfFromFile(t, uriLocation[5:]))
})
set := ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
URIs: []string{uriLocation},
ProviderFactories: []confmap.ProviderFactory{fileProvider},
},
}

configBytes, err := os.ReadFile(filepath.Join("testdata", "otelcol-nop.yaml"))
require.NoError(t, err)

yamlMap := map[string]any{}
err = yaml.Unmarshal(configBytes, yamlMap)
require.NoError(t, err)

cp, err := NewConfigProvider(set)
require.NoError(t, err)

cmp, ok := cp.(ConfmapProvider)
require.True(t, ok)

cmap, err := cmp.GetConfmap(context.Background())
require.NoError(t, err)

assert.EqualValues(t, yamlMap, cmap.ToStringMap())
}

0 comments on commit 26fb7cb

Please sign in to comment.