Skip to content

Commit 98b3564

Browse files
authored
Merge pull request #564 from TomeMD/fix/issue563/opentsdb-bad-timestamp
fix(database/opentsdb): Add timezone info to timestamp before sending to OpenTSDB
2 parents d3840c1 + d806a3f commit 98b3564

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/powerapi/database/opentsdb/opentsdb.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

3030
import logging
31+
from datetime import timezone
3132
try:
3233
from opentsdb import TSDBClient
3334
except ImportError:
@@ -101,8 +102,8 @@ def save(self, report: PowerReport):
101102
102103
:param report: Report to save
103104
"""
104-
self.client.send(self.metric_name, report.power, timestamp=int(report.timestamp.timestamp()),
105-
host=report.target)
105+
self.client.send(self.metric_name, report.power,
106+
timestamp=int(report.timestamp.replace(tzinfo=timezone.utc).timestamp()), host=report.target)
106107

107108
def save_many(self, reports: list[Report]):
108109
"""

0 commit comments

Comments
 (0)