From 61621d405325f8dca6de228592fdc886ea6d3967 Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Wed, 18 Mar 2020 09:37:35 -0700 Subject: [PATCH] Add extra fields to ORT telemetry (#3234) * Add extra fields to ORT telemetry * fix linux build failure caused by using HRESULT * little refactor --- include/onnxruntime/core/common/common.h | 24 +++++++++---------- .../core/platform/windows/telemetry.cc | 20 ++++++++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/include/onnxruntime/core/common/common.h b/include/onnxruntime/core/common/common.h index a0adf066f6..becc3d39d5 100644 --- a/include/onnxruntime/core/common/common.h +++ b/include/onnxruntime/core/common/common.h @@ -152,25 +152,25 @@ void LogRuntimeError(uint32_t session_id, const common::Status& status, const ch ORT_DISALLOW_COPY_AND_ASSIGNMENT(TypeName); \ ORT_DISALLOW_MOVE(TypeName) -#define ORT_RETURN_IF_ERROR_SESSIONID(expr, session_id) \ - do { \ - auto _status = (expr); \ - if ((!_status.IsOK())) { \ +#define ORT_RETURN_IF_ERROR_SESSIONID(expr, session_id) \ + do { \ + auto _status = (expr); \ + if ((!_status.IsOK())) { \ ::onnxruntime::LogRuntimeError(session_id, _status, __FILE__, __FUNCTION__, __LINE__); \ - return _status; \ - } \ + return _status; \ + } \ } while (0) #define ORT_RETURN_IF_ERROR_SESSIONID_(expr) ORT_RETURN_IF_ERROR_SESSIONID(expr, session_id_) #define ORT_RETURN_IF_ERROR(expr) ORT_RETURN_IF_ERROR_SESSIONID(expr, 0) -#define ORT_THROW_IF_ERROR(expr) \ - do { \ - auto _status = (expr); \ - if ((!_status.IsOK())) { \ +#define ORT_THROW_IF_ERROR(expr) \ + do { \ + auto _status = (expr); \ + if ((!_status.IsOK())) { \ ::onnxruntime::LogRuntimeError(0, _status, __FILE__, __FUNCTION__, __LINE__); \ - ORT_THROW(_status); \ - } \ + ORT_THROW(_status); \ + } \ } while (0) // use this macro when cannot early return diff --git a/onnxruntime/core/platform/windows/telemetry.cc b/onnxruntime/core/platform/windows/telemetry.cc index e5b9598069..1317a4f636 100644 --- a/onnxruntime/core/platform/windows/telemetry.cc +++ b/onnxruntime/core/platform/windows/telemetry.cc @@ -218,6 +218,24 @@ void WindowsTelemetry::LogRuntimeError(uint32_t session_id, const common::Status if (global_register_count_ == 0 || enabled_ == false) return; +#ifdef _WIN32 + HRESULT hr = common::StatusCodeToHRESULT(static_cast(status.Code())); + TraceLoggingWrite(telemetry_provider_handle, + "RuntimeError", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingHResult(hr, "hResult"), + TraceLoggingUInt32(session_id, "sessionId"), + TraceLoggingUInt32(status.Code(), "errorCode"), + TraceLoggingUInt32(status.Category(), "errorCategory"), + TraceLoggingString(status.ErrorMessage().c_str(), "errorMessage"), + TraceLoggingString(file, "file"), + TraceLoggingString(function, "function"), + TraceLoggingInt32(line, "line")); +#else TraceLoggingWrite(telemetry_provider_handle, "RuntimeError", TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), @@ -232,6 +250,7 @@ void WindowsTelemetry::LogRuntimeError(uint32_t session_id, const common::Status TraceLoggingString(file, "file"), TraceLoggingString(function, "function"), TraceLoggingInt32(line, "line")); +#endif } void WindowsTelemetry::LogRuntimePerf(uint32_t session_id, uint32_t total_runs_since_last, int64_t total_run_duration_since_last) const { @@ -240,6 +259,7 @@ void WindowsTelemetry::LogRuntimePerf(uint32_t session_id, uint32_t total_runs_s TraceLoggingWrite(telemetry_provider_handle, "RuntimePerf", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance), TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), // Telemetry info