diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h index 2ab92a050c..fe3f7b3d4a 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h @@ -363,11 +363,11 @@ class ETWProvider } } - // forwardMessage.push_back(nameField); nlohmann::json payloadPair = nlohmann::json::array(); - payloadPair.push_back(utils::GetMsgPackEventTimeFromSystemTimestamp(std::chrono::system_clock::now())); + payloadPair.push_back( + utils::GetMsgPackEventTimeFromSystemTimestamp(std::chrono::system_clock::now())); payloadPair.push_back(jObj); nlohmann::json payloadArray = nlohmann::json::array({payloadPair}); diff --git a/exporters/etw/include/opentelemetry/exporters/etw/utils.h b/exporters/etw/include/opentelemetry/exporters/etw/utils.h index 7c4f057529..fbf1a2ad52 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/utils.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/utils.h @@ -388,45 +388,45 @@ static inline void PopulateAttribute(nlohmann::json &attribute, #if defined(HAVE_MSGPACK) static inline nlohmann::byte_container_with_subtype> -get_msgpack_eventtimeext(int32_t seconds = 0, int32_t nanoseconds = 0) { - if ((seconds == 0) && (nanoseconds == 0)) { +get_msgpack_eventtimeext(int32_t seconds = 0, int32_t nanoseconds = 0) +{ + if ((seconds == 0) && (nanoseconds == 0)) + { std::chrono::system_clock::time_point tp = std::chrono::system_clock::now(); - auto duration = tp.time_since_epoch(); - seconds = static_cast( - std::chrono::duration_cast(duration).count()); + auto duration = tp.time_since_epoch(); + seconds = + static_cast(std::chrono::duration_cast(duration).count()); nanoseconds = static_cast( - std::chrono::duration_cast(duration).count() % - 1000000000); + std::chrono::duration_cast(duration).count() % 1000000000); } - uint64_t timestamp = ((static_cast(seconds/100)) & ((1ull << 34) - 1)) | - ((static_cast(seconds % 100 * 1e7 + nanoseconds/100) & ((1ull << 30) - 1)) << 34); + uint64_t timestamp = + ((static_cast(seconds / 100)) & ((1ull << 34) - 1)) | + ((static_cast(seconds % 100 * 1e7 + nanoseconds / 100) & ((1ull << 30) - 1)) << 34); - nlohmann::byte_container_with_subtype> ts{ - std::vector(8)}; - for (int i = 0; i < 8; i++) { - ts[i] = timestamp & 0xff; - timestamp >>= 8; + nlohmann::byte_container_with_subtype> ts{std::vector(8)}; + for (int i = 0; i < 8; i++) + { + ts[i] = timestamp & 0xff; + timestamp >>= 8; } ts.set_subtype(0x00); return ts; } static inline nlohmann::byte_container_with_subtype> - GetMsgPackEventTimeFromSystemTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept { +GetMsgPackEventTimeFromSystemTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept +{ return get_msgpack_eventtimeext( // Add all whole seconds to the event time - static_cast(std::chrono::duration_cast( - timestamp.time_since_epoch()) - .count()), + static_cast( + std::chrono::duration_cast(timestamp.time_since_epoch()).count()), // Add any remaining nanoseconds past the last whole second - std::chrono::duration_cast( - timestamp.time_since_epoch()) - .count() % - 1000000000); + std::chrono::duration_cast(timestamp.time_since_epoch()).count() % + 1e9); } -#endif // defined(HAVE_MSGPACK) +#endif // defined(HAVE_MSGPACK) }; // namespace utils