Skip to content

Commit

Permalink
Remove non pdata deprecated funcs/structs (open-telemetry#5220)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored and Nicholaswang committed Jun 7, 2022
1 parent 34373b0 commit 698bfd7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 125 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### 🛑 Breaking changes 🛑

- Remove non pdata deprecated funcs/structs (#5220)

### 🚩 Deprecations 🚩

### 💡 Enhancements 💡
Expand Down
26 changes: 0 additions & 26 deletions config/configmapprovider/deprecated.go

This file was deleted.

16 changes: 5 additions & 11 deletions service/collector_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,18 @@ import (
"go.opentelemetry.io/collector/service/featuregate"
)

// Deprecated: [v0.48.0] will be made private soon.
type WindowsService struct {
type windowsService struct {
settings CollectorSettings
col *Collector
}

// Deprecated: [v0.48.0] use NewSvcHandler.
func NewWindowsService(set CollectorSettings) *WindowsService {
return &WindowsService{settings: set}
}

// NewSvcHandler constructs a new svc.Handler using the given CollectorSettings.
func NewSvcHandler(set CollectorSettings) svc.Handler {
return &WindowsService{settings: set}
return &windowsService{settings: set}
}

// Execute implements https://godoc.org/golang.org/x/sys/windows/svc#Handler
func (s *WindowsService) Execute(args []string, requests <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) {
func (s *windowsService) Execute(args []string, requests <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) {
// The first argument supplied to service.Execute is the service name. If this is
// not provided for some reason, raise a relevant error to the system event log
if len(args) == 0 {
Expand Down Expand Up @@ -94,7 +88,7 @@ func (s *WindowsService) Execute(args []string, requests <-chan svc.ChangeReques
return false, 0
}

func (s *WindowsService) start(elog *eventlog.Log, colErrorChannel chan error) error {
func (s *windowsService) start(elog *eventlog.Log, colErrorChannel chan error) error {
// Parse all the flags manually.
if err := flags().Parse(os.Args[1:]); err != nil {
return err
Expand Down Expand Up @@ -128,7 +122,7 @@ func (s *WindowsService) start(elog *eventlog.Log, colErrorChannel chan error) e
return <-colErrorChannel
}

func (s *WindowsService) stop(colErrorChannel chan error) error {
func (s *windowsService) stop(colErrorChannel chan error) error {
// simulate a SIGTERM signal to terminate the collector server
s.col.signalsChannel <- syscall.SIGTERM
// return the response of col.Start
Expand Down
30 changes: 0 additions & 30 deletions service/config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"go.opentelemetry.io/collector/config/configunmarshaler"
"go.opentelemetry.io/collector/config/experimental/configsource"
"go.opentelemetry.io/collector/config/mapconverter/expandmapconverter"
"go.opentelemetry.io/collector/config/mapconverter/overwritepropertiesmapconverter"
"go.opentelemetry.io/collector/config/mapprovider/envmapprovider"
"go.opentelemetry.io/collector/config/mapprovider/filemapprovider"
"go.opentelemetry.io/collector/config/mapprovider/yamlmapprovider"
Expand Down Expand Up @@ -106,24 +105,6 @@ func newDefaultConfigProviderSettings(locations []string) ConfigProviderSettings
}
}

// Deprecated: [v0.49.0] use NewConfigProvider instead.
func MustNewConfigProvider(
locations []string,
configMapProviders map[string]config.MapProvider,
configMapConverters []config.MapConverterFunc,
configUnmarshaler configunmarshaler.ConfigUnmarshaler) ConfigProvider {
cfgProvider, err := NewConfigProvider(ConfigProviderSettings{
Locations: locations,
MapProviders: configMapProviders,
MapConverters: configMapConverters,
Unmarshaler: configUnmarshaler,
})
if err != nil {
panic(err)
}
return cfgProvider
}

// NewConfigProvider returns a new ConfigProvider that provides the configuration:
// * Retrieve the config.Map by merging all retrieved maps from the given `locations` in order.
// * Then applies all the config.MapConverterFunc in the given order.
Expand Down Expand Up @@ -156,17 +137,6 @@ func NewConfigProvider(set ConfigProviderSettings) (ConfigProvider, error) {
}, nil
}

// Deprecated: [v0.49.0] use NewConfigProvider instead.
func MustNewDefaultConfigProvider(locations []string, properties []string) ConfigProvider {
set := newDefaultConfigProviderSettings(locations)
set.MapConverters = append([]config.MapConverterFunc{overwritepropertiesmapconverter.New(properties)}, set.MapConverters...)
cfgProvider, err := NewConfigProvider(set)
if err != nil {
panic(err)
}
return cfgProvider
}

func (cm *configProvider) Get(ctx context.Context, factories component.Factories) (*config.Config, error) {
// First check if already an active watching, close that if any.
if err := cm.closeIfNeeded(ctx); err != nil {
Expand Down
58 changes: 0 additions & 58 deletions service/config_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,41 +220,6 @@ func TestConfigProvider(t *testing.T) {
assert.NoError(t, errC)
}

// TODO: Remove when remove MustNewConfigProvider, duplicate of TestConfigProvider.
func TestMustNewConfigProvider(t *testing.T) {
factories, errF := componenttest.NopFactories()
require.NoError(t, errF)
configMapProvider := func() config.MapProvider {
// Use fakeRetrieved with nil errors to have Watchable interface implemented.
cfgMap, err := configtest.LoadConfigMap(filepath.Join("testdata", "otelcol-nop.yaml"))
require.NoError(t, err)
return &mockProvider{retM: cfgMap}
}()

cfgW := MustNewConfigProvider(
[]string{"mock:"},
map[string]config.MapProvider{"mock": configMapProvider},
nil,
configunmarshaler.NewDefault())

_, errN := cfgW.Get(context.Background(), factories)
assert.NoError(t, errN)

errW := <-cfgW.Watch()
assert.NoError(t, errW)

// Repeat Get/Watch.

_, errN = cfgW.Get(context.Background(), factories)
assert.NoError(t, errN)

errW = <-cfgW.Watch()
assert.NoError(t, errW)

errC := cfgW.Shutdown(context.Background())
assert.NoError(t, errC)
}

func TestConfigProviderNoWatcher(t *testing.T) {
factories, errF := componenttest.NopFactories()
require.NoError(t, errF)
Expand All @@ -278,29 +243,6 @@ func TestConfigProviderNoWatcher(t *testing.T) {
watcherWG.Wait()
}

// TODO: Remove when remove MustNewDefaultConfigProvider, duplicate of TestConfigProviderNoWatcher.
func TestMustNewDefaultConfigProvider(t *testing.T) {
factories, errF := componenttest.NopFactories()
require.NoError(t, errF)

watcherWG := sync.WaitGroup{}
cfgW := MustNewDefaultConfigProvider([]string{filepath.Join("testdata", "otelcol-nop.yaml")}, nil)
_, errN := cfgW.Get(context.Background(), factories)
assert.NoError(t, errN)

watcherWG.Add(1)
go func() {
errW, ok := <-cfgW.Watch()
// Channel is closed, no exception
assert.False(t, ok)
assert.NoError(t, errW)
watcherWG.Done()
}()

assert.NoError(t, cfgW.Shutdown(context.Background()))
watcherWG.Wait()
}

func TestConfigProvider_ShutdownClosesWatch(t *testing.T) {
factories, errF := componenttest.NopFactories()
require.NoError(t, errF)
Expand Down

0 comments on commit 698bfd7

Please sign in to comment.