userver-framework / userver

Production-ready C++ Asynchronous Framework with rich functionality
https://userver.tech
Apache License 2.0
2.37k stars 275 forks source link

OTLP: bug timezone #649

Closed root-kidik closed 1 month ago

root-kidik commented 2 months ago
--- a/otlp/src/otlp/logs/logger.cpp
+++ b/otlp/src/otlp/logs/logger.cpp
@@ -118,7 +118,7 @@ void Logger::HandleLog(const std::vector<std::string_view>& key_values) {
     }
     if (key == "timestamp") {
       timestamp = utils::datetime::Stringtime(std::string{value},
-                                              utils::datetime::kDefaultTimezone,
+                                             utils::datetime::LocalTimezoneStringtime(),
                                               kTimestampFormat);
       continue;
     }

if system timezone is UTC, all ok if system timezone another - Loki send error to otlp collector has timestamp to new this fix can help solve this problem

apolukhin commented 1 month ago

Fixed in https://github.com/userver-framework/userver/commit/bedde8b69715441aa6cf4b0be41097bcbfa4a5d9

Many thanks for the bugrepprt!