Skip to content

Commit 36ab028

Browse files
committed
Update to latest gocommon and tweak default cloudwatch namespace
1 parent 229df67 commit 36ab028

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

daemon.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"sync"
88
"time"
99

10-
"github.com/aws/aws-sdk-go-v2/aws"
1110
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
11+
"github.com/nyaruka/gocommon/aws/cwatch"
1212
"github.com/nyaruka/rp-indexer/v9/indexers"
1313
"github.com/nyaruka/rp-indexer/v9/runtime"
1414
)
@@ -113,12 +113,12 @@ func (d *Daemon) reportStats(includeLag bool) {
113113
rateInPeriod = float64(indexedInPeriod) / (float64(elapsedInPeriod) / float64(time.Second))
114114
}
115115

116-
dims := []types.Dimension{{Name: aws.String("Index"), Value: aws.String(ix.Name())}}
116+
idxDim := cwatch.Dimension("Index", ix.Name())
117117

118118
metrics = append(metrics,
119-
types.MetricDatum{MetricName: aws.String("IndexerIndexed"), Dimensions: dims, Value: aws.Float64(float64(indexedInPeriod)), Unit: types.StandardUnitCount},
120-
types.MetricDatum{MetricName: aws.String("IndexerDeleted"), Dimensions: dims, Value: aws.Float64(float64(deletedInPeriod)), Unit: types.StandardUnitCount},
121-
types.MetricDatum{MetricName: aws.String("IndexerRate"), Dimensions: dims, Value: aws.Float64(rateInPeriod), Unit: types.StandardUnitCountSecond},
119+
cwatch.Datum("RecordsIndexed", float64(indexedInPeriod), types.StandardUnitCount, idxDim),
120+
cwatch.Datum("RecordsDeleted", float64(deletedInPeriod), types.StandardUnitCount, idxDim),
121+
cwatch.Datum("IndexingRate", rateInPeriod, types.StandardUnitCountSecond, idxDim),
122122
)
123123

124124
d.prevStats[ix] = stats
@@ -128,8 +128,7 @@ func (d *Daemon) reportStats(includeLag bool) {
128128
if err != nil {
129129
log.Error("error getting db last modified", "index", ix.Name(), "error", err)
130130
} else {
131-
132-
metrics = append(metrics, types.MetricDatum{MetricName: aws.String("IndexerLag"), Dimensions: dims, Value: aws.Float64(lag.Seconds()), Unit: types.StandardUnitSeconds})
131+
metrics = append(metrics, cwatch.Datum("IndexingLag", lag.Seconds(), types.StandardUnitSeconds, idxDim))
133132
}
134133
}
135134
}

go.mod

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ module github.com/nyaruka/rp-indexer/v9
33
go 1.23
44

55
require (
6-
github.com/aws/aws-sdk-go-v2 v1.32.6
76
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.43.3
87
github.com/getsentry/sentry-go v0.30.0
98
github.com/lib/pq v1.10.9
109
github.com/nyaruka/ezconf v0.3.0
11-
github.com/nyaruka/gocommon v1.60.3
10+
github.com/nyaruka/gocommon v1.60.4
1211
github.com/samber/slog-multi v1.2.4
1312
github.com/samber/slog-sentry v1.2.2
1413
github.com/stretchr/testify v1.10.0
1514
)
1615

1716
require (
17+
github.com/aws/aws-sdk-go-v2 v1.32.6 // indirect
1818
github.com/aws/aws-sdk-go-v2/config v1.28.6 // indirect
1919
github.com/aws/aws-sdk-go-v2/credentials v1.17.47 // indirect
2020
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21 // indirect
@@ -30,22 +30,21 @@ require (
3030
github.com/davecgh/go-spew v1.1.1 // indirect
3131
github.com/fatih/structs v1.1.0 // indirect
3232
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
33-
github.com/go-chi/chi/v5 v5.1.0 // indirect
33+
github.com/go-chi/chi/v5 v5.2.0 // indirect
3434
github.com/gorilla/websocket v1.5.3 // indirect
3535
github.com/jmespath/go-jmespath v0.4.0 // indirect
3636
github.com/kylelemons/godebug v1.1.0 // indirect
3737
github.com/naoina/go-stringutil v0.1.0 // indirect
3838
github.com/naoina/toml v0.1.1 // indirect
39-
github.com/nyaruka/librato v1.1.1 // indirect
4039
github.com/nyaruka/null/v2 v2.0.3 // indirect
4140
github.com/nyaruka/phonenumbers v1.4.3 // indirect
4241
github.com/pmezard/go-difflib v1.0.0 // indirect
4342
github.com/samber/lo v1.47.0 // indirect
4443
github.com/shopspring/decimal v1.4.0 // indirect
45-
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
44+
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e // indirect
4645
golang.org/x/net v0.32.0 // indirect
4746
golang.org/x/sys v0.28.0 // indirect
4847
golang.org/x/text v0.21.0 // indirect
49-
google.golang.org/protobuf v1.35.2 // indirect
48+
google.golang.org/protobuf v1.36.0 // indirect
5049
gopkg.in/yaml.v3 v3.0.1 // indirect
5150
)

go.sum

+8-10
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ github.com/gabriel-vasile/mimetype v1.4.7 h1:SKFKl7kD0RiPdbht0s7hFtjl489WcQ1VyPW
3535
github.com/gabriel-vasile/mimetype v1.4.7/go.mod h1:GDlAgAyIRT27BhFl53XNAFtfjzOkLaF35JdEG0P7LtU=
3636
github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo=
3737
github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA=
38-
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
39-
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
38+
github.com/go-chi/chi/v5 v5.2.0 h1:Aj1EtB0qR2Rdo2dG4O94RIU35w2lvQSj6BRA4+qwFL0=
39+
github.com/go-chi/chi/v5 v5.2.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
4040
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
4141
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
4242
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
@@ -59,10 +59,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
5959
github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
6060
github.com/nyaruka/ezconf v0.3.0 h1:kGvJqVN8AHowb4HdaHAviJ0Z3yI5Pyekp1WqibFEaGk=
6161
github.com/nyaruka/ezconf v0.3.0/go.mod h1:89GUW6EPRNLIxT7lC4LWnjWTgZeQwRoX7lBmc8ralAU=
62-
github.com/nyaruka/gocommon v1.60.3 h1:fPQ9t6NX+mu7JQ7nXefgpBs8paqGvGXq3eA7VscsAVo=
63-
github.com/nyaruka/gocommon v1.60.3/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
64-
github.com/nyaruka/librato v1.1.1 h1:0nTYtJLl3Sn7lX3CuHsLf+nXy1k/tGV0OjVxLy3Et4s=
65-
github.com/nyaruka/librato v1.1.1/go.mod h1:fme1Fu1PT2qvkaBZyw8WW+SrnFe2qeeCWpvqmAaKAKE=
62+
github.com/nyaruka/gocommon v1.60.4 h1:QpnSJailgaXpfjFjjuKTy/4NufgfmGfdFGib8khXm9o=
63+
github.com/nyaruka/gocommon v1.60.4/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
6664
github.com/nyaruka/null/v2 v2.0.3 h1:rdmMRQyVzrOF3Jff/gpU/7BDR9mQX0lcLl4yImsA3kw=
6765
github.com/nyaruka/null/v2 v2.0.3/go.mod h1:OCVeCkCXwrg5/qE6RU0c1oUVZBy+ZDrT+xYg1XSaIWA=
6866
github.com/nyaruka/phonenumbers v1.4.3 h1:tR71UJ+DZu7TSkxoG8JI8HzHJkPD/m4KNiUX34Fvmlo=
@@ -84,16 +82,16 @@ github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+D
8482
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
8583
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
8684
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
87-
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 h1:Y/Mj/94zIQQGHVSv1tTtQBDaQaJe62U9bkDZKKyhPCU=
88-
golang.org/x/exp v0.0.0-20241210194714-1829a127f884/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
85+
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e h1:4qufH0hlUYs6AO6XmZC3GqfDPGSXHVXUFR6OND+iJX4=
86+
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
8987
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
9088
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
9189
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
9290
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9391
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
9492
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
95-
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
96-
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
93+
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
94+
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
9795
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
9896
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9997
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

runtime/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func NewDefaultConfig() *Config {
3434
AWSSecretAccessKey: "",
3535
AWSRegion: "us-east-1",
3636

37-
CloudwatchNamespace: "Temba",
37+
CloudwatchNamespace: "Temba/Indexer",
3838
DeploymentID: "dev",
3939

4040
ContactsIndex: "contacts",

0 commit comments

Comments
 (0)