mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 19:04:02 +03:00
Remove juju/errors
This commit is contained in:
+4
-5
@@ -2,11 +2,10 @@ package stats
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/juju/errors"
|
||||
|
||||
"github.com/9seconds/mtg/config"
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
)
|
||||
@@ -66,21 +65,21 @@ func Init(ctx context.Context) error {
|
||||
instanceJSON := newStatsJSON(mux)
|
||||
instancePrometheus, err := newStatsPrometheus(mux)
|
||||
if err != nil {
|
||||
return errors.Annotate(err, "Cannot initialize Prometheus")
|
||||
return fmt.Errorf("cannot initialize prometheus: %w", err)
|
||||
}
|
||||
|
||||
stats := []Stats{instanceJSON, instancePrometheus}
|
||||
if config.C.StatsdStats.Addr.IP != nil {
|
||||
instanceStatsd, err := newStatsStatsd()
|
||||
if err != nil {
|
||||
return errors.Annotate(err, "Cannot initialize StatsD")
|
||||
return fmt.Errorf("cannot inialize statsd: %w", err)
|
||||
}
|
||||
stats = append(stats, instanceStatsd)
|
||||
}
|
||||
|
||||
listener, err := net.Listen("tcp", config.C.StatsAddr.String())
|
||||
if err != nil {
|
||||
return errors.Annotate(err, "Cannot initialize stats server")
|
||||
return fmt.Errorf("cannot initialize stats server: %w", err)
|
||||
}
|
||||
|
||||
srv := http.Server{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
@@ -91,16 +91,16 @@ func newStatsPrometheus(mux *http.ServeMux) (Stats, error) {
|
||||
}
|
||||
|
||||
if err := registry.Register(instance.connections); err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot register metrics for connections")
|
||||
return nil, fmt.Errorf("cannot register metrics for connections: %w", err)
|
||||
}
|
||||
if err := registry.Register(instance.traffic); err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot register metrics for traffic")
|
||||
return nil, fmt.Errorf("cannot register metrics for traffic: %w", err)
|
||||
}
|
||||
if err := registry.Register(instance.crashes); err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot register metrics for crashes")
|
||||
return nil, fmt.Errorf("cannot register metrics for crashes: %w", err)
|
||||
}
|
||||
if err := registry.Register(instance.antiReplays); err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot register metrics for anti replays")
|
||||
return nil, fmt.Errorf("cannot register metrics for anti replays: %w", err)
|
||||
}
|
||||
|
||||
handler := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"gopkg.in/alexcesaro/statsd.v2"
|
||||
|
||||
"github.com/9seconds/mtg/config"
|
||||
@@ -78,7 +78,7 @@ func newStatsStatsd() (Stats, error) {
|
||||
|
||||
client, err := statsd.New(options...)
|
||||
if err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot initialize a client")
|
||||
return nil, fmt.Errorf("cannot initialize a client: %w", err)
|
||||
}
|
||||
|
||||
return &statsStatsd{
|
||||
|
||||
Reference in New Issue
Block a user