diff --git a/cmd/rp-indexer/main.go b/cmd/rp-indexer/main.go index 89179f8..f019e82 100644 --- a/cmd/rp-indexer/main.go +++ b/cmd/rp-indexer/main.go @@ -44,9 +44,6 @@ func main() { logHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level}) slog.SetDefault(slog.New(logHandler)) - logger := slog.With("comp", "main") - logger.Info("starting indexer", "version", version, "released", date) - // if we have a DSN entry, try to initialize it if rt.Config.SentryDSN != "" { err := sentry.Init(sentry.ClientOptions{ @@ -60,7 +57,7 @@ func main() { defer sentry.Flush(2 * time.Second) - logger = slog.New( + logger := slog.New( slogmulti.Fanout( logHandler, slogsentry.Option{Level: slog.LevelError}.NewSentryHandler(), @@ -70,16 +67,17 @@ func main() { slog.SetDefault(logger) } + log := slog.With("comp", "main") + log.Info("starting indexer", "version", version, "released", date) + rt.DB, err = sql.Open("postgres", cfg.DB) if err != nil { - logger.Error("unable to connect to database") + log.Error("unable to connect to database", "error", err) } - if rt.Config.DeploymentID != "dev" { - rt.CW, err = cwatch.NewService(rt.Config.AWSAccessKeyID, rt.Config.AWSSecretAccessKey, rt.Config.AWSRegion, rt.Config.CloudwatchNamespace, rt.Config.DeploymentID) - if err != nil { - logger.Error("unable to create cloudwatch service") - } + rt.CW, err = cwatch.NewService(rt.Config.AWSAccessKeyID, rt.Config.AWSSecretAccessKey, rt.Config.AWSRegion, rt.Config.CloudwatchNamespace, rt.Config.DeploymentID) + if err != nil { + log.Error("unable to create cloudwatch service", "error", err) } idxrs := []indexers.Indexer{ @@ -91,7 +89,7 @@ func main() { // the rebuild argument can be become the name of the index to rebuild, e.g. --rebuild=contacts idxr := idxrs[0] if _, err := idxr.Index(rt, true, rt.Config.Cleanup); err != nil { - logger.Error("error during rebuilding", "error", err, "indexer", idxr.Name()) + log.Error("error during rebuilding", "error", err, "indexer", idxr.Name()) } } else { d := indexer.NewDaemon(rt, idxrs) diff --git a/daemon.go b/daemon.go index 51eadc6..e7dafff 100644 --- a/daemon.go +++ b/daemon.go @@ -38,13 +38,6 @@ func NewDaemon(rt *runtime.Runtime, ixs []indexers.Indexer) *Daemon { // Start starts this daemon func (d *Daemon) Start() { - // if we have a librato token, configure it - if d.rt.Config.LibratoToken != "" { - analytics.RegisterBackend(analytics.NewLibrato(d.rt.Config.LibratoUsername, d.rt.Config.LibratoToken, d.rt.Config.InstanceName, time.Second, d.wg)) - } - - analytics.Start() - for _, i := range d.indexers { d.startIndexer(i) } diff --git a/go.mod b/go.mod index fe9519c..70b3672 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/getsentry/sentry-go v0.30.0 github.com/lib/pq v1.10.9 github.com/nyaruka/ezconf v0.3.0 - github.com/nyaruka/gocommon v1.60.1 + github.com/nyaruka/gocommon v1.60.2 github.com/samber/slog-multi v1.2.4 github.com/samber/slog-sentry v1.2.2 github.com/stretchr/testify v1.10.0 diff --git a/go.sum b/go.sum index ed50210..f76545e 100644 --- a/go.sum +++ b/go.sum @@ -59,8 +59,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8= github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/nyaruka/ezconf v0.3.0 h1:kGvJqVN8AHowb4HdaHAviJ0Z3yI5Pyekp1WqibFEaGk= github.com/nyaruka/ezconf v0.3.0/go.mod h1:89GUW6EPRNLIxT7lC4LWnjWTgZeQwRoX7lBmc8ralAU= -github.com/nyaruka/gocommon v1.60.1 h1:m/BXoBQ1KVzbpmTJ5vuQrv084mWyQ6gtuX6cOeva+lM= -github.com/nyaruka/gocommon v1.60.1/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0= +github.com/nyaruka/gocommon v1.60.2 h1:AvvSSAV70SV49ocNtvjpdb9NlcdiA2OQAL4NYVUcuV0= +github.com/nyaruka/gocommon v1.60.2/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0= github.com/nyaruka/librato v1.1.1 h1:0nTYtJLl3Sn7lX3CuHsLf+nXy1k/tGV0OjVxLy3Et4s= github.com/nyaruka/librato v1.1.1/go.mod h1:fme1Fu1PT2qvkaBZyw8WW+SrnFe2qeeCWpvqmAaKAKE= github.com/nyaruka/null/v2 v2.0.3 h1:rdmMRQyVzrOF3Jff/gpU/7BDR9mQX0lcLl4yImsA3kw= diff --git a/runtime/config.go b/runtime/config.go index 056b618..05a591e 100644 --- a/runtime/config.go +++ b/runtime/config.go @@ -1,7 +1,5 @@ package runtime -import "os" - type Config struct { ElasticURL string `help:"the url for our elastic search instance"` DB string `help:"the connection string for our database"` @@ -18,18 +16,12 @@ type Config struct { CloudwatchNamespace string `help:"the namespace to use for cloudwatch metrics"` DeploymentID string `help:"the deployment identifier to use for metrics"` - LibratoUsername string `help:"the username that will be used to authenticate to Librato"` - LibratoToken string `help:"the token that will be used to authenticate to Librato"` - InstanceName string `help:"the unique name of this instance used for analytics"` - ContactsIndex string `help:"the alias to use for the contact index"` ContactsShards int `help:"the number of shards to use for the contacts index"` ContactsReplicas int `help:"the number of replicas to use for the contacts index"` } func NewDefaultConfig() *Config { - hostname, _ := os.Hostname() - return &Config{ ElasticURL: "http://localhost:9200", DB: "postgres://localhost/temba?sslmode=disable", @@ -45,8 +37,6 @@ func NewDefaultConfig() *Config { CloudwatchNamespace: "Temba", DeploymentID: "dev", - InstanceName: hostname, - ContactsIndex: "contacts", ContactsShards: 2, ContactsReplicas: 1,