handle python2 encoding

This commit is contained in:
Ulric Qin 2021-12-31 11:13:57 +08:00
parent a56d6b568b
commit e9ce679649
2 changed files with 6 additions and 3 deletions

View File

@ -6,6 +6,9 @@ import urllib2
import smtplib
from email.mime.text import MIMEText
reload(sys)
sys.setdefaultencoding('utf8')
notify_channel_funcs = {
"email":"email",
"sms":"sms",

View File

@ -42,11 +42,11 @@ func (m *DatadogMetric) Clean() error {
func (m *DatadogMetric) ToProm() (*prompb.TimeSeries, string, error) {
pt := &prompb.TimeSeries{}
for _, point := range m.Points {
for i := 0; i < len(m.Points); i++ {
pt.Samples = append(pt.Samples, prompb.Sample{
// use ms
Timestamp: int64(point[0]) * 1000,
Value: point[1],
Timestamp: int64(m.Points[i][0]) * 1000,
Value: m.Points[i][1],
})
}