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

Update to latest gocommon #114

Merged
merged 1 commit into from
Dec 16, 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
78 changes: 14 additions & 64 deletions archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"path/filepath"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"
"github.com/nyaruka/gocommon/aws/cwatch"
"github.com/nyaruka/gocommon/dates"
"github.com/nyaruka/rp-archiver/runtime"
)
Expand Down Expand Up @@ -967,71 +967,21 @@ func ArchiveActiveOrgs(rt *runtime.Runtime) error {
timeTaken := dates.Now().Sub(start)
slog.Info("archiving of active orgs complete", "time_taken", timeTaken, "num_orgs", len(orgs))

msgsDim := types.Dimension{Name: aws.String("ArchiveType"), Value: aws.String("msgs")}
runsDim := types.Dimension{Name: aws.String("ArchiveType"), Value: aws.String("runs")}
msgsDim := cwatch.Dimension("ArchiveType", "msgs")
runsDim := cwatch.Dimension("ArchiveType", "runs")

metrics := []types.MetricDatum{
{MetricName: aws.String("ArchivingElapsed"), Value: aws.Float64(timeTaken.Seconds()), Unit: types.StandardUnitSeconds},
{
MetricName: aws.String("RecordsArchived"),
Dimensions: []types.Dimension{msgsDim},
Value: aws.Float64(float64(totalMsgsRecordsArchived)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("RecordsArchived"),
Dimensions: []types.Dimension{runsDim},
Value: aws.Float64(float64(totalRunsRecordsArchived)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("ArchivesCreated"),
Dimensions: []types.Dimension{msgsDim},
Value: aws.Float64(float64(totalMsgsArchivesCreated)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("ArchivesCreated"),
Dimensions: []types.Dimension{runsDim},
Value: aws.Float64(float64(totalRunsArchivesCreated)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("ArchivesFailed"),
Dimensions: []types.Dimension{msgsDim},
Value: aws.Float64(float64(totalMsgsArchivesFailed)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("ArchivesFailed"),
Dimensions: []types.Dimension{runsDim},
Value: aws.Float64(float64(totalRunsArchivesFailed)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("RollupsCreated"),
Dimensions: []types.Dimension{msgsDim},
Value: aws.Float64(float64(totalMsgsRollupsCreated)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("RollupsCreated"),
Dimensions: []types.Dimension{runsDim},
Value: aws.Float64(float64(totalRunsRollupsCreated)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("RollupsFailed"),
Dimensions: []types.Dimension{msgsDim},
Value: aws.Float64(float64(totalMsgsRollupsFailed)),
Unit: types.StandardUnitCount,
},
{
MetricName: aws.String("RollupsFailed"),
Dimensions: []types.Dimension{runsDim},
Value: aws.Float64(float64(totalRunsRollupsFailed)),
Unit: types.StandardUnitCount,
},
cwatch.Datum("ArchivingElapsed", timeTaken.Seconds(), types.StandardUnitSeconds),
cwatch.Datum("RecordsArchived", float64(totalMsgsRecordsArchived), types.StandardUnitCount, msgsDim),
cwatch.Datum("RecordsArchived", float64(totalRunsRecordsArchived), types.StandardUnitCount, runsDim),
cwatch.Datum("ArchivesCreated", float64(totalMsgsArchivesCreated), types.StandardUnitCount, msgsDim),
cwatch.Datum("ArchivesCreated", float64(totalRunsArchivesCreated), types.StandardUnitCount, runsDim),
cwatch.Datum("ArchivesFailed", float64(totalMsgsArchivesFailed), types.StandardUnitCount, msgsDim),
cwatch.Datum("ArchivesFailed", float64(totalRunsArchivesFailed), types.StandardUnitCount, runsDim),
cwatch.Datum("RollupsCreated", float64(totalMsgsRollupsCreated), types.StandardUnitCount, msgsDim),
cwatch.Datum("RollupsCreated", float64(totalRunsRollupsCreated), types.StandardUnitCount, runsDim),
cwatch.Datum("RollupsFailed", float64(totalMsgsRollupsFailed), types.StandardUnitCount, msgsDim),
cwatch.Datum("RollupsFailed", float64(totalRunsRollupsFailed), types.StandardUnitCount, runsDim),
}

if err = rt.CW.Send(ctx, metrics...); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/jmoiron/sqlx v1.4.0
github.com/lib/pq v1.10.9
github.com/nyaruka/ezconf v0.3.0
github.com/nyaruka/gocommon v1.60.3
github.com/nyaruka/gocommon v1.60.4
github.com/samber/slog-multi v1.2.0
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 @@ -71,8 +71,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.3 h1:fPQ9t6NX+mu7JQ7nXefgpBs8paqGvGXq3eA7VscsAVo=
github.com/nyaruka/gocommon v1.60.3/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
github.com/nyaruka/gocommon v1.60.4 h1:QpnSJailgaXpfjFjjuKTy/4NufgfmGfdFGib8khXm9o=
github.com/nyaruka/gocommon v1.60.4/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
github.com/nyaruka/null/v2 v2.0.3 h1:rdmMRQyVzrOF3Jff/gpU/7BDR9mQX0lcLl4yImsA3kw=
github.com/nyaruka/null/v2 v2.0.3/go.mod h1:OCVeCkCXwrg5/qE6RU0c1oUVZBy+ZDrT+xYg1XSaIWA=
github.com/nyaruka/phonenumbers v1.4.3 h1:tR71UJ+DZu7TSkxoG8JI8HzHJkPD/m4KNiUX34Fvmlo=
Expand Down
Loading