@@ -36,7 +36,20 @@ type metricsData struct {
3636 usageRates map [string ]float64
3737}
3838
39- func (m * metricsData ) CreateTable (ctx context.Context , desc chunk.TableDesc ) error {
39+ func newMetrics (cfg DynamoDBConfig ) (* metricsData , error ) {
40+ client , err := promApi .NewClient (promApi.Config {Address : cfg .MetricsURL })
41+ if err != nil {
42+ return nil , err
43+ }
44+ return & metricsData {
45+ promAPI : promV1 .NewAPI (client ),
46+ queueLengthTarget : cfg .MetricsTargetQueueLen ,
47+ scaleUpFactor : cfg .MetricsScaleUpFactor ,
48+ tableLastUpdated : make (map [string ]time.Time ),
49+ }, nil
50+ }
51+
52+ func (m * metricsData ) PostCreateTable (ctx context.Context , desc chunk.TableDesc ) error {
4053 return nil
4154}
4255
@@ -129,19 +142,6 @@ func (m *metricsData) scaleUpWrite(current chunk.TableDesc, expected *chunk.Tabl
129142 }
130143}
131144
132- func newMetrics (cfg DynamoDBConfig ) (* metricsData , error ) {
133- client , err := promApi .NewClient (promApi.Config {Address : cfg .MetricsURL })
134- if err != nil {
135- return nil , err
136- }
137- return & metricsData {
138- promAPI : promV1 .NewAPI (client ),
139- queueLengthTarget : cfg .MetricsTargetQueueLen ,
140- scaleUpFactor : cfg .MetricsScaleUpFactor ,
141- tableLastUpdated : make (map [string ]time.Time ),
142- }, nil
143- }
144-
145145func (m * metricsData ) update (ctx context.Context ) error {
146146 if m .promLastQuery .After (mtime .Now ().Add (- cachePromDataFor )) {
147147 return nil
0 commit comments