1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-08-10 22:31:50 +02:00

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 <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-08-09 00:38:22 +02:00
committed by GitHub
parent 4b0c8f174b
commit 68841fa6db
53 changed files with 123 additions and 122 deletions

View File

@@ -181,6 +181,7 @@ linters:
- fmt.Printf - fmt.Printf
- fmt.Println - fmt.Println
- name: unused-parameter - name: unused-parameter
- name: unused-receiver
- name: unnecessary-stmt - name: unnecessary-stmt
- name: use-any - name: use-any
- name: useless-break - name: useless-break

View File

@@ -53,12 +53,12 @@ func (o *Tracer) StartSpanWithRemoteParent(
} }
// FromContext returns the Span stored in a context. // 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)) return NewSpan(trace.SpanFromContext(ctx))
} }
// NewContext returns a new context with the given Span attached. // 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 { if otSpan, ok := s.Internal().(*Span); ok {
return trace.ContextWithSpan(parent, otSpan.otelSpan) return trace.ContextWithSpan(parent, otSpan.otelSpan)
} }

View File

@@ -139,7 +139,7 @@ type differentSpan struct {
octrace.SpanInterface octrace.SpanInterface
} }
func (s *differentSpan) String() string { return "testing span" } func (*differentSpan) String() string { return "testing span" }
func TestTracerNewContextErrors(t *testing.T) { func TestTracerNewContextErrors(t *testing.T) {
h, restore := withHandler() h, restore := withHandler()

View File

@@ -832,12 +832,12 @@ func newTextMapWrapperForInject(carrier any) (*textMapWrapper, error) {
type textMapWriter struct{} type textMapWriter struct{}
func (t *textMapWriter) Set(string, string) { func (*textMapWriter) Set(string, string) {
// maybe print a warning log. // maybe print a warning log.
} }
type textMapReader struct{} 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. return nil // maybe print a warning log.
} }

View File

@@ -30,7 +30,7 @@ func newTestOnlyTextMapReader() *testOnlyTextMapReader {
return &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("key1", "val1")
_ = handler("key2", "val2") _ = handler("key2", "val2")
@@ -134,7 +134,7 @@ var (
type testTextMapPropagator struct{} 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()) carrier.Set(testHeader, traceID.String()+":"+spanID.String())
// Test for panic // Test for panic
@@ -142,7 +142,7 @@ func (t testTextMapPropagator) Inject(_ context.Context, carrier propagation.Tex
_ = carrier.Keys() _ = 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) traces := carrier.Get(testHeader)
str := strings.Split(traces, ":") str := strings.Split(traces, ":")
@@ -179,7 +179,7 @@ func (t testTextMapPropagator) Extract(ctx context.Context, carrier propagation.
return trace.ContextWithRemoteSpanContext(ctx, sc) return trace.ContextWithRemoteSpanContext(ctx, sc)
} }
func (t testTextMapPropagator) Fields() []string { func (testTextMapPropagator) Fields() []string {
return []string{"test"} return []string{"test"}
} }

View File

@@ -145,7 +145,7 @@ func (st *simpleTest) runOTOtelOT(t *testing.T, ctx context.Context) {
runOTOtelOT(t, ctx, "simple", st.noop) 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 return ctx
} }

View File

@@ -132,7 +132,7 @@ func (t *mockTracer) getParentSpanID(ctx context.Context, config *trace.SpanConf
return trace.SpanID{} 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() { if !config.NewRoot() {
return trace.SpanContextFromContext(ctx) return trace.SpanContextFromContext(ctx)
} }
@@ -309,4 +309,4 @@ func (s *mockSpan) OverrideTracer(tracer trace.Tracer) {
s.officialTracer = tracer s.officialTracer = tracer
} }
func (s *mockSpan) TracerProvider() trace.TracerProvider { return noop.NewTracerProvider() } func (*mockSpan) TracerProvider() trace.TracerProvider { return noop.NewTracerProvider() }

View File

@@ -21,7 +21,7 @@ type namedMockTracerProvider struct{ embedded.TracerProvider }
var _ trace.TracerProvider = (*namedMockTracerProvider)(nil) var _ trace.TracerProvider = (*namedMockTracerProvider)(nil)
// Tracer returns the WrapperTracer associated with the WrapperTracerProvider. // 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{ return &namedMockTracer{
name: name, name: name,
mockTracer: newMockTracer(), mockTracer: newMockTracer(),

View File

@@ -217,9 +217,9 @@ func newNoopClient() *noopClient {
return &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 // 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. // duration to wait for if an explicit throttle time is included in err.

View File

@@ -89,6 +89,6 @@ func (e *Exporter) Shutdown(ctx context.Context) error {
} }
// ForceFlush does nothing. The Exporter holds no state. // ForceFlush does nothing. The Exporter holds no state.
func (e *Exporter) ForceFlush(context.Context) error { func (*Exporter) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -353,7 +353,7 @@ func (c *httpCollector) record(r *http.Request) exportResult {
return exportResult{Err: err} 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 var reader io.ReadCloser
switch r.Header.Get("Content-Encoding") { switch r.Header.Get("Content-Encoding") {
case "gzip": case "gzip":

View File

@@ -68,6 +68,6 @@ func (e *Exporter) Shutdown(context.Context) error {
} }
// ForceFlush does nothing. The Exporter holds no state. // ForceFlush does nothing. The Exporter holds no state.
func (e *Exporter) ForceFlush(context.Context) error { func (*Exporter) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -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 returns an error if the method is canceled by the passed context.
// //
// This method is safe to call concurrently. // 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. // The exporter and client hold no state, nothing to flush.
return ctx.Err() return ctx.Err()
} }
@@ -120,7 +120,7 @@ var errShutdown = errors.New("gRPC exporter is shutdown")
type shutdownClient struct{} type shutdownClient struct{}
func (c shutdownClient) err(ctx context.Context) error { func (shutdownClient) err(ctx context.Context) error {
if err := ctx.Err(); err != nil { if err := ctx.Err(); err != nil {
return err return err
} }
@@ -136,7 +136,7 @@ func (c shutdownClient) Shutdown(ctx context.Context) error {
} }
// MarshalLog returns logging data about the Exporter. // MarshalLog returns logging data about the Exporter.
func (e *Exporter) MarshalLog() any { func (*Exporter) MarshalLog() any {
return struct{ Type string }{Type: "OTLP/gRPC"} return struct{ Type string }{Type: "OTLP/gRPC"}
} }

View File

@@ -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 returns an error if the method is canceled by the passed context.
// //
// This method is safe to call concurrently. // 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. // The exporter and client hold no state, nothing to flush.
return ctx.Err() return ctx.Err()
} }
@@ -120,7 +120,7 @@ var errShutdown = errors.New("HTTP exporter is shutdown")
type shutdownClient struct{} type shutdownClient struct{}
func (c shutdownClient) err(ctx context.Context) error { func (shutdownClient) err(ctx context.Context) error {
if err := ctx.Err(); err != nil { if err := ctx.Err(); err != nil {
return err return err
} }
@@ -136,7 +136,7 @@ func (c shutdownClient) Shutdown(ctx context.Context) error {
} }
// MarshalLog returns logging data about the Exporter. // MarshalLog returns logging data about the Exporter.
func (e *Exporter) MarshalLog() any { func (*Exporter) MarshalLog() any {
return struct{ Type string }{Type: "OTLP/HTTP"} return struct{ Type string }{Type: "OTLP/HTTP"}
} }

View File

@@ -21,11 +21,11 @@ type client struct {
var _ otlptrace.Client = &client{} var _ otlptrace.Client = &client{}
func (c *client) Start(context.Context) error { func (*client) Start(context.Context) error {
return nil return nil
} }
func (c *client) Stop(context.Context) error { func (*client) Stop(context.Context) error {
return nil return nil
} }

View File

@@ -104,7 +104,7 @@ func NewClient(opts ...Option) otlptrace.Client {
} }
// Start does nothing in a HTTP 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 // nothing to do
select { select {
case <-ctx.Done(): case <-ctx.Done():

View File

@@ -143,7 +143,7 @@ func New(opts ...Option) (*Exporter, error) {
} }
// Describe implements prometheus.Collector. // 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 // 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, // is registered. By returning nothing we are an "unchecked" collector in Prometheus,
// and assume responsibility for consistency of the metrics produced. // 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) 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) { switch v := m.Data.(type) {
case metricdata.ExponentialHistogram[int64], metricdata.ExponentialHistogram[float64]: case metricdata.ExponentialHistogram[int64], metricdata.ExponentialHistogram[float64]:
return dto.MetricType_HISTOGRAM.Enum() return dto.MetricType_HISTOGRAM.Enum()

View File

@@ -67,6 +67,6 @@ func (e *Exporter) Shutdown(context.Context) error {
} }
// ForceFlush performs no action. // ForceFlush performs no action.
func (e *Exporter) ForceFlush(context.Context) error { func (*Exporter) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -63,7 +63,7 @@ func (e *exporter) Export(ctx context.Context, data *metricdata.ResourceMetrics)
return e.encVal.Load().(encoderHolder).Encode(data) 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. // exporter holds no state, nothing to flush.
return nil return nil
} }
@@ -77,7 +77,7 @@ func (e *exporter) Shutdown(context.Context) error {
return nil return nil
} }
func (e *exporter) MarshalLog() any { func (*exporter) MarshalLog() any {
return struct{ Type string }{Type: "STDOUT"} return struct{ Type string }{Type: "STDOUT"}
} }

View File

@@ -106,22 +106,22 @@ func (*altRegistration) Unregister() error {
return nil 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) return noop.NewMeterProvider().Meter("noop").Int64Counter(name)
} }
func (am *altMeter) Int64UpDownCounter( func (*altMeter) Int64UpDownCounter(
name string, name string,
_ ...metric.Int64UpDownCounterOption, _ ...metric.Int64UpDownCounterOption,
) (metric.Int64UpDownCounter, error) { ) (metric.Int64UpDownCounter, error) {
return noop.NewMeterProvider().Meter("noop").Int64UpDownCounter(name) 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) 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) return noop.NewMeterProvider().Meter("noop").Int64Gauge(name)
} }
@@ -152,25 +152,25 @@ func (am *altMeter) Int64ObservableGauge(
}, nil }, 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) return noop.NewMeterProvider().Meter("noop").Float64Counter(name)
} }
func (am *altMeter) Float64UpDownCounter( func (*altMeter) Float64UpDownCounter(
name string, name string,
_ ...metric.Float64UpDownCounterOption, _ ...metric.Float64UpDownCounterOption,
) (metric.Float64UpDownCounter, error) { ) (metric.Float64UpDownCounter, error) {
return noop.NewMeterProvider().Meter("noop").Float64UpDownCounter(name) return noop.NewMeterProvider().Meter("noop").Float64UpDownCounter(name)
} }
func (am *altMeter) Float64Histogram( func (*altMeter) Float64Histogram(
name string, name string,
_ ...metric.Float64HistogramOption, _ ...metric.Float64HistogramOption,
) (metric.Float64Histogram, error) { ) (metric.Float64Histogram, error) {
return noop.NewMeterProvider().Meter("noop").Float64Histogram(name) 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) return noop.NewMeterProvider().Meter("noop").Float64Gauge(name)
} }

View File

@@ -442,7 +442,7 @@ type failingRegisterCallbackMeter struct {
noop.Meter noop.Meter
} }
func (m *failingRegisterCallbackMeter) RegisterCallback( func (*failingRegisterCallbackMeter) RegisterCallback(
metric.Callback, metric.Callback,
...metric.Observable, ...metric.Observable,
) (metric.Registration, error) { ) (metric.Registration, error) {

View File

@@ -182,14 +182,14 @@ type observationRecorder struct {
ctx context.Context 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) iImpl, ok := i.(*testCountingFloatInstrument)
if ok { if ok {
iImpl.observe() 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) iImpl, ok := i.(*testCountingIntInstrument)
if ok { if ok {
iImpl.observe() iImpl.observe()

View File

@@ -20,7 +20,7 @@ type Baggage struct{}
var _ TextMapPropagator = Baggage{} var _ TextMapPropagator = Baggage{}
// Inject sets baggage key-values from ctx into the carrier. // 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() bStr := baggage.FromContext(ctx).String()
if bStr != "" { if bStr != "" {
carrier.Set(baggageHeader, 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. // Extract returns a copy of parent with the baggage from the carrier added.
// If carrier implements [ValuesGetter] (e.g. [HeaderCarrier]), Values is invoked // If carrier implements [ValuesGetter] (e.g. [HeaderCarrier]), Values is invoked
// for multiple values extraction. Otherwise, Get is called. // 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 { if multiCarrier, ok := carrier.(ValuesGetter); ok {
return extractMultiBaggage(parent, multiCarrier) 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. // Fields returns the keys who's values are set with Inject.
func (b Baggage) Fields() []string { func (Baggage) Fields() []string {
return []string{baggageHeader} return []string{baggageHeader}
} }

View File

@@ -20,9 +20,9 @@ var ctxKey ctxKeyType
type carrier []string 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) { func (c *carrier) Set(setter, _ string) {
*c = append(*c, setter) *c = append(*c, setter)

View File

@@ -36,7 +36,7 @@ var (
) )
// Inject injects the trace context from ctx into carrier. // 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) sc := trace.SpanContextFromContext(ctx)
if !sc.IsValid() { if !sc.IsValid() {
return return
@@ -77,7 +77,7 @@ func (tc TraceContext) Extract(ctx context.Context, carrier TextMapCarrier) cont
return trace.ContextWithRemoteSpanContext(ctx, sc) return trace.ContextWithRemoteSpanContext(ctx, sc)
} }
func (tc TraceContext) extract(carrier TextMapCarrier) trace.SpanContext { func (TraceContext) extract(carrier TextMapCarrier) trace.SpanContext {
h := carrier.Get(traceparentHeader) h := carrier.Get(traceparentHeader)
if h == "" { if h == "" {
return trace.SpanContext{} 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. // Fields returns the keys who's values are set with Inject.
func (tc TraceContext) Fields() []string { func (TraceContext) Fields() []string {
return []string{traceparentHeader, tracestateHeader} return []string{traceparentHeader, tracestateHeader}
} }

View File

@@ -128,57 +128,57 @@ func BenchmarkProcessor(b *testing.B) {
type timestampProcessor struct{} 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)) r.SetObservedTimestamp(time.Date(1988, time.November, 17, 0, 0, 0, 0, time.UTC))
return nil return nil
} }
func (p timestampProcessor) Enabled(context.Context, Record) bool { func (timestampProcessor) Enabled(context.Context, Record) bool {
return true return true
} }
func (p timestampProcessor) Shutdown(context.Context) error { func (timestampProcessor) Shutdown(context.Context) error {
return nil return nil
} }
func (p timestampProcessor) ForceFlush(context.Context) error { func (timestampProcessor) ForceFlush(context.Context) error {
return nil return nil
} }
type attrAddProcessor struct{} 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")) r.AddAttributes(log.String("add", "me"))
return nil return nil
} }
func (p attrAddProcessor) Enabled(context.Context, Record) bool { func (attrAddProcessor) Enabled(context.Context, Record) bool {
return true return true
} }
func (p attrAddProcessor) Shutdown(context.Context) error { func (attrAddProcessor) Shutdown(context.Context) error {
return nil return nil
} }
func (p attrAddProcessor) ForceFlush(context.Context) error { func (attrAddProcessor) ForceFlush(context.Context) error {
return nil return nil
} }
type attrSetDecorator struct{} 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")) r.SetAttributes(log.String("replace", "me"))
return nil return nil
} }
func (p attrSetDecorator) Enabled(context.Context, Record) bool { func (attrSetDecorator) Enabled(context.Context, Record) bool {
return true return true
} }
func (p attrSetDecorator) Shutdown(context.Context) error { func (attrSetDecorator) Shutdown(context.Context) error {
return nil return nil
} }
func (p attrSetDecorator) ForceFlush(context.Context) error { func (attrSetDecorator) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -135,7 +135,7 @@ type RedactTokensProcessor struct{}
// OnEmit redacts values from attributes containing "token" in the key // OnEmit redacts values from attributes containing "token" in the key
// by replacing them with a REDACTED value. // 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 { record.WalkAttributes(func(kv logapi.KeyValue) bool {
if strings.Contains(strings.ToLower(kv.Key), "token") { if strings.Contains(strings.ToLower(kv.Key), "token") {
record.AddAttributes(logapi.String(kv.Key, "REDACTED")) record.AddAttributes(logapi.String(kv.Key, "REDACTED"))
@@ -146,11 +146,11 @@ func (p *RedactTokensProcessor) OnEmit(_ context.Context, record *log.Record) er
} }
// Shutdown returns nil. // Shutdown returns nil.
func (p *RedactTokensProcessor) Shutdown(context.Context) error { func (*RedactTokensProcessor) Shutdown(context.Context) error {
return nil return nil
} }
// ForceFlush returns nil. // ForceFlush returns nil.
func (p *RedactTokensProcessor) ForceFlush(context.Context) error { func (*RedactTokensProcessor) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -54,11 +54,11 @@ func (e exporter) Export(_ context.Context, records []log.Record) error {
return nil return nil
} }
func (e exporter) Shutdown(context.Context) error { func (exporter) Shutdown(context.Context) error {
return nil return nil
} }
// appropriate error should be returned in these situations. // appropriate error should be returned in these situations.
func (e exporter) ForceFlush(context.Context) error { func (exporter) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -278,7 +278,7 @@ type logSink struct {
keysAndValues []any 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) { func (l *logSink) Info(level int, msg string, keysAndValues ...any) {
l.level, l.msg, l.keysAndValues = level, msg, keysAndValues l.level, l.msg, l.keysAndValues = level, msg, keysAndValues

View File

@@ -77,11 +77,11 @@ func (e *writerExporter) Export(_ context.Context, records []log.Record) error {
return nil return nil
} }
func (e *writerExporter) Shutdown(context.Context) error { func (*writerExporter) Shutdown(context.Context) error {
return nil return nil
} }
func (e *writerExporter) ForceFlush(context.Context) error { func (*writerExporter) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -56,7 +56,7 @@ func newFixedSizeReservoir(s *storage) *FixedSizeReservoir {
// randomFloat64 returns, as a float64, a uniform pseudo-random number in the // randomFloat64 returns, as a float64, a uniform pseudo-random number in the
// open interval (0.0,1.0). // 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: // TODO: Use an algorithm that avoids rejection sampling. For example:
// //
// const precision = 1 << 53 // 2^53 // const precision = 1 << 53 // 2^53

View File

@@ -18,10 +18,10 @@ func dropReservoir[N int64 | float64](attribute.Set) FilteredExemplarReservoir[N
type dropRes[N int64 | float64] struct{} type dropRes[N int64 | float64] struct{}
// Offer does nothing, all measurements offered will be dropped. // 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. // 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 clear(*dest) // Erase elements to let GC collect objects
*dest = (*dest)[:0] *dest = (*dest)[:0]
} }

View File

@@ -466,7 +466,7 @@ func (i *inserter[N]) logConflict(id instID) {
global.Warn(msg, args...) 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 var zero N
return instID{ return instID{
Name: stream.Name, Name: stream.Name,

View File

@@ -117,7 +117,7 @@ type produceHolder struct {
type shutdownProducer struct{} type shutdownProducer struct{}
// produce returns an ErrReaderShutdown error. // produce returns an ErrReaderShutdown error.
func (p shutdownProducer) produce(context.Context, *metricdata.ResourceMetrics) error { func (shutdownProducer) produce(context.Context, *metricdata.ResourceMetrics) error {
return ErrReaderShutdown return ErrReaderShutdown
} }

View File

@@ -796,7 +796,7 @@ func TestResourceConcurrentSafe(t *testing.T) {
type fakeDetector struct{} 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 // A bit pedantic, but resource.NewWithAttributes returns an empty Resource when
// no attributes specified. We want to make sure that this is concurrent-safe. // no attributes specified. We want to make sure that this is concurrent-safe.
return resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0"), nil return resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0"), nil

View File

@@ -121,7 +121,7 @@ func NewBatchSpanProcessor(exporter SpanExporter, options ...BatchSpanProcessorO
} }
// OnStart method does nothing. // 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. // OnEnd method enqueues a ReadOnlySpan for later processing.
func (bsp *batchSpanProcessor) OnEnd(s ReadOnlySpan) { func (bsp *batchSpanProcessor) OnEnd(s ReadOnlySpan) {
@@ -169,7 +169,7 @@ type forceFlushSpan struct {
flushed chan struct{} flushed chan struct{}
} }
func (f forceFlushSpan) SpanContext() trace.SpanContext { func (forceFlushSpan) SpanContext() trace.SpanContext {
return trace.NewSpanContext(trace.SpanContextConfig{TraceFlags: trace.FlagsSampled}) return trace.NewSpanContext(trace.SpanContextConfig{TraceFlags: trace.FlagsSampled})
} }

View File

@@ -525,7 +525,7 @@ func newIndefiniteExporter(t *testing.T) indefiniteExporter {
return e return e
} }
func (e indefiniteExporter) Shutdown(context.Context) error { func (indefiniteExporter) Shutdown(context.Context) error {
return nil return nil
} }

View File

@@ -32,7 +32,7 @@ type randomIDGenerator struct{}
var _ IDGenerator = &randomIDGenerator{} var _ IDGenerator = &randomIDGenerator{}
// NewSpanID returns a non-zero span ID from a randomly-chosen sequence. // 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{} sid := trace.SpanID{}
for { for {
binary.NativeEndian.PutUint64(sid[:], rand.Uint64()) 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 // NewIDs returns a non-zero trace ID and a non-zero span ID from a
// randomly-chosen sequence. // 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{} tid := trace.TraceID{}
sid := trace.SpanID{} sid := trace.SpanID{}
for { for {

View File

@@ -33,8 +33,8 @@ func (t *basicSpanProcessor) Shutdown(context.Context) error {
return t.injectShutdownError return t.injectShutdownError
} }
func (t *basicSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} func (*basicSpanProcessor) OnStart(context.Context, ReadWriteSpan) {}
func (t *basicSpanProcessor) OnEnd(ReadOnlySpan) {} func (*basicSpanProcessor) OnEnd(ReadOnlySpan) {}
func (t *basicSpanProcessor) ForceFlush(context.Context) error { func (t *basicSpanProcessor) ForceFlush(context.Context) error {
t.flushed = true t.flushed = true
return nil return nil
@@ -48,9 +48,9 @@ func (t *shutdownSpanProcessor) Shutdown(ctx context.Context) error {
return t.shutdown(ctx) return t.shutdown(ctx)
} }
func (t *shutdownSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} func (*shutdownSpanProcessor) OnStart(context.Context, ReadWriteSpan) {}
func (t *shutdownSpanProcessor) OnEnd(ReadOnlySpan) {} func (*shutdownSpanProcessor) OnEnd(ReadOnlySpan) {}
func (t *shutdownSpanProcessor) ForceFlush(context.Context) error { func (*shutdownSpanProcessor) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -110,14 +110,14 @@ func TraceIDRatioBased(fraction float64) Sampler {
type alwaysOnSampler struct{} type alwaysOnSampler struct{}
func (as alwaysOnSampler) ShouldSample(p SamplingParameters) SamplingResult { func (alwaysOnSampler) ShouldSample(p SamplingParameters) SamplingResult {
return SamplingResult{ return SamplingResult{
Decision: RecordAndSample, Decision: RecordAndSample,
Tracestate: trace.SpanContextFromContext(p.ParentContext).TraceState(), Tracestate: trace.SpanContextFromContext(p.ParentContext).TraceState(),
} }
} }
func (as alwaysOnSampler) Description() string { func (alwaysOnSampler) Description() string {
return "AlwaysOnSampler" return "AlwaysOnSampler"
} }
@@ -131,14 +131,14 @@ func AlwaysSample() Sampler {
type alwaysOffSampler struct{} type alwaysOffSampler struct{}
func (as alwaysOffSampler) ShouldSample(p SamplingParameters) SamplingResult { func (alwaysOffSampler) ShouldSample(p SamplingParameters) SamplingResult {
return SamplingResult{ return SamplingResult{
Decision: Drop, Decision: Drop,
Tracestate: trace.SpanContextFromContext(p.ParentContext).TraceState(), Tracestate: trace.SpanContextFromContext(p.ParentContext).TraceState(),
} }
} }
func (as alwaysOffSampler) Description() string { func (alwaysOffSampler) Description() string {
return "AlwaysOffSampler" return "AlwaysOffSampler"
} }

View File

@@ -39,7 +39,7 @@ func NewSimpleSpanProcessor(exporter SpanExporter) SpanProcessor {
} }
// OnStart does nothing. // OnStart does nothing.
func (ssp *simpleSpanProcessor) OnStart(context.Context, ReadWriteSpan) {} func (*simpleSpanProcessor) OnStart(context.Context, ReadWriteSpan) {}
// OnEnd immediately exports a ReadOnlySpan. // OnEnd immediately exports a ReadOnlySpan.
func (ssp *simpleSpanProcessor) OnEnd(s 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. // 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 return nil
} }

View File

@@ -35,7 +35,7 @@ type snapshot struct {
var _ ReadOnlySpan = snapshot{} var _ ReadOnlySpan = snapshot{}
func (s snapshot) private() {} func (snapshot) private() {}
// Name returns the name of the span. // Name returns the name of the span.
func (s snapshot) Name() string { func (s snapshot) Name() string {

View File

@@ -129,10 +129,10 @@ func TestSettingSpanLimits(t *testing.T) {
type recorder []ReadOnlySpan type recorder []ReadOnlySpan
func (r *recorder) OnStart(context.Context, ReadWriteSpan) {} func (*recorder) OnStart(context.Context, ReadWriteSpan) {}
func (r *recorder) OnEnd(s ReadOnlySpan) { *r = append(*r, s) } func (r *recorder) OnEnd(s ReadOnlySpan) { *r = append(*r, s) }
func (r *recorder) ForceFlush(context.Context) error { return nil } func (*recorder) ForceFlush(context.Context) error { return nil }
func (r *recorder) Shutdown(context.Context) error { return nil } func (*recorder) Shutdown(context.Context) error { return nil }
func testSpanLimits(t *testing.T, limits SpanLimits) ReadOnlySpan { func testSpanLimits(t *testing.T, limits SpanLimits) ReadOnlySpan {
rec := new(recorder) rec := new(recorder)

View File

@@ -34,9 +34,9 @@ type Annotator struct {
} }
func (a Annotator) OnStart(_ context.Context, s ReadWriteSpan) { s.SetAttributes(a.AttrsFunc()...) } func (a Annotator) OnStart(_ context.Context, s ReadWriteSpan) { s.SetAttributes(a.AttrsFunc()...) }
func (a Annotator) Shutdown(context.Context) error { return nil } func (Annotator) Shutdown(context.Context) error { return nil }
func (a Annotator) ForceFlush(context.Context) error { return nil } func (Annotator) ForceFlush(context.Context) error { return nil }
func (a Annotator) OnEnd(s ReadOnlySpan) { func (Annotator) OnEnd(s ReadOnlySpan) {
attr := s.Attributes()[0] attr := s.Attributes()[0]
fmt.Printf("%s: %s\n", attr.Key, attr.Value.AsString()) fmt.Printf("%s: %s\n", attr.Key, attr.Value.AsString())
} }

View File

@@ -161,7 +161,7 @@ func (ts *testSampler) ShouldSample(p SamplingParameters) SamplingResult {
} }
} }
func (ts testSampler) Description() string { func (testSampler) Description() string {
return "testSampler" return "testSampler"
} }
@@ -1799,7 +1799,7 @@ func (s *stateSampler) ShouldSample(p SamplingParameters) SamplingResult {
return SamplingResult{Decision: decision, Tracestate: ts} return SamplingResult{Decision: decision, Tracestate: ts}
} }
func (s stateSampler) Description() string { func (stateSampler) Description() string {
return "stateSampler" return "stateSampler"
} }
@@ -2641,7 +2641,7 @@ func RecordingOnly() Sampler {
type recordOnlySampler struct{} type recordOnlySampler struct{}
// ShouldSample implements Sampler interface. It always returns Record but not Sample. // 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) psc := trace.SpanContextFromContext(p.ParentContext)
return SamplingResult{ return SamplingResult{
Decision: RecordOnly, Decision: RecordOnly,

View File

@@ -25,10 +25,10 @@ func NewNoopExporter() *NoopExporter {
type NoopExporter struct{} type NoopExporter struct{}
// ExportSpans handles export of spans by dropping them. // 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. // 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) var _ trace.SpanExporter = (*InMemoryExporter)(nil)

View File

@@ -47,14 +47,14 @@ func (sr *SpanRecorder) OnEnd(s sdktrace.ReadOnlySpan) {
// Shutdown does nothing. // Shutdown does nothing.
// //
// This method is safe to be called concurrently. // This method is safe to be called concurrently.
func (sr *SpanRecorder) Shutdown(context.Context) error { func (*SpanRecorder) Shutdown(context.Context) error {
return nil return nil
} }
// ForceFlush does nothing. // ForceFlush does nothing.
// //
// This method is safe to be called concurrently. // This method is safe to be called concurrently.
func (sr *SpanRecorder) ForceFlush(context.Context) error { func (*SpanRecorder) ForceFlush(context.Context) error {
return nil return nil
} }

View File

@@ -298,7 +298,7 @@ func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue {
return c.header("http.response.header", h) 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 { key := func(k string) attribute.Key {
k = strings.ToLower(k) k = strings.ToLower(k)
k = strings.ReplaceAll(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 // ClientStatus returns a span status code and message for an HTTP status code
// value received by a client. // 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) stat, valid := validateHTTPStatusCode(code)
if !valid { if !valid {
return stat, fmt.Sprintf("Invalid HTTP status code %d", code) 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 // 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 // value returned by a server. Status codes in the 400-499 range are not
// returned as errors. // returned as errors.
func (c *HTTPConv) ServerStatus(code int) (codes.Code, string) { func (*HTTPConv) ServerStatus(code int) (codes.Code, string) {
stat, valid := validateHTTPStatusCode(code) stat, valid := validateHTTPStatusCode(code)
if !valid { if !valid {
return stat, fmt.Sprintf("Invalid HTTP status code %d", code) return stat, fmt.Sprintf("Invalid HTTP status code %d", code)

View File

@@ -298,7 +298,7 @@ func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue {
return c.header("http.response.header", h) 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 { key := func(k string) attribute.Key {
k = strings.ToLower(k) k = strings.ToLower(k)
k = strings.ReplaceAll(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 // ClientStatus returns a span status code and message for an HTTP status code
// value received by a client. // 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) stat, valid := validateHTTPStatusCode(code)
if !valid { if !valid {
return stat, fmt.Sprintf("Invalid HTTP status code %d", code) 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 // 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 // value returned by a server. Status codes in the 400-499 range are not
// returned as errors. // returned as errors.
func (c *HTTPConv) ServerStatus(code int) (codes.Code, string) { func (*HTTPConv) ServerStatus(code int) (codes.Code, string) {
stat, valid := validateHTTPStatusCode(code) stat, valid := validateHTTPStatusCode(code)
if !valid { if !valid {
return stat, fmt.Sprintf("Invalid HTTP status code %d", code) return stat, fmt.Sprintf("Invalid HTTP status code %d", code)

View File

@@ -299,7 +299,7 @@ func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue {
return c.header("http.response.header", h) 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 { key := func(k string) attribute.Key {
k = strings.ToLower(k) k = strings.ToLower(k)
k = strings.ReplaceAll(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 // ClientStatus returns a span status code and message for an HTTP status code
// value received by a client. // 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) stat, valid := validateHTTPStatusCode(code)
if !valid { if !valid {
return stat, fmt.Sprintf("Invalid HTTP status code %d", code) 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 // 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 // value returned by a server. Status codes in the 400-499 range are not
// returned as errors. // returned as errors.
func (c *HTTPConv) ServerStatus(code int) (codes.Code, string) { func (*HTTPConv) ServerStatus(code int) (codes.Code, string) {
stat, valid := validateHTTPStatusCode(code) stat, valid := validateHTTPStatusCode(code)
if !valid { if !valid {
return stat, fmt.Sprintf("Invalid HTTP status code %d", code) return stat, fmt.Sprintf("Invalid HTTP status code %d", code)

View File

@@ -39,7 +39,7 @@ type autoTracerProvider struct{ embedded.TracerProvider }
var _ TracerProvider = autoTracerProvider{} var _ TracerProvider = autoTracerProvider{}
func (p autoTracerProvider) Tracer(name string, opts ...TracerOption) Tracer { func (autoTracerProvider) Tracer(name string, opts ...TracerOption) Tracer {
cfg := NewTracerConfig(opts...) cfg := NewTracerConfig(opts...)
return autoTracer{ return autoTracer{
name: name, name: name,
@@ -81,7 +81,7 @@ func (t autoTracer) Start(ctx context.Context, name string, opts ...SpanStartOpt
// Expected to be implemented in eBPF. // Expected to be implemented in eBPF.
// //
//go:noinline //go:noinline
func (t *autoTracer) start( func (*autoTracer) start(
ctx context.Context, ctx context.Context,
spanPtr *autoSpan, spanPtr *autoSpan,
psc *SpanContext, psc *SpanContext,

View File

@@ -26,7 +26,7 @@ type noopTracerProvider struct{ embedded.TracerProvider }
var _ TracerProvider = noopTracerProvider{} var _ TracerProvider = noopTracerProvider{}
// Tracer returns noop implementation of Tracer. // Tracer returns noop implementation of Tracer.
func (p noopTracerProvider) Tracer(string, ...TracerOption) Tracer { func (noopTracerProvider) Tracer(string, ...TracerOption) Tracer {
return noopTracer{} 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 // Start carries forward a non-recording Span, if one is present in the context, otherwise it
// creates a no-op Span. // 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) span := SpanFromContext(ctx)
if _, ok := span.(nonRecordingSpan); !ok { if _, ok := span.(nonRecordingSpan); !ok {
// span is likely already a noopSpan, but let's be sure // span is likely already a noopSpan, but let's be sure

View File

@@ -51,7 +51,7 @@ type Tracer struct{ embedded.Tracer }
// If ctx contains a span context, the returned span will also contain that // 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 context. If the span context in ctx is for a non-recording span, that
// span instance will be returned directly. // 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) span := trace.SpanFromContext(ctx)
// If the parent context contains a non-zero span context, that span // If the parent context contains a non-zero span context, that span