mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-15 11:36:44 +02:00
Add unconvert linter (#5529)
This adds the unconvert linter, and fixes every new issue related to it. Co-authored-by: Sam Xie <sam@samxie.me> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
4a509d24e2
commit
3e91436a3b
@ -23,6 +23,7 @@ linters:
|
|||||||
- staticcheck
|
- staticcheck
|
||||||
- tenv
|
- tenv
|
||||||
- typecheck
|
- typecheck
|
||||||
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
|
@ -233,7 +233,7 @@ func convertKV(key string, value any) attribute.KeyValue {
|
|||||||
case uintptr:
|
case uintptr:
|
||||||
return uint64KV(key, uint64(typedVal))
|
return uint64KV(key, uint64(typedVal))
|
||||||
case uint64:
|
case uint64:
|
||||||
return uint64KV(key, uint64(typedVal))
|
return uint64KV(key, typedVal)
|
||||||
case float32:
|
case float32:
|
||||||
return attribute.Float64(key, float64(typedVal))
|
return attribute.Float64(key, float64(typedVal))
|
||||||
case float64:
|
case float64:
|
||||||
|
@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test With Timeout",
|
name: "Test With Timeout",
|
||||||
opts: []GenericOption{
|
opts: []GenericOption{
|
||||||
WithTimeout(time.Duration(5 * time.Second)),
|
WithTimeout(5 * time.Second),
|
||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
||||||
|
@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
|
|||||||
out := &mpb.Metric{
|
out := &mpb.Metric{
|
||||||
Name: m.Name,
|
Name: m.Name,
|
||||||
Description: m.Description,
|
Description: m.Description,
|
||||||
Unit: string(m.Unit),
|
Unit: m.Unit,
|
||||||
}
|
}
|
||||||
switch a := m.Data.(type) {
|
switch a := m.Data.(type) {
|
||||||
case metricdata.Gauge[int64]:
|
case metricdata.Gauge[int64]:
|
||||||
|
@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test With Timeout",
|
name: "Test With Timeout",
|
||||||
opts: []GenericOption{
|
opts: []GenericOption{
|
||||||
WithTimeout(time.Duration(5 * time.Second)),
|
WithTimeout(5 * time.Second),
|
||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
||||||
|
@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
|
|||||||
out := &mpb.Metric{
|
out := &mpb.Metric{
|
||||||
Name: m.Name,
|
Name: m.Name,
|
||||||
Description: m.Description,
|
Description: m.Description,
|
||||||
Unit: string(m.Unit),
|
Unit: m.Unit,
|
||||||
}
|
}
|
||||||
switch a := m.Data.(type) {
|
switch a := m.Data.(type) {
|
||||||
case metricdata.Gauge[int64]:
|
case metricdata.Gauge[int64]:
|
||||||
|
@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test With Timeout",
|
name: "Test With Timeout",
|
||||||
opts: []GenericOption{
|
opts: []GenericOption{
|
||||||
WithTimeout(time.Duration(5 * time.Second)),
|
WithTimeout(5 * time.Second),
|
||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
||||||
|
@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test With Timeout",
|
name: "Test With Timeout",
|
||||||
opts: []GenericOption{
|
opts: []GenericOption{
|
||||||
WithTimeout(time.Duration(5 * time.Second)),
|
WithTimeout(5 * time.Second),
|
||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
||||||
|
@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test With Timeout",
|
name: "Test With Timeout",
|
||||||
opts: []GenericOption{
|
opts: []GenericOption{
|
||||||
WithTimeout(time.Duration(5 * time.Second)),
|
WithTimeout(5 * time.Second),
|
||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
||||||
|
@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
|
|||||||
out := &mpb.Metric{
|
out := &mpb.Metric{
|
||||||
Name: m.Name,
|
Name: m.Name,
|
||||||
Description: m.Description,
|
Description: m.Description,
|
||||||
Unit: string(m.Unit),
|
Unit: m.Unit,
|
||||||
}
|
}
|
||||||
switch a := m.Data.(type) {
|
switch a := m.Data.(type) {
|
||||||
case metricdata.Gauge[int64]:
|
case metricdata.Gauge[int64]:
|
||||||
|
@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test With Timeout",
|
name: "Test With Timeout",
|
||||||
opts: []GenericOption{
|
opts: []GenericOption{
|
||||||
WithTimeout(time.Duration(5 * time.Second)),
|
WithTimeout(5 * time.Second),
|
||||||
},
|
},
|
||||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||||
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
||||||
|
@ -50,8 +50,8 @@ func ReservoirTest[N int64 | float64](f factory) func(*testing.T) {
|
|||||||
want := Exemplar{
|
want := Exemplar{
|
||||||
Time: staticTime,
|
Time: staticTime,
|
||||||
Value: NewValue(N(10)),
|
Value: NewValue(N(10)),
|
||||||
SpanID: []byte(sID[:]),
|
SpanID: sID[:],
|
||||||
TraceID: []byte(tID[:]),
|
TraceID: tID[:],
|
||||||
}
|
}
|
||||||
require.Len(t, dest, 1, "number of collected exemplars")
|
require.Len(t, dest, 1, "number of collected exemplars")
|
||||||
assert.Equal(t, want, dest[0])
|
assert.Equal(t, want, dest[0])
|
||||||
|
@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
|
|||||||
attrs := make([]attribute.KeyValue, 0, n)
|
attrs := make([]attribute.KeyValue, 0, n)
|
||||||
attrs = append(attrs, c.HostName(h))
|
attrs = append(attrs, c.HostName(h))
|
||||||
if p > 0 {
|
if p > 0 {
|
||||||
attrs = append(attrs, c.HostPort(int(p)))
|
attrs = append(attrs, c.HostPort(p))
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
|
|||||||
attrs := make([]attribute.KeyValue, 0, n)
|
attrs := make([]attribute.KeyValue, 0, n)
|
||||||
attrs = append(attrs, c.PeerName(h))
|
attrs = append(attrs, c.PeerName(h))
|
||||||
if p > 0 {
|
if p > 0 {
|
||||||
attrs = append(attrs, c.PeerPort(int(p)))
|
attrs = append(attrs, c.PeerPort(p))
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
|
|||||||
attrs := make([]attribute.KeyValue, 0, n)
|
attrs := make([]attribute.KeyValue, 0, n)
|
||||||
attrs = append(attrs, c.HostName(h))
|
attrs = append(attrs, c.HostName(h))
|
||||||
if p > 0 {
|
if p > 0 {
|
||||||
attrs = append(attrs, c.HostPort(int(p)))
|
attrs = append(attrs, c.HostPort(p))
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
|
|||||||
attrs := make([]attribute.KeyValue, 0, n)
|
attrs := make([]attribute.KeyValue, 0, n)
|
||||||
attrs = append(attrs, c.PeerName(h))
|
attrs = append(attrs, c.PeerName(h))
|
||||||
if p > 0 {
|
if p > 0 {
|
||||||
attrs = append(attrs, c.PeerPort(int(p)))
|
attrs = append(attrs, c.PeerPort(p))
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
|
|||||||
attrs := make([]attribute.KeyValue, 0, n)
|
attrs := make([]attribute.KeyValue, 0, n)
|
||||||
attrs = append(attrs, c.HostName(h))
|
attrs = append(attrs, c.HostName(h))
|
||||||
if p > 0 {
|
if p > 0 {
|
||||||
attrs = append(attrs, c.HostPort(int(p)))
|
attrs = append(attrs, c.HostPort(p))
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
|
|||||||
attrs := make([]attribute.KeyValue, 0, n)
|
attrs := make([]attribute.KeyValue, 0, n)
|
||||||
attrs = append(attrs, c.PeerName(h))
|
attrs = append(attrs, c.PeerName(h))
|
||||||
if p > 0 {
|
if p > 0 {
|
||||||
attrs = append(attrs, c.PeerPort(int(p)))
|
attrs = append(attrs, c.PeerPort(p))
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user