Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove librato, use latest gocommon #89

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions cmd/rp-indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
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{
Expand All @@ -60,7 +57,7 @@

defer sentry.Flush(2 * time.Second)

logger = slog.New(
logger := slog.New(

Check warning on line 60 in cmd/rp-indexer/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-indexer/main.go#L60

Added line #L60 was not covered by tests
slogmulti.Fanout(
logHandler,
slogsentry.Option{Level: slog.LevelError}.NewSentryHandler(),
Expand All @@ -70,16 +67,17 @@
slog.SetDefault(logger)
}

log := slog.With("comp", "main")
log.Info("starting indexer", "version", version, "released", date)

Check warning on line 72 in cmd/rp-indexer/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-indexer/main.go#L70-L72

Added lines #L70 - L72 were not covered by tests
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)

Check warning on line 75 in cmd/rp-indexer/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-indexer/main.go#L75

Added line #L75 was not covered by tests
}

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)

Check warning on line 80 in cmd/rp-indexer/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-indexer/main.go#L78-L80

Added lines #L78 - L80 were not covered by tests
}

idxrs := []indexers.Indexer{
Expand All @@ -91,7 +89,7 @@
// 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())

Check warning on line 92 in cmd/rp-indexer/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-indexer/main.go#L92

Added line #L92 was not covered by tests
}
} else {
d := indexer.NewDaemon(rt, idxrs)
Expand Down
7 changes: 0 additions & 7 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 0 additions & 10 deletions runtime/config.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand All @@ -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",
Expand All @@ -45,8 +37,6 @@ func NewDefaultConfig() *Config {
CloudwatchNamespace: "Temba",
DeploymentID: "dev",

InstanceName: hostname,

ContactsIndex: "contacts",
ContactsShards: 2,
ContactsReplicas: 1,
Expand Down
Loading