-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding platform telemetry #2109
Changes from 12 commits
c58b508
1447aeb
c380add
f9ea7a4
ed8c955
176c07c
e16a24d
c2a47fa
e90e6b4
bc1d66c
882f7ab
0c45370
8b07208
8038585
f50935b
fb8393b
beec829
e721907
7d1a1b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ | |
**[Contributions and Feedback](#contribute)** | ||
|
||
**[License](#license)** | ||
|
||
**[Data/Telemetry](#Data/Telemetry)** | ||
*** | ||
# Key Features | ||
## Run any ONNX model | ||
|
@@ -174,3 +176,8 @@ or contact [[email protected]](mailto:[email protected]) with any addi | |
*** | ||
# License | ||
[MIT License](LICENSE) | ||
|
||
# Data/Telemetry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put this above the License #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
This project collects usage data and sends it to Microsoft to help improve our products and services. See the [privacy statement](docs/Privacy.md) for more details. | ||
|
||
For more information on telemetry implementation see the [developer guide](docs/C_API.md#Telemetry). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,12 @@ | |
The example below shows a sample run using the SqueezeNet model from ONNX model zoo, including dynamically reading model inputs, outputs, shape and type information, as well as running a sample vector and fetching the resulting class probabilities for inspection. | ||
|
||
* [../csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp](../csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp) | ||
|
||
# Telemetry | ||
This project collects usage data and sends it to Microsoft to help improve our products and services. Note however that no data collection is performed by default when using your private builds | ||
|
||
Telemetry is turned on by default when using the Official Builds. This is implemented via 'Platform Telemetry' per vendor platform providers (see telemetry.h). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turned "off" by default. Also, is it better to write the documentation in one place and link to it from everywhere else? #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check out my comments on the other doc on why i like have the "spec" be ON by default, and the code will catch up later when we are ready (bug level fixes) . as to the docs spread around a bit, i went back and forth on it :) . pros/cons.
what ya think? In reply to: 335297643 [](ancestors = 335297643) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok as long as we don't end up with inconsistent documentation. @faxu can probably review this and give some comments. #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned above, the spec/documentation should reflect the current state for accuracy. that said, the top-level page (main readme) can be general enough to not require updating once default state changes. The intent of that page is to inform about the presence of telemetry-collecting code. All further details on default states can live on the Privacy info page. The info on how to turn on/off should also be on that Privacy info page, I think. #Resolved |
||
|
||
The Windows provider uses the [TraceLogging](https://docs.microsoft.com/en-us/windows/win32/tracelogging/trace-logging-about) API for its implementation. | ||
|
||
You can turn this off using the DisableTelemetryEvents() API. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Data Collection | ||
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices. | ||
|
||
For more information on telemetry implementation see the [developer guide](C_API.md#Telemetry). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,9 @@ using common::Status; | |
static_cast<void>(fn) | ||
|
||
std::vector<std::string> GetStackTrace(); | ||
// these is a helper function that gets defined by platform/Telemetry | ||
void LogRuntimeError(uint32_t session_id, const common::Status& status, const char* file, | ||
const char* function, uint32_t line); | ||
|
||
// __PRETTY_FUNCTION__ isn't a macro on gcc, so use a check for _MSC_VER | ||
// so we only define it as one for MSVC | ||
|
@@ -137,16 +140,25 @@ std::vector<std::string> GetStackTrace(); | |
ORT_DISALLOW_COPY_AND_ASSIGNMENT(TypeName); \ | ||
ORT_DISALLOW_MOVE(TypeName) | ||
|
||
#define ORT_RETURN_IF_ERROR(expr) \ | ||
do { \ | ||
auto _status = (expr); \ | ||
if ((!_status.IsOK())) return _status; \ | ||
#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; \ | ||
} \ | ||
} 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) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we plan to send events for cases when we just do ORT_THROW? #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch. I first coded ORT_RETURN_IF and ORT_THROW_IF . it covers most all code paths, but not all. how about i file a tracking item in a second PR to catch all of the macros? In reply to: 335302117 [](ancestors = 335302117) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, that's fine. #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
do { \ | ||
auto _status = (expr); \ | ||
if ((!_status.IsOK())) ORT_THROW(_status); \ | ||
if ((!_status.IsOK())) { \ | ||
::onnxruntime::LogRuntimeError(0, _status, __FILE__, __FUNCTION__, __LINE__); \ | ||
ORT_THROW(_status); \ | ||
} \ | ||
} while (0) | ||
|
||
// use this macro when cannot early return | ||
|
@@ -164,8 +176,8 @@ std::vector<std::string> GetStackTrace(); | |
#define GSL_SUPPRESS(tag) | ||
#endif | ||
|
||
inline void MakeStringInternal(std::ostringstream& /*ss*/) noexcept { | ||
} | ||
inline void MakeStringInternal(std::ostringstream& /*ss*/) noexcept { | ||
} | ||
|
||
template <typename T> | ||
inline void MakeStringInternal(std::ostringstream& ss, const T& t) noexcept { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#define ONNXRUNTIME_VERSION_STRING "1.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,8 +266,14 @@ class PosixEnv : public Env { | |
return filename; | ||
} | ||
|
||
// \brief returns a provider that will handle telemetry on the current platform | ||
const Telemetry& GetTelemetryProvider() const override { | ||
return telemetryProvider_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. telemetry_provider_ #Resolved |
||
} | ||
|
||
private: | ||
PosixEnv() = default; | ||
Telemetry telemetryProvider_; | ||
}; | ||
|
||
} // namespace | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "core/platform/telemetry.h" | ||
#include "core/platform/env.h" | ||
|
||
namespace onnxruntime { | ||
|
||
void LogRuntimeError(uint32_t sessionId, const common::Status& status, const char* file, | ||
const char* function, uint32_t line) | ||
{ | ||
const Env& env = Env::Default(); | ||
env.GetTelemetryProvider().LogRuntimeError(sessionId, status, file, function, line); | ||
} | ||
|
||
void Telemetry::EnableTelemetryEvents() const { | ||
} | ||
|
||
void Telemetry::DisableTelemetryEvents() const { | ||
} | ||
|
||
void Telemetry::LogProcessInfo() const { | ||
} | ||
|
||
void Telemetry::LogSessionCreation(uint32_t session_id, int64_t ir_version, const std::string& model_producer_name, | ||
const std::string& model_producer_version, const std::string& model_domain, | ||
const std::unordered_map<std::string, int>& domain_to_version_map, | ||
const std::string& model_graph_name, | ||
const std::unordered_map<std::string, std::string>& model_metadata, | ||
const std::string& loadedFrom, const std::vector<std::string>& execution_provider_ids) const { | ||
ORT_UNUSED_PARAMETER(session_id); | ||
ORT_UNUSED_PARAMETER(ir_version); | ||
ORT_UNUSED_PARAMETER(model_producer_name); | ||
ORT_UNUSED_PARAMETER(model_producer_version); | ||
ORT_UNUSED_PARAMETER(model_domain); | ||
ORT_UNUSED_PARAMETER(domain_to_version_map); | ||
ORT_UNUSED_PARAMETER(model_graph_name); | ||
ORT_UNUSED_PARAMETER(model_metadata); | ||
ORT_UNUSED_PARAMETER(loadedFrom); | ||
ORT_UNUSED_PARAMETER(execution_provider_ids); | ||
} | ||
|
||
void Telemetry::LogRuntimeError(uint32_t session_id, const common::Status& status, const char* file, | ||
const char* function, uint32_t line) const { | ||
ORT_UNUSED_PARAMETER(session_id); | ||
ORT_UNUSED_PARAMETER(status); | ||
ORT_UNUSED_PARAMETER(file); | ||
ORT_UNUSED_PARAMETER(function); | ||
ORT_UNUSED_PARAMETER(line); | ||
} | ||
|
||
void Telemetry::LogRuntimePerf(uint32_t session_id, uint32_t total_runs_since_last, int64_t total_run_duration_since_last) const { | ||
ORT_UNUSED_PARAMETER(session_id); | ||
ORT_UNUSED_PARAMETER(total_runs_since_last); | ||
ORT_UNUSED_PARAMETER(total_run_duration_since_last); | ||
} | ||
|
||
} // namespace onnxruntime | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <unordered_map> | ||
|
||
#include "core/common/status.h" | ||
#include "core/common/common.h" | ||
|
||
namespace onnxruntime { | ||
|
||
/** | ||
* Configuration information for a session. | ||
* An interface used by the onnxruntime implementation to | ||
* access operating system functionality for telemetry | ||
* | ||
* look at env.h and the Env objection which is the activation factory | ||
* for telemetry instances | ||
* | ||
* All Telemetry implementations are safe for concurrent access from | ||
* multiple threads without any external synchronization. | ||
*/ | ||
class Telemetry { | ||
public: | ||
// don't create these, use Env::GetTelemetryProvider() instead | ||
// this constructor is made public so that other platform Env providers can | ||
// use this base class as a "stub" implementation | ||
Telemetry() = default; | ||
virtual ~Telemetry() = default; | ||
|
||
virtual void EnableTelemetryEvents() const; | ||
virtual void DisableTelemetryEvents() const; | ||
|
||
virtual void LogProcessInfo() const; | ||
|
||
virtual void LogSessionCreation(uint32_t session_id, int64_t ir_version, const std::string& model_producer_name, | ||
const std::string& model_producer_version, const std::string& model_domain, | ||
const std::unordered_map<std::string, int>& domain_to_version_map, | ||
const std::string& model_graph_name, | ||
const std::unordered_map<std::string, std::string>& model_metadata, | ||
const std::string& loadedFrom, const std::vector<std::string>& execution_provider_ids) const; | ||
|
||
virtual void LogRuntimeError(uint32_t session_id, const common::Status& status, const char* file, | ||
const char* function, uint32_t line) const; | ||
|
||
virtual void LogRuntimePerf(uint32_t session_id, uint32_t total_runs_since_last, int64_t total_run_duration_since_last) const; | ||
|
||
private: | ||
ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Telemetry); | ||
}; | ||
|
||
} // namespace onnxruntime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must call out that it is disabled by default. #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea was to have the DOCS clear that telemetry will be on by default. then make the code obey that as and when we are ready . What I want to avoid is have the docs say that they are off by default, and then when we later turn the code on it's not super clear that you need to go an read the docs again (aka breaking change). in this manner, the docs and "design" are all such that it is clearly messaged telemetry is ON by default. it's a "bug" that we don't have the code behaving per spec yet. In that fashion we can "fix the code" later and all be good. It isnt a breaking change . you like ?
In reply to: 335297148 [](ancestors = 335297148)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we decided to leave the session option for this to be disabled by default in 1.0 release. The session option config should match the docs, right? Or I'm missing something? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs should reflect the current state. To start, it will be OFF by default. When it's out of preview and ready to fully turn on, we will update the documentation to reflect that state.
For the specific documentation, I suggest:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the docs to denote it is OFF by default during BETA, and to expect it to ON by default once it graduates from BETA (for transparency)
In reply to: 335777476 [](ancestors = 335777476)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change like you suggested, just a heads up that now we have C API specific docs embedded in the privacy statement. If we ever have projections on these (like C# or WinRT) we might have to figure out where to put those docs. I had the turn/on and off in the C_API docs since it was specific to the C_API.
Let me know what you think with the new doc layout !
In reply to: 335829030 [](ancestors = 335829030)