Skip to content

Commit d806a3f

Browse files
committed
fix: add timezone info to timestamp in PowerReport before conversion and sending to OpenTSDB
1 parent d3840c1 commit d806a3f

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)