Skip to content

Commit

Permalink
improved error handling and metrics for dynamoDB (#4)
Browse files Browse the repository at this point in the history
* improved error handling and metrics

* renamed capacity unit metric

* added CapacityUnitConsumedCounter

* restructure dynamodb metrics

* added helper metric method
  • Loading branch information
kcajmagic authored May 29, 2020
1 parent 7e276d2 commit ff35bf5
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 66 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [v0.2.1]
- added capacity consumed metrics to dynamoDB
- improved error handling for dynamoDB
- fixed webhookclient to use `PUT` instead of `POST`

## [v0.2.0]
- reworked api
- added dynamodb support
Expand All @@ -17,8 +22,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [v0.1.0] Tue May 07 2020 Jack Murdock - 0.1.0
- initial creation

[Unreleased]: https://github.com/Comcast/talaria/compare/v0.2.0...HEAD
[v0.2.0]: https://github.com/Comcast/talaria/compare/v0.1.1...v0.2.0
[v0.1.1]: https://github.com/Comcast/talaria/compare/v0.1.0...v0.1.1
[v0.1.0]: https://github.com/Comcast/talaria/compare/v0.1.0...v0.1.0
[Unreleased]: https://github.com/xmidt-org/argus/compare/v0.2.1...HEAD
[v0.2.1]: https://github.com/xmidt-org/argus/compare/v0.2.0...v0.2.1
[v0.2.0]: https://github.com/xmidt-org/argus/compare/v0.1.1...v0.2.0
[v0.1.1]: https://github.com/xmidt-org/argus/compare/v0.1.0...v0.1.1
[v0.1.0]: https://github.com/xmidt-org/argus/compare/v0.1.0...v0.1.0

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/xmidt-org/argus
go 1.13

require (
emperror.dev/emperror v0.30.0
github.com/InVisionApp/go-health v2.1.0+incompatible
github.com/aws/aws-sdk-go v1.8.12
github.com/aws/aws-sdk-go v1.31.6
github.com/go-kit/kit v0.9.0
github.com/gocql/gocql v0.0.0-20200505093417-effcbd8bcf0e
github.com/goph/emperror v0.17.3-0.20190703203600-60a8d9faa17b
github.com/gorilla/mux v1.7.3
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d // indirect
Expand Down
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
emperror.dev/emperror v0.17.1/go.mod h1:+ZbQ+fUNO/6FNiUo0ujtMjhgad9Xa6fQL9KhH4LNHic=
emperror.dev/emperror v0.17.3-0.20190703203600-60a8d9faa17b/go.mod h1:+ZbQ+fUNO/6FNiUo0ujtMjhgad9Xa6fQL9KhH4LNHic=
emperror.dev/emperror v0.30.0 h1:RLQ9WaCdFMD2Nhp/+8RN/iaXjaaqRCh+UFVrkThHOO4=
emperror.dev/emperror v0.30.0/go.mod h1:ZasUgT1WGMbTYZzEWmyPuc6pCxRjO6Kp8lZz4FRRIiM=
emperror.dev/errors v0.7.0 h1:vf0gZ0j9BJCXQYm0M21DPKeXy9PUjvX1YHXhNzIsqOY=
emperror.dev/errors v0.7.0/go.mod h1:X4dljzQehaz3WfBKc6c7bR+ve2ZsRzbBkFBF+HTcW0M=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/GaryBoone/GoStats v0.0.0-20130122001700-1993eafbef57/go.mod h1:5zDl2HgTb/k5i9op9y6IUSiuVkZFpUrWGQbZc9tNR40=
github.com/InVisionApp/go-health v2.1.0+incompatible/go.mod h1:/+Gv1o8JUsrjC6pi6MN6/CgKJo4OqZ6x77XAnImrzhg=
Expand All @@ -14,6 +20,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/aws/aws-sdk-go v1.8.12/go.mod h1:ZRmQr0FajVIyZ4ZzBYKG5P3ZqPz9IHG41ZoMu1ADI3k=
github.com/aws/aws-sdk-go v1.31.6 h1:nKjQbpXhdImctBh1e0iLg9iQW/X297LPPuY/9f92R2k=
github.com/aws/aws-sdk-go v1.31.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down Expand Up @@ -49,6 +57,7 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gocql/gocql v0.0.0-20200505093417-effcbd8bcf0e h1:k4NKEJg2i2J7l6y44DHiq+U2ua0vvLUKbpktGA4UhQM=
github.com/gocql/gocql v0.0.0-20200505093417-effcbd8bcf0e/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY=
Expand Down Expand Up @@ -101,6 +110,8 @@ github.com/influxdata/influxdb v1.5.1-0.20180921190457-8d679cf0c36e/go.mod h1:qZ
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d h1:/WZQPMZNsjZ7IlCpsLGdQBINg5bxKQ1K1sh6awxLtkA=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -145,6 +156,9 @@ github.com/peterbourgon/g2s v0.0.0-20170223122336-d4e7ad98afea/go.mod h1:1VcHEd3
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1-0.20181008045315-2233dee583dc/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
Expand Down Expand Up @@ -259,6 +273,8 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
2 changes: 1 addition & 1 deletion store/cassandra/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package cassandra

import (
"context"
"emperror.dev/emperror"
"errors"
"github.com/gocql/gocql"
"github.com/goph/emperror"
"github.com/xmidt-org/argus/model"
"github.com/xmidt-org/argus/store"
"github.com/xmidt-org/argus/store/db/metric"
Expand Down
34 changes: 34 additions & 0 deletions store/db/metric/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"go.uber.org/fx"
)

// Generic Metrics
const (
PoolInUseConnectionsGauge = "pool_in_use_connections"
SQLDurationSeconds = "sql_duration_seconds"
Expand All @@ -35,6 +36,13 @@ const (
SQLDeletedRecordsCounter = "sql_deleted_rows_count"
)

// DynamoDB metrics
const (
CapacityUnitConsumedCounter = "capacity_unit_consumed"
ReadCapacityConsumedCounter = "read_capacity_unit_consumed"
WriteCapacityConsumedCounter = "write_capacity_unit_consumed"
)

// Metrics returns the Metrics relevant to this package
func ProvideMetrics() fx.Option {
return fx.Provide(
Expand Down Expand Up @@ -85,6 +93,27 @@ func ProvideMetrics() fx.Option {
Help: "The total number of rows deleted",
},
),
xmetrics.ProvideCounter(
prometheus.CounterOpts{
Name: CapacityUnitConsumedCounter,
Help: "The number of capacity units consumed by the operation.",
},
store.TypeLabel,
),
xmetrics.ProvideCounter(
prometheus.CounterOpts{
Name: ReadCapacityConsumedCounter,
Help: "The number of read capacity units consumed by the operation.",
},
store.TypeLabel,
),
xmetrics.ProvideCounter(
prometheus.CounterOpts{
Name: WriteCapacityConsumedCounter,
Help: "The number of write capacity units consumed by the operation.",
},
store.TypeLabel,
),
)
}

Expand All @@ -97,4 +126,9 @@ type Measures struct {
SQLInsertedRecords metrics.Counter `name:"sql_inserted_rows_count"`
SQLReadRecords metrics.Counter `name:"sql_read_rows_count"`
SQLDeletedRecords metrics.Counter `name:"sql_deleted_rows_count"`

// DynamoDB Metrics
CapacityUnitConsumedCount metrics.Counter `name:"capacity_unit_consumed"`
ReadCapacityUnitConsumedCount metrics.Counter `name:"read_capacity_unit_consumed"`
WriteCapacityUnitConsumedCount metrics.Counter `name:"write_capacity_unit_consumed"`
}
47 changes: 28 additions & 19 deletions store/dynamodb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package dynamodb
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/go-kit/kit/log"
"github.com/xmidt-org/argus/model"
"github.com/xmidt-org/argus/store"
"github.com/xmidt-org/argus/store/db/metric"
"github.com/xmidt-org/themis/config"
"github.com/xmidt-org/webpa-common/logging"
)

const (
DynamoDB = "dynamo"

defaultTable = "gifnoc"
defaultMaxRetries = 3
defaultWaitTimeMult = 1
defaultTable = "gifnoc"
defaultMaxRetries = 3
)

type Config struct {
Expand All @@ -28,7 +29,7 @@ type Config struct {
}

type DynamoClient struct {
client store.S
client storeConsumable
config Config
logger log.Logger
measures metric.Measures
Expand Down Expand Up @@ -65,7 +66,8 @@ func ProvideDynamodDB(unmarshaller config.Unmarshaller, measures metric.Measures
}

func (s *DynamoClient) Push(key model.Key, item store.OwnableItem) error {
err := s.client.Push(key, item)
consumedCapacity, err := s.client.Push(key, item)
s.updateCapacityMetric(consumedCapacity, store.InsertType)
if err != nil {
s.measures.SQLQueryFailureCount.With(store.TypeLabel, store.InsertType).Add(1.0)
return err
Expand All @@ -75,11 +77,9 @@ func (s *DynamoClient) Push(key model.Key, item store.OwnableItem) error {
}

func (s *DynamoClient) Get(key model.Key) (store.OwnableItem, error) {
item, err := s.client.Get(key)
item, consumedCapacity, err := s.client.Get(key)
s.updateCapacityMetric(consumedCapacity, store.ReadType)
if err != nil {
if err == noDataResponse {
return item, store.KeyNotFoundError{Key: key}
}
s.measures.SQLQueryFailureCount.With(store.TypeLabel, store.ReadType).Add(1.0)
return item, err
}
Expand All @@ -88,11 +88,9 @@ func (s *DynamoClient) Get(key model.Key) (store.OwnableItem, error) {
}

func (s *DynamoClient) Delete(key model.Key) (store.OwnableItem, error) {
item, err := s.client.Delete(key)
item, consumedCapacity, err := s.client.Delete(key)
s.updateCapacityMetric(consumedCapacity, store.DeleteType)
if err != nil {
if err == noDataResponse {
return item, store.KeyNotFoundError{Key: key}
}
s.measures.SQLQueryFailureCount.With(store.TypeLabel, store.DeleteType).Add(1.0)
return item, err
}
Expand All @@ -101,13 +99,9 @@ func (s *DynamoClient) Delete(key model.Key) (store.OwnableItem, error) {
}

func (s *DynamoClient) GetAll(bucket string) (map[string]store.OwnableItem, error) {
item, err := s.client.GetAll(bucket)
item, consumedCapacity, err := s.client.GetAll(bucket)
s.updateCapacityMetric(consumedCapacity, store.ReadType)
if err != nil {
if err == noDataResponse {
return item, store.KeyNotFoundError{Key: model.Key{
Bucket: bucket,
}}
}
s.measures.SQLQueryFailureCount.With(store.TypeLabel, store.ReadType).Add(1.0)
return item, err
}
Expand All @@ -124,3 +118,18 @@ func validateConfig(config Config) {
config.MaxRetries = defaultMaxRetries
}
}

func (s *DynamoClient) updateCapacityMetric(consumedCapacity *dynamodb.ConsumedCapacity, action string) {
if consumedCapacity != nil {
logging.Debug(s.logger).Log(logging.MessageKey(), "Updating consumed capacity", "consumed", consumedCapacity, "action", action)
if consumedCapacity.CapacityUnits != nil {
s.measures.CapacityUnitConsumedCount.With(store.TypeLabel, action).Add(*consumedCapacity.CapacityUnits)
}
if consumedCapacity.ReadCapacityUnits != nil {
s.measures.ReadCapacityUnitConsumedCount.With(store.TypeLabel, action).Add(*consumedCapacity.ReadCapacityUnits)
}
if consumedCapacity.WriteCapacityUnits != nil {
s.measures.WriteCapacityUnitConsumedCount.With(store.TypeLabel, action).Add(*consumedCapacity.WriteCapacityUnits)
}
}
}
56 changes: 40 additions & 16 deletions store/dynamodb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package dynamodb

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/stretchr/testify/mock"
"github.com/xmidt-org/argus/store"
"github.com/xmidt-org/argus/store/db/metric"
Expand All @@ -29,15 +31,14 @@ import (
)

func TestDynamo(t *testing.T) {
// TODO: Test metrics
// require := require.New(t)
mockDB := &test.MockDB{}
mockDB.On("Push", mock.Anything, mock.Anything).Return(nil)
mockDB.On("Get", mock.Anything).Return(test.GenericTestKeyPair.OwnableItem, nil).Once()
mockDB.On("Get", mock.Anything).Return(store.OwnableItem{}, nil).Once()
mockDB.On("Delete", mock.Anything, mock.Anything).Return(test.GenericTestKeyPair.OwnableItem, nil)
mockDB.On("GetAll", mock.Anything).Return(map[string]store.OwnableItem{"earth": test.GenericTestKeyPair.OwnableItem}, nil).Once()
mockDB.On("GetAll", mock.Anything).Return(map[string]store.OwnableItem{}, nil).Once()
mockDB := &MockDB{}
mockDB.On("Push", mock.Anything, mock.Anything).Return(&dynamodb.ConsumedCapacity{CapacityUnits: aws.Float64(0.5), TableName: aws.String("fignoc")}, nil)
mockDB.On("Get", mock.Anything).Return(test.GenericTestKeyPair.OwnableItem, &dynamodb.ConsumedCapacity{CapacityUnits: aws.Float64(1.0), TableName: aws.String("fignoc")}, nil).Once()
mockDB.On("Get", mock.Anything).Return(store.OwnableItem{}, &dynamodb.ConsumedCapacity{CapacityUnits: aws.Float64(1.0), TableName: aws.String("fignoc")}, nil).Once()
mockDB.On("Delete", mock.Anything, mock.Anything).Return(test.GenericTestKeyPair.OwnableItem, &dynamodb.ConsumedCapacity{CapacityUnits: aws.Float64(1.0), TableName: aws.String("fignoc")}, nil)
mockDB.On("GetAll", mock.Anything).Return(map[string]store.OwnableItem{"earth": test.GenericTestKeyPair.OwnableItem}, &dynamodb.ConsumedCapacity{CapacityUnits: aws.Float64(1.0), TableName: aws.String("fignoc")}, nil).Once()
mockDB.On("GetAll", mock.Anything).Return(map[string]store.OwnableItem{}, &dynamodb.ConsumedCapacity{CapacityUnits: aws.Float64(0.0), TableName: aws.String("fignoc")}, nil).Once()

mockDB.On("Ping").Return(nil)

Expand Down Expand Up @@ -82,6 +83,24 @@ func TestDynamo(t *testing.T) {
Type: "counter",
Help: "The total number of rows deleted",
},
{
Name: metric.CapacityUnitConsumedCounter,
Type: "counter",
Help: "The number of capacity units consumed by the operation.",
LabelNames: []string{store.TypeLabel},
},
{
Name: metric.ReadCapacityConsumedCounter,
Type: "counter",
Help: "The number of read capacity units consumed by the operation.",
LabelNames: []string{store.TypeLabel},
},
{
Name: metric.WriteCapacityConsumedCounter,
Type: "counter",
Help: "The number of write capacity units consumed by the operation.",
LabelNames: []string{store.TypeLabel},
},
}
})

Expand All @@ -90,13 +109,16 @@ func TestDynamo(t *testing.T) {
config: Config{},
logger: logging.NewTestLogger(nil, t),
measures: metric.Measures{
PoolInUseConnections: p.NewGauge(metric.PoolInUseConnectionsGauge),
SQLDuration: p.NewHistogram(metric.SQLDurationSeconds, 11),
SQLQuerySuccessCount: p.NewCounter(metric.SQLQuerySuccessCounter),
SQLQueryFailureCount: p.NewCounter(metric.SQLQueryFailureCounter),
SQLInsertedRecords: p.NewCounter(metric.SQLInsertedRecordsCounter),
SQLReadRecords: p.NewCounter(metric.SQLReadRecordsCounter),
SQLDeletedRecords: p.NewCounter(metric.SQLDeletedRecordsCounter),
PoolInUseConnections: p.NewGauge(metric.PoolInUseConnectionsGauge),
SQLDuration: p.NewHistogram(metric.SQLDurationSeconds, 11),
SQLQuerySuccessCount: p.NewCounter(metric.SQLQuerySuccessCounter),
SQLQueryFailureCount: p.NewCounter(metric.SQLQueryFailureCounter),
SQLInsertedRecords: p.NewCounter(metric.SQLInsertedRecordsCounter),
SQLReadRecords: p.NewCounter(metric.SQLReadRecordsCounter),
SQLDeletedRecords: p.NewCounter(metric.SQLDeletedRecordsCounter),
CapacityUnitConsumedCount: p.NewCounter(metric.CapacityUnitConsumedCounter),
ReadCapacityUnitConsumedCount: p.NewCounter(metric.ReadCapacityConsumedCounter),
WriteCapacityUnitConsumedCount: p.NewCounter(metric.WriteCapacityConsumedCounter),
},
}
p.Assert(t, metric.SQLQuerySuccessCounter)(xmetricstest.Value(0.0))
Expand All @@ -109,5 +131,7 @@ func TestDynamo(t *testing.T) {
p.Assert(t, metric.SQLInsertedRecordsCounter)(xmetricstest.Value(0.0))
p.Assert(t, metric.SQLReadRecordsCounter)(xmetricstest.Value(0.0))
p.Assert(t, metric.SQLDeletedRecordsCounter)(xmetricstest.Value(0.0))

p.Assert(t, metric.CapacityUnitConsumedCounter, store.TypeLabel, store.ReadType)(xmetricstest.Value(2.0))
p.Assert(t, metric.CapacityUnitConsumedCounter, store.TypeLabel, store.InsertType)(xmetricstest.Value(0.5))
p.Assert(t, metric.CapacityUnitConsumedCounter, store.TypeLabel, store.DeleteType)(xmetricstest.Value(1.0))
}
Loading

0 comments on commit ff35bf5

Please sign in to comment.