mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-26 21:05:00 +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
|
||||
- tenv
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
|
||||
issues:
|
||||
|
@ -233,7 +233,7 @@ func convertKV(key string, value any) attribute.KeyValue {
|
||||
case uintptr:
|
||||
return uint64KV(key, uint64(typedVal))
|
||||
case uint64:
|
||||
return uint64KV(key, uint64(typedVal))
|
||||
return uint64KV(key, typedVal)
|
||||
case float32:
|
||||
return attribute.Float64(key, float64(typedVal))
|
||||
case float64:
|
||||
|
@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
|
||||
{
|
||||
name: "Test With Timeout",
|
||||
opts: []GenericOption{
|
||||
WithTimeout(time.Duration(5 * time.Second)),
|
||||
WithTimeout(5 * time.Second),
|
||||
},
|
||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
||||
|
@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
|
||||
out := &mpb.Metric{
|
||||
Name: m.Name,
|
||||
Description: m.Description,
|
||||
Unit: string(m.Unit),
|
||||
Unit: m.Unit,
|
||||
}
|
||||
switch a := m.Data.(type) {
|
||||
case metricdata.Gauge[int64]:
|
||||
|
@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
|
||||
{
|
||||
name: "Test With Timeout",
|
||||
opts: []GenericOption{
|
||||
WithTimeout(time.Duration(5 * time.Second)),
|
||||
WithTimeout(5 * time.Second),
|
||||
},
|
||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
||||
|
@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
|
||||
out := &mpb.Metric{
|
||||
Name: m.Name,
|
||||
Description: m.Description,
|
||||
Unit: string(m.Unit),
|
||||
Unit: m.Unit,
|
||||
}
|
||||
switch a := m.Data.(type) {
|
||||
case metricdata.Gauge[int64]:
|
||||
|
@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
|
||||
{
|
||||
name: "Test With Timeout",
|
||||
opts: []GenericOption{
|
||||
WithTimeout(time.Duration(5 * time.Second)),
|
||||
WithTimeout(5 * time.Second),
|
||||
},
|
||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
||||
|
@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
|
||||
{
|
||||
name: "Test With Timeout",
|
||||
opts: []GenericOption{
|
||||
WithTimeout(time.Duration(5 * time.Second)),
|
||||
WithTimeout(5 * time.Second),
|
||||
},
|
||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
|
||||
|
@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
|
||||
{
|
||||
name: "Test With Timeout",
|
||||
opts: []GenericOption{
|
||||
WithTimeout(time.Duration(5 * time.Second)),
|
||||
WithTimeout(5 * time.Second),
|
||||
},
|
||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
|
||||
|
@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
|
||||
out := &mpb.Metric{
|
||||
Name: m.Name,
|
||||
Description: m.Description,
|
||||
Unit: string(m.Unit),
|
||||
Unit: m.Unit,
|
||||
}
|
||||
switch a := m.Data.(type) {
|
||||
case metricdata.Gauge[int64]:
|
||||
|
@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
|
||||
{
|
||||
name: "Test With Timeout",
|
||||
opts: []GenericOption{
|
||||
WithTimeout(time.Duration(5 * time.Second)),
|
||||
WithTimeout(5 * time.Second),
|
||||
},
|
||||
asserts: func(t *testing.T, c *Config, grpcOption bool) {
|
||||
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{
|
||||
Time: staticTime,
|
||||
Value: NewValue(N(10)),
|
||||
SpanID: []byte(sID[:]),
|
||||
TraceID: []byte(tID[:]),
|
||||
SpanID: sID[:],
|
||||
TraceID: tID[:],
|
||||
}
|
||||
require.Len(t, dest, 1, "number of collected exemplars")
|
||||
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 = append(attrs, c.HostName(h))
|
||||
if p > 0 {
|
||||
attrs = append(attrs, c.HostPort(int(p)))
|
||||
attrs = append(attrs, c.HostPort(p))
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
attrs = append(attrs, c.PeerName(h))
|
||||
if p > 0 {
|
||||
attrs = append(attrs, c.PeerPort(int(p)))
|
||||
attrs = append(attrs, c.PeerPort(p))
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
attrs = append(attrs, c.HostName(h))
|
||||
if p > 0 {
|
||||
attrs = append(attrs, c.HostPort(int(p)))
|
||||
attrs = append(attrs, c.HostPort(p))
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
attrs = append(attrs, c.PeerName(h))
|
||||
if p > 0 {
|
||||
attrs = append(attrs, c.PeerPort(int(p)))
|
||||
attrs = append(attrs, c.PeerPort(p))
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
attrs = append(attrs, c.HostName(h))
|
||||
if p > 0 {
|
||||
attrs = append(attrs, c.HostPort(int(p)))
|
||||
attrs = append(attrs, c.HostPort(p))
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
attrs = append(attrs, c.PeerName(h))
|
||||
if p > 0 {
|
||||
attrs = append(attrs, c.PeerPort(int(p)))
|
||||
attrs = append(attrs, c.PeerPort(p))
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user