From 366e73fb7b440f0eac25d76f5f5279106984a14d Mon Sep 17 00:00:00 2001 From: Matt Weagle Date: Fri, 29 Nov 2019 22:43:18 -0800 Subject: [PATCH] Log error --- aws/cloudwatch/structured_metric.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aws/cloudwatch/structured_metric.go b/aws/cloudwatch/structured_metric.go index 78a9dde73..78a071675 100644 --- a/aws/cloudwatch/structured_metric.go +++ b/aws/cloudwatch/structured_metric.go @@ -156,10 +156,14 @@ func (em *EmbeddedMetric) PublishToSink(additionalProperties map[string]interfac em = em.WithProperty(eachKey, eachValue) } rawJSON, rawJSONErr := json.Marshal(em) + var writtenErr error if rawJSONErr == nil { - io.WriteString(sink, (string)(rawJSON)) + _, writtenErr = io.WriteString(sink, (string)(rawJSON)) } else { - io.WriteString(sink, fmt.Sprintf("Error publishing metric: %v", rawJSONErr)) + _, writtenErr = io.WriteString(sink, fmt.Sprintf("Error publishing metric: %v", rawJSONErr)) + } + if writtenErr != nil { + fmt.Printf("ERROR: %#v", writtenErr) } }