mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
chore: use errors.New() instead of fmt.Errorf()
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ func TestTombTracking(t *testing.T) {
|
|||||||
case <-tomb.Dying():
|
case <-tomb.Dying():
|
||||||
t.Fatalf("Dying() should not happen inside the tomb")
|
t.Fatalf("Dying() should not happen inside the tomb")
|
||||||
case <-ch:
|
case <-ch:
|
||||||
return fmt.Errorf("crashing")
|
return errors.New("crashing")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package clickhouse
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -66,7 +67,7 @@ func (c *Component) migrateDatabase() error {
|
|||||||
return fmt.Errorf("unable to parse cluster settings: %w", err)
|
return fmt.Errorf("unable to parse cluster settings: %w", err)
|
||||||
}
|
}
|
||||||
if shardNum == 0 {
|
if shardNum == 0 {
|
||||||
return fmt.Errorf("cannot get the number of shards for the cluster")
|
return errors.New("cannot get the number of shards for the cluster")
|
||||||
}
|
}
|
||||||
c.shards = int(shardNum)
|
c.shards = int(shardNum)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package clickhouse
|
package clickhouse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -84,7 +85,7 @@ func New(r *reporter.Reporter, configuration Configuration, dependencies Depende
|
|||||||
return c.config.Resolutions[i].Interval < c.config.Resolutions[j].Interval
|
return c.config.Resolutions[i].Interval < c.config.Resolutions[j].Interval
|
||||||
})
|
})
|
||||||
if len(c.config.Resolutions) == 0 || c.config.Resolutions[0].Interval != 0 {
|
if len(c.config.Resolutions) == 0 || c.config.Resolutions[0].Interval != 0 {
|
||||||
return nil, fmt.Errorf("resolutions need to be configured, including interval: 0")
|
return nil, errors.New("resolutions need to be configured, including interval: 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
c.d.Daemon.Track(&c.t, "orchestrator/clickhouse")
|
c.d.Daemon.Track(&c.t, "orchestrator/clickhouse")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package gnmi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
@@ -333,5 +334,5 @@ func (p *Provider) detectModelAndEncoding(ctx context.Context, tg *target.Target
|
|||||||
return model, encoding, nil
|
return model, encoding, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Model{}, "", fmt.Errorf("no compatible model found")
|
return Model{}, "", errors.New("no compatible model found")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func (p *Provider) Poll(ctx context.Context, exporter, agent netip.Addr, port ui
|
|||||||
results = slices.Clone(currentResult.Variables)
|
results = slices.Clone(currentResult.Variables)
|
||||||
} else {
|
} else {
|
||||||
if len(results) != len(currentResult.Variables) {
|
if len(results) != len(currentResult.Variables) {
|
||||||
logError(fmt.Errorf("SNMP mismatch on variable lengths"))
|
logError(errors.New("SNMP mismatch on variable lengths"))
|
||||||
}
|
}
|
||||||
for idx := range results {
|
for idx := range results {
|
||||||
switch results[idx].Type {
|
switch results[idx].Type {
|
||||||
@@ -128,7 +128,7 @@ func (p *Provider) Poll(ctx context.Context, exporter, agent netip.Addr, port ui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(results) != len(requests) {
|
if len(results) != len(requests) {
|
||||||
logError(fmt.Errorf("SNMP mismatch on variable lengths"))
|
logError(errors.New("SNMP mismatch on variable lengths"))
|
||||||
}
|
}
|
||||||
p.metrics.times.WithLabelValues(exporterStr).Observe(time.Since(start).Seconds())
|
p.metrics.times.WithLabelValues(exporterStr).Observe(time.Since(start).Seconds())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user