Skip to content

Commit

Permalink
Fix linter issues:
Browse files Browse the repository at this point in the history
- Fix import orders
- Rename stutter structs

Signed-off-by: Patryk Matyjasek <pmatyjasek@sumologic.com>
  • Loading branch information
pmatyjasek-sumo committed May 19, 2021
1 parent 22bcedc commit 41cf216
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- Remove `tracetranslator.TagHTTPStatusCode`, use `conventions.AttributeHTTPStatusCode` (#3111)
- Remove OpenCensus status constants and transformation (#3110)
- Remove `tracetranslator.AttributeArrayToSlice`, not used in core or contrib (#3109)
- Introduce `ServiceSettings` and `ApplicationSettings` instead of `Parameters` (#3163)
- Introduce `SvcSettings` and `AppSettings` instead of `Parameters` (#3163)

## v0.26.0 Beta

Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func main() {
Factories: factories,
}

if err := run(service.ApplicationSettings{CommonSettings: commonSettings}); err != nil {
if err := run(service.AppSettings{CommonSettings: commonSettings}); err != nil {
log.Fatal(err)
}
}

func runInteractive(settings service.ApplicationSettings) error {
func runInteractive(settings service.AppSettings) error {
app, err := service.New(settings)
if err != nil {
return fmt.Errorf("failed to construct the application: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/otelcol/main_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ package main

import "go.opentelemetry.io/collector/service"

func run(settings service.ApplicationSettings) error {
func run(settings service.AppSettings) error {
return runInteractive(settings)
}
4 changes: 2 additions & 2 deletions cmd/otelcol/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"go.opentelemetry.io/collector/service"
)

func run(set service.ApplicationSettings) error {
func run(set service.AppSettings) error {
if useInteractiveMode, err := checkUseInteractiveMode(); err != nil {
return err
} else if useInteractiveMode {
Expand All @@ -51,7 +51,7 @@ func checkUseInteractiveMode() (bool, error) {
}
}

func runService(set service.ApplicationSettings) error {
func runService(set service.AppSettings) error {
// do not need to supply service name when startup is invoked through Service Control Manager directly
if err := svc.Run("", service.NewWindowsService(set)); err != nil {
return fmt.Errorf("failed to start service %w", err)
Expand Down
4 changes: 2 additions & 2 deletions component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ type Component interface {
Shutdown(ctx context.Context) error
}

// ComponentSettings is passed to ReceiverFactory.Create* functions.
type ComponentSettings struct {
// Settings is passed to ReceiverFactory.Create* functions.
type Settings struct {
// Logger that the factory can use during creation and can pass to the created
// component to be used later as well.
Logger *zap.Logger
Expand Down
4 changes: 2 additions & 2 deletions service/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type Application struct {
}

// New creates and returns a new instance of Application.
func New(set ApplicationSettings) (*Application, error) {
func New(set AppSettings) (*Application, error) {
if err := configcheck.ValidateConfigFromFactories(set.CommonSettings.Factories); err != nil {
return nil, err
}
Expand Down Expand Up @@ -229,7 +229,7 @@ func (app *Application) setupConfigurationComponents(ctx context.Context) error
Factories: app.factories,
}

service, err := newService(&ServiceSettings{
service, err := newService(&SvcSettings{
CommonSettings: commonSettings,
Config: cfg,
Logger: app.logger,
Expand Down
6 changes: 3 additions & 3 deletions service/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestApplication_Start(t *testing.T) {
Factories: factories,
}

app, err := New(ApplicationSettings{CommonSettings: commonSettings, LoggingOptions: []zap.Option{zap.Hooks(hook)}})
app, err := New(AppSettings{CommonSettings: commonSettings, LoggingOptions: []zap.Option{zap.Hooks(hook)}})
require.NoError(t, err)
assert.Equal(t, app.rootCmd, app.Command())

Expand Down Expand Up @@ -129,7 +129,7 @@ func TestApplication_ReportError(t *testing.T) {
Factories: factories,
}

app, err := New(ApplicationSettings{CommonSettings: commonSettings})
app, err := New(AppSettings{CommonSettings: commonSettings})
require.NoError(t, err)

app.rootCmd.SetArgs([]string{"--config=testdata/otelcol-config-minimal.yaml"})
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestApplication_StartAsGoRoutine(t *testing.T) {
Factories: factories,
}

params := ApplicationSettings{
params := AppSettings{
CommonSettings: commonSettings,
ParserProvider: new(minimalParserLoader),
}
Expand Down
6 changes: 3 additions & 3 deletions service/application_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
)

type WindowsService struct {
settings ApplicationSettings
settings AppSettings
app *Application
}

func NewWindowsService(set ApplicationSettings) *WindowsService {
func NewWindowsService(set AppSettings) *WindowsService {
return &WindowsService{settings: set}
}

Expand Down Expand Up @@ -120,7 +120,7 @@ func openEventLog(serviceName string) (*eventlog.Log, error) {
return elog, nil
}

func newWithEventViewerLoggingHook(set ApplicationSettings, elog *eventlog.Log) (*Application, error) {
func newWithEventViewerLoggingHook(set AppSettings, elog *eventlog.Log) (*Application, error) {
set.LoggingOptions = append(
set.LoggingOptions,
zap.Hooks(func(entry zapcore.Entry) error {
Expand Down
2 changes: 1 addition & 1 deletion service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type service struct {
builtExtensions builder.Extensions
}

func newService(set *ServiceSettings) (*service, error) {
func newService(set *SvcSettings) (*service, error) {
srv := &service{
factories: set.CommonSettings.Factories,
buildInfo: set.CommonSettings.BuildInfo,
Expand Down
2 changes: 1 addition & 1 deletion service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func createExampleService(t *testing.T) *service {
Factories: factories,
}

srv, err := newService(&ServiceSettings{
srv, err := newService(&SvcSettings{
CommonSettings: commonSettings,
Logger: zap.NewNop(),
Config: cfg,
Expand Down
11 changes: 6 additions & 5 deletions service/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package service

import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/service/parserprovider"
"go.uber.org/zap"
)

// CommonSettings holds common settings for Service and Application
Expand All @@ -30,8 +31,8 @@ type CommonSettings struct {
BuildInfo component.BuildInfo
}

// ServiceSettings holds configuration for building a new service.
type ServiceSettings struct {
// SvcSettings holds configuration for building a new service.
type SvcSettings struct {
// CommonSettings contains Factories and BuildInfo
CommonSettings CommonSettings

Expand All @@ -45,8 +46,8 @@ type ServiceSettings struct {
AsyncErrorChannel chan error
}

// ApplicationSettings holds configuration for creating a new Application.
type ApplicationSettings struct {
// AppSettings holds configuration for creating a new Application.
type AppSettings struct {
// CommonSettings contains Factories and BuildInfo
CommonSettings CommonSettings

Expand Down
2 changes: 1 addition & 1 deletion testbed/testbed/otelcol_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (ipp *InProcessCollector) Start(args StartParams) error {
},
Factories: ipp.factories,
}
settings := service.ApplicationSettings{
settings := service.AppSettings{
CommonSettings: commonSettings,
ParserProvider: parserprovider.NewInMemory(strings.NewReader(ipp.configStr)),
}
Expand Down

0 comments on commit 41cf216

Please sign in to comment.