Skip to content

Commit 6789e64

Browse files
xieofxiehualxie
andcommitted
add session_id_ to LogEvaluationStart/Stop, LogSessionCreationStart (#25590)
### Description <!-- Describe your changes. --> use session id to track them with LogSessionCreation if we call Run in different threads, we could differentiate them with thread id given Run is not async ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: hualxie <[email protected]>
1 parent fa3f6e3 commit 6789e64

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

onnxruntime/core/platform/telemetry.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ void Telemetry::SetLanguageProjection(uint32_t projection) const {
4040
void Telemetry::LogProcessInfo() const {
4141
}
4242

43-
void Telemetry::LogSessionCreationStart() const {
43+
void Telemetry::LogSessionCreationStart(uint32_t session_id) const {
44+
ORT_UNUSED_PARAMETER(session_id);
4445
}
4546

46-
void Telemetry::LogEvaluationStop() const {
47+
void Telemetry::LogEvaluationStop(uint32_t session_id) const {
48+
ORT_UNUSED_PARAMETER(session_id);
4749
}
4850

49-
void Telemetry::LogEvaluationStart() const {
51+
void Telemetry::LogEvaluationStart(uint32_t session_id) const {
52+
ORT_UNUSED_PARAMETER(session_id);
5053
}
5154

5255
void Telemetry::LogSessionCreation(uint32_t session_id, int64_t ir_version, const std::string& model_producer_name,

onnxruntime/core/platform/telemetry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ class Telemetry {
4848

4949
virtual void LogProcessInfo() const;
5050

51-
virtual void LogSessionCreationStart() const;
51+
virtual void LogSessionCreationStart(uint32_t session_id) const;
5252

53-
virtual void LogEvaluationStop() const;
53+
virtual void LogEvaluationStop(uint32_t session_id) const;
5454

55-
virtual void LogEvaluationStart() const;
55+
virtual void LogEvaluationStart(uint32_t session_id) const;
5656

5757
virtual void LogSessionCreation(uint32_t session_id, int64_t ir_version, const std::string& model_producer_name,
5858
const std::string& model_producer_version, const std::string& model_domain,

onnxruntime/core/platform/windows/telemetry.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void WindowsTelemetry::LogProcessInfo() const {
194194
process_info_logged = true;
195195
}
196196

197-
void WindowsTelemetry::LogSessionCreationStart() const {
197+
void WindowsTelemetry::LogSessionCreationStart(uint32_t session_id) const {
198198
if (global_register_count_ == 0 || enabled_ == false)
199199
return;
200200

@@ -203,23 +203,26 @@ void WindowsTelemetry::LogSessionCreationStart() const {
203203
TraceLoggingBool(true, "UTCReplace_AppSessionGuid"),
204204
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage),
205205
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
206+
TraceLoggingUInt32(session_id, "sessionId"),
206207
TraceLoggingLevel(WINEVENT_LEVEL_INFO));
207208
}
208209

209-
void WindowsTelemetry::LogEvaluationStop() const {
210+
void WindowsTelemetry::LogEvaluationStop(uint32_t session_id) const {
210211
if (global_register_count_ == 0 || enabled_ == false)
211212
return;
212213

213214
TraceLoggingWrite(telemetry_provider_handle,
214-
"EvaluationStop");
215+
"EvaluationStop",
216+
TraceLoggingUInt32(session_id, "sessionId"));
215217
}
216218

217-
void WindowsTelemetry::LogEvaluationStart() const {
219+
void WindowsTelemetry::LogEvaluationStart(uint32_t session_id) const {
218220
if (global_register_count_ == 0 || enabled_ == false)
219221
return;
220222

221223
TraceLoggingWrite(telemetry_provider_handle,
222-
"EvaluationStart");
224+
"EvaluationStart",
225+
TraceLoggingUInt32(session_id, "sessionId"));
223226
}
224227

225228
void WindowsTelemetry::LogSessionCreation(uint32_t session_id, int64_t ir_version, const std::string& model_producer_name,

onnxruntime/core/platform/windows/telemetry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class WindowsTelemetry : public Telemetry {
4141

4242
void LogProcessInfo() const override;
4343

44-
void LogSessionCreationStart() const override;
44+
void LogSessionCreationStart(uint32_t session_id) const override;
4545

46-
void LogEvaluationStop() const override;
46+
void LogEvaluationStop(uint32_t session_id) const override;
4747

48-
void LogEvaluationStart() const override;
48+
void LogEvaluationStart(uint32_t session_id) const override;
4949

5050
void LogSessionCreation(uint32_t session_id, int64_t ir_version, const std::string& model_producer_name,
5151
const std::string& model_producer_version, const std::string& model_domain,

onnxruntime/core/session/inference_session.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ common::Status InferenceSession::Initialize() {
20412041
ORT_TRY {
20422042
LOGS(*session_logger_, INFO) << "Initializing session.";
20432043
const Env& env = Env::Default();
2044-
env.GetTelemetryProvider().LogSessionCreationStart();
2044+
env.GetTelemetryProvider().LogSessionCreationStart(session_id_);
20452045

20462046
bool have_cpu_ep = false;
20472047

@@ -2980,7 +2980,7 @@ Status InferenceSession::Run(const RunOptions& run_options,
29802980
}
29812981

29822982
// log evaluation start to trace logging provider
2983-
env.GetTelemetryProvider().LogEvaluationStart();
2983+
env.GetTelemetryProvider().LogEvaluationStart(session_id_);
29842984

29852985
ORT_RETURN_IF_ERROR_SESSIONID_(ValidateInputs(feed_names, feeds));
29862986
ORT_RETURN_IF_ERROR_SESSIONID_(ValidateOutputs(output_names, p_fetches));
@@ -3133,7 +3133,7 @@ Status InferenceSession::Run(const RunOptions& run_options,
31333133
}
31343134

31353135
// log evaluation stop to trace logging provider
3136-
env.GetTelemetryProvider().LogEvaluationStop();
3136+
env.GetTelemetryProvider().LogEvaluationStop(session_id_);
31373137

31383138
// send out profiling events (optional)
31393139
if (session_profiler_.IsEnabled()) {

0 commit comments

Comments
 (0)