You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-08-10 22:31:50 +02:00
chore: enable ptrToRefParam from go-critic (#7131)
#### Description Enable and fixes [ptrToRefParam](https://go-critic.com/overview.html#ptrtorefparam) rule from go-critic Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
@@ -94,7 +94,6 @@ linters:
|
||||
- dupArg
|
||||
- hugeParam
|
||||
- importShadow
|
||||
- ptrToRefParam
|
||||
- preferDecodeRune
|
||||
- rangeValCopy
|
||||
- unnamedResult
|
||||
|
@@ -214,15 +214,15 @@ func (t *textMapCarrier) Keys() []string {
|
||||
|
||||
// testTextMapReader only implemented opentracing.TextMapReader interface.
|
||||
type testTextMapReader struct {
|
||||
m *map[string]string
|
||||
m map[string]string
|
||||
}
|
||||
|
||||
func newTestTextMapReader(m *map[string]string) *testTextMapReader {
|
||||
func newTestTextMapReader(m map[string]string) *testTextMapReader {
|
||||
return &testTextMapReader{m: m}
|
||||
}
|
||||
|
||||
func (t *testTextMapReader) ForeachKey(handler func(key, val string) error) error {
|
||||
for key, val := range *t.m {
|
||||
for key, val := range t.m {
|
||||
if err := handler(key, val); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -233,15 +233,15 @@ func (t *testTextMapReader) ForeachKey(handler func(key, val string) error) erro
|
||||
|
||||
// testTextMapWriter only implemented opentracing.TextMapWriter interface.
|
||||
type testTextMapWriter struct {
|
||||
m *map[string]string
|
||||
m map[string]string
|
||||
}
|
||||
|
||||
func newTestTextMapWriter(m *map[string]string) *testTextMapWriter {
|
||||
func newTestTextMapWriter(m map[string]string) *testTextMapWriter {
|
||||
return &testTextMapWriter{m: m}
|
||||
}
|
||||
|
||||
func (t *testTextMapWriter) Set(key, val string) {
|
||||
(*t.m)[key] = val
|
||||
t.m[key] = val
|
||||
}
|
||||
|
||||
type samplable interface {
|
||||
@@ -290,9 +290,9 @@ func TestBridgeTracer_ExtractAndInject(t *testing.T) {
|
||||
{
|
||||
name: "support for opentracing.TextMapReader and opentracing.TextMapWriter,non-same instance",
|
||||
injectCarrierType: ot.TextMap,
|
||||
injectCarrier: newTestTextMapWriter(&shareMap),
|
||||
injectCarrier: newTestTextMapWriter(shareMap),
|
||||
extractCarrierType: ot.TextMap,
|
||||
extractCarrier: newTestTextMapReader(&shareMap),
|
||||
extractCarrier: newTestTextMapReader(shareMap),
|
||||
},
|
||||
{
|
||||
name: "inject: format type is HTTPHeaders, but carrier is not HTTPHeadersCarrier",
|
||||
|
@@ -350,7 +350,9 @@ func (e *expoHistogram[N]) measure(
|
||||
v.res.Offer(ctx, value, droppedAttr)
|
||||
}
|
||||
|
||||
func (e *expoHistogram[N]) delta(dest *metricdata.Aggregation) int {
|
||||
func (e *expoHistogram[N]) delta(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
|
||||
// If *dest is not a metricdata.ExponentialHistogram, memory reuse is missed.
|
||||
@@ -411,7 +413,9 @@ func (e *expoHistogram[N]) delta(dest *metricdata.Aggregation) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func (e *expoHistogram[N]) cumulative(dest *metricdata.Aggregation) int {
|
||||
func (e *expoHistogram[N]) cumulative(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
|
||||
// If *dest is not a metricdata.ExponentialHistogram, memory reuse is missed.
|
||||
|
@@ -140,7 +140,9 @@ type histogram[N int64 | float64] struct {
|
||||
start time.Time
|
||||
}
|
||||
|
||||
func (s *histogram[N]) delta(dest *metricdata.Aggregation) int {
|
||||
func (s *histogram[N]) delta(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
|
||||
// If *dest is not a metricdata.Histogram, memory reuse is missed. In that
|
||||
@@ -190,7 +192,9 @@ func (s *histogram[N]) delta(dest *metricdata.Aggregation) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *histogram[N]) cumulative(dest *metricdata.Aggregation) int {
|
||||
func (s *histogram[N]) cumulative(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
|
||||
// If *dest is not a metricdata.Histogram, memory reuse is missed. In that
|
||||
|
@@ -55,7 +55,9 @@ func (s *lastValue[N]) measure(ctx context.Context, value N, fltrAttr attribute.
|
||||
s.values[attr.Equivalent()] = d
|
||||
}
|
||||
|
||||
func (s *lastValue[N]) delta(dest *metricdata.Aggregation) int {
|
||||
func (s *lastValue[N]) delta(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||
// the DataPoints is missed (better luck next time).
|
||||
@@ -75,7 +77,9 @@ func (s *lastValue[N]) delta(dest *metricdata.Aggregation) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *lastValue[N]) cumulative(dest *metricdata.Aggregation) int {
|
||||
func (s *lastValue[N]) cumulative(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||
// the DataPoints is missed (better luck next time).
|
||||
@@ -126,7 +130,9 @@ type precomputedLastValue[N int64 | float64] struct {
|
||||
*lastValue[N]
|
||||
}
|
||||
|
||||
func (s *precomputedLastValue[N]) delta(dest *metricdata.Aggregation) int {
|
||||
func (s *precomputedLastValue[N]) delta(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||
// the DataPoints is missed (better luck next time).
|
||||
@@ -146,7 +152,9 @@ func (s *precomputedLastValue[N]) delta(dest *metricdata.Aggregation) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *precomputedLastValue[N]) cumulative(dest *metricdata.Aggregation) int {
|
||||
func (s *precomputedLastValue[N]) cumulative(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||
// the DataPoints is missed (better luck next time).
|
||||
|
@@ -70,7 +70,9 @@ type sum[N int64 | float64] struct {
|
||||
start time.Time
|
||||
}
|
||||
|
||||
func (s *sum[N]) delta(dest *metricdata.Aggregation) int {
|
||||
func (s *sum[N]) delta(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
|
||||
// If *dest is not a metricdata.Sum, memory reuse is missed. In that case,
|
||||
@@ -105,7 +107,9 @@ func (s *sum[N]) delta(dest *metricdata.Aggregation) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *sum[N]) cumulative(dest *metricdata.Aggregation) int {
|
||||
func (s *sum[N]) cumulative(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
|
||||
// If *dest is not a metricdata.Sum, memory reuse is missed. In that case,
|
||||
@@ -165,7 +169,9 @@ type precomputedSum[N int64 | float64] struct {
|
||||
reported map[attribute.Distinct]N
|
||||
}
|
||||
|
||||
func (s *precomputedSum[N]) delta(dest *metricdata.Aggregation) int {
|
||||
func (s *precomputedSum[N]) delta(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
newReported := make(map[attribute.Distinct]N)
|
||||
|
||||
@@ -206,7 +212,9 @@ func (s *precomputedSum[N]) delta(dest *metricdata.Aggregation) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *precomputedSum[N]) cumulative(dest *metricdata.Aggregation) int {
|
||||
func (s *precomputedSum[N]) cumulative(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
t := now()
|
||||
|
||||
// If *dest is not a metricdata.Sum, memory reuse is missed. In that case,
|
||||
|
@@ -32,7 +32,9 @@ import (
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
func testSumAggregateOutput(dest *metricdata.Aggregation) int {
|
||||
func testSumAggregateOutput(
|
||||
dest *metricdata.Aggregation, //nolint:gocritic // The pointer is needed for the ComputeAggregation interface
|
||||
) int {
|
||||
*dest = metricdata.Sum[int64]{
|
||||
Temporality: metricdata.CumulativeTemporality,
|
||||
IsMonotonic: false,
|
||||
|
Reference in New Issue
Block a user