From 68841fa6dbd5f149e461863763c4bb614c973760 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sat, 9 Aug 2025 00:38:22 +0200 Subject: [PATCH] chore: enable unused-receiver rule from revive (#7130) #### Description Enable and fixes [unused-receiver](https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-receiver) rule from revive Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 + bridge/opencensus/internal/tracer.go | 4 ++-- bridge/opencensus/internal/tracer_test.go | 2 +- bridge/opentracing/bridge.go | 4 ++-- bridge/opentracing/bridge_test.go | 8 +++---- bridge/opentracing/mix_test.go | 2 +- bridge/opentracing/mock.go | 4 ++-- bridge/opentracing/provider_test.go | 2 +- exporters/otlp/otlplog/otlploggrpc/client.go | 4 ++-- .../otlp/otlplog/otlploggrpc/exporter.go | 2 +- .../otlp/otlplog/otlploghttp/client_test.go | 2 +- .../otlp/otlplog/otlploghttp/exporter.go | 2 +- .../otlpmetric/otlpmetricgrpc/exporter.go | 6 ++--- .../otlpmetric/otlpmetrichttp/exporter.go | 6 ++--- exporters/otlp/otlptrace/exporter_test.go | 4 ++-- .../otlp/otlptrace/otlptracehttp/client.go | 2 +- exporters/prometheus/exporter.go | 4 ++-- exporters/stdout/stdoutlog/exporter.go | 2 +- exporters/stdout/stdoutmetric/exporter.go | 4 ++-- internal/global/alternate_meter_test.go | 16 ++++++------- internal/global/meter_test.go | 2 +- internal/global/meter_types_test.go | 4 ++-- propagation/baggage.go | 6 ++--- propagation/propagation_test.go | 4 ++-- propagation/trace_context.go | 6 ++--- sdk/log/bench_test.go | 24 +++++++++---------- sdk/log/example_test.go | 6 ++--- sdk/log/logtest/example_test.go | 4 ++-- sdk/log/provider_test.go | 2 +- sdk/log/simple_test.go | 4 ++-- sdk/metric/exemplar/fixed_size_reservoir.go | 2 +- sdk/metric/internal/aggregate/drop.go | 4 ++-- sdk/metric/pipeline.go | 2 +- sdk/metric/reader.go | 2 +- sdk/resource/resource_test.go | 2 +- sdk/trace/batch_span_processor.go | 4 ++-- sdk/trace/batch_span_processor_test.go | 2 +- sdk/trace/id_generator.go | 4 ++-- sdk/trace/provider_test.go | 10 ++++---- sdk/trace/sampling.go | 8 +++---- sdk/trace/simple_span_processor.go | 4 ++-- sdk/trace/snapshot.go | 2 +- sdk/trace/span_limits_test.go | 8 +++---- .../span_processor_annotator_example_test.go | 6 ++--- sdk/trace/trace_test.go | 6 ++--- sdk/trace/tracetest/exporter.go | 4 ++-- sdk/trace/tracetest/recorder.go | 4 ++-- semconv/internal/v2/http.go | 6 ++--- semconv/internal/v3/http.go | 6 ++--- semconv/internal/v4/http.go | 6 ++--- trace/auto.go | 4 ++-- trace/noop.go | 4 ++-- trace/noop/noop.go | 2 +- 53 files changed, 123 insertions(+), 122 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3aff2d957..b01762ffc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -181,6 +181,7 @@ linters: - fmt.Printf - fmt.Println - name: unused-parameter + - name: unused-receiver - name: unnecessary-stmt - name: use-any - name: useless-break diff --git a/bridge/opencensus/internal/tracer.go b/bridge/opencensus/internal/tracer.go index bb1b0839c..db301976b 100644 --- a/bridge/opencensus/internal/tracer.go +++ b/bridge/opencensus/internal/tracer.go @@ -53,12 +53,12 @@ func (o *Tracer) StartSpanWithRemoteParent( } // FromContext returns the Span stored in a context. -func (o *Tracer) FromContext(ctx context.Context) *octrace.Span { +func (*Tracer) FromContext(ctx context.Context) *octrace.Span { return NewSpan(trace.SpanFromContext(ctx)) } // NewContext returns a new context with the given Span attached. -func (o *Tracer) NewContext(parent context.Context, s *octrace.Span) context.Context { +func (*Tracer) NewContext(parent context.Context, s *octrace.Span) context.Context { if otSpan, ok := s.Internal().(*Span); ok { return trace.ContextWithSpan(parent, otSpan.otelSpan) } diff --git a/bridge/opencensus/internal/tracer_test.go b/bridge/opencensus/internal/tracer_test.go index d1516fd36..395735f6e 100644 --- a/bridge/opencensus/internal/tracer_test.go +++ b/bridge/opencensus/internal/tracer_test.go @@ -139,7 +139,7 @@ type differentSpan struct { octrace.SpanInterface } -func (s *differentSpan) String() string { return "testing span" } +func (*differentSpan) String() string { return "testing span" } func TestTracerNewContextErrors(t *testing.T) { h, restore := withHandler() diff --git a/bridge/opentracing/bridge.go b/bridge/opentracing/bridge.go index 6d0fc45d0..d9952fa59 100644 --- a/bridge/opentracing/bridge.go +++ b/bridge/opentracing/bridge.go @@ -832,12 +832,12 @@ func newTextMapWrapperForInject(carrier any) (*textMapWrapper, error) { type textMapWriter struct{} -func (t *textMapWriter) Set(string, string) { +func (*textMapWriter) Set(string, string) { // maybe print a warning log. } type textMapReader struct{} -func (t *textMapReader) ForeachKey(func(string, string) error) error { +func (*textMapReader) ForeachKey(func(string, string) error) error { return nil // maybe print a warning log. } diff --git a/bridge/opentracing/bridge_test.go b/bridge/opentracing/bridge_test.go index f27f6b22e..c7c7bcea6 100644 --- a/bridge/opentracing/bridge_test.go +++ b/bridge/opentracing/bridge_test.go @@ -30,7 +30,7 @@ func newTestOnlyTextMapReader() *testOnlyTextMapReader { return &testOnlyTextMapReader{} } -func (t *testOnlyTextMapReader) ForeachKey(handler func(key, val string) error) error { +func (*testOnlyTextMapReader) ForeachKey(handler func(key, val string) error) error { _ = handler("key1", "val1") _ = handler("key2", "val2") @@ -134,7 +134,7 @@ var ( type testTextMapPropagator struct{} -func (t testTextMapPropagator) Inject(_ context.Context, carrier propagation.TextMapCarrier) { +func (testTextMapPropagator) Inject(_ context.Context, carrier propagation.TextMapCarrier) { carrier.Set(testHeader, traceID.String()+":"+spanID.String()) // Test for panic @@ -142,7 +142,7 @@ func (t testTextMapPropagator) Inject(_ context.Context, carrier propagation.Tex _ = carrier.Keys() } -func (t testTextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context { +func (testTextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context { traces := carrier.Get(testHeader) str := strings.Split(traces, ":") @@ -179,7 +179,7 @@ func (t testTextMapPropagator) Extract(ctx context.Context, carrier propagation. return trace.ContextWithRemoteSpanContext(ctx, sc) } -func (t testTextMapPropagator) Fields() []string { +func (testTextMapPropagator) Fields() []string { return []string{"test"} } diff --git a/bridge/opentracing/mix_test.go b/bridge/opentracing/mix_test.go index aa868e7d1..8d502d44e 100644 --- a/bridge/opentracing/mix_test.go +++ b/bridge/opentracing/mix_test.go @@ -145,7 +145,7 @@ func (st *simpleTest) runOTOtelOT(t *testing.T, ctx context.Context) { runOTOtelOT(t, ctx, "simple", st.noop) } -func (st *simpleTest) noop(_ *testing.T, ctx context.Context) context.Context { +func (*simpleTest) noop(_ *testing.T, ctx context.Context) context.Context { return ctx } diff --git a/bridge/opentracing/mock.go b/bridge/opentracing/mock.go index 7b720d0a9..431b22a0d 100644 --- a/bridge/opentracing/mock.go +++ b/bridge/opentracing/mock.go @@ -132,7 +132,7 @@ func (t *mockTracer) getParentSpanID(ctx context.Context, config *trace.SpanConf return trace.SpanID{} } -func (t *mockTracer) getParentSpanContext(ctx context.Context, config *trace.SpanConfig) trace.SpanContext { +func (*mockTracer) getParentSpanContext(ctx context.Context, config *trace.SpanConfig) trace.SpanContext { if !config.NewRoot() { return trace.SpanContextFromContext(ctx) } @@ -309,4 +309,4 @@ func (s *mockSpan) OverrideTracer(tracer trace.Tracer) { s.officialTracer = tracer } -func (s *mockSpan) TracerProvider() trace.TracerProvider { return noop.NewTracerProvider() } +func (*mockSpan) TracerProvider() trace.TracerProvider { return noop.NewTracerProvider() } diff --git a/bridge/opentracing/provider_test.go b/bridge/opentracing/provider_test.go index 65603bcaa..31a4c9ebb 100644 --- a/bridge/opentracing/provider_test.go +++ b/bridge/opentracing/provider_test.go @@ -21,7 +21,7 @@ type namedMockTracerProvider struct{ embedded.TracerProvider } var _ trace.TracerProvider = (*namedMockTracerProvider)(nil) // Tracer returns the WrapperTracer associated with the WrapperTracerProvider. -func (p *namedMockTracerProvider) Tracer(name string, _ ...trace.TracerOption) trace.Tracer { +func (*namedMockTracerProvider) Tracer(name string, _ ...trace.TracerOption) trace.Tracer { return &namedMockTracer{ name: name, mockTracer: newMockTracer(), diff --git a/exporters/otlp/otlplog/otlploggrpc/client.go b/exporters/otlp/otlplog/otlploggrpc/client.go index 05e2afe8f..d1b31ef2a 100644 --- a/exporters/otlp/otlplog/otlploggrpc/client.go +++ b/exporters/otlp/otlplog/otlploggrpc/client.go @@ -217,9 +217,9 @@ func newNoopClient() *noopClient { return &noopClient{} } -func (c *noopClient) UploadLogs(context.Context, []*logpb.ResourceLogs) error { return nil } +func (*noopClient) UploadLogs(context.Context, []*logpb.ResourceLogs) error { return nil } -func (c *noopClient) Shutdown(context.Context) error { return nil } +func (*noopClient) Shutdown(context.Context) error { return nil } // retryable returns if err identifies a request that can be retried and a // duration to wait for if an explicit throttle time is included in err. diff --git a/exporters/otlp/otlplog/otlploggrpc/exporter.go b/exporters/otlp/otlplog/otlploggrpc/exporter.go index 392ebb5c4..898eecf77 100644 --- a/exporters/otlp/otlplog/otlploggrpc/exporter.go +++ b/exporters/otlp/otlplog/otlploggrpc/exporter.go @@ -89,6 +89,6 @@ func (e *Exporter) Shutdown(ctx context.Context) error { } // ForceFlush does nothing. The Exporter holds no state. -func (e *Exporter) ForceFlush(context.Context) error { +func (*Exporter) ForceFlush(context.Context) error { return nil } diff --git a/exporters/otlp/otlplog/otlploghttp/client_test.go b/exporters/otlp/otlplog/otlploghttp/client_test.go index 55f91b728..0069fa0e8 100644 --- a/exporters/otlp/otlplog/otlploghttp/client_test.go +++ b/exporters/otlp/otlplog/otlploghttp/client_test.go @@ -353,7 +353,7 @@ func (c *httpCollector) record(r *http.Request) exportResult { return exportResult{Err: err} } -func (c *httpCollector) readBody(r *http.Request) (body []byte, err error) { +func (*httpCollector) readBody(r *http.Request) (body []byte, err error) { var reader io.ReadCloser switch r.Header.Get("Content-Encoding") { case "gzip": diff --git a/exporters/otlp/otlplog/otlploghttp/exporter.go b/exporters/otlp/otlplog/otlploghttp/exporter.go index 7860da2c8..4436d0cd8 100644 --- a/exporters/otlp/otlplog/otlploghttp/exporter.go +++ b/exporters/otlp/otlplog/otlploghttp/exporter.go @@ -68,6 +68,6 @@ func (e *Exporter) Shutdown(context.Context) error { } // ForceFlush does nothing. The Exporter holds no state. -func (e *Exporter) ForceFlush(context.Context) error { +func (*Exporter) ForceFlush(context.Context) error { return nil } diff --git a/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter.go b/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter.go index 91fc20808..35cdf4661 100644 --- a/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter.go +++ b/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter.go @@ -92,7 +92,7 @@ func (e *Exporter) Export(ctx context.Context, rm *metricdata.ResourceMetrics) e // This method returns an error if the method is canceled by the passed context. // // This method is safe to call concurrently. -func (e *Exporter) ForceFlush(ctx context.Context) error { +func (*Exporter) ForceFlush(ctx context.Context) error { // The exporter and client hold no state, nothing to flush. return ctx.Err() } @@ -120,7 +120,7 @@ var errShutdown = errors.New("gRPC exporter is shutdown") type shutdownClient struct{} -func (c shutdownClient) err(ctx context.Context) error { +func (shutdownClient) err(ctx context.Context) error { if err := ctx.Err(); err != nil { return err } @@ -136,7 +136,7 @@ func (c shutdownClient) Shutdown(ctx context.Context) error { } // MarshalLog returns logging data about the Exporter. -func (e *Exporter) MarshalLog() any { +func (*Exporter) MarshalLog() any { return struct{ Type string }{Type: "OTLP/gRPC"} } diff --git a/exporters/otlp/otlpmetric/otlpmetrichttp/exporter.go b/exporters/otlp/otlpmetric/otlpmetrichttp/exporter.go index 994da4264..292645a38 100644 --- a/exporters/otlp/otlpmetric/otlpmetrichttp/exporter.go +++ b/exporters/otlp/otlpmetric/otlpmetrichttp/exporter.go @@ -92,7 +92,7 @@ func (e *Exporter) Export(ctx context.Context, rm *metricdata.ResourceMetrics) e // This method returns an error if the method is canceled by the passed context. // // This method is safe to call concurrently. -func (e *Exporter) ForceFlush(ctx context.Context) error { +func (*Exporter) ForceFlush(ctx context.Context) error { // The exporter and client hold no state, nothing to flush. return ctx.Err() } @@ -120,7 +120,7 @@ var errShutdown = errors.New("HTTP exporter is shutdown") type shutdownClient struct{} -func (c shutdownClient) err(ctx context.Context) error { +func (shutdownClient) err(ctx context.Context) error { if err := ctx.Err(); err != nil { return err } @@ -136,7 +136,7 @@ func (c shutdownClient) Shutdown(ctx context.Context) error { } // MarshalLog returns logging data about the Exporter. -func (e *Exporter) MarshalLog() any { +func (*Exporter) MarshalLog() any { return struct{ Type string }{Type: "OTLP/HTTP"} } diff --git a/exporters/otlp/otlptrace/exporter_test.go b/exporters/otlp/otlptrace/exporter_test.go index 302f76760..7fcc1bde0 100644 --- a/exporters/otlp/otlptrace/exporter_test.go +++ b/exporters/otlp/otlptrace/exporter_test.go @@ -21,11 +21,11 @@ type client struct { var _ otlptrace.Client = &client{} -func (c *client) Start(context.Context) error { +func (*client) Start(context.Context) error { return nil } -func (c *client) Stop(context.Context) error { +func (*client) Stop(context.Context) error { return nil } diff --git a/exporters/otlp/otlptrace/otlptracehttp/client.go b/exporters/otlp/otlptrace/otlptracehttp/client.go index 6f277c22f..c7b1a5514 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/client.go +++ b/exporters/otlp/otlptrace/otlptracehttp/client.go @@ -104,7 +104,7 @@ func NewClient(opts ...Option) otlptrace.Client { } // Start does nothing in a HTTP client. -func (d *client) Start(ctx context.Context) error { +func (*client) Start(ctx context.Context) error { // nothing to do select { case <-ctx.Done(): diff --git a/exporters/prometheus/exporter.go b/exporters/prometheus/exporter.go index f00c1ebf4..03f5d51c7 100644 --- a/exporters/prometheus/exporter.go +++ b/exporters/prometheus/exporter.go @@ -143,7 +143,7 @@ func New(opts ...Option) (*Exporter, error) { } // Describe implements prometheus.Collector. -func (c *collector) Describe(chan<- *prometheus.Desc) { +func (*collector) Describe(chan<- *prometheus.Desc) { // The Opentelemetry SDK doesn't have information on which will exist when the collector // is registered. By returning nothing we are an "unchecked" collector in Prometheus, // and assume responsibility for consistency of the metrics produced. @@ -529,7 +529,7 @@ func (c *collector) getName(m metricdata.Metrics) string { return c.metricNamer.Build(translatorMetric) } -func (c *collector) metricType(m metricdata.Metrics) *dto.MetricType { +func (*collector) metricType(m metricdata.Metrics) *dto.MetricType { switch v := m.Data.(type) { case metricdata.ExponentialHistogram[int64], metricdata.ExponentialHistogram[float64]: return dto.MetricType_HISTOGRAM.Enum() diff --git a/exporters/stdout/stdoutlog/exporter.go b/exporters/stdout/stdoutlog/exporter.go index e2bf9bfa2..3d48d6708 100644 --- a/exporters/stdout/stdoutlog/exporter.go +++ b/exporters/stdout/stdoutlog/exporter.go @@ -67,6 +67,6 @@ func (e *Exporter) Shutdown(context.Context) error { } // ForceFlush performs no action. -func (e *Exporter) ForceFlush(context.Context) error { +func (*Exporter) ForceFlush(context.Context) error { return nil } diff --git a/exporters/stdout/stdoutmetric/exporter.go b/exporters/stdout/stdoutmetric/exporter.go index 36c6c1d41..07a31f829 100644 --- a/exporters/stdout/stdoutmetric/exporter.go +++ b/exporters/stdout/stdoutmetric/exporter.go @@ -63,7 +63,7 @@ func (e *exporter) Export(ctx context.Context, data *metricdata.ResourceMetrics) return e.encVal.Load().(encoderHolder).Encode(data) } -func (e *exporter) ForceFlush(context.Context) error { +func (*exporter) ForceFlush(context.Context) error { // exporter holds no state, nothing to flush. return nil } @@ -77,7 +77,7 @@ func (e *exporter) Shutdown(context.Context) error { return nil } -func (e *exporter) MarshalLog() any { +func (*exporter) MarshalLog() any { return struct{ Type string }{Type: "STDOUT"} } diff --git a/internal/global/alternate_meter_test.go b/internal/global/alternate_meter_test.go index c6b4af328..f3994c56d 100644 --- a/internal/global/alternate_meter_test.go +++ b/internal/global/alternate_meter_test.go @@ -106,22 +106,22 @@ func (*altRegistration) Unregister() error { return nil } -func (am *altMeter) Int64Counter(name string, _ ...metric.Int64CounterOption) (metric.Int64Counter, error) { +func (*altMeter) Int64Counter(name string, _ ...metric.Int64CounterOption) (metric.Int64Counter, error) { return noop.NewMeterProvider().Meter("noop").Int64Counter(name) } -func (am *altMeter) Int64UpDownCounter( +func (*altMeter) Int64UpDownCounter( name string, _ ...metric.Int64UpDownCounterOption, ) (metric.Int64UpDownCounter, error) { return noop.NewMeterProvider().Meter("noop").Int64UpDownCounter(name) } -func (am *altMeter) Int64Histogram(name string, _ ...metric.Int64HistogramOption) (metric.Int64Histogram, error) { +func (*altMeter) Int64Histogram(name string, _ ...metric.Int64HistogramOption) (metric.Int64Histogram, error) { return noop.NewMeterProvider().Meter("noop").Int64Histogram(name) } -func (am *altMeter) Int64Gauge(name string, _ ...metric.Int64GaugeOption) (metric.Int64Gauge, error) { +func (*altMeter) Int64Gauge(name string, _ ...metric.Int64GaugeOption) (metric.Int64Gauge, error) { return noop.NewMeterProvider().Meter("noop").Int64Gauge(name) } @@ -152,25 +152,25 @@ func (am *altMeter) Int64ObservableGauge( }, nil } -func (am *altMeter) Float64Counter(name string, _ ...metric.Float64CounterOption) (metric.Float64Counter, error) { +func (*altMeter) Float64Counter(name string, _ ...metric.Float64CounterOption) (metric.Float64Counter, error) { return noop.NewMeterProvider().Meter("noop").Float64Counter(name) } -func (am *altMeter) Float64UpDownCounter( +func (*altMeter) Float64UpDownCounter( name string, _ ...metric.Float64UpDownCounterOption, ) (metric.Float64UpDownCounter, error) { return noop.NewMeterProvider().Meter("noop").Float64UpDownCounter(name) } -func (am *altMeter) Float64Histogram( +func (*altMeter) Float64Histogram( name string, _ ...metric.Float64HistogramOption, ) (metric.Float64Histogram, error) { return noop.NewMeterProvider().Meter("noop").Float64Histogram(name) } -func (am *altMeter) Float64Gauge(name string, _ ...metric.Float64GaugeOption) (metric.Float64Gauge, error) { +func (*altMeter) Float64Gauge(name string, _ ...metric.Float64GaugeOption) (metric.Float64Gauge, error) { return noop.NewMeterProvider().Meter("noop").Float64Gauge(name) } diff --git a/internal/global/meter_test.go b/internal/global/meter_test.go index 6a64886b7..219fbf50d 100644 --- a/internal/global/meter_test.go +++ b/internal/global/meter_test.go @@ -442,7 +442,7 @@ type failingRegisterCallbackMeter struct { noop.Meter } -func (m *failingRegisterCallbackMeter) RegisterCallback( +func (*failingRegisterCallbackMeter) RegisterCallback( metric.Callback, ...metric.Observable, ) (metric.Registration, error) { diff --git a/internal/global/meter_types_test.go b/internal/global/meter_types_test.go index 39c9fe7a9..0bcc6b58d 100644 --- a/internal/global/meter_types_test.go +++ b/internal/global/meter_types_test.go @@ -182,14 +182,14 @@ type observationRecorder struct { ctx context.Context } -func (o observationRecorder) ObserveFloat64(i metric.Float64Observable, _ float64, _ ...metric.ObserveOption) { +func (observationRecorder) ObserveFloat64(i metric.Float64Observable, _ float64, _ ...metric.ObserveOption) { iImpl, ok := i.(*testCountingFloatInstrument) if ok { iImpl.observe() } } -func (o observationRecorder) ObserveInt64(i metric.Int64Observable, _ int64, _ ...metric.ObserveOption) { +func (observationRecorder) ObserveInt64(i metric.Int64Observable, _ int64, _ ...metric.ObserveOption) { iImpl, ok := i.(*testCountingIntInstrument) if ok { iImpl.observe() diff --git a/propagation/baggage.go b/propagation/baggage.go index ebda5026d..051882602 100644 --- a/propagation/baggage.go +++ b/propagation/baggage.go @@ -20,7 +20,7 @@ type Baggage struct{} var _ TextMapPropagator = Baggage{} // Inject sets baggage key-values from ctx into the carrier. -func (b Baggage) Inject(ctx context.Context, carrier TextMapCarrier) { +func (Baggage) Inject(ctx context.Context, carrier TextMapCarrier) { bStr := baggage.FromContext(ctx).String() if bStr != "" { carrier.Set(baggageHeader, bStr) @@ -30,7 +30,7 @@ func (b Baggage) Inject(ctx context.Context, carrier TextMapCarrier) { // Extract returns a copy of parent with the baggage from the carrier added. // If carrier implements [ValuesGetter] (e.g. [HeaderCarrier]), Values is invoked // for multiple values extraction. Otherwise, Get is called. -func (b Baggage) Extract(parent context.Context, carrier TextMapCarrier) context.Context { +func (Baggage) Extract(parent context.Context, carrier TextMapCarrier) context.Context { if multiCarrier, ok := carrier.(ValuesGetter); ok { return extractMultiBaggage(parent, multiCarrier) } @@ -38,7 +38,7 @@ func (b Baggage) Extract(parent context.Context, carrier TextMapCarrier) context } // Fields returns the keys who's values are set with Inject. -func (b Baggage) Fields() []string { +func (Baggage) Fields() []string { return []string{baggageHeader} } diff --git a/propagation/propagation_test.go b/propagation/propagation_test.go index 8c7e9d80a..e8482dc4c 100644 --- a/propagation/propagation_test.go +++ b/propagation/propagation_test.go @@ -20,9 +20,9 @@ var ctxKey ctxKeyType type carrier []string -func (c *carrier) Keys() []string { return nil } +func (*carrier) Keys() []string { return nil } -func (c *carrier) Get(string) string { return "" } +func (*carrier) Get(string) string { return "" } func (c *carrier) Set(setter, _ string) { *c = append(*c, setter) diff --git a/propagation/trace_context.go b/propagation/trace_context.go index 6870e316d..6692d2665 100644 --- a/propagation/trace_context.go +++ b/propagation/trace_context.go @@ -36,7 +36,7 @@ var ( ) // Inject injects the trace context from ctx into carrier. -func (tc TraceContext) Inject(ctx context.Context, carrier TextMapCarrier) { +func (TraceContext) Inject(ctx context.Context, carrier TextMapCarrier) { sc := trace.SpanContextFromContext(ctx) if !sc.IsValid() { return @@ -77,7 +77,7 @@ func (tc TraceContext) Extract(ctx context.Context, carrier TextMapCarrier) cont return trace.ContextWithRemoteSpanContext(ctx, sc) } -func (tc TraceContext) extract(carrier TextMapCarrier) trace.SpanContext { +func (TraceContext) extract(carrier TextMapCarrier) trace.SpanContext { h := carrier.Get(traceparentHeader) if h == "" { return trace.SpanContext{} @@ -151,6 +151,6 @@ func extractPart(dst []byte, h *string, n int) bool { } // Fields returns the keys who's values are set with Inject. -func (tc TraceContext) Fields() []string { +func (TraceContext) Fields() []string { return []string{traceparentHeader, tracestateHeader} } diff --git a/sdk/log/bench_test.go b/sdk/log/bench_test.go index e46715262..8b12dc2e8 100644 --- a/sdk/log/bench_test.go +++ b/sdk/log/bench_test.go @@ -128,57 +128,57 @@ func BenchmarkProcessor(b *testing.B) { type timestampProcessor struct{} -func (p timestampProcessor) OnEmit(_ context.Context, r *Record) error { +func (timestampProcessor) OnEmit(_ context.Context, r *Record) error { r.SetObservedTimestamp(time.Date(1988, time.November, 17, 0, 0, 0, 0, time.UTC)) return nil } -func (p timestampProcessor) Enabled(context.Context, Record) bool { +func (timestampProcessor) Enabled(context.Context, Record) bool { return true } -func (p timestampProcessor) Shutdown(context.Context) error { +func (timestampProcessor) Shutdown(context.Context) error { return nil } -func (p timestampProcessor) ForceFlush(context.Context) error { +func (timestampProcessor) ForceFlush(context.Context) error { return nil } type attrAddProcessor struct{} -func (p attrAddProcessor) OnEmit(_ context.Context, r *Record) error { +func (attrAddProcessor) OnEmit(_ context.Context, r *Record) error { r.AddAttributes(log.String("add", "me")) return nil } -func (p attrAddProcessor) Enabled(context.Context, Record) bool { +func (attrAddProcessor) Enabled(context.Context, Record) bool { return true } -func (p attrAddProcessor) Shutdown(context.Context) error { +func (attrAddProcessor) Shutdown(context.Context) error { return nil } -func (p attrAddProcessor) ForceFlush(context.Context) error { +func (attrAddProcessor) ForceFlush(context.Context) error { return nil } type attrSetDecorator struct{} -func (p attrSetDecorator) OnEmit(_ context.Context, r *Record) error { +func (attrSetDecorator) OnEmit(_ context.Context, r *Record) error { r.SetAttributes(log.String("replace", "me")) return nil } -func (p attrSetDecorator) Enabled(context.Context, Record) bool { +func (attrSetDecorator) Enabled(context.Context, Record) bool { return true } -func (p attrSetDecorator) Shutdown(context.Context) error { +func (attrSetDecorator) Shutdown(context.Context) error { return nil } -func (p attrSetDecorator) ForceFlush(context.Context) error { +func (attrSetDecorator) ForceFlush(context.Context) error { return nil } diff --git a/sdk/log/example_test.go b/sdk/log/example_test.go index a8ac3f7f9..b0e737432 100644 --- a/sdk/log/example_test.go +++ b/sdk/log/example_test.go @@ -135,7 +135,7 @@ type RedactTokensProcessor struct{} // OnEmit redacts values from attributes containing "token" in the key // by replacing them with a REDACTED value. -func (p *RedactTokensProcessor) OnEmit(_ context.Context, record *log.Record) error { +func (*RedactTokensProcessor) OnEmit(_ context.Context, record *log.Record) error { record.WalkAttributes(func(kv logapi.KeyValue) bool { if strings.Contains(strings.ToLower(kv.Key), "token") { record.AddAttributes(logapi.String(kv.Key, "REDACTED")) @@ -146,11 +146,11 @@ func (p *RedactTokensProcessor) OnEmit(_ context.Context, record *log.Record) er } // Shutdown returns nil. -func (p *RedactTokensProcessor) Shutdown(context.Context) error { +func (*RedactTokensProcessor) Shutdown(context.Context) error { return nil } // ForceFlush returns nil. -func (p *RedactTokensProcessor) ForceFlush(context.Context) error { +func (*RedactTokensProcessor) ForceFlush(context.Context) error { return nil } diff --git a/sdk/log/logtest/example_test.go b/sdk/log/logtest/example_test.go index ea8cf351f..8b3ac0c8f 100644 --- a/sdk/log/logtest/example_test.go +++ b/sdk/log/logtest/example_test.go @@ -54,11 +54,11 @@ func (e exporter) Export(_ context.Context, records []log.Record) error { return nil } -func (e exporter) Shutdown(context.Context) error { +func (exporter) Shutdown(context.Context) error { return nil } // appropriate error should be returned in these situations. -func (e exporter) ForceFlush(context.Context) error { +func (exporter) ForceFlush(context.Context) error { return nil } diff --git a/sdk/log/provider_test.go b/sdk/log/provider_test.go index f9ca530ec..23a74630c 100644 --- a/sdk/log/provider_test.go +++ b/sdk/log/provider_test.go @@ -278,7 +278,7 @@ type logSink struct { keysAndValues []any } -func (l *logSink) Enabled(int) bool { return true } +func (*logSink) Enabled(int) bool { return true } func (l *logSink) Info(level int, msg string, keysAndValues ...any) { l.level, l.msg, l.keysAndValues = level, msg, keysAndValues diff --git a/sdk/log/simple_test.go b/sdk/log/simple_test.go index b028c9c88..394e4b796 100644 --- a/sdk/log/simple_test.go +++ b/sdk/log/simple_test.go @@ -77,11 +77,11 @@ func (e *writerExporter) Export(_ context.Context, records []log.Record) error { return nil } -func (e *writerExporter) Shutdown(context.Context) error { +func (*writerExporter) Shutdown(context.Context) error { return nil } -func (e *writerExporter) ForceFlush(context.Context) error { +func (*writerExporter) ForceFlush(context.Context) error { return nil } diff --git a/sdk/metric/exemplar/fixed_size_reservoir.go b/sdk/metric/exemplar/fixed_size_reservoir.go index 8625dca27..08e8f68fe 100644 --- a/sdk/metric/exemplar/fixed_size_reservoir.go +++ b/sdk/metric/exemplar/fixed_size_reservoir.go @@ -56,7 +56,7 @@ func newFixedSizeReservoir(s *storage) *FixedSizeReservoir { // randomFloat64 returns, as a float64, a uniform pseudo-random number in the // open interval (0.0,1.0). -func (r *FixedSizeReservoir) randomFloat64() float64 { +func (*FixedSizeReservoir) randomFloat64() float64 { // TODO: Use an algorithm that avoids rejection sampling. For example: // // const precision = 1 << 53 // 2^53 diff --git a/sdk/metric/internal/aggregate/drop.go b/sdk/metric/internal/aggregate/drop.go index 8396faaa4..129920cbd 100644 --- a/sdk/metric/internal/aggregate/drop.go +++ b/sdk/metric/internal/aggregate/drop.go @@ -18,10 +18,10 @@ func dropReservoir[N int64 | float64](attribute.Set) FilteredExemplarReservoir[N type dropRes[N int64 | float64] struct{} // Offer does nothing, all measurements offered will be dropped. -func (r *dropRes[N]) Offer(context.Context, N, []attribute.KeyValue) {} +func (*dropRes[N]) Offer(context.Context, N, []attribute.KeyValue) {} // Collect resets dest. No exemplars will ever be returned. -func (r *dropRes[N]) Collect(dest *[]exemplar.Exemplar) { +func (*dropRes[N]) Collect(dest *[]exemplar.Exemplar) { clear(*dest) // Erase elements to let GC collect objects *dest = (*dest)[:0] } diff --git a/sdk/metric/pipeline.go b/sdk/metric/pipeline.go index 3a256d92a..408fddc8d 100644 --- a/sdk/metric/pipeline.go +++ b/sdk/metric/pipeline.go @@ -466,7 +466,7 @@ func (i *inserter[N]) logConflict(id instID) { global.Warn(msg, args...) } -func (i *inserter[N]) instID(kind InstrumentKind, stream Stream) instID { +func (*inserter[N]) instID(kind InstrumentKind, stream Stream) instID { var zero N return instID{ Name: stream.Name, diff --git a/sdk/metric/reader.go b/sdk/metric/reader.go index c96e500a2..5c1cea825 100644 --- a/sdk/metric/reader.go +++ b/sdk/metric/reader.go @@ -117,7 +117,7 @@ type produceHolder struct { type shutdownProducer struct{} // produce returns an ErrReaderShutdown error. -func (p shutdownProducer) produce(context.Context, *metricdata.ResourceMetrics) error { +func (shutdownProducer) produce(context.Context, *metricdata.ResourceMetrics) error { return ErrReaderShutdown } diff --git a/sdk/resource/resource_test.go b/sdk/resource/resource_test.go index 471c4dcfd..a06967fe7 100644 --- a/sdk/resource/resource_test.go +++ b/sdk/resource/resource_test.go @@ -796,7 +796,7 @@ func TestResourceConcurrentSafe(t *testing.T) { type fakeDetector struct{} -func (f fakeDetector) Detect(context.Context) (*resource.Resource, error) { +func (fakeDetector) Detect(context.Context) (*resource.Resource, error) { // A bit pedantic, but resource.NewWithAttributes returns an empty Resource when // no attributes specified. We want to make sure that this is concurrent-safe. return resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0"), nil diff --git a/sdk/trace/batch_span_processor.go b/sdk/trace/batch_span_processor.go index a6e35919b..83c72bb88 100644 --- a/sdk/trace/batch_span_processor.go +++ b/sdk/trace/batch_span_processor.go @@ -121,7 +121,7 @@ func NewBatchSpanProcessor(exporter SpanExporter, options ...BatchSpanProcessorO } // OnStart method does nothing. -func (bsp *batchSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} +func (*batchSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} // OnEnd method enqueues a ReadOnlySpan for later processing. func (bsp *batchSpanProcessor) OnEnd(s ReadOnlySpan) { @@ -169,7 +169,7 @@ type forceFlushSpan struct { flushed chan struct{} } -func (f forceFlushSpan) SpanContext() trace.SpanContext { +func (forceFlushSpan) SpanContext() trace.SpanContext { return trace.NewSpanContext(trace.SpanContextConfig{TraceFlags: trace.FlagsSampled}) } diff --git a/sdk/trace/batch_span_processor_test.go b/sdk/trace/batch_span_processor_test.go index f3f4596e1..020f11774 100644 --- a/sdk/trace/batch_span_processor_test.go +++ b/sdk/trace/batch_span_processor_test.go @@ -525,7 +525,7 @@ func newIndefiniteExporter(t *testing.T) indefiniteExporter { return e } -func (e indefiniteExporter) Shutdown(context.Context) error { +func (indefiniteExporter) Shutdown(context.Context) error { return nil } diff --git a/sdk/trace/id_generator.go b/sdk/trace/id_generator.go index 2164ec00d..3649322a6 100644 --- a/sdk/trace/id_generator.go +++ b/sdk/trace/id_generator.go @@ -32,7 +32,7 @@ type randomIDGenerator struct{} var _ IDGenerator = &randomIDGenerator{} // NewSpanID returns a non-zero span ID from a randomly-chosen sequence. -func (gen *randomIDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { +func (*randomIDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { sid := trace.SpanID{} for { binary.NativeEndian.PutUint64(sid[:], rand.Uint64()) @@ -45,7 +45,7 @@ func (gen *randomIDGenerator) NewSpanID(context.Context, trace.TraceID) trace.Sp // NewIDs returns a non-zero trace ID and a non-zero span ID from a // randomly-chosen sequence. -func (gen *randomIDGenerator) NewIDs(context.Context) (trace.TraceID, trace.SpanID) { +func (*randomIDGenerator) NewIDs(context.Context) (trace.TraceID, trace.SpanID) { tid := trace.TraceID{} sid := trace.SpanID{} for { diff --git a/sdk/trace/provider_test.go b/sdk/trace/provider_test.go index d0bd1e64e..78279d20c 100644 --- a/sdk/trace/provider_test.go +++ b/sdk/trace/provider_test.go @@ -33,8 +33,8 @@ func (t *basicSpanProcessor) Shutdown(context.Context) error { return t.injectShutdownError } -func (t *basicSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} -func (t *basicSpanProcessor) OnEnd(ReadOnlySpan) {} +func (*basicSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} +func (*basicSpanProcessor) OnEnd(ReadOnlySpan) {} func (t *basicSpanProcessor) ForceFlush(context.Context) error { t.flushed = true return nil @@ -48,9 +48,9 @@ func (t *shutdownSpanProcessor) Shutdown(ctx context.Context) error { return t.shutdown(ctx) } -func (t *shutdownSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} -func (t *shutdownSpanProcessor) OnEnd(ReadOnlySpan) {} -func (t *shutdownSpanProcessor) ForceFlush(context.Context) error { +func (*shutdownSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} +func (*shutdownSpanProcessor) OnEnd(ReadOnlySpan) {} +func (*shutdownSpanProcessor) ForceFlush(context.Context) error { return nil } diff --git a/sdk/trace/sampling.go b/sdk/trace/sampling.go index aa7b262d0..689663d48 100644 --- a/sdk/trace/sampling.go +++ b/sdk/trace/sampling.go @@ -110,14 +110,14 @@ func TraceIDRatioBased(fraction float64) Sampler { type alwaysOnSampler struct{} -func (as alwaysOnSampler) ShouldSample(p SamplingParameters) SamplingResult { +func (alwaysOnSampler) ShouldSample(p SamplingParameters) SamplingResult { return SamplingResult{ Decision: RecordAndSample, Tracestate: trace.SpanContextFromContext(p.ParentContext).TraceState(), } } -func (as alwaysOnSampler) Description() string { +func (alwaysOnSampler) Description() string { return "AlwaysOnSampler" } @@ -131,14 +131,14 @@ func AlwaysSample() Sampler { type alwaysOffSampler struct{} -func (as alwaysOffSampler) ShouldSample(p SamplingParameters) SamplingResult { +func (alwaysOffSampler) ShouldSample(p SamplingParameters) SamplingResult { return SamplingResult{ Decision: Drop, Tracestate: trace.SpanContextFromContext(p.ParentContext).TraceState(), } } -func (as alwaysOffSampler) Description() string { +func (alwaysOffSampler) Description() string { return "AlwaysOffSampler" } diff --git a/sdk/trace/simple_span_processor.go b/sdk/trace/simple_span_processor.go index 9cd281421..411d9ccdd 100644 --- a/sdk/trace/simple_span_processor.go +++ b/sdk/trace/simple_span_processor.go @@ -39,7 +39,7 @@ func NewSimpleSpanProcessor(exporter SpanExporter) SpanProcessor { } // OnStart does nothing. -func (ssp *simpleSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} +func (*simpleSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} // OnEnd immediately exports a ReadOnlySpan. func (ssp *simpleSpanProcessor) OnEnd(s ReadOnlySpan) { @@ -104,7 +104,7 @@ func (ssp *simpleSpanProcessor) Shutdown(ctx context.Context) error { } // ForceFlush does nothing as there is no data to flush. -func (ssp *simpleSpanProcessor) ForceFlush(context.Context) error { +func (*simpleSpanProcessor) ForceFlush(context.Context) error { return nil } diff --git a/sdk/trace/snapshot.go b/sdk/trace/snapshot.go index d511d0f27..63aa33780 100644 --- a/sdk/trace/snapshot.go +++ b/sdk/trace/snapshot.go @@ -35,7 +35,7 @@ type snapshot struct { var _ ReadOnlySpan = snapshot{} -func (s snapshot) private() {} +func (snapshot) private() {} // Name returns the name of the span. func (s snapshot) Name() string { diff --git a/sdk/trace/span_limits_test.go b/sdk/trace/span_limits_test.go index 871a4fe4b..3e5e7b2ae 100644 --- a/sdk/trace/span_limits_test.go +++ b/sdk/trace/span_limits_test.go @@ -129,10 +129,10 @@ func TestSettingSpanLimits(t *testing.T) { type recorder []ReadOnlySpan -func (r *recorder) OnStart(context.Context, ReadWriteSpan) {} -func (r *recorder) OnEnd(s ReadOnlySpan) { *r = append(*r, s) } -func (r *recorder) ForceFlush(context.Context) error { return nil } -func (r *recorder) Shutdown(context.Context) error { return nil } +func (*recorder) OnStart(context.Context, ReadWriteSpan) {} +func (r *recorder) OnEnd(s ReadOnlySpan) { *r = append(*r, s) } +func (*recorder) ForceFlush(context.Context) error { return nil } +func (*recorder) Shutdown(context.Context) error { return nil } func testSpanLimits(t *testing.T, limits SpanLimits) ReadOnlySpan { rec := new(recorder) diff --git a/sdk/trace/span_processor_annotator_example_test.go b/sdk/trace/span_processor_annotator_example_test.go index e963afc5c..7f74b6f03 100644 --- a/sdk/trace/span_processor_annotator_example_test.go +++ b/sdk/trace/span_processor_annotator_example_test.go @@ -34,9 +34,9 @@ type Annotator struct { } func (a Annotator) OnStart(_ context.Context, s ReadWriteSpan) { s.SetAttributes(a.AttrsFunc()...) } -func (a Annotator) Shutdown(context.Context) error { return nil } -func (a Annotator) ForceFlush(context.Context) error { return nil } -func (a Annotator) OnEnd(s ReadOnlySpan) { +func (Annotator) Shutdown(context.Context) error { return nil } +func (Annotator) ForceFlush(context.Context) error { return nil } +func (Annotator) OnEnd(s ReadOnlySpan) { attr := s.Attributes()[0] fmt.Printf("%s: %s\n", attr.Key, attr.Value.AsString()) } diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 6bff7f2a3..febfac488 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -161,7 +161,7 @@ func (ts *testSampler) ShouldSample(p SamplingParameters) SamplingResult { } } -func (ts testSampler) Description() string { +func (testSampler) Description() string { return "testSampler" } @@ -1799,7 +1799,7 @@ func (s *stateSampler) ShouldSample(p SamplingParameters) SamplingResult { return SamplingResult{Decision: decision, Tracestate: ts} } -func (s stateSampler) Description() string { +func (stateSampler) Description() string { return "stateSampler" } @@ -2641,7 +2641,7 @@ func RecordingOnly() Sampler { type recordOnlySampler struct{} // ShouldSample implements Sampler interface. It always returns Record but not Sample. -func (s recordOnlySampler) ShouldSample(p SamplingParameters) SamplingResult { +func (recordOnlySampler) ShouldSample(p SamplingParameters) SamplingResult { psc := trace.SpanContextFromContext(p.ParentContext) return SamplingResult{ Decision: RecordOnly, diff --git a/sdk/trace/tracetest/exporter.go b/sdk/trace/tracetest/exporter.go index 07117495a..e12fa67e6 100644 --- a/sdk/trace/tracetest/exporter.go +++ b/sdk/trace/tracetest/exporter.go @@ -25,10 +25,10 @@ func NewNoopExporter() *NoopExporter { type NoopExporter struct{} // ExportSpans handles export of spans by dropping them. -func (nsb *NoopExporter) ExportSpans(context.Context, []trace.ReadOnlySpan) error { return nil } +func (*NoopExporter) ExportSpans(context.Context, []trace.ReadOnlySpan) error { return nil } // Shutdown stops the exporter by doing nothing. -func (nsb *NoopExporter) Shutdown(context.Context) error { return nil } +func (*NoopExporter) Shutdown(context.Context) error { return nil } var _ trace.SpanExporter = (*InMemoryExporter)(nil) diff --git a/sdk/trace/tracetest/recorder.go b/sdk/trace/tracetest/recorder.go index 732669a17..ca63038f3 100644 --- a/sdk/trace/tracetest/recorder.go +++ b/sdk/trace/tracetest/recorder.go @@ -47,14 +47,14 @@ func (sr *SpanRecorder) OnEnd(s sdktrace.ReadOnlySpan) { // Shutdown does nothing. // // This method is safe to be called concurrently. -func (sr *SpanRecorder) Shutdown(context.Context) error { +func (*SpanRecorder) Shutdown(context.Context) error { return nil } // ForceFlush does nothing. // // This method is safe to be called concurrently. -func (sr *SpanRecorder) ForceFlush(context.Context) error { +func (*SpanRecorder) ForceFlush(context.Context) error { return nil } diff --git a/semconv/internal/v2/http.go b/semconv/internal/v2/http.go index d88c7f5df..5d5f12a56 100644 --- a/semconv/internal/v2/http.go +++ b/semconv/internal/v2/http.go @@ -298,7 +298,7 @@ func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue { return c.header("http.response.header", h) } -func (c *HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { +func (*HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { key := func(k string) attribute.Key { k = strings.ToLower(k) k = strings.ReplaceAll(k, "-", "_") @@ -315,7 +315,7 @@ func (c *HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { // ClientStatus returns a span status code and message for an HTTP status code // value received by a client. -func (c *HTTPConv) ClientStatus(code int) (codes.Code, string) { +func (*HTTPConv) ClientStatus(code int) (codes.Code, string) { stat, valid := validateHTTPStatusCode(code) if !valid { return stat, fmt.Sprintf("Invalid HTTP status code %d", code) @@ -326,7 +326,7 @@ func (c *HTTPConv) ClientStatus(code int) (codes.Code, string) { // ServerStatus returns a span status code and message for an HTTP status code // value returned by a server. Status codes in the 400-499 range are not // returned as errors. -func (c *HTTPConv) ServerStatus(code int) (codes.Code, string) { +func (*HTTPConv) ServerStatus(code int) (codes.Code, string) { stat, valid := validateHTTPStatusCode(code) if !valid { return stat, fmt.Sprintf("Invalid HTTP status code %d", code) diff --git a/semconv/internal/v3/http.go b/semconv/internal/v3/http.go index f24fd3ef4..baaad7265 100644 --- a/semconv/internal/v3/http.go +++ b/semconv/internal/v3/http.go @@ -298,7 +298,7 @@ func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue { return c.header("http.response.header", h) } -func (c *HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { +func (*HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { key := func(k string) attribute.Key { k = strings.ToLower(k) k = strings.ReplaceAll(k, "-", "_") @@ -315,7 +315,7 @@ func (c *HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { // ClientStatus returns a span status code and message for an HTTP status code // value received by a client. -func (c *HTTPConv) ClientStatus(code int) (codes.Code, string) { +func (*HTTPConv) ClientStatus(code int) (codes.Code, string) { stat, valid := validateHTTPStatusCode(code) if !valid { return stat, fmt.Sprintf("Invalid HTTP status code %d", code) @@ -326,7 +326,7 @@ func (c *HTTPConv) ClientStatus(code int) (codes.Code, string) { // ServerStatus returns a span status code and message for an HTTP status code // value returned by a server. Status codes in the 400-499 range are not // returned as errors. -func (c *HTTPConv) ServerStatus(code int) (codes.Code, string) { +func (*HTTPConv) ServerStatus(code int) (codes.Code, string) { stat, valid := validateHTTPStatusCode(code) if !valid { return stat, fmt.Sprintf("Invalid HTTP status code %d", code) diff --git a/semconv/internal/v4/http.go b/semconv/internal/v4/http.go index c02dafcc6..4595ae34c 100644 --- a/semconv/internal/v4/http.go +++ b/semconv/internal/v4/http.go @@ -299,7 +299,7 @@ func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue { return c.header("http.response.header", h) } -func (c *HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { +func (*HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { key := func(k string) attribute.Key { k = strings.ToLower(k) k = strings.ReplaceAll(k, "-", "_") @@ -316,7 +316,7 @@ func (c *HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { // ClientStatus returns a span status code and message for an HTTP status code // value received by a client. -func (c *HTTPConv) ClientStatus(code int) (codes.Code, string) { +func (*HTTPConv) ClientStatus(code int) (codes.Code, string) { stat, valid := validateHTTPStatusCode(code) if !valid { return stat, fmt.Sprintf("Invalid HTTP status code %d", code) @@ -327,7 +327,7 @@ func (c *HTTPConv) ClientStatus(code int) (codes.Code, string) { // ServerStatus returns a span status code and message for an HTTP status code // value returned by a server. Status codes in the 400-499 range are not // returned as errors. -func (c *HTTPConv) ServerStatus(code int) (codes.Code, string) { +func (*HTTPConv) ServerStatus(code int) (codes.Code, string) { stat, valid := validateHTTPStatusCode(code) if !valid { return stat, fmt.Sprintf("Invalid HTTP status code %d", code) diff --git a/trace/auto.go b/trace/auto.go index f3aa39813..27787f261 100644 --- a/trace/auto.go +++ b/trace/auto.go @@ -39,7 +39,7 @@ type autoTracerProvider struct{ embedded.TracerProvider } var _ TracerProvider = autoTracerProvider{} -func (p autoTracerProvider) Tracer(name string, opts ...TracerOption) Tracer { +func (autoTracerProvider) Tracer(name string, opts ...TracerOption) Tracer { cfg := NewTracerConfig(opts...) return autoTracer{ name: name, @@ -81,7 +81,7 @@ func (t autoTracer) Start(ctx context.Context, name string, opts ...SpanStartOpt // Expected to be implemented in eBPF. // //go:noinline -func (t *autoTracer) start( +func (*autoTracer) start( ctx context.Context, spanPtr *autoSpan, psc *SpanContext, diff --git a/trace/noop.go b/trace/noop.go index eeb23c9eb..400fab123 100644 --- a/trace/noop.go +++ b/trace/noop.go @@ -26,7 +26,7 @@ type noopTracerProvider struct{ embedded.TracerProvider } var _ TracerProvider = noopTracerProvider{} // Tracer returns noop implementation of Tracer. -func (p noopTracerProvider) Tracer(string, ...TracerOption) Tracer { +func (noopTracerProvider) Tracer(string, ...TracerOption) Tracer { return noopTracer{} } @@ -37,7 +37,7 @@ var _ Tracer = noopTracer{} // Start carries forward a non-recording Span, if one is present in the context, otherwise it // creates a no-op Span. -func (t noopTracer) Start(ctx context.Context, _ string, _ ...SpanStartOption) (context.Context, Span) { +func (noopTracer) Start(ctx context.Context, _ string, _ ...SpanStartOption) (context.Context, Span) { span := SpanFromContext(ctx) if _, ok := span.(nonRecordingSpan); !ok { // span is likely already a noopSpan, but let's be sure diff --git a/trace/noop/noop.go b/trace/noop/noop.go index 64a4f1b36..689d220df 100644 --- a/trace/noop/noop.go +++ b/trace/noop/noop.go @@ -51,7 +51,7 @@ type Tracer struct{ embedded.Tracer } // If ctx contains a span context, the returned span will also contain that // span context. If the span context in ctx is for a non-recording span, that // span instance will be returned directly. -func (t Tracer) Start(ctx context.Context, _ string, _ ...trace.SpanStartOption) (context.Context, trace.Span) { +func (Tracer) Start(ctx context.Context, _ string, _ ...trace.SpanStartOption) (context.Context, trace.Span) { span := trace.SpanFromContext(ctx) // If the parent context contains a non-zero span context, that span