@@ -98,6 +98,7 @@ func toModelDimensions(dimensions []types.Dimension) []model.Dimension {
9898
9999func (c client ) GetMetricData (ctx context.Context , getMetricData []* model.CloudwatchData , namespace string , startTime time.Time , endTime time.Time ) []cloudwatch_client.MetricDataResult {
100100 metricDataQueries := make ([]types.MetricDataQuery , 0 , len (getMetricData ))
101+ exportAllDataPoints := false
101102 for _ , data := range getMetricData {
102103 metricStat := & types.MetricStat {
103104 Metric : & types.Metric {
@@ -113,6 +114,7 @@ func (c client) GetMetricData(ctx context.Context, getMetricData []*model.Cloudw
113114 MetricStat : metricStat ,
114115 ReturnData : aws .Bool (true ),
115116 })
117+ exportAllDataPoints = exportAllDataPoints || data .MetricMigrationParams .ExportAllDataPoints
116118 }
117119
118120 input := & cloudwatch.GetMetricDataInput {
@@ -143,23 +145,32 @@ func (c client) GetMetricData(ctx context.Context, getMetricData []*model.Cloudw
143145
144146 c .logger .Debug ("GetMetricData" , "output" , resp )
145147
146- return toMetricDataResult (resp )
148+ return toMetricDataResult (resp , exportAllDataPoints )
147149}
148150
149- func toMetricDataResult (resp cloudwatch.GetMetricDataOutput ) []cloudwatch_client.MetricDataResult {
151+ func toMetricDataResult (resp cloudwatch.GetMetricDataOutput , exportAllDataPoints bool ) []cloudwatch_client.MetricDataResult {
150152 output := make ([]cloudwatch_client.MetricDataResult , 0 , len (resp .MetricDataResults ))
151153 for _ , metricDataResult := range resp .MetricDataResults {
152- mappedResult := cloudwatch_client.MetricDataResult {ID : * metricDataResult .Id }
153- if len (metricDataResult .Values ) > 0 {
154- mappedResult .Datapoint = & metricDataResult .Values [0 ]
155- mappedResult .Timestamp = metricDataResult .Timestamps [0 ]
154+ mappedResult := cloudwatch_client.MetricDataResult {
155+ ID : * metricDataResult .Id ,
156+ DataPoints : make ([]cloudwatch_client.DataPoint , 0 , len (metricDataResult .Timestamps )),
157+ }
158+ for i := 0 ; i < len (metricDataResult .Timestamps ); i ++ {
159+ mappedResult .DataPoints = append (mappedResult .DataPoints , cloudwatch_client.DataPoint {
160+ Value : & metricDataResult .Values [i ],
161+ Timestamp : metricDataResult .Timestamps [i ],
162+ })
163+
164+ if ! exportAllDataPoints {
165+ break
166+ }
156167 }
157168 output = append (output , mappedResult )
158169 }
159170 return output
160171}
161172
162- func (c client ) GetMetricStatistics (ctx context.Context , logger * slog.Logger , dimensions []model.Dimension , namespace string , metric * model.MetricConfig ) []* model.Datapoint {
173+ func (c client ) GetMetricStatistics (ctx context.Context , logger * slog.Logger , dimensions []model.Dimension , namespace string , metric * model.MetricConfig ) []* model.MetricStatisticsResult {
163174 filter := createGetMetricStatisticsInput (logger , dimensions , & namespace , metric )
164175 c .logger .Debug ("GetMetricStatistics" , "input" , filter )
165176
@@ -181,18 +192,18 @@ func (c client) GetMetricStatistics(ctx context.Context, logger *slog.Logger, di
181192 ptrs = append (ptrs , & datapoint )
182193 }
183194
184- return toModelDatapoints (ptrs )
195+ return toModelDataPoints (ptrs )
185196}
186197
187- func toModelDatapoints ( cwDatapoints []* types.Datapoint ) []* model.Datapoint {
188- modelDataPoints := make ([]* model.Datapoint , 0 , len (cwDatapoints ))
198+ func toModelDataPoints ( cwDataPoints []* types.Datapoint ) []* model.MetricStatisticsResult {
199+ modelDataPoints := make ([]* model.MetricStatisticsResult , 0 , len (cwDataPoints ))
189200
190- for _ , cwDatapoint := range cwDatapoints {
201+ for _ , cwDatapoint := range cwDataPoints {
191202 extendedStats := make (map [string ]* float64 , len (cwDatapoint .ExtendedStatistics ))
192203 for name , value := range cwDatapoint .ExtendedStatistics {
193204 extendedStats [name ] = & value
194205 }
195- modelDataPoints = append (modelDataPoints , & model.Datapoint {
206+ modelDataPoints = append (modelDataPoints , & model.MetricStatisticsResult {
196207 Average : cwDatapoint .Average ,
197208 ExtendedStatistics : extendedStats ,
198209 Maximum : cwDatapoint .Maximum ,
0 commit comments