Skip to content

Commit

Permalink
[chore] more unused params (open-telemetry#22954)
Browse files Browse the repository at this point in the history
Linked issue: open-telemetry#20424

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten committed May 30, 2023
1 parent a0a3ebe commit 39641df
Show file tree
Hide file tree
Showing 49 changed files with 88 additions and 88 deletions.
6 changes: 3 additions & 3 deletions exporter/sumologicexporter/compress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ type mockedEncrypter struct {
closeError error
}

func (e mockedEncrypter) Reset(dst io.Writer) {
func (e mockedEncrypter) Reset(_ io.Writer) {
}

func (e mockedEncrypter) Write(p []byte) (n int, err error) {
func (e mockedEncrypter) Write(_ []byte) (n int, err error) {
return 0, e.writeError
}

Expand All @@ -43,7 +43,7 @@ func getTestCompressor(w error, c error) compressor {

type mockedReader struct{}

func (r mockedReader) Read(p []byte) (n int, err error) {
func (r mockedReader) Read(_ []byte) (n int, err error) {
return 0, errors.New("read error")
}

Expand Down
4 changes: 2 additions & 2 deletions extension/bearertokenauthextension/bearertokenauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newBearerTokenAuth(cfg *Config, logger *zap.Logger) *BearerTokenAuth {
// Start of BearerTokenAuth does nothing and returns nil if no filename
// is specified. Otherwise a routine is started to monitor the file containing
// the token to be transferred.
func (b *BearerTokenAuth) Start(ctx context.Context, host component.Host) error {
func (b *BearerTokenAuth) Start(ctx context.Context, _ component.Host) error {
if b.filename == "" {
return nil
}
Expand Down Expand Up @@ -135,7 +135,7 @@ func (b *BearerTokenAuth) refreshToken() {
}

// Shutdown of BearerTokenAuth does nothing and returns nil
func (b *BearerTokenAuth) Shutdown(ctx context.Context) error {
func (b *BearerTokenAuth) Shutdown(_ context.Context) error {
if b.filename == "" {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion extension/jaegerremotesampling/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type samplingServer struct {
api_v2.UnimplementedSamplingManagerServer
}

func (s samplingServer) GetSamplingStrategy(ctx context.Context, param *api_v2.SamplingStrategyParameters) (*api_v2.SamplingStrategyResponse, error) {
func (s samplingServer) GetSamplingStrategy(_ context.Context, _ *api_v2.SamplingStrategyParameters) (*api_v2.SamplingStrategyResponse, error) {
return &api_v2.SamplingStrategyResponse{
StrategyType: api_v2.SamplingStrategyType_PROBABILISTIC,
}, nil
Expand Down
6 changes: 3 additions & 3 deletions extension/jaegerremotesampling/internal/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ type grpcServerMock struct {
timeToGracefulStop time.Duration
}

func (g *grpcServerMock) Serve(lis net.Listener) error { return nil }
func (g *grpcServerMock) Stop() {}
func (g *grpcServerMock) GracefulStop() { time.Sleep(g.timeToGracefulStop) }
func (g *grpcServerMock) Serve(_ net.Listener) error { return nil }
func (g *grpcServerMock) Stop() {}
func (g *grpcServerMock) GracefulStop() { time.Sleep(g.timeToGracefulStop) }
4 changes: 2 additions & 2 deletions extension/observer/dockerobserver/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func newObserver(logger *zap.Logger, config *Config) (extension.Extension, error
}

// Start will instantiate required components needed by the Docker observer
func (d *dockerObserver) Start(ctx context.Context, host component.Host) error {
func (d *dockerObserver) Start(ctx context.Context, _ component.Host) error {
dCtx, cancel := context.WithCancel(context.Background())
d.cancel = cancel
d.ctx = dCtx
Expand Down Expand Up @@ -103,7 +103,7 @@ func (d *dockerObserver) Start(ctx context.Context, host component.Host) error {
return nil
}

func (d *dockerObserver) Shutdown(ctx context.Context) error {
func (d *dockerObserver) Shutdown(_ context.Context) error {
d.cancel()
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion extension/observer/ecsobserver/docker_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (d *dockerLabelMatcher) matcherType() matcherType {
// MatchTargets first checks the port label to find the expected port value.
// Then it checks if that port is specified in container definition.
// It only returns match target when both conditions are met.
func (d *dockerLabelMatcher) matchTargets(t *taskAnnotated, c *ecs.ContainerDefinition) ([]matchedTarget, error) {
func (d *dockerLabelMatcher) matchTargets(_ *taskAnnotated, c *ecs.ContainerDefinition) ([]matchedTarget, error) {
portLabel := d.cfg.PortLabel

// Only check port label
Expand Down
2 changes: 1 addition & 1 deletion extension/observer/ecsobserver/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"go.uber.org/zap"
)

func TestSetInvalidError(t *testing.T) {
func TestSetInvalidError(_ *testing.T) {
printErrors(zap.NewExample(), nil) // you know, for coverage
// The actual test cen be found in the following locations:
//
Expand Down
2 changes: 1 addition & 1 deletion extension/observer/ecsobserver/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (e *ecsObserver) Start(_ context.Context, host component.Host) error {
return nil
}

func (e *ecsObserver) Shutdown(ctx context.Context) error {
func (e *ecsObserver) Shutdown(_ context.Context) error {
e.logger.Info("Stopping ECSDiscovery")
e.cancel()
return nil
Expand Down
2 changes: 1 addition & 1 deletion extension/observer/ecsobserver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func createDefaultConfig() component.Config {
return &cfg
}

func createExtension(ctx context.Context, params extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
func createExtension(_ context.Context, params extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
sdCfg := cfg.(*Config)
fetcher, err := newTaskFetcherFromConfig(*sdCfg, params.Logger)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions extension/observer/k8sobserver/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type k8sObserver struct {
}

// Start will populate the cache.SharedInformers for pods and nodes as configured and run them as goroutines.
func (k *k8sObserver) Start(ctx context.Context, host component.Host) error {
func (k *k8sObserver) Start(_ context.Context, _ component.Host) error {
if k.once == nil {
return fmt.Errorf("cannot Start() partial k8sObserver (nil *sync.Once)")
}
Expand Down Expand Up @@ -65,7 +65,7 @@ func (k *k8sObserver) Start(ctx context.Context, host component.Host) error {
}

// Shutdown tells any cache.SharedInformers to stop running.
func (k *k8sObserver) Shutdown(ctx context.Context) error {
func (k *k8sObserver) Shutdown(_ context.Context) error {
close(k.stop)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion extension/observer/k8sobserver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func createDefaultConfig() component.Config {

// CreateExtension creates the extension based on this config.
func createExtension(
ctx context.Context,
_ context.Context,
params extension.CreateSettings,
cfg component.Config,
) (extension.Extension, error) {
Expand Down
2 changes: 1 addition & 1 deletion extension/observer/k8sobserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (h *handler) ListEndpoints() []observer.Endpoint {
}

// OnAdd is called in response to a new pod or node being detected.
func (h *handler) OnAdd(objectInterface interface{}, isInitialList bool) {
func (h *handler) OnAdd(objectInterface interface{}, _ bool) {
var endpoints []observer.Endpoint

switch object := objectInterface.(type) {
Expand Down
2 changes: 1 addition & 1 deletion extension/sigv4authextension/signingroundtripper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

type errorRoundTripper struct{}

func (ert *errorRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
func (ert *errorRoundTripper) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/adapter/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (o *UnstartableOperator) Start(_ operator.Persister) error {
}

// Process will return nil
func (o *UnstartableOperator) Process(ctx context.Context, entry *entry.Entry) error {
func (o *UnstartableOperator) Process(_ context.Context, _ *entry.Entry) error {
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/stanza/entry/nil_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ package entry // import "github.com/open-telemetry/opentelemetry-collector-contr
type NilField struct{}

// Get will return always return nil
func (l NilField) Get(entry *Entry) (interface{}, bool) {
func (l NilField) Get(_ *Entry) (interface{}, bool) {
return nil, true
}

// Set will do nothing and return no error
func (l NilField) Set(entry *Entry, val interface{}) error {
func (l NilField) Set(_ *Entry, _ interface{}) error {
return nil
}

// Delete will do nothing and return no error
func (l NilField) Delete(entry *Entry) (interface{}, bool) {
func (l NilField) Delete(_ *Entry) (interface{}, bool) {
return nil, true
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/fileconsumer/roller_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ OUTER:
lostWG.Wait()
}

func (r *detectLostFiles) roll(ctx context.Context, readers []*Reader) {
func (r *detectLostFiles) roll(_ context.Context, readers []*Reader) {
for _, reader := range r.oldReaders {
reader.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/fileconsumer/splitter_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func newCustomizeSplitterFactory(
}

// Build builds Multiline Splitter struct
func (factory *customizeSplitterFactory) Build(maxLogSize int) (bufio.SplitFunc, error) {
func (factory *customizeSplitterFactory) Build(_ int) (bufio.SplitFunc, error) {
flusher := factory.Flusher.Build()
if flusher != nil {
return flusher.SplitFunc(factory.Splitter), nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (f *FakeBuilder) Build(_ *zap.SugaredLogger) (Operator, error) {
}
func (f *FakeBuilder) ID() string { return "operator" }
func (f *FakeBuilder) Type() string { return "operator" }
func (f *FakeBuilder) SetID(s string) {}
func (f *FakeBuilder) SetID(_ string) {}

func TestUnmarshalJSONErrors(t *testing.T) {
t.Cleanup(func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/helper/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (i *InputOperator) CanProcess() bool {
}

// Process will always return an error if called.
func (i *InputOperator) Process(ctx context.Context, entry *entry.Entry) error {
func (i *InputOperator) Process(_ context.Context, entry *entry.Entry) error {
i.Errorw("Operator received an entry, but can not process", zap.Any("entry", entry))
return errors.NewError(
"Operator can not process logs.",
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/helper/ip_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestIPResolver100Hits(t *testing.T) {
}
}

func TestIPResolverWithMultipleStops(t *testing.T) {
func TestIPResolverWithMultipleStops(_ *testing.T) {
resolver := NewIPResolver()

resolver.Stop()
Expand Down
4 changes: 2 additions & 2 deletions pkg/stanza/operator/helper/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ func (o *OutputOperator) GetOutputIDs() []string {
}

// SetOutputs will return an error if called.
func (o *OutputOperator) SetOutputs(operators []operator.Operator) error {
func (o *OutputOperator) SetOutputs(_ []operator.Operator) error {
return errors.NewError(
"Operator can not output, but is attempting to set an output.",
"This is an unexpected internal error. Please submit a bug/issue.",
)
}

// SetOutputIDs will return nothing and does nothing.
func (o *OutputOperator) SetOutputIDs(opIDs []string) {
func (o *OutputOperator) SetOutputIDs(_ []string) {
}
2 changes: 1 addition & 1 deletion pkg/stanza/operator/helper/severity_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type SeverityConfig struct {
}

// Build builds a SeverityParser from a SeverityConfig
func (c *SeverityConfig) Build(logger *zap.SugaredLogger) (SeverityParser, error) {
func (c *SeverityConfig) Build(_ *zap.SugaredLogger) (SeverityParser, error) {
operatorMapping := getBuiltinMapping(c.Preset)

for severity, unknown := range c.Mapping {
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/helper/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (t *TransformerOperator) HandleEntryError(ctx context.Context, entry *entry
return err
}

func (t *TransformerOperator) Skip(ctx context.Context, entry *entry.Entry) (bool, error) {
func (t *TransformerOperator) Skip(_ context.Context, entry *entry.Entry) (bool, error) {
if t.IfExpr == nil {
return false, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/input/udp/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type Input struct {
}

// Start will start listening for messages on a socket.
func (u *Input) Start(persister operator.Persister) error {
func (u *Input) Start(_ operator.Persister) error {
ctx, cancel := context.WithCancel(context.Background())
u.cancel = cancel

Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/output/drop/drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ type Output struct {
}

// Process will drop the incoming entry.
func (p *Output) Process(ctx context.Context, entry *entry.Entry) error {
func (p *Output) Process(_ context.Context, _ *entry.Entry) error {
return nil
}
2 changes: 1 addition & 1 deletion pkg/stanza/operator/output/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (fo *Output) Stop() error {
}

// Process will write an entry to the output file.
func (fo *Output) Process(ctx context.Context, entry *entry.Entry) error {
func (fo *Output) Process(_ context.Context, entry *entry.Entry) error {
fo.mux.Lock()
defer fo.mux.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/output/stdout/stdout.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Output struct {
}

// Process will log entries received.
func (o *Output) Process(ctx context.Context, entry *entry.Entry) error {
func (o *Output) Process(_ context.Context, entry *entry.Entry) error {
o.mux.Lock()
err := o.encoder.Encode(entry)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/transformer/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (p *Transformer) SetOutputs(operators []operator.Operator) error {
}

// SetOutputIDs will do nothing.
func (p *Transformer) SetOutputIDs(opIDs []string) {}
func (p *Transformer) SetOutputIDs(_ []string) {}

// findOperators will find a subset of operators from a collection.
func (p *Transformer) findOperators(operators []operator.Operator, operatorIDs []string) ([]operator.Operator, error) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/stanza/testutil/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func (f *FakeOutput) Outputs() []operator.Operator { return nil }
func (f *FakeOutput) GetOutputIDs() []string { return nil }

// SetOutputs immediately returns nil for a fake output
func (f *FakeOutput) SetOutputs(outputs []operator.Operator) error { return nil }
func (f *FakeOutput) SetOutputs(_ []operator.Operator) error { return nil }

// SetOutputIDs immediately returns nil for a fake output
func (f *FakeOutput) SetOutputIDs(s []string) {}
func (f *FakeOutput) SetOutputIDs(_ []string) {}

// Start immediately returns nil for a fake output
func (f *FakeOutput) Start(_ operator.Persister) error { return nil }
Expand All @@ -73,7 +73,7 @@ func (f *FakeOutput) Stop() error { return nil }
func (f *FakeOutput) Type() string { return "fake_output" }

// Process will place all incoming entries on the Received channel of a fake output
func (f *FakeOutput) Process(ctx context.Context, entry *entry.Entry) error {
func (f *FakeOutput) Process(_ context.Context, entry *entry.Entry) error {
f.Received <- entry
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/stanza/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ type mockPersister struct {
dataMux sync.Mutex
}

func (p *mockPersister) Get(ctx context.Context, k string) ([]byte, error) {
func (p *mockPersister) Get(_ context.Context, k string) ([]byte, error) {
p.dataMux.Lock()
defer p.dataMux.Unlock()
return p.data[k], nil
}

func (p *mockPersister) Set(ctx context.Context, k string, v []byte) error {
func (p *mockPersister) Set(_ context.Context, k string, v []byte) error {
p.dataMux.Lock()
defer p.dataMux.Unlock()
p.data[k] = v
return nil
}

func (p *mockPersister) Delete(ctx context.Context, k string) error {
func (p *mockPersister) Delete(_ context.Context, k string) error {
p.dataMux.Lock()
defer p.dataMux.Unlock()
delete(p.data, k)
Expand Down
4 changes: 2 additions & 2 deletions processor/filterprocessor/internal/common/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func newHasAttributeOnDatapointFactory() ottl.Factory[ottlmetric.TransformContex
return ottl.NewFactory("HasAttrOnDatapoint", &hasAttributeOnDatapointArguments{}, createHasAttributeOnDatapointFunction)
}

func createHasAttributeOnDatapointFunction(fCtx ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[ottlmetric.TransformContext], error) {
func createHasAttributeOnDatapointFunction(_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[ottlmetric.TransformContext], error) {
args, ok := oArgs.(*hasAttributeOnDatapointArguments)

if !ok {
Expand All @@ -57,7 +57,7 @@ func newHasAttributeKeyOnDatapointFactory() ottl.Factory[ottlmetric.TransformCon
return ottl.NewFactory("HasAttrKeyOnDatapoint", &hasAttributeKeyOnDatapointArguments{}, createHasAttributeKeyOnDatapointFunction)
}

func createHasAttributeKeyOnDatapointFunction(fCtx ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[ottlmetric.TransformContext], error) {
func createHasAttributeKeyOnDatapointFunction(_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[ottlmetric.TransformContext], error) {
args, ok := oArgs.(*hasAttributeKeyOnDatapointArguments)

if !ok {
Expand Down
2 changes: 1 addition & 1 deletion processor/k8sattributesprocessor/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func selectors() (labels.Selector, fields.Selector) {
}

// newFakeClient instantiates a new FakeClient object and satisfies the ClientProvider type
func newFakeClient(_ *zap.Logger, apiCfg k8sconfig.APIConfig, rules kube.ExtractionRules, filters kube.Filters, associations []kube.Association, exclude kube.Excludes, _ kube.APIClientsetProvider, _ kube.InformerProvider, _ kube.InformerProviderNamespace, _ kube.InformerProviderReplicaSet) (kube.Client, error) {
func newFakeClient(_ *zap.Logger, _ k8sconfig.APIConfig, rules kube.ExtractionRules, filters kube.Filters, associations []kube.Association, _ kube.Excludes, _ kube.APIClientsetProvider, _ kube.InformerProvider, _ kube.InformerProviderNamespace, _ kube.InformerProviderReplicaSet) (kube.Client, error) {
cs := fake.NewSimpleClientset()

ls, fs := selectors()
Expand Down
Loading

0 comments on commit 39641df

Please sign in to comment.