Skip to content

Commit

Permalink
Remove librato
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Dec 13, 2024
1 parent bade8ef commit 2e05f47
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 60 deletions.
14 changes: 0 additions & 14 deletions archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"
"github.com/nyaruka/gocommon/analytics"
"github.com/nyaruka/gocommon/dates"
"github.com/nyaruka/rp-archiver/runtime"
)
Expand Down Expand Up @@ -981,18 +980,5 @@ func ArchiveActiveOrgs(rt *runtime.Runtime) error {
rt.CW.Queue(types.MetricDatum{MetricName: aws.String("RunsRollupsCreated"), Value: aws.Float64(float64(totalRunsRollupsCreated)), Unit: types.StandardUnitCount})
rt.CW.Queue(types.MetricDatum{MetricName: aws.String("RunsRollupsFailed"), Value: aws.Float64(float64(totalRunsRollupsFailed)), Unit: types.StandardUnitCount})

Check warning on line 981 in archives/archives.go

View check run for this annotation

Codecov / codecov/patch

archives/archives.go#L970-L981

Added lines #L970 - L981 were not covered by tests

analytics.Gauge("archiver.archive_elapsed", timeTaken.Seconds())
analytics.Gauge("archiver.orgs_archived", float64(len(orgs)))
analytics.Gauge("archiver.msgs_records_archived", float64(totalMsgsRecordsArchived))
analytics.Gauge("archiver.msgs_archives_created", float64(totalMsgsArchivesCreated))
analytics.Gauge("archiver.msgs_archives_failed", float64(totalMsgsArchivesFailed))
analytics.Gauge("archiver.msgs_rollups_created", float64(totalMsgsRollupsCreated))
analytics.Gauge("archiver.msgs_rollups_failed", float64(totalMsgsRollupsFailed))
analytics.Gauge("archiver.runs_records_archived", float64(totalRunsRecordsArchived))
analytics.Gauge("archiver.runs_archives_created", float64(totalRunsArchivesCreated))
analytics.Gauge("archiver.runs_archives_failed", float64(totalRunsArchivesFailed))
analytics.Gauge("archiver.runs_rollups_created", float64(totalRunsRollupsCreated))
analytics.Gauge("archiver.runs_rollups_failed", float64(totalRunsRollupsFailed))

return nil
}
29 changes: 0 additions & 29 deletions archives/archives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"github.com/nyaruka/gocommon/analytics"
"github.com/nyaruka/gocommon/aws/cwatch"
"github.com/nyaruka/gocommon/dates"
"github.com/nyaruka/rp-archiver/runtime"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -516,33 +514,6 @@ func TestArchiveActiveOrgs(t *testing.T) {
rt.CW.Queue(types.MetricDatum{MetricName: aws.String("SleepTime"), Value: aws.Float64(30), Unit: types.StandardUnitSeconds})

time.Sleep(time.Millisecond * 300)

mockAnalytics := analytics.NewMock()
analytics.RegisterBackend(mockAnalytics)
analytics.Start()

dates.SetNowFunc(dates.NewSequentialNow(time.Date(2018, 1, 8, 12, 30, 0, 0, time.UTC), time.Second))
defer dates.SetNowFunc(time.Now)

err = ArchiveActiveOrgs(rt)
assert.NoError(t, err)

assert.Equal(t, map[string][]float64{
"archiver.archive_elapsed": {848.0},
"archiver.orgs_archived": {3},
"archiver.msgs_records_archived": {5},
"archiver.msgs_archives_created": {92},
"archiver.msgs_archives_failed": {0},
"archiver.msgs_rollups_created": {3},
"archiver.msgs_rollups_failed": {0},
"archiver.runs_records_archived": {5},
"archiver.runs_archives_created": {41},
"archiver.runs_archives_failed": {1},
"archiver.runs_rollups_created": {3},
"archiver.runs_rollups_failed": {1},
}, mockAnalytics.Gauges)

analytics.Stop()
rt.CW.StopQueue()

// check the queued metric was sent
Expand Down
8 changes: 0 additions & 8 deletions cmd/rp-archiver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"github.com/nyaruka/ezconf"
"github.com/nyaruka/gocommon/analytics"
"github.com/nyaruka/gocommon/aws/cwatch"
"github.com/nyaruka/gocommon/dates"
"github.com/nyaruka/rp-archiver/archives"
Expand Down Expand Up @@ -122,19 +121,13 @@ func main() {
logger.Error("invalid start time supplied, format: HH:MM", "error", err)
}

// if we have a librato token, configure it
if config.LibratoToken != "" {
analytics.RegisterBackend(analytics.NewLibrato(config.LibratoUsername, config.LibratoToken, config.InstanceName, time.Second, wg))
}

rt.CW, err = cwatch.NewService(config.AWSAccessKeyID, config.AWSSecretAccessKey, config.AWSRegion, config.CloudwatchNamespace, config.DeploymentID)
if err != nil {
logger.Error("unable to create cloudwatch service", "error", err)
} else {
logger.Info("cloudwatch service ok", "state", "starting")

Check warning on line 128 in cmd/rp-archiver/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-archiver/main.go#L124-L128

Added lines #L124 - L128 were not covered by tests
}

analytics.Start()
rt.CW.StartQueue(wg, time.Second*3)

Check warning on line 131 in cmd/rp-archiver/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-archiver/main.go#L131

Added line #L131 was not covered by tests

if config.Once {
Expand All @@ -151,7 +144,6 @@ func main() {
}
}

analytics.Stop()
rt.CW.StopQueue()

Check warning on line 147 in cmd/rp-archiver/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/rp-archiver/main.go#L147

Added line #L147 was not covered by tests
wg.Wait()
}
Expand Down
10 changes: 1 addition & 9 deletions runtime/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package runtime

import "os"

// Config is our top level configuration object
type Config struct {
DB string `help:"the connection string for our database"`
Expand All @@ -28,17 +26,12 @@ type Config struct {
StartTime string `help:"what time archive jobs should run in UTC HH:MM "`
Once bool `help:"whether archiver should run once and exit (default false)"`

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"`

CloudwatchNamespace string `help:"the namespace to use for cloudwatch metrics"`
DeploymentID string `help:"the deployment identifier to use for metrics"`
}

// NewDefaultConfig returns a new default configuration object
func NewDefaultConfig() *Config {
hostname, _ := os.Hostname()

return &Config{
DB: "postgres://localhost/archiver_test?sslmode=disable",
Expand Down Expand Up @@ -66,7 +59,6 @@ func NewDefaultConfig() *Config {
CloudwatchNamespace: "Temba",
DeploymentID: "dev",

InstanceName: hostname,
LogLevel: "info",
LogLevel: "info",
}
}

0 comments on commit 2e05f47

Please sign in to comment.