From 60ed832eb5dbf43cf3bf6275ab6600ec783a87af Mon Sep 17 00:00:00 2001 From: Darshak Bhatti Date: Sun, 15 Feb 2026 22:48:19 -0800 Subject: [PATCH 1/3] cp --- onnxruntime/core/platform/telemetry.cc | 30 +++++ onnxruntime/core/platform/telemetry.h | 14 +++ .../core/platform/windows/telemetry.cc | 118 +++++++++++++++++- onnxruntime/core/platform/windows/telemetry.h | 14 +++ onnxruntime/core/session/environment.cc | 8 +- onnxruntime/core/session/inference_session.cc | 43 ++++++- onnxruntime/core/session/inference_session.h | 8 +- 7 files changed, 228 insertions(+), 7 deletions(-) diff --git a/onnxruntime/core/platform/telemetry.cc b/onnxruntime/core/platform/telemetry.cc index bb9130add215a..669059e834dd7 100644 --- a/onnxruntime/core/platform/telemetry.cc +++ b/onnxruntime/core/platform/telemetry.cc @@ -157,4 +157,34 @@ void Telemetry::LogProviderOptions(const std::string& provider_id, ORT_UNUSED_PARAMETER(captureState); } +void Telemetry::LogModelLoadStart(uint32_t session_id) const { + ORT_UNUSED_PARAMETER(session_id); +} + +void Telemetry::LogModelLoadEnd(uint32_t session_id, const common::Status& status) const { + ORT_UNUSED_PARAMETER(session_id); + ORT_UNUSED_PARAMETER(status); +} + +void Telemetry::LogSessionCreationEnd(uint32_t session_id, + const common::Status& status) const { + ORT_UNUSED_PARAMETER(session_id); + ORT_UNUSED_PARAMETER(status); +} + +void Telemetry::LogRunStart(uint32_t session_id, uint64_t run_id) const { + ORT_UNUSED_PARAMETER(session_id); + ORT_UNUSED_PARAMETER(run_id); +} + +void Telemetry::LogRegisterEpLibraryStart(const std::string& registration_name) const { + ORT_UNUSED_PARAMETER(registration_name); +} + +void Telemetry::LogRegisterEpLibraryEnd(const std::string& registration_name, + const common::Status& status) const { + ORT_UNUSED_PARAMETER(registration_name); + ORT_UNUSED_PARAMETER(status); +} + } // namespace onnxruntime diff --git a/onnxruntime/core/platform/telemetry.h b/onnxruntime/core/platform/telemetry.h index e74d7ed0180fd..6a8b3b913ea01 100644 --- a/onnxruntime/core/platform/telemetry.h +++ b/onnxruntime/core/platform/telemetry.h @@ -101,6 +101,20 @@ class Telemetry { const std::string& provider_options_string, bool captureState) const; + virtual void LogModelLoadStart(uint32_t session_id) const; + + virtual void LogModelLoadEnd(uint32_t session_id, const common::Status& status) const; + + virtual void LogSessionCreationEnd(uint32_t session_id, + const common::Status& status) const; + + virtual void LogRunStart(uint32_t session_id, uint64_t run_id) const; + + virtual void LogRegisterEpLibraryStart(const std::string& registration_name) const; + + virtual void LogRegisterEpLibraryEnd(const std::string& registration_name, + const common::Status& status) const; + private: ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Telemetry); }; diff --git a/onnxruntime/core/platform/windows/telemetry.cc b/onnxruntime/core/platform/windows/telemetry.cc index 6d5a400be703b..d6e040ee0c8f8 100644 --- a/onnxruntime/core/platform/windows/telemetry.cc +++ b/onnxruntime/core/platform/windows/telemetry.cc @@ -457,7 +457,8 @@ void WindowsTelemetry::LogCompileModelStart(uint32_t session_id, TraceLoggingInt32(graph_optimization_level, "graphOptimizationLevel"), TraceLoggingBool(embed_ep_context, "embedEpContext"), TraceLoggingBool(has_external_initializers_file, "hasExternalInitializersFile"), - TraceLoggingString(execution_provider_string.c_str(), "executionProviderIds")); + TraceLoggingString(execution_provider_string.c_str(), "executionProviderIds"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); } void WindowsTelemetry::LogCompileModelComplete(uint32_t session_id, @@ -480,7 +481,8 @@ void WindowsTelemetry::LogCompileModelComplete(uint32_t session_id, TraceLoggingBool(success, "success"), TraceLoggingUInt32(error_code, "errorCode"), TraceLoggingUInt32(error_category, "errorCategory"), - TraceLoggingString(error_message.c_str(), "errorMessage")); + TraceLoggingString(error_message.c_str(), "errorMessage"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); } void WindowsTelemetry::LogRuntimeError(uint32_t session_id, const common::Status& status, const char* file, @@ -548,6 +550,7 @@ void WindowsTelemetry::LogRuntimePerf(uint32_t session_id, uint32_t total_runs_s TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance), TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), // Telemetry info TraceLoggingUInt8(0, "schemaVersion"), TraceLoggingUInt32(session_id, "sessionId"), @@ -668,4 +671,115 @@ void WindowsTelemetry::LogProviderOptions(const std::string& provider_id, const } } +void WindowsTelemetry::LogModelLoadStart(uint32_t session_id) const { + if (global_register_count_ == 0 || enabled_ == false) + return; + + TraceLoggingWrite(telemetry_provider_handle, + "ModelLoadStart", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingUInt32(session_id, "sessionId"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); +} + +void WindowsTelemetry::LogModelLoadEnd(uint32_t session_id, const common::Status& status) const { + if (global_register_count_ == 0 || enabled_ == false) + return; + + TraceLoggingWrite(telemetry_provider_handle, + "ModelLoadEnd", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingUInt32(session_id, "sessionId"), + TraceLoggingBool(status.IsOK(), "isSuccess"), + TraceLoggingUInt32(status.Code(), "errorCode"), + TraceLoggingUInt32(status.Category(), "errorCategory"), + TraceLoggingString(status.IsOK() ? "" : status.ErrorMessage().c_str(), "errorMessage"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); +} + +void WindowsTelemetry::LogSessionCreationEnd(uint32_t session_id, + const common::Status& status) const { + if (global_register_count_ == 0 || enabled_ == false) + return; + + TraceLoggingWrite(telemetry_provider_handle, + "SessionCreationEnd", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingUInt32(session_id, "sessionId"), + TraceLoggingBool(status.IsOK(), "isSuccess"), + TraceLoggingUInt32(status.Code(), "errorCode"), + TraceLoggingUInt32(status.Category(), "errorCategory"), + TraceLoggingString(status.IsOK() ? "" : status.ErrorMessage().c_str(), "errorMessage"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); +} + +void WindowsTelemetry::LogRunStart(uint32_t session_id, uint64_t run_id) const { + if (global_register_count_ == 0 || enabled_ == false) + return; + + TraceLoggingWrite(telemetry_provider_handle, + "RunStart", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingUInt32(session_id, "sessionId"), + TraceLoggingUInt64(run_id, "runId"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); +} + +void WindowsTelemetry::LogRegisterEpLibraryStart(const std::string& registration_name) const { + if (global_register_count_ == 0 || enabled_ == false) + return; + + TraceLoggingWrite(telemetry_provider_handle, + "RegisterEpLibraryStart", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingString(registration_name.c_str(), "registrationName"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); +} + +void WindowsTelemetry::LogRegisterEpLibraryEnd(const std::string& registration_name, + const common::Status& status) const { + if (global_register_count_ == 0 || enabled_ == false) + return; + + TraceLoggingWrite(telemetry_provider_handle, + "RegisterEpLibraryEnd", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingString(registration_name.c_str(), "registrationName"), + TraceLoggingBool(status.IsOK(), "isSuccess"), + TraceLoggingUInt32(status.Code(), "errorCode"), + TraceLoggingUInt32(status.Category(), "errorCategory"), + TraceLoggingString(status.IsOK() ? "" : status.ErrorMessage().c_str(), "errorMessage"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); +} + } // namespace onnxruntime diff --git a/onnxruntime/core/platform/windows/telemetry.h b/onnxruntime/core/platform/windows/telemetry.h index 591a248d70ab8..63c8ff8019cb5 100644 --- a/onnxruntime/core/platform/windows/telemetry.h +++ b/onnxruntime/core/platform/windows/telemetry.h @@ -94,6 +94,20 @@ class WindowsTelemetry : public Telemetry { const std::string& provider_options_string, bool captureState) const override; + void LogModelLoadStart(uint32_t session_id) const override; + + void LogModelLoadEnd(uint32_t session_id, const common::Status& status) const override; + + void LogSessionCreationEnd(uint32_t session_id, + const common::Status& status) const override; + + void LogRunStart(uint32_t session_id, uint64_t run_id) const override; + + void LogRegisterEpLibraryStart(const std::string& registration_name) const override; + + void LogRegisterEpLibraryEnd(const std::string& registration_name, + const common::Status& status) const override; + using EtwInternalCallback = std::function; diff --git a/onnxruntime/core/session/environment.cc b/onnxruntime/core/session/environment.cc index 523ff8eaf13b8..105600d1b0ac8 100644 --- a/onnxruntime/core/session/environment.cc +++ b/onnxruntime/core/session/environment.cc @@ -539,8 +539,13 @@ bool AreVirtualDevicesAllowed(std::string_view lib_registration_name) { Status Environment::RegisterExecutionProviderLibrary(const std::string& registration_name, std::unique_ptr ep_library, const std::vector& internal_factories) { + const Env& env = Env::Default(); + env.GetTelemetryProvider().LogRegisterEpLibraryStart(registration_name); + if (ep_libraries_.count(registration_name) > 0) { - return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "library is already registered under ", registration_name); + auto status = ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "library is already registered under ", registration_name); + env.GetTelemetryProvider().LogRegisterEpLibraryEnd(registration_name, status); + return status; } auto status = Status::OK(); @@ -592,6 +597,7 @@ Status Environment::RegisterExecutionProviderLibrary(const std::string& registra }); } + env.GetTelemetryProvider().LogRegisterEpLibraryEnd(registration_name, status); return status; } diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index c00d63d0be8a2..089a87e0d886c 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -976,6 +976,9 @@ common::Status InferenceSession::LoadWithLoader(std::function l(session_mutex_); if (is_model_loaded_) { // already loaded LOGS(*session_logger_, ERROR) << "This session already contains a loaded model."; @@ -1011,6 +1014,11 @@ common::Status InferenceSession::LoadWithLoader(std::function load_ort_format_model_bytes) { + const Env& env = Env::Default(); + env.GetTelemetryProvider().LogModelLoadStart(session_id_); + std::lock_guard l(session_mutex_); if (is_model_loaded_) { // already loaded @@ -1767,6 +1778,8 @@ Status InferenceSession::LoadOrtModelWithLoader(std::function load_ort is_model_loaded_ = true; + env.GetTelemetryProvider().LogModelLoadEnd(session_id_, Status::OK()); + return Status::OK(); } @@ -2618,6 +2631,12 @@ common::Status InferenceSession::Initialize() { } } + // Log session creation end telemetry + { + const Env& init_env = Env::Default(); + init_env.GetTelemetryProvider().LogSessionCreationEnd(session_id_, status); + } + return status; } #if defined(_MSC_VER) && !defined(__clang__) @@ -3015,6 +3034,22 @@ Status InferenceSession::Run(const RunOptions& run_options, Status retval = Status::OK(); const Env& env = Env::Default(); + // Assign a unique run_id for telemetry correlation + const uint64_t run_id = run_id_counter_.fetch_add(1); + + // Determine whether to emit Run telemetry (LogRunStart + LogRuntimePerf pair) + bool emit_run_telemetry = false; + { + std::lock_guard telemetry_lock(telemetry_mutex_); + if (TimeDiffMicroSeconds(telemetry_.time_sent_last_) > telemetry_.runtime_perf_interval_) { + emit_run_telemetry = true; + } + } + + if (emit_run_telemetry) { + env.GetTelemetryProvider().LogRunStart(session_id_, run_id); + } + int graph_annotation_id = 0; const std::string& graph_annotation_str = run_options.config_options.GetConfigOrDefault(kOrtRunOptionsConfigCudaGraphAnnotation, ""); @@ -3210,8 +3245,8 @@ Status InferenceSession::Run(const RunOptions& run_options, telemetry_.total_run_duration_since_last_ += TimeDiffMicroSeconds(tp); telemetry_.duration_per_batch_size_[batch_size] += TimeDiffMicroSeconds(tp); - if (TimeDiffMicroSeconds(telemetry_.time_sent_last_) > Telemetry::kDurationBetweenSending) { - // send the telemetry + // Emit RuntimePerf paired with the LogRunStart that fired at entry + if (emit_run_telemetry) { env.GetTelemetryProvider().LogRuntimePerf(session_id_, telemetry_.total_runs_since_last_, telemetry_.total_run_duration_since_last_, telemetry_.duration_per_batch_size_); @@ -3220,6 +3255,10 @@ Status InferenceSession::Run(const RunOptions& run_options, telemetry_.total_runs_since_last_ = 0; telemetry_.total_run_duration_since_last_ = 0; telemetry_.duration_per_batch_size_.clear(); + + // Double the interval, capping at kRuntimePerfMaxInterval + telemetry_.runtime_perf_interval_ = std::min(telemetry_.runtime_perf_interval_ * 2, + Telemetry::kRuntimePerfMaxInterval); } } diff --git a/onnxruntime/core/session/inference_session.h b/onnxruntime/core/session/inference_session.h index 1dbf0318c988c..e168e99426e2e 100644 --- a/onnxruntime/core/session/inference_session.h +++ b/onnxruntime/core/session/inference_session.h @@ -976,10 +976,14 @@ class InferenceSession { std::unordered_map duration_per_batch_size_; // the duration (us) of Run() calls per batch size since the last report TimePoint time_sent_last_; // the TimePoint of the last report - // Event Rate per provider < 20 peak events per second - constexpr static long long kDurationBetweenSending = 1000 * 1000 * 60 * 10; // duration in (us). send a report every 10 mins + // RuntimePerf backoff: starts at 2s, doubles each emission, caps at 10 min + constexpr static long long kRuntimePerfInitialInterval = 2 * 1000 * 1000; // 2 seconds in (us) + constexpr static long long kRuntimePerfMaxInterval = 1000 * 1000 * 60 * 10; // 10 minutes in (us) + long long runtime_perf_interval_ = kRuntimePerfInitialInterval; } telemetry_; + std::atomic run_id_counter_{0}; // monotonically increasing run id for correlation + mutable std::mutex telemetry_mutex_; // to ensure thread-safe access to telemetry data #ifdef ONNXRUNTIME_ENABLE_INSTRUMENT From 13aeb82524f372ba6f96a83c8873d30c92a54f92 Mon Sep 17 00:00:00 2001 From: Darshak Bhatti Date: Sun, 15 Feb 2026 23:35:18 -0800 Subject: [PATCH 2/3] cp --- onnxruntime/core/platform/telemetry.cc | 6 ++++++ onnxruntime/core/platform/telemetry.h | 3 +++ onnxruntime/core/platform/windows/telemetry.cc | 18 ++++++++++++++++++ onnxruntime/core/platform/windows/telemetry.h | 3 +++ onnxruntime/core/session/environment.cc | 2 ++ 5 files changed, 32 insertions(+) diff --git a/onnxruntime/core/platform/telemetry.cc b/onnxruntime/core/platform/telemetry.cc index 669059e834dd7..696c588a456cf 100644 --- a/onnxruntime/core/platform/telemetry.cc +++ b/onnxruntime/core/platform/telemetry.cc @@ -177,6 +177,12 @@ void Telemetry::LogRunStart(uint32_t session_id, uint64_t run_id) const { ORT_UNUSED_PARAMETER(run_id); } +void Telemetry::LogRegisterEpLibraryWithLibPath(const std::string& registration_name, + const std::string& lib_path) const { + ORT_UNUSED_PARAMETER(registration_name); + ORT_UNUSED_PARAMETER(lib_path); +} + void Telemetry::LogRegisterEpLibraryStart(const std::string& registration_name) const { ORT_UNUSED_PARAMETER(registration_name); } diff --git a/onnxruntime/core/platform/telemetry.h b/onnxruntime/core/platform/telemetry.h index 6a8b3b913ea01..5fbd3795b98ff 100644 --- a/onnxruntime/core/platform/telemetry.h +++ b/onnxruntime/core/platform/telemetry.h @@ -110,6 +110,9 @@ class Telemetry { virtual void LogRunStart(uint32_t session_id, uint64_t run_id) const; + virtual void LogRegisterEpLibraryWithLibPath(const std::string& registration_name, + const std::string& lib_path) const; + virtual void LogRegisterEpLibraryStart(const std::string& registration_name) const; virtual void LogRegisterEpLibraryEnd(const std::string& registration_name, diff --git a/onnxruntime/core/platform/windows/telemetry.cc b/onnxruntime/core/platform/windows/telemetry.cc index d6e040ee0c8f8..99cf1e1e56533 100644 --- a/onnxruntime/core/platform/windows/telemetry.cc +++ b/onnxruntime/core/platform/windows/telemetry.cc @@ -745,6 +745,24 @@ void WindowsTelemetry::LogRunStart(uint32_t session_id, uint64_t run_id) const { TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); } +void WindowsTelemetry::LogRegisterEpLibraryWithLibPath(const std::string& registration_name, + const std::string& lib_path) const { + if (global_register_count_ == 0 || enabled_ == false) + return; + + TraceLoggingWrite(telemetry_provider_handle, + "RegisterEpLibraryWithLibPath", + TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), + TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingLevel(WINEVENT_LEVEL_INFO), + // Telemetry info + TraceLoggingUInt8(0, "schemaVersion"), + TraceLoggingString(registration_name.c_str(), "registrationName"), + TraceLoggingString(lib_path.c_str(), "libPath"), + TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); +} + void WindowsTelemetry::LogRegisterEpLibraryStart(const std::string& registration_name) const { if (global_register_count_ == 0 || enabled_ == false) return; diff --git a/onnxruntime/core/platform/windows/telemetry.h b/onnxruntime/core/platform/windows/telemetry.h index 63c8ff8019cb5..a41b085ddc618 100644 --- a/onnxruntime/core/platform/windows/telemetry.h +++ b/onnxruntime/core/platform/windows/telemetry.h @@ -103,6 +103,9 @@ class WindowsTelemetry : public Telemetry { void LogRunStart(uint32_t session_id, uint64_t run_id) const override; + void LogRegisterEpLibraryWithLibPath(const std::string& registration_name, + const std::string& lib_path) const override; + void LogRegisterEpLibraryStart(const std::string& registration_name) const override; void LogRegisterEpLibraryEnd(const std::string& registration_name, diff --git a/onnxruntime/core/session/environment.cc b/onnxruntime/core/session/environment.cc index 105600d1b0ac8..049d70209d878 100644 --- a/onnxruntime/core/session/environment.cc +++ b/onnxruntime/core/session/environment.cc @@ -617,6 +617,8 @@ Status Environment::CreateAndRegisterInternalEps() { Status Environment::RegisterExecutionProviderLibrary(const std::string& registration_name, const ORTCHAR_T* lib_path) { std::lock_guard lock{mutex_}; + Env::Default().GetTelemetryProvider().LogRegisterEpLibraryWithLibPath(registration_name, ToUTF8String(lib_path)); + std::vector internal_factories = {}; std::unique_ptr ep_library; From 1512f14b25932a6e7e35b48720590f3bd0328618 Mon Sep 17 00:00:00 2001 From: Darshak Bhatti Date: Sun, 15 Feb 2026 23:45:34 -0800 Subject: [PATCH 3/3] cleanup --- onnxruntime/core/platform/telemetry.cc | 3 +-- onnxruntime/core/platform/telemetry.h | 2 +- onnxruntime/core/platform/windows/telemetry.cc | 4 +--- onnxruntime/core/platform/windows/telemetry.h | 2 +- onnxruntime/core/session/inference_session.cc | 9 +++------ onnxruntime/core/session/inference_session.h | 2 -- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/onnxruntime/core/platform/telemetry.cc b/onnxruntime/core/platform/telemetry.cc index 696c588a456cf..3ee57e62e2672 100644 --- a/onnxruntime/core/platform/telemetry.cc +++ b/onnxruntime/core/platform/telemetry.cc @@ -172,9 +172,8 @@ void Telemetry::LogSessionCreationEnd(uint32_t session_id, ORT_UNUSED_PARAMETER(status); } -void Telemetry::LogRunStart(uint32_t session_id, uint64_t run_id) const { +void Telemetry::LogRunStart(uint32_t session_id) const { ORT_UNUSED_PARAMETER(session_id); - ORT_UNUSED_PARAMETER(run_id); } void Telemetry::LogRegisterEpLibraryWithLibPath(const std::string& registration_name, diff --git a/onnxruntime/core/platform/telemetry.h b/onnxruntime/core/platform/telemetry.h index 5fbd3795b98ff..47fd2ca1a9e12 100644 --- a/onnxruntime/core/platform/telemetry.h +++ b/onnxruntime/core/platform/telemetry.h @@ -108,7 +108,7 @@ class Telemetry { virtual void LogSessionCreationEnd(uint32_t session_id, const common::Status& status) const; - virtual void LogRunStart(uint32_t session_id, uint64_t run_id) const; + virtual void LogRunStart(uint32_t session_id) const; virtual void LogRegisterEpLibraryWithLibPath(const std::string& registration_name, const std::string& lib_path) const; diff --git a/onnxruntime/core/platform/windows/telemetry.cc b/onnxruntime/core/platform/windows/telemetry.cc index 99cf1e1e56533..bbae6daa1e9d7 100644 --- a/onnxruntime/core/platform/windows/telemetry.cc +++ b/onnxruntime/core/platform/windows/telemetry.cc @@ -550,7 +550,6 @@ void WindowsTelemetry::LogRuntimePerf(uint32_t session_id, uint32_t total_runs_s TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance), TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), - TraceLoggingLevel(WINEVENT_LEVEL_INFO), // Telemetry info TraceLoggingUInt8(0, "schemaVersion"), TraceLoggingUInt32(session_id, "sessionId"), @@ -728,7 +727,7 @@ void WindowsTelemetry::LogSessionCreationEnd(uint32_t session_id, TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); } -void WindowsTelemetry::LogRunStart(uint32_t session_id, uint64_t run_id) const { +void WindowsTelemetry::LogRunStart(uint32_t session_id) const { if (global_register_count_ == 0 || enabled_ == false) return; @@ -741,7 +740,6 @@ void WindowsTelemetry::LogRunStart(uint32_t session_id, uint64_t run_id) const { // Telemetry info TraceLoggingUInt8(0, "schemaVersion"), TraceLoggingUInt32(session_id, "sessionId"), - TraceLoggingUInt64(run_id, "runId"), TraceLoggingString(ORT_CALLER_FRAMEWORK, "frameworkName")); } diff --git a/onnxruntime/core/platform/windows/telemetry.h b/onnxruntime/core/platform/windows/telemetry.h index a41b085ddc618..caedbfbd42ece 100644 --- a/onnxruntime/core/platform/windows/telemetry.h +++ b/onnxruntime/core/platform/windows/telemetry.h @@ -101,7 +101,7 @@ class WindowsTelemetry : public Telemetry { void LogSessionCreationEnd(uint32_t session_id, const common::Status& status) const override; - void LogRunStart(uint32_t session_id, uint64_t run_id) const override; + void LogRunStart(uint32_t session_id) const override; void LogRegisterEpLibraryWithLibPath(const std::string& registration_name, const std::string& lib_path) const override; diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index 089a87e0d886c..ef2174179a186 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -3034,10 +3034,7 @@ Status InferenceSession::Run(const RunOptions& run_options, Status retval = Status::OK(); const Env& env = Env::Default(); - // Assign a unique run_id for telemetry correlation - const uint64_t run_id = run_id_counter_.fetch_add(1); - - // Determine whether to emit Run telemetry (LogRunStart + LogRuntimePerf pair) + // Determine whether to emit Run telemetry bool emit_run_telemetry = false; { std::lock_guard telemetry_lock(telemetry_mutex_); @@ -3047,7 +3044,7 @@ Status InferenceSession::Run(const RunOptions& run_options, } if (emit_run_telemetry) { - env.GetTelemetryProvider().LogRunStart(session_id_, run_id); + env.GetTelemetryProvider().LogRunStart(session_id_); } int graph_annotation_id = 0; @@ -3245,7 +3242,7 @@ Status InferenceSession::Run(const RunOptions& run_options, telemetry_.total_run_duration_since_last_ += TimeDiffMicroSeconds(tp); telemetry_.duration_per_batch_size_[batch_size] += TimeDiffMicroSeconds(tp); - // Emit RuntimePerf paired with the LogRunStart that fired at entry + // Emit RuntimePerf if (emit_run_telemetry) { env.GetTelemetryProvider().LogRuntimePerf(session_id_, telemetry_.total_runs_since_last_, telemetry_.total_run_duration_since_last_, diff --git a/onnxruntime/core/session/inference_session.h b/onnxruntime/core/session/inference_session.h index e168e99426e2e..a29eba1cdacca 100644 --- a/onnxruntime/core/session/inference_session.h +++ b/onnxruntime/core/session/inference_session.h @@ -982,8 +982,6 @@ class InferenceSession { long long runtime_perf_interval_ = kRuntimePerfInitialInterval; } telemetry_; - std::atomic run_id_counter_{0}; // monotonically increasing run id for correlation - mutable std::mutex telemetry_mutex_; // to ensure thread-safe access to telemetry data #ifdef ONNXRUNTIME_ENABLE_INSTRUMENT