@@ -322,36 +322,28 @@ func produceCloudWatchMetrics(t metricsTarget, families map[string]*dto.MetricFa
322
322
for _ , action := range convertMetrics .actions {
323
323
switch metricType {
324
324
case dto .MetricType_COUNTER :
325
- if t .submitCloudWatch () {
326
- dataPoint := & cloudwatch.MetricDatum {
327
- MetricName : aws .String (action .cwMetricName ),
328
- Unit : aws .String (cloudwatch .StandardUnitCount ),
329
- Value : aws .Float64 (action .data .curSingleDataPoint ),
330
- }
331
- cw .Publish (dataPoint )
325
+ dataPoint := & cloudwatch.MetricDatum {
326
+ MetricName : aws .String (action .cwMetricName ),
327
+ Unit : aws .String (cloudwatch .StandardUnitCount ),
328
+ Value : aws .Float64 (action .data .curSingleDataPoint ),
332
329
}
330
+ cw .Publish (dataPoint )
333
331
case dto .MetricType_GAUGE :
334
- if t .submitCloudWatch () {
335
- dataPoint := & cloudwatch.MetricDatum {
336
- MetricName : aws .String (action .cwMetricName ),
337
- Unit : aws .String (cloudwatch .StandardUnitCount ),
338
- Value : aws .Float64 (action .data .curSingleDataPoint ),
339
- }
340
- cw .Publish (dataPoint )
332
+ dataPoint := & cloudwatch.MetricDatum {
333
+ MetricName : aws .String (action .cwMetricName ),
334
+ Unit : aws .String (cloudwatch .StandardUnitCount ),
335
+ Value : aws .Float64 (action .data .curSingleDataPoint ),
341
336
}
337
+ cw .Publish (dataPoint )
342
338
case dto .MetricType_SUMMARY :
343
- if t .submitCloudWatch () {
344
- dataPoint := & cloudwatch.MetricDatum {
345
- MetricName : aws .String (action .cwMetricName ),
346
- Unit : aws .String (cloudwatch .StandardUnitCount ),
347
- Value : aws .Float64 (action .data .curSingleDataPoint ),
348
- }
349
- cw .Publish (dataPoint )
339
+ dataPoint := & cloudwatch.MetricDatum {
340
+ MetricName : aws .String (action .cwMetricName ),
341
+ Unit : aws .String (cloudwatch .StandardUnitCount ),
342
+ Value : aws .Float64 (action .data .curSingleDataPoint ),
350
343
}
344
+ cw .Publish (dataPoint )
351
345
case dto .MetricType_HISTOGRAM :
352
- if t .submitCloudWatch () {
353
- produceHistogram (action , cw )
354
- }
346
+ produceHistogram (action , cw )
355
347
}
356
348
}
357
349
}
@@ -378,7 +370,6 @@ func producePrometheusMetrics(t metricsTarget, families map[string]*dto.MetricFa
378
370
}
379
371
}
380
372
}
381
-
382
373
}
383
374
384
375
func resetMetrics (interestingMetrics map [string ]metricsConvert ) {
@@ -451,8 +442,11 @@ func Handler(ctx context.Context, t metricsTarget) {
451
442
t .getLogger ().Infof ("Skipping 1st poll after reset, error: %v" , err )
452
443
}
453
444
454
- cw := t .getCWMetricsPublisher ()
455
- produceCloudWatchMetrics (t , families , interestingMetrics , cw )
445
+ if t .submitCloudWatch () {
446
+ cw := t .getCWMetricsPublisher ()
447
+ produceCloudWatchMetrics (t , families , interestingMetrics , cw )
448
+ }
449
+
456
450
if t .submitPrometheus () {
457
451
producePrometheusMetrics (t , families , interestingMetrics )
458
452
}
0 commit comments