[chore] fix unused params (#9578)
Related to #9577 Signed-off-by: Alex Boten <aboten@lightstep.com>
This commit is contained in:
parent
5cfc68fc27
commit
4688461318
|
|
@ -53,7 +53,7 @@ build configuration given by the "--config" argument. If no build
|
|||
configuration is provided, ocb will generate a default Collector.
|
||||
`,
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
if err := initConfig(cmd.Flags()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func versionCommand() *cobra.Command {
|
|||
Use: "version",
|
||||
Short: "Version of ocb",
|
||||
Long: "Prints the version of the ocb binary",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
version, err := binVersion()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func TestEnsureTemplatesLoaded(t *testing.T) {
|
|||
}
|
||||
count = 0
|
||||
)
|
||||
assert.NoError(t, fs.WalkDir(templateFS, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
assert.NoError(t, fs.WalkDir(templateFS, ".", func(path string, d fs.DirEntry, _ error) error {
|
||||
if d != nil && d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func TestValidateMetricDuplicates(t *testing.T) {
|
|||
"container.uptime": {"docker_stats", "kubeletstats"},
|
||||
}
|
||||
allMetrics := map[string][]string{}
|
||||
err := filepath.Walk("../../receiver", func(path string, info fs.FileInfo, err error) error {
|
||||
err := filepath.Walk("../../receiver", func(path string, info fs.FileInfo, _ error) error {
|
||||
if info.Name() == "metadata.yaml" {
|
||||
md, err := loadMetadata(path)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -812,7 +812,7 @@ func TestStreamInterceptorEnhancesClient(t *testing.T) {
|
|||
ctx: inCtx,
|
||||
}
|
||||
|
||||
handler := func(srv any, stream grpc.ServerStream) error {
|
||||
handler := func(_ any, stream grpc.ServerStream) error {
|
||||
outContext = stream.Context()
|
||||
return nil
|
||||
}
|
||||
|
|
@ -927,7 +927,7 @@ func TestDefaultUnaryInterceptorAuthSucceeded(t *testing.T) {
|
|||
|
||||
return ctx, nil
|
||||
}
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
handler := func(ctx context.Context, _ any) (any, error) {
|
||||
handlerCalled = true
|
||||
cl := client.FromContext(ctx)
|
||||
assert.Equal(t, "1.2.3.4", cl.Addr.String())
|
||||
|
|
@ -953,7 +953,7 @@ func TestDefaultUnaryInterceptorAuthFailure(t *testing.T) {
|
|||
authCalled = true
|
||||
return context.Background(), expectedErr
|
||||
}
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
handler := func(_ context.Context, _ any) (any, error) {
|
||||
assert.FailNow(t, "the handler should not have been called on auth failure!")
|
||||
return nil, nil
|
||||
}
|
||||
|
|
@ -974,7 +974,7 @@ func TestDefaultUnaryInterceptorMissingMetadata(t *testing.T) {
|
|||
assert.FailNow(t, "the auth func should not have been called!")
|
||||
return context.Background(), nil
|
||||
}
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
handler := func(_ context.Context, _ any) (any, error) {
|
||||
assert.FailNow(t, "the handler should not have been called!")
|
||||
return nil, nil
|
||||
}
|
||||
|
|
@ -998,7 +998,7 @@ func TestDefaultStreamInterceptorAuthSucceeded(t *testing.T) {
|
|||
})
|
||||
return ctx, nil
|
||||
}
|
||||
handler := func(srv any, stream grpc.ServerStream) error {
|
||||
handler := func(_ any, stream grpc.ServerStream) error {
|
||||
// ensure that the client information is propagated down to the underlying stream
|
||||
cl := client.FromContext(stream.Context())
|
||||
assert.Equal(t, "1.2.3.4", cl.Addr.String())
|
||||
|
|
@ -1027,7 +1027,7 @@ func TestDefaultStreamInterceptorAuthFailure(t *testing.T) {
|
|||
authCalled = true
|
||||
return context.Background(), expectedErr
|
||||
}
|
||||
handler := func(srv any, stream grpc.ServerStream) error {
|
||||
handler := func(_ any, _ grpc.ServerStream) error {
|
||||
assert.FailNow(t, "the handler should not have been called on auth failure!")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1050,7 +1050,7 @@ func TestDefaultStreamInterceptorMissingMetadata(t *testing.T) {
|
|||
assert.FailNow(t, "the auth func should not have been called!")
|
||||
return context.Background(), nil
|
||||
}
|
||||
handler := func(srv any, stream grpc.ServerStream) error {
|
||||
handler := func(_ any, _ grpc.ServerStream) error {
|
||||
assert.FailNow(t, "the handler should not have been called!")
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ func httpContentDecompressor(h http.Handler, eh func(w http.ResponseWriter, r *h
|
|||
errHandler: errHandler,
|
||||
base: h,
|
||||
decoders: map[string]func(body io.ReadCloser) (io.ReadCloser, error){
|
||||
"": func(body io.ReadCloser) (io.ReadCloser, error) {
|
||||
"": func(_ io.ReadCloser) (io.ReadCloser, error) {
|
||||
// Not a compressed payload. Nothing to do.
|
||||
return nil, nil
|
||||
},
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ func (*copyFailBody) Close() error {
|
|||
}
|
||||
|
||||
func TestHTTPContentCompressionCopyError(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
t.Cleanup(server.Close)
|
||||
|
|
@ -333,7 +333,7 @@ func (*closeFailBody) Close() error {
|
|||
}
|
||||
|
||||
func TestHTTPContentCompressionRequestBodyCloseError(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
t.Cleanup(server.Close)
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ func (hss *ServerConfig) ToServer(host component.Host, settings component.Teleme
|
|||
otelhttp.WithTracerProvider(settings.TracerProvider),
|
||||
otelhttp.WithMeterProvider(settings.MeterProvider),
|
||||
otelhttp.WithPropagators(otel.GetTextMapPropagator()),
|
||||
otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
|
||||
otelhttp.WithSpanNameFormatter(func(_ string, r *http.Request) string {
|
||||
return r.URL.Path
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ func TestAllHTTPClientSettings(t *testing.T) {
|
|||
},
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 512,
|
||||
CustomRoundTripper: func(next http.RoundTripper) (http.RoundTripper, error) { return nil, errors.New("error") },
|
||||
CustomRoundTripper: func(_ http.RoundTripper) (http.RoundTripper, error) { return nil, errors.New("error") },
|
||||
},
|
||||
shouldError: true,
|
||||
},
|
||||
|
|
@ -557,7 +557,7 @@ func TestHTTPServerWarning(t *testing.T) {
|
|||
_, err := test.settings.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
set,
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
_, errWrite := fmt.Fprint(w, "test")
|
||||
assert.NoError(t, errWrite)
|
||||
}))
|
||||
|
|
@ -703,7 +703,7 @@ func TestHttpReception(t *testing.T) {
|
|||
s, err := hss.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
componenttest.NewNopTelemetrySettings(),
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
_, errWrite := fmt.Fprint(w, "test")
|
||||
assert.NoError(t, errWrite)
|
||||
}))
|
||||
|
|
@ -816,7 +816,7 @@ func TestHttpCors(t *testing.T) {
|
|||
s, err := hss.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
componenttest.NewNopTelemetrySettings(),
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
require.NoError(t, err)
|
||||
|
|
@ -856,7 +856,7 @@ func TestHttpCorsInvalidSettings(t *testing.T) {
|
|||
s, err := hss.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
componenttest.NewNopTelemetrySettings(),
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, s)
|
||||
require.NoError(t, s.Close())
|
||||
|
|
@ -876,7 +876,7 @@ func TestHttpCorsWithSettings(t *testing.T) {
|
|||
host := &mockHost{
|
||||
ext: map[component.ID]component.Component{
|
||||
mockID: auth.NewServer(
|
||||
auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) {
|
||||
auth.WithServerAuthenticate(func(ctx context.Context, _ map[string][]string) (context.Context, error) {
|
||||
return ctx, errors.New("Settings failed")
|
||||
}),
|
||||
),
|
||||
|
|
@ -932,7 +932,7 @@ func TestHttpServerHeaders(t *testing.T) {
|
|||
s, err := hss.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
componenttest.NewNopTelemetrySettings(),
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
require.NoError(t, err)
|
||||
|
|
@ -1177,7 +1177,7 @@ func TestServerAuth(t *testing.T) {
|
|||
host := &mockHost{
|
||||
ext: map[component.ID]component.Component{
|
||||
mockID: auth.NewServer(
|
||||
auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) {
|
||||
auth.WithServerAuthenticate(func(ctx context.Context, _ map[string][]string) (context.Context, error) {
|
||||
authCalled = true
|
||||
return ctx, nil
|
||||
}),
|
||||
|
|
@ -1186,7 +1186,7 @@ func TestServerAuth(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handler := http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
|
||||
handlerCalled = true
|
||||
})
|
||||
|
||||
|
|
@ -1224,14 +1224,14 @@ func TestFailedServerAuth(t *testing.T) {
|
|||
host := &mockHost{
|
||||
ext: map[component.ID]component.Component{
|
||||
mockID: auth.NewServer(
|
||||
auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) {
|
||||
auth.WithServerAuthenticate(func(ctx context.Context, _ map[string][]string) (context.Context, error) {
|
||||
return ctx, errors.New("Settings failed")
|
||||
}),
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
srv, err := hss.ToServer(host, componenttest.NewNopTelemetrySettings(), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
srv, err := hss.ToServer(host, componenttest.NewNopTelemetrySettings(), http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
|
||||
require.NoError(t, err)
|
||||
|
||||
// test
|
||||
|
|
@ -1248,17 +1248,16 @@ func TestServerWithErrorHandler(t *testing.T) {
|
|||
hss := ServerConfig{
|
||||
Endpoint: "localhost:0",
|
||||
}
|
||||
eh := func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int) {
|
||||
eh := func(w http.ResponseWriter, _ *http.Request, _ string, statusCode int) {
|
||||
assert.Equal(t, statusCode, http.StatusBadRequest)
|
||||
// custom error handler changes returned status code
|
||||
http.Error(w, "invalid request", http.StatusInternalServerError)
|
||||
|
||||
}
|
||||
|
||||
srv, err := hss.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
componenttest.NewNopTelemetrySettings(),
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}),
|
||||
http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}),
|
||||
WithErrorHandler(eh),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -1286,7 +1285,7 @@ func TestServerWithDecoder(t *testing.T) {
|
|||
srv, err := hss.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
componenttest.NewNopTelemetrySettings(),
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}),
|
||||
http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}),
|
||||
WithDecoder("something-else", decoder),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -1362,7 +1361,7 @@ func BenchmarkHttpRequest(b *testing.B) {
|
|||
s, err := hss.ToServer(
|
||||
componenttest.NewNopHost(),
|
||||
componenttest.NewNopTelemetrySettings(),
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
_, errWrite := fmt.Fprint(w, "test")
|
||||
require.NoError(b, errWrite)
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -169,8 +169,8 @@ func (c TLSSetting) loadTLSConfig() (*tls.Config, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load TLS cert and key: %w", err)
|
||||
}
|
||||
getCertificate = func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
|
||||
getClientCertificate = func(cri *tls.CertificateRequestInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
|
||||
getCertificate = func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
|
||||
getClientCertificate = func(_ *tls.CertificateRequestInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
|
||||
}
|
||||
|
||||
minTLS, err := convertVersion(c.MinVersion, defaultMinTLSVersion)
|
||||
|
|
@ -342,7 +342,7 @@ func (c TLSServerSetting) LoadTLSConfig() (*tls.Config, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tlsCfg.GetConfigForClient = func(t *tls.ClientHelloInfo) (*tls.Config, error) { return reloader.getClientConfig(tlsCfg) }
|
||||
tlsCfg.GetConfigForClient = func(_ *tls.ClientHelloInfo) (*tls.Config, error) { return reloader.getClientConfig(tlsCfg) }
|
||||
}
|
||||
tlsCfg.ClientCAs = reloader.certPool
|
||||
tlsCfg.ClientAuth = tls.RequireAndVerifyClientCert
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ func TestUnsupportedScheme(t *testing.T) {
|
|||
|
||||
func TestEmptyURI(t *testing.T) {
|
||||
fp := New(HTTPScheme, confmap.ProviderSettings{})
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
|
@ -254,7 +254,7 @@ func TestEmptyURI(t *testing.T) {
|
|||
|
||||
func TestRetrieveFromShutdownServer(t *testing.T) {
|
||||
fp := New(HTTPScheme, confmap.ProviderSettings{})
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
|
||||
ts.Close()
|
||||
_, err := fp.Retrieve(context.Background(), ts.URL, nil)
|
||||
assert.Error(t, err)
|
||||
|
|
@ -263,7 +263,7 @@ func TestRetrieveFromShutdownServer(t *testing.T) {
|
|||
|
||||
func TestNonExistent(t *testing.T) {
|
||||
fp := New(HTTPScheme, confmap.ProviderSettings{})
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
|
@ -274,7 +274,7 @@ func TestNonExistent(t *testing.T) {
|
|||
|
||||
func TestInvalidYAML(t *testing.T) {
|
||||
fp := New(HTTPScheme, confmap.ProviderSettings{})
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err := w.Write([]byte("wrong : ["))
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ func TestResolverErrors(t *testing.T) {
|
|||
locations: []string{"mock:", "err:"},
|
||||
providers: []Provider{
|
||||
&mockProvider{},
|
||||
&mockProvider{scheme: "err", retM: map[string]any{}, closeFunc: func(ctx context.Context) error { return errors.New("close_err") }},
|
||||
&mockProvider{scheme: "err", retM: map[string]any{}, closeFunc: func(_ context.Context) error { return errors.New("close_err") }},
|
||||
},
|
||||
expectCloseErr: true,
|
||||
},
|
||||
|
|
@ -270,7 +270,7 @@ func TestResolver(t *testing.T) {
|
|||
numCalls := atomic.Int32{}
|
||||
resolver, err := NewResolver(ResolverSettings{
|
||||
URIs: []string{"mock:"},
|
||||
Providers: makeMapProvidersMap(&mockProvider{retM: map[string]any{}, closeFunc: func(ctx context.Context) error {
|
||||
Providers: makeMapProvidersMap(&mockProvider{retM: map[string]any{}, closeFunc: func(_ context.Context) error {
|
||||
numCalls.Add(1)
|
||||
return nil
|
||||
}}),
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import (
|
|||
// NewErr returns a Consumer that just drops all received data and returns the specified error to Consume* callers.
|
||||
func NewErr(err error) Consumer {
|
||||
return &baseConsumer{
|
||||
ConsumeTracesFunc: func(ctx context.Context, td ptrace.Traces) error { return err },
|
||||
ConsumeMetricsFunc: func(ctx context.Context, md pmetric.Metrics) error { return err },
|
||||
ConsumeLogsFunc: func(ctx context.Context, ld plog.Logs) error { return err },
|
||||
ConsumeTracesFunc: func(_ context.Context, _ ptrace.Traces) error { return err },
|
||||
ConsumeMetricsFunc: func(_ context.Context, _ pmetric.Metrics) error { return err },
|
||||
ConsumeLogsFunc: func(_ context.Context, _ plog.Logs) error { return err },
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import (
|
|||
// NewNop returns a Consumer that just drops all received data and returns no error.
|
||||
func NewNop() Consumer {
|
||||
return &baseConsumer{
|
||||
ConsumeTracesFunc: func(ctx context.Context, td ptrace.Traces) error { return nil },
|
||||
ConsumeMetricsFunc: func(ctx context.Context, md pmetric.Metrics) error { return nil },
|
||||
ConsumeLogsFunc: func(ctx context.Context, ld plog.Logs) error { return nil },
|
||||
ConsumeTracesFunc: func(_ context.Context, _ ptrace.Traces) error { return nil },
|
||||
ConsumeMetricsFunc: func(_ context.Context, _ pmetric.Metrics) error { return nil },
|
||||
ConsumeLogsFunc: func(_ context.Context, _ plog.Logs) error { return nil },
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ func TestBaseExporterWithOptions(t *testing.T) {
|
|||
want := errors.New("my error")
|
||||
be, err := newBaseExporter(
|
||||
defaultSettings, defaultType, false, nil, nil, newNoopObsrepSender,
|
||||
WithStart(func(ctx context.Context, host component.Host) error { return want }),
|
||||
WithShutdown(func(ctx context.Context) error { return want }),
|
||||
WithStart(func(_ context.Context, _ component.Host) error { return want }),
|
||||
WithShutdown(func(_ context.Context) error { return want }),
|
||||
WithTimeout(NewDefaultTimeoutSettings()),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ func TestLogsRequestExporter_WithShutdown_ReturnError(t *testing.T) {
|
|||
}
|
||||
|
||||
func newPushLogsData(retError error) consumer.ConsumeLogsFunc {
|
||||
return func(ctx context.Context, td plog.Logs) error {
|
||||
return func(_ context.Context, _ plog.Logs) error {
|
||||
return retError
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ func TestMetricsRequestExporter_WithShutdown_ReturnError(t *testing.T) {
|
|||
}
|
||||
|
||||
func newPushMetricsData(retError error) consumer.ConsumeMetricsFunc {
|
||||
return func(ctx context.Context, td pmetric.Metrics) error {
|
||||
return func(_ context.Context, _ pmetric.Metrics) error {
|
||||
return retError
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
)
|
||||
|
||||
func mockRequestUnmarshaler(mr Request) exporterqueue.Unmarshaler[Request] {
|
||||
return func(bytes []byte) (Request, error) {
|
||||
return func(_ []byte) (Request, error) {
|
||||
return mr, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ func TestTracesRequestExporter_WithShutdown_ReturnError(t *testing.T) {
|
|||
}
|
||||
|
||||
func newTraceDataPusher(retError error) consumer.ConsumeTracesFunc {
|
||||
return func(ctx context.Context, td ptrace.Traces) error {
|
||||
return func(_ context.Context, _ ptrace.Traces) error {
|
||||
return retError
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ func checkMetrics(t *testing.T, params CheckConsumeContractParams, mockReceiver
|
|||
fmt.Printf("Number of permanent errors: %d\n", reqCounter.error.permanent)
|
||||
fmt.Printf("Number of non-permanent errors: %d\n", reqCounter.error.nonpermanent)
|
||||
|
||||
assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
assert.EventuallyWithT(t, func(_ *assert.CollectT) {
|
||||
checkIfTestPassed(t, params.NumberOfTestElements, *reqCounter)
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ func checkTraces(t *testing.T, params CheckConsumeContractParams, mockReceiver c
|
|||
fmt.Printf("Number of permanent errors: %d\n", reqCounter.error.permanent)
|
||||
fmt.Printf("Number of non-permanent errors: %d\n", reqCounter.error.nonpermanent)
|
||||
|
||||
assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
assert.EventuallyWithT(t, func(_ *assert.CollectT) {
|
||||
checkIfTestPassed(t, params.NumberOfTestElements, *reqCounter)
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ func checkLogs(t *testing.T, params CheckConsumeContractParams, mockReceiver com
|
|||
fmt.Printf("Number of permanent errors: %d\n", reqCounter.error.permanent)
|
||||
fmt.Printf("Number of non-permanent errors: %d\n", reqCounter.error.nonpermanent)
|
||||
|
||||
assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
assert.EventuallyWithT(t, func(_ *assert.CollectT) {
|
||||
checkIfTestPassed(t, params.NumberOfTestElements, *reqCounter)
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ func TestBoundedQueue(t *testing.T) {
|
|||
assert.NoError(t, q.Offer(context.Background(), "a"))
|
||||
|
||||
numConsumed := 0
|
||||
assert.True(t, q.Consume(func(ctx context.Context, item string) error {
|
||||
assert.True(t, q.Consume(func(_ context.Context, item string) error {
|
||||
assert.Equal(t, "a", item)
|
||||
numConsumed++
|
||||
return nil
|
||||
|
|
@ -42,7 +42,7 @@ func TestBoundedQueue(t *testing.T) {
|
|||
assert.ErrorIs(t, q.Offer(context.Background(), "c"), ErrQueueIsFull)
|
||||
assert.Equal(t, 1, q.Size())
|
||||
|
||||
assert.True(t, q.Consume(func(ctx context.Context, item string) error {
|
||||
assert.True(t, q.Consume(func(_ context.Context, item string) error {
|
||||
assert.Equal(t, "b", item)
|
||||
numConsumed++
|
||||
return nil
|
||||
|
|
@ -51,7 +51,7 @@ func TestBoundedQueue(t *testing.T) {
|
|||
|
||||
for _, toAddItem := range []string{"d", "e", "f"} {
|
||||
assert.NoError(t, q.Offer(context.Background(), toAddItem))
|
||||
assert.True(t, q.Consume(func(ctx context.Context, item string) error {
|
||||
assert.True(t, q.Consume(func(_ context.Context, item string) error {
|
||||
assert.Equal(t, toAddItem, item)
|
||||
numConsumed++
|
||||
return nil
|
||||
|
|
@ -59,7 +59,7 @@ func TestBoundedQueue(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, 5, numConsumed)
|
||||
assert.NoError(t, q.Shutdown(context.Background()))
|
||||
assert.False(t, q.Consume(func(ctx context.Context, item string) error {
|
||||
assert.False(t, q.Consume(func(_ context.Context, item string) error {
|
||||
panic(item)
|
||||
}))
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ func TestShutdownWhileNotEmpty(t *testing.T) {
|
|||
assert.Equal(t, 10, q.Size())
|
||||
numConsumed := 0
|
||||
for i := 0; i < 10; i++ {
|
||||
assert.True(t, q.Consume(func(ctx context.Context, item string) error {
|
||||
assert.True(t, q.Consume(func(_ context.Context, item string) error {
|
||||
assert.Equal(t, strconv.FormatInt(int64(i), 10), item)
|
||||
numConsumed++
|
||||
return nil
|
||||
|
|
@ -91,7 +91,7 @@ func TestShutdownWhileNotEmpty(t *testing.T) {
|
|||
assert.Equal(t, 10, numConsumed)
|
||||
assert.Equal(t, 0, q.Size())
|
||||
|
||||
assert.False(t, q.Consume(func(ctx context.Context, item string) error {
|
||||
assert.False(t, q.Consume(func(_ context.Context, item string) error {
|
||||
panic(item)
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ func TestPersistentQueue_CorruptedData(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
assert.Equal(t, 3, ps.Size())
|
||||
require.True(t, ps.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
require.True(t, ps.Consume(func(_ context.Context, _ tracesRequest) error {
|
||||
return NewShutdownErr(nil)
|
||||
}))
|
||||
assert.Equal(t, 2, ps.Size())
|
||||
|
|
@ -483,7 +483,7 @@ func TestPersistentQueue_CurrentlyProcessedItems(t *testing.T) {
|
|||
|
||||
// We should be able to pull all remaining items now
|
||||
for i := 0; i < 4; i++ {
|
||||
newPs.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
newPs.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, req, traces)
|
||||
return nil
|
||||
})
|
||||
|
|
@ -519,7 +519,7 @@ func TestPersistentQueueStartWithNonDispatched(t *testing.T) {
|
|||
|
||||
// get one item out, but don't mark it as processed
|
||||
<-ps.putChan
|
||||
require.True(t, ps.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
require.True(t, ps.Consume(func(_ context.Context, _ tracesRequest) error {
|
||||
// put one more item in
|
||||
require.NoError(t, ps.Offer(context.Background(), req))
|
||||
require.Equal(t, 5, ps.Size())
|
||||
|
|
@ -550,13 +550,13 @@ func TestPersistentQueue_PutCloseReadClose(t *testing.T) {
|
|||
require.Equal(t, 2, newPs.Size())
|
||||
|
||||
// Let's read both of the elements we put
|
||||
newPs.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
newPs.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
require.Equal(t, req, traces)
|
||||
return nil
|
||||
})
|
||||
assert.Equal(t, 1, newPs.Size())
|
||||
|
||||
newPs.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
newPs.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
require.Equal(t, req, traces)
|
||||
return nil
|
||||
})
|
||||
|
|
@ -625,7 +625,7 @@ func TestItemIndexMarshaling(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(fmt.Sprintf("#elements:%v", c.in), func(tt *testing.T) {
|
||||
t.Run(fmt.Sprintf("#elements:%v", c.in), func(_ *testing.T) {
|
||||
buf := itemIndexToBytes(c.in)
|
||||
out, err := bytesToItemIndex(buf)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -654,7 +654,7 @@ func TestItemIndexArrayMarshaling(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(fmt.Sprintf("#elements:%v", c.in), func(tt *testing.T) {
|
||||
t.Run(fmt.Sprintf("#elements:%v", c.in), func(_ *testing.T) {
|
||||
buf := itemIndexArrayToBytes(c.in)
|
||||
out, err := bytesToItemIndexArray(buf)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -791,7 +791,7 @@ func TestPersistentQueue_ItemsCapacityUsageRestoredOnShutdown(t *testing.T) {
|
|||
assert.ErrorIs(t, pq.Offer(context.Background(), newTracesRequest(5, 5)), ErrQueueIsFull)
|
||||
assert.Equal(t, 100, pq.Size())
|
||||
|
||||
assert.True(t, pq.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
assert.True(t, pq.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, 40, traces.traces.SpanCount())
|
||||
return nil
|
||||
}))
|
||||
|
|
@ -809,13 +809,13 @@ func TestPersistentQueue_ItemsCapacityUsageRestoredOnShutdown(t *testing.T) {
|
|||
// Check the combined queue size.
|
||||
assert.Equal(t, 70, newPQ.Size())
|
||||
|
||||
assert.True(t, newPQ.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
assert.True(t, newPQ.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, 40, traces.traces.SpanCount())
|
||||
return nil
|
||||
}))
|
||||
assert.Equal(t, 30, newPQ.Size())
|
||||
|
||||
assert.True(t, newPQ.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
assert.True(t, newPQ.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, 20, traces.traces.SpanCount())
|
||||
return nil
|
||||
}))
|
||||
|
|
@ -836,7 +836,7 @@ func TestPersistentQueue_ItemsCapacityUsageIsNotPreserved(t *testing.T) {
|
|||
assert.NoError(t, pq.Offer(context.Background(), newTracesRequest(5, 5)))
|
||||
assert.Equal(t, 3, pq.Size())
|
||||
|
||||
assert.True(t, pq.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
assert.True(t, pq.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, 40, traces.traces.SpanCount())
|
||||
return nil
|
||||
}))
|
||||
|
|
@ -855,19 +855,19 @@ func TestPersistentQueue_ItemsCapacityUsageIsNotPreserved(t *testing.T) {
|
|||
assert.Equal(t, 10, newPQ.Size())
|
||||
|
||||
// Consuming old items should does not affect the size.
|
||||
assert.True(t, newPQ.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
assert.True(t, newPQ.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, 20, traces.traces.SpanCount())
|
||||
return nil
|
||||
}))
|
||||
assert.Equal(t, 10, newPQ.Size())
|
||||
|
||||
assert.True(t, newPQ.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
assert.True(t, newPQ.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, 25, traces.traces.SpanCount())
|
||||
return nil
|
||||
}))
|
||||
assert.Equal(t, 10, newPQ.Size())
|
||||
|
||||
assert.True(t, newPQ.Consume(func(ctx context.Context, traces tracesRequest) error {
|
||||
assert.True(t, newPQ.Consume(func(_ context.Context, traces tracesRequest) error {
|
||||
assert.Equal(t, 10, traces.traces.SpanCount())
|
||||
return nil
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ func TestErrorResponses(t *testing.T) {
|
|||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
srv := createBackend("/v1/traces", func(writer http.ResponseWriter, request *http.Request) {
|
||||
srv := createBackend("/v1/traces", func(writer http.ResponseWriter, _ *http.Request) {
|
||||
for k, v := range test.headers {
|
||||
writer.Header().Add(k, v)
|
||||
}
|
||||
|
|
@ -420,7 +420,7 @@ func TestPartialSuccessUnsupportedContentType(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPartialSuccess_logs(t *testing.T) {
|
||||
srv := createBackend("/v1/logs", func(writer http.ResponseWriter, request *http.Request) {
|
||||
srv := createBackend("/v1/logs", func(writer http.ResponseWriter, _ *http.Request) {
|
||||
response := plogotlp.NewExportResponse()
|
||||
partial := response.PartialSuccess()
|
||||
partial.SetErrorMessage("hello")
|
||||
|
|
@ -591,7 +591,7 @@ func TestPartialSuccessInvalidResponseBody(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPartialSuccess_traces(t *testing.T) {
|
||||
srv := createBackend("/v1/traces", func(writer http.ResponseWriter, request *http.Request) {
|
||||
srv := createBackend("/v1/traces", func(writer http.ResponseWriter, _ *http.Request) {
|
||||
response := ptraceotlp.NewExportResponse()
|
||||
partial := response.PartialSuccess()
|
||||
partial.SetErrorMessage("hello")
|
||||
|
|
@ -631,7 +631,7 @@ func TestPartialSuccess_traces(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPartialSuccess_metrics(t *testing.T) {
|
||||
srv := createBackend("/v1/metrics", func(writer http.ResponseWriter, request *http.Request) {
|
||||
srv := createBackend("/v1/metrics", func(writer http.ResponseWriter, _ *http.Request) {
|
||||
response := pmetricotlp.NewExportResponse()
|
||||
partial := response.PartialSuccess()
|
||||
partial.SetErrorMessage("hello")
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func TestClientDefaultValues(t *testing.T) {
|
|||
|
||||
func TestWithClientStart(t *testing.T) {
|
||||
called := false
|
||||
e := NewClient(WithClientStart(func(c context.Context, h component.Host) error {
|
||||
e := NewClient(WithClientStart(func(_ context.Context, _ component.Host) error {
|
||||
called = true
|
||||
return nil
|
||||
}))
|
||||
|
|
@ -60,7 +60,7 @@ func TestWithClientStart(t *testing.T) {
|
|||
|
||||
func TestWithClientShutdown(t *testing.T) {
|
||||
called := false
|
||||
e := NewClient(WithClientShutdown(func(c context.Context) error {
|
||||
e := NewClient(WithClientShutdown(func(_ context.Context) error {
|
||||
called = true
|
||||
return nil
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func TestWithServerAuthenticateFunc(t *testing.T) {
|
|||
// prepare
|
||||
authCalled := false
|
||||
e := NewServer(
|
||||
WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) {
|
||||
WithServerAuthenticate(func(ctx context.Context, _ map[string][]string) (context.Context, error) {
|
||||
authCalled = true
|
||||
return ctx, nil
|
||||
}),
|
||||
|
|
@ -55,7 +55,7 @@ func TestWithServerAuthenticateFunc(t *testing.T) {
|
|||
|
||||
func TestWithServerStart(t *testing.T) {
|
||||
called := false
|
||||
e := NewServer(WithServerStart(func(c context.Context, h component.Host) error {
|
||||
e := NewServer(WithServerStart(func(_ context.Context, _ component.Host) error {
|
||||
called = true
|
||||
return nil
|
||||
}))
|
||||
|
|
@ -70,7 +70,7 @@ func TestWithServerStart(t *testing.T) {
|
|||
|
||||
func TestWithServerShutdown(t *testing.T) {
|
||||
called := false
|
||||
e := NewServer(WithServerShutdown(func(c context.Context) error {
|
||||
e := NewServer(WithServerShutdown(func(_ context.Context) error {
|
||||
called = true
|
||||
return nil
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func TestNewFactory(t *testing.T) {
|
|||
factory := NewFactory(
|
||||
testType,
|
||||
func() component.Config { return &defaultCfg },
|
||||
func(ctx context.Context, settings CreateSettings, extension component.Config) (Extension, error) {
|
||||
func(_ context.Context, _ CreateSettings, _ component.Config) (Extension, error) {
|
||||
return nopExtensionInstance, nil
|
||||
},
|
||||
component.StabilityLevelDevelopment)
|
||||
|
|
@ -88,7 +88,7 @@ func TestBuilder(t *testing.T) {
|
|||
NewFactory(
|
||||
testType,
|
||||
func() component.Config { return &defaultCfg },
|
||||
func(ctx context.Context, settings CreateSettings, extension component.Config) (Extension, error) {
|
||||
func(_ context.Context, settings CreateSettings, _ component.Config) (Extension, error) {
|
||||
return nopExtension{CreateSettings: settings}, nil
|
||||
},
|
||||
component.StabilityLevelDevelopment),
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ func (r *Registry) Set(id string, enabled bool) error {
|
|||
// VisitAll visits all the gates in lexicographical order, calling fn for each.
|
||||
func (r *Registry) VisitAll(fn func(*Gate)) {
|
||||
var gates []*Gate
|
||||
r.gates.Range(func(key, value any) bool {
|
||||
r.gates.Range(func(_, value any) bool {
|
||||
gates = append(gates, value.(*Gate))
|
||||
return true
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ func TestGlobalRegistry(t *testing.T) {
|
|||
func TestRegistry(t *testing.T) {
|
||||
r := NewRegistry()
|
||||
// Expect that no gates to visit.
|
||||
r.VisitAll(func(gate *Gate) {
|
||||
r.VisitAll(func(_ *Gate) {
|
||||
t.FailNow()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ func TestLogsRoundTrip(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIssue_4221(t *testing.T) {
|
||||
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
||||
defer func() { assert.NoError(t, r.Body.Close()) }()
|
||||
compressedData, err := io.ReadAll(r.Body)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ func NewCommand(set CollectorSettings) *cobra.Command {
|
|||
Use: set.BuildInfo.Command,
|
||||
Version: set.BuildInfo.Version,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
col, err := newCollectorWithFlags(set, flagSet)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command {
|
|||
Short: "Outputs available components in this collector distribution",
|
||||
Long: "Outputs available components in this collector distribution including their stability levels. The output format is not stable and can change between releases.",
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
|
||||
factories, err := set.Factories()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func newValidateSubCommand(set CollectorSettings, flagSet *flag.FlagSet) *cobra.
|
|||
Use: "validate",
|
||||
Short: "Validates the config without running the collector",
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
if set.ConfigProvider == nil {
|
||||
var err error
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func TestMapReadOnly(t *testing.T) {
|
|||
assert.Panics(t, func() { m.PutEmptyMap("k2") })
|
||||
assert.Panics(t, func() { m.PutEmptySlice("k2") })
|
||||
assert.Panics(t, func() { m.Remove("k1") })
|
||||
assert.Panics(t, func() { m.RemoveIf(func(k string, v Value) bool { return true }) })
|
||||
assert.Panics(t, func() { m.RemoveIf(func(_ string, _ Value) bool { return true }) })
|
||||
assert.Panics(t, func() { m.EnsureCapacity(2) })
|
||||
|
||||
m2 := NewMap()
|
||||
|
|
@ -289,7 +289,7 @@ func TestMapWithEmpty(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMapIterationNil(t *testing.T) {
|
||||
NewMap().Range(func(k string, v Value) bool {
|
||||
NewMap().Range(func(_ string, _ Value) bool {
|
||||
// Fail if any element is returned
|
||||
t.Fail()
|
||||
return true
|
||||
|
|
@ -309,7 +309,7 @@ func TestMap_Range(t *testing.T) {
|
|||
assert.Equal(t, 5, am.Len())
|
||||
|
||||
calls := 0
|
||||
am.Range(func(k string, v Value) bool {
|
||||
am.Range(func(_ string, _ Value) bool {
|
||||
calls++
|
||||
return false
|
||||
})
|
||||
|
|
@ -523,7 +523,7 @@ func generateTestBytesMap(t *testing.T) Map {
|
|||
func TestInvalidMap(t *testing.T) {
|
||||
v := Map{}
|
||||
|
||||
testFunc := func(s string, v Value) bool {
|
||||
testFunc := func(_ string, _ Value) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func TestSliceReadOnly(t *testing.T) {
|
|||
assert.Panics(t, func() { es.MoveAndAppendTo(es2) })
|
||||
assert.Panics(t, func() { es2.MoveAndAppendTo(es) })
|
||||
|
||||
assert.Panics(t, func() { es.RemoveIf(func(el Value) bool { return false }) })
|
||||
assert.Panics(t, func() { es.RemoveIf(func(_ Value) bool { return false }) })
|
||||
|
||||
assert.Equal(t, []any{int64(3)}, es.AsRaw())
|
||||
assert.Panics(t, func() { _ = es.FromRaw([]any{3}) })
|
||||
|
|
@ -122,7 +122,7 @@ func TestSlice_MoveAndAppendTo(t *testing.T) {
|
|||
func TestSlice_RemoveIf(t *testing.T) {
|
||||
// Test RemoveIf on empty slice
|
||||
emptySlice := NewSlice()
|
||||
emptySlice.RemoveIf(func(el Value) bool {
|
||||
emptySlice.RemoveIf(func(_ Value) bool {
|
||||
t.Fail()
|
||||
return false
|
||||
})
|
||||
|
|
@ -130,7 +130,7 @@ func TestSlice_RemoveIf(t *testing.T) {
|
|||
// Test RemoveIf
|
||||
filtered := Slice(internal.GenerateTestSlice())
|
||||
pos := 0
|
||||
filtered.RemoveIf(func(el Value) bool {
|
||||
filtered.RemoveIf(func(_ Value) bool {
|
||||
pos++
|
||||
return pos%3 == 0
|
||||
})
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func (ms Logs) unmarshalJsoniter(iter *jsoniter.Iterator) {
|
|||
iter.ReadObjectCB(func(iter *jsoniter.Iterator, f string) bool {
|
||||
switch f {
|
||||
case "resource_logs", "resourceLogs":
|
||||
iter.ReadArrayCB(func(iterator *jsoniter.Iterator) bool {
|
||||
iter.ReadArrayCB(func(_ *jsoniter.Iterator) bool {
|
||||
ms.ResourceLogs().AppendEmpty().unmarshalJsoniter(iter)
|
||||
return true
|
||||
})
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func (ms ExportResponse) unmarshalJsoniter(iter *jsoniter.Iterator) {
|
|||
}
|
||||
|
||||
func (ms ExportPartialSuccess) unmarshalJsoniter(iter *jsoniter.Iterator) {
|
||||
iter.ReadObjectCB(func(iterator *jsoniter.Iterator, f string) bool {
|
||||
iter.ReadObjectCB(func(_ *jsoniter.Iterator, f string) bool {
|
||||
switch f {
|
||||
case "rejected_log_records", "rejectedLogRecords":
|
||||
ms.orig.RejectedLogRecords = json.ReadInt64(iter)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func (ms Metrics) unmarshalJsoniter(iter *jsoniter.Iterator) {
|
|||
iter.ReadObjectCB(func(iter *jsoniter.Iterator, f string) bool {
|
||||
switch f {
|
||||
case "resource_metrics", "resourceMetrics":
|
||||
iter.ReadArrayCB(func(iterator *jsoniter.Iterator) bool {
|
||||
iter.ReadArrayCB(func(_ *jsoniter.Iterator) bool {
|
||||
ms.ResourceMetrics().AppendEmpty().unmarshalJsoniter(iter)
|
||||
return true
|
||||
})
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func (ms ExportResponse) unmarshalJsoniter(iter *jsoniter.Iterator) {
|
|||
}
|
||||
|
||||
func (ms ExportPartialSuccess) unmarshalJsoniter(iter *jsoniter.Iterator) {
|
||||
iter.ReadObjectCB(func(iterator *jsoniter.Iterator, f string) bool {
|
||||
iter.ReadObjectCB(func(_ *jsoniter.Iterator, f string) bool {
|
||||
switch f {
|
||||
case "rejected_data_points", "rejectedDataPoints":
|
||||
ms.orig.RejectedDataPoints = json.ReadInt64(iter)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (ms ExportResponse) PartialSuccess() ExportPartialSuccess {
|
|||
}
|
||||
|
||||
func (ms ExportPartialSuccess) unmarshalJsoniter(iter *jsoniter.Iterator) {
|
||||
iter.ReadObjectCB(func(iterator *jsoniter.Iterator, f string) bool {
|
||||
iter.ReadObjectCB(func(_ *jsoniter.Iterator, f string) bool {
|
||||
switch f {
|
||||
case "rejected_spans", "rejectedSpans":
|
||||
ms.orig.RejectedSpans = json.ReadInt64(iter)
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ func CheckConsumeContract(params CheckConsumeContractParams) {
|
|||
{
|
||||
name: "always_succeed",
|
||||
// Always succeed. We expect all data to be delivered as is.
|
||||
decisionFunc: func(ids idSet) error { return nil },
|
||||
decisionFunc: func(_ idSet) error { return nil },
|
||||
},
|
||||
{
|
||||
name: "random_non_permanent_error",
|
||||
|
|
@ -96,7 +96,7 @@ func CheckConsumeContract(params CheckConsumeContractParams) {
|
|||
|
||||
for _, scenario := range scenarios {
|
||||
params.T.Run(
|
||||
scenario.name, func(t *testing.T) {
|
||||
scenario.name, func(_ *testing.T) {
|
||||
checkConsumeContractScenario(params, scenario.decisionFunc)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ func TestScrapeControllerInitialDelay(t *testing.T) {
|
|||
}
|
||||
)
|
||||
|
||||
scp, err := NewScraper("timed", func(ctx context.Context) (pmetric.Metrics, error) {
|
||||
scp, err := NewScraper("timed", func(_ context.Context) (pmetric.Metrics, error) {
|
||||
elapsed <- time.Now()
|
||||
return pmetric.NewMetrics(), nil
|
||||
})
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ func (tc testOrderCase) testOrdering(t *testing.T) {
|
|||
var startOrder []string
|
||||
var shutdownOrder []string
|
||||
|
||||
recordingExtensionFactory := newRecordingExtensionFactory(func(set extension.CreateSettings, host component.Host) error {
|
||||
recordingExtensionFactory := newRecordingExtensionFactory(func(set extension.CreateSettings, _ component.Host) error {
|
||||
startOrder = append(startOrder, set.ID.String())
|
||||
return nil
|
||||
}, func(set extension.CreateSettings) error {
|
||||
|
|
@ -326,7 +326,7 @@ func newConfigWatcherExtensionFactory(name component.Type, fn func() error) exte
|
|||
func() component.Config {
|
||||
return &struct{}{}
|
||||
},
|
||||
func(ctx context.Context, set extension.CreateSettings, extension component.Config) (extension.Extension, error) {
|
||||
func(_ context.Context, _ extension.CreateSettings, _ component.Config) (extension.Extension, error) {
|
||||
return newConfigWatcherExtension(fn), nil
|
||||
},
|
||||
component.StabilityLevelDevelopment,
|
||||
|
|
@ -339,7 +339,7 @@ func newBadExtensionFactory() extension.Factory {
|
|||
func() component.Config {
|
||||
return &struct{}{}
|
||||
},
|
||||
func(ctx context.Context, set extension.CreateSettings, extension component.Config) (extension.Extension, error) {
|
||||
func(_ context.Context, _ extension.CreateSettings, _ component.Config) (extension.Extension, error) {
|
||||
return nil, nil
|
||||
},
|
||||
component.StabilityLevelDevelopment,
|
||||
|
|
@ -352,7 +352,7 @@ func newCreateErrorExtensionFactory() extension.Factory {
|
|||
func() component.Config {
|
||||
return &struct{}{}
|
||||
},
|
||||
func(ctx context.Context, set extension.CreateSettings, extension component.Config) (extension.Extension, error) {
|
||||
func(_ context.Context, _ extension.CreateSettings, _ component.Config) (extension.Extension, error) {
|
||||
return nil, errors.New("cannot create \"err\" extension type")
|
||||
},
|
||||
component.StabilityLevelDevelopment,
|
||||
|
|
@ -433,7 +433,7 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
var actualStatuses []*component.StatusEvent
|
||||
rep := status.NewReporter(func(id *component.InstanceID, ev *component.StatusEvent) {
|
||||
rep := status.NewReporter(func(_ *component.InstanceID, ev *component.StatusEvent) {
|
||||
actualStatuses = append(actualStatuses, ev)
|
||||
}, func(err error) {
|
||||
require.NoError(t, err)
|
||||
|
|
@ -476,7 +476,7 @@ func newStatusTestExtensionFactory(name component.Type, startErr, shutdownErr er
|
|||
func() component.Config {
|
||||
return &struct{}{}
|
||||
},
|
||||
func(ctx context.Context, set extension.CreateSettings, extension component.Config) (extension.Extension, error) {
|
||||
func(_ context.Context, _ extension.CreateSettings, _ component.Config) (extension.Extension, error) {
|
||||
return newStatusTestExtension(startErr, shutdownErr), nil
|
||||
},
|
||||
component.StabilityLevelDevelopment,
|
||||
|
|
@ -489,7 +489,7 @@ func newRecordingExtensionFactory(startCallback func(set extension.CreateSetting
|
|||
func() component.Config {
|
||||
return &recordingExtensionConfig{}
|
||||
},
|
||||
func(ctx context.Context, set extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
|
||||
func(_ context.Context, set extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
|
||||
return &recordingExtension{
|
||||
config: cfg.(recordingExtensionConfig),
|
||||
createSettings: set,
|
||||
|
|
|
|||
|
|
@ -2337,7 +2337,7 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) {
|
|||
actualStatuses := make(map[*component.InstanceID][]*component.StatusEvent)
|
||||
rep := status.NewReporter(func(id *component.InstanceID, ev *component.StatusEvent) {
|
||||
actualStatuses[id] = append(actualStatuses[id], ev)
|
||||
}, func(err error) {
|
||||
}, func(_ error) {
|
||||
})
|
||||
|
||||
pg.telemetry.Status = rep
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ func NewNopTelemetrySettings() TelemetrySettings {
|
|||
MeterProvider: noopmetric.NewMeterProvider(),
|
||||
MetricsLevel: configtelemetry.LevelNone,
|
||||
Resource: pcommon.NewResource(),
|
||||
Status: status.NewReporter(func(*component.InstanceID, *component.StatusEvent) {}, func(err error) {}),
|
||||
Status: status.NewReporter(func(*component.InstanceID, *component.StatusEvent) {}, func(_ error) {}),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ func TestStatusFuncs(t *testing.T) {
|
|||
func TestStatusFuncsConcurrent(t *testing.T) {
|
||||
ids := []*component.InstanceID{{}, {}, {}, {}}
|
||||
count := 0
|
||||
statusFunc := func(id *component.InstanceID, ev *component.StatusEvent) {
|
||||
statusFunc := func(_ *component.InstanceID, _ *component.StatusEvent) {
|
||||
count++
|
||||
}
|
||||
rep := NewReporter(statusFunc,
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ func TestServiceTelemetry(t *testing.T) {
|
|||
func testCollectorStartHelper(t *testing.T, tc ownMetricsTestCase) {
|
||||
var once sync.Once
|
||||
loggingHookCalled := false
|
||||
hook := func(entry zapcore.Entry) error {
|
||||
hook := func(_ zapcore.Entry) error {
|
||||
once.Do(func() {
|
||||
loggingHookCalled = true
|
||||
})
|
||||
|
|
@ -599,7 +599,7 @@ func newConfigWatcherExtensionFactory(name component.Type) extension.Factory {
|
|||
func() component.Config {
|
||||
return &struct{}{}
|
||||
},
|
||||
func(ctx context.Context, set extension.CreateSettings, extension component.Config) (extension.Extension, error) {
|
||||
func(_ context.Context, _ extension.CreateSettings, _ component.Config) (extension.Extension, error) {
|
||||
return &configWatcherExtension{}, nil
|
||||
},
|
||||
component.StabilityLevelDevelopment,
|
||||
|
|
|
|||
Loading…
Reference in New Issue