Add extra fields to ORT telemetry (#3234)

* Add extra fields to ORT telemetry

* fix linux build failure caused by using HRESULT

* little refactor
This commit is contained in:
Xiang Zhang 2020-03-18 09:37:35 -07:00 committed by GitHub
parent bd348ec6ca
commit 61621d4053
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 12 deletions

View file

@ -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

View file

@ -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<common::StatusCode>(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