Skip to content

Commit d6c8492

Browse files
zhangxiang1993Pranav Sharma
authored andcommitted
move logSessionCreation after session is initialized (#2481)
1 parent ca8ff8c commit d6c8492

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

onnxruntime/core/session/inference_session.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,7 @@ common::Status InferenceSession::Load(std::function<common::Status(std::shared_p
240240
// all steps complete, mark the model as loaded.
241241
is_model_loaded_ = true;
242242

243-
// and log telemetry
244-
const Env& env = Env::Default();
245-
env.GetTelemetryProvider().LogSessionCreation(session_id_, model_->IrVersion(), model_->ProducerName(), model_->ProducerVersion(),
246-
model_->Domain(), model_->MainGraph().DomainToVersionMap(), model_->MainGraph().Name(),
247-
model_->MetaData(), event_name, execution_providers_.GetIds());
243+
event_name_ = event_name;
248244

249245
} catch (const std::exception& ex) {
250246
status = Status(common::ONNXRUNTIME, common::FAIL, "Exception during loading: " + std::string(ex.what()));
@@ -633,6 +629,13 @@ common::Status InferenceSession::Initialize() {
633629
// handle any subgraphs
634630
ORT_RETURN_IF_ERROR_SESSIONID_(InitializeSubgraphSessions(graph, session_state_));
635631
is_inited_ = true;
632+
633+
// and log telemetry
634+
const Env& env = Env::Default();
635+
env.GetTelemetryProvider().LogSessionCreation(session_id_, model_->IrVersion(), model_->ProducerName(), model_->ProducerVersion(),
636+
model_->Domain(), model_->MainGraph().DomainToVersionMap(), model_->MainGraph().Name(),
637+
model_->MetaData(), event_name_, execution_providers_.GetIds());
638+
636639
LOGS(*session_logger_, INFO) << "Session successfully initialized.";
637640
} catch (const NotImplementedException& ex) {
638641
status = ORT_MAKE_STATUS(ONNXRUNTIME, NOT_IMPLEMENTED, "Exception during initialization: ", ex.what());

onnxruntime/core/session/inference_session.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ class InferenceSession {
445445
long long total_run_duration_since_last_; // the total duration (us) of Run() calls since the last report
446446
TimePoint time_sent_last_; // the TimePoint of the last report
447447
const long long kDurationBetweenSending = 1000* 1000 * 60 * 10; // duration in (us). send a report every 10 mins
448+
std::string event_name_; // where the model is loaded from: ["model_loading_uri", "model_loading_proto", "model_loading_istream"]
448449

449450
#ifdef ONNXRUNTIME_ENABLE_INSTRUMENT
450451
bool session_activity_started_ = false;

0 commit comments

Comments
 (0)