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
|
- dupArg
|
||||||
- hugeParam
|
- hugeParam
|
||||||
- importShadow
|
- importShadow
|
||||||
- ptrToRefParam
|
|
||||||
- preferDecodeRune
|
- preferDecodeRune
|
||||||
- rangeValCopy
|
- rangeValCopy
|
||||||
- unnamedResult
|
- unnamedResult
|
||||||
|
@@ -214,15 +214,15 @@ func (t *textMapCarrier) Keys() []string {
|
|||||||
|
|
||||||
// testTextMapReader only implemented opentracing.TextMapReader interface.
|
// testTextMapReader only implemented opentracing.TextMapReader interface.
|
||||||
type testTextMapReader struct {
|
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}
|
return &testTextMapReader{m: m}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testTextMapReader) ForeachKey(handler func(key, val string) error) error {
|
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 {
|
if err := handler(key, val); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -233,15 +233,15 @@ func (t *testTextMapReader) ForeachKey(handler func(key, val string) error) erro
|
|||||||
|
|
||||||
// testTextMapWriter only implemented opentracing.TextMapWriter interface.
|
// testTextMapWriter only implemented opentracing.TextMapWriter interface.
|
||||||
type testTextMapWriter struct {
|
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}
|
return &testTextMapWriter{m: m}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testTextMapWriter) Set(key, val string) {
|
func (t *testTextMapWriter) Set(key, val string) {
|
||||||
(*t.m)[key] = val
|
t.m[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
type samplable interface {
|
type samplable interface {
|
||||||
@@ -290,9 +290,9 @@ func TestBridgeTracer_ExtractAndInject(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "support for opentracing.TextMapReader and opentracing.TextMapWriter,non-same instance",
|
name: "support for opentracing.TextMapReader and opentracing.TextMapWriter,non-same instance",
|
||||||
injectCarrierType: ot.TextMap,
|
injectCarrierType: ot.TextMap,
|
||||||
injectCarrier: newTestTextMapWriter(&shareMap),
|
injectCarrier: newTestTextMapWriter(shareMap),
|
||||||
extractCarrierType: ot.TextMap,
|
extractCarrierType: ot.TextMap,
|
||||||
extractCarrier: newTestTextMapReader(&shareMap),
|
extractCarrier: newTestTextMapReader(shareMap),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "inject: format type is HTTPHeaders, but carrier is not HTTPHeadersCarrier",
|
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)
|
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()
|
t := now()
|
||||||
|
|
||||||
// If *dest is not a metricdata.ExponentialHistogram, memory reuse is missed.
|
// 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
|
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()
|
t := now()
|
||||||
|
|
||||||
// If *dest is not a metricdata.ExponentialHistogram, memory reuse is missed.
|
// If *dest is not a metricdata.ExponentialHistogram, memory reuse is missed.
|
||||||
|
@@ -140,7 +140,9 @@ type histogram[N int64 | float64] struct {
|
|||||||
start time.Time
|
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()
|
t := now()
|
||||||
|
|
||||||
// If *dest is not a metricdata.Histogram, memory reuse is missed. In that
|
// 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
|
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()
|
t := now()
|
||||||
|
|
||||||
// If *dest is not a metricdata.Histogram, memory reuse is missed. In that
|
// 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
|
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()
|
t := now()
|
||||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||||
// the DataPoints is missed (better luck next time).
|
// the DataPoints is missed (better luck next time).
|
||||||
@@ -75,7 +77,9 @@ func (s *lastValue[N]) delta(dest *metricdata.Aggregation) int {
|
|||||||
return n
|
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()
|
t := now()
|
||||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||||
// the DataPoints is missed (better luck next time).
|
// the DataPoints is missed (better luck next time).
|
||||||
@@ -126,7 +130,9 @@ type precomputedLastValue[N int64 | float64] struct {
|
|||||||
*lastValue[N]
|
*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()
|
t := now()
|
||||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||||
// the DataPoints is missed (better luck next time).
|
// the DataPoints is missed (better luck next time).
|
||||||
@@ -146,7 +152,9 @@ func (s *precomputedLastValue[N]) delta(dest *metricdata.Aggregation) int {
|
|||||||
return n
|
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()
|
t := now()
|
||||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
// Ignore if dest is not a metricdata.Gauge. The chance for memory reuse of
|
||||||
// the DataPoints is missed (better luck next time).
|
// the DataPoints is missed (better luck next time).
|
||||||
|
@@ -70,7 +70,9 @@ type sum[N int64 | float64] struct {
|
|||||||
start time.Time
|
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()
|
t := now()
|
||||||
|
|
||||||
// If *dest is not a metricdata.Sum, memory reuse is missed. In that case,
|
// 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
|
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()
|
t := now()
|
||||||
|
|
||||||
// If *dest is not a metricdata.Sum, memory reuse is missed. In that case,
|
// 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
|
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()
|
t := now()
|
||||||
newReported := make(map[attribute.Distinct]N)
|
newReported := make(map[attribute.Distinct]N)
|
||||||
|
|
||||||
@@ -206,7 +212,9 @@ func (s *precomputedSum[N]) delta(dest *metricdata.Aggregation) int {
|
|||||||
return n
|
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()
|
t := now()
|
||||||
|
|
||||||
// If *dest is not a metricdata.Sum, memory reuse is missed. In that case,
|
// If *dest is not a metricdata.Sum, memory reuse is missed. In that case,
|
||||||
|
@@ -32,7 +32,9 @@ import (
|
|||||||
"go.opentelemetry.io/otel/trace"
|
"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]{
|
*dest = metricdata.Sum[int64]{
|
||||||
Temporality: metricdata.CumulativeTemporality,
|
Temporality: metricdata.CumulativeTemporality,
|
||||||
IsMonotonic: false,
|
IsMonotonic: false,
|
||||||
|
Reference in New Issue
Block a user