Skip to content

Commit 43f81fb

Browse files
bmehta001shaahji
andauthored
Add telemetry to track usage and errors (microsoft#2319)
## Add telemetry library and Olive-specific functionality - Convert .NET OneCollector library to Python and add to telemetry/library - Track actions/errors with telemetry decorator - Use heartbeat event to track general usage - Add flag to disable telemetry, if desired (`--disable-telemetry`) - Create telemetry cache so events can be sent when network connectivity is convenient Nits: - Break out version into separate file - Remove Python 3.9 from classifiers, since library only supports 3.10+ - Update minimum onnxscript version needed, since FOLDED_FROM_KEY requires 0.5.3 Description of change for release notes: > Add telemetry to help improve our products and services ## Checklist before requesting a review - [ ] Add unit tests for this change. - [x] Make sure all tests can pass. - [x] Update documents if necessary. - [x] Lint and apply fixes to your code by running `lintrunner -a` - [x] Is this a user-facing change? If yes, give a description of this change to be included in the release notes. --------- Co-authored-by: shaahji <96227573+shaahji@users.noreply.github.com>
1 parent 9147769 commit 43f81fb

45 files changed

Lines changed: 3031 additions & 12 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ The sample chat app to run is found as [model-chat.py](https://github.com/micros
114114
- [Documentation](https://microsoft.github.io/Olive)
115115
- [Recipes](https://github.com/microsoft/olive-recipes)
116116
117+
## Data/Telemetry
118+
Distributions of this project may collect usage data and send it to Microsoft to help improve our products and services. See the [privacy statement](docs/Privacy.md) for more details.
119+
117120
## 🤝 Contributions and Feedback
118121
- We welcome contributions! Please read the [contribution guidelines](./CONTRIBUTING.md) for more details on how to contribute to the Olive project.
119122
- For feature requests or bug reports, file a [GitHub Issue](https://github.com/microsoft/Olive/issues).

docs/Privacy.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Privacy
2+
3+
## Data Collection
4+
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 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 can be found [here](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.
5+
6+
***
7+
8+
## Technical Details
9+
Olive uses the [OpenTelemetry](https://opentelemetry.io/) API for its implementation. Telemetry is turned ON by default. Based on user consent, this data may be periodically sent to Microsoft servers following GDPR and privacy regulations for anonymity and data access controls. Application, device, and version information is collected automatically.
10+
11+
In addition, Olive may collect additional telemetry data such as:
12+
- Invoked commands
13+
- Performance data
14+
- Exception information
15+
16+
Collection of this additional telemetry can be disabled by adding the `--disable_telemetry` flag to any Olive CLI command, or by setting the `OLIVE_DISABLE_TELEMETRY` environment variable to `1` before running. If telemetry is enabled, but cannot be sent to Microsoft, it will be stored locally and sent when a connection is available. You can override the default cache location by setting the `OLIVE_TELEMETRY_CACHE_PATH` environment variable to a valid file path.

olive/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
_logger.addHandler(_sc)
1515
_logger.propagate = False
1616

17-
__version__ = "0.11.0.dev0"
18-
1917
# pylint: disable=C0413
2018

2119
# Import Python API functions
@@ -33,10 +31,12 @@
3331
tune_session_params,
3432
)
3533
from olive.engine.output import ModelOutput, WorkflowOutput # noqa: E402
34+
from olive.version import __version__ # noqa: E402
3635

3736
__all__ = [
3837
"ModelOutput",
3938
"WorkflowOutput",
39+
"__version__",
4040
# Python API functions
4141
"benchmark",
4242
"capture_onnx_graph",

olive/cli/auto_opt.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
add_logging_options,
1515
add_save_config_file_options,
1616
add_shared_cache_options,
17+
add_telemetry_options,
1718
get_input_model_config,
1819
update_accelerator_options,
1920
update_shared_cache_options,
@@ -22,6 +23,7 @@
2223
from olive.constants import Precision
2324
from olive.hardware.constants import ExecutionProvider
2425
from olive.package_config import OlivePackageConfig
26+
from olive.telemetry import action
2527

2628

2729
class AutoOptCommand(BaseOliveCLICommand):
@@ -167,8 +169,10 @@ def register_subcommand(parser: ArgumentParser):
167169
add_shared_cache_options(sub_parser)
168170
add_logging_options(sub_parser)
169171
add_save_config_file_options(sub_parser)
172+
add_telemetry_options(sub_parser)
170173
sub_parser.set_defaults(func=AutoOptCommand)
171174

175+
@action
172176
def run(self):
173177
return self._run_workflow()
174178

olive/cli/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,12 @@ def add_search_options(sub_parser: ArgumentParser):
631631
search_strategy_group.add_argument("--seed", type=int, default=0, help="Random seed for search sampler")
632632

633633

634+
def add_telemetry_options(sub_parser: ArgumentParser):
635+
"""Add telemetry options to the sub_parser."""
636+
sub_parser.add_argument("--disable_telemetry", action="store_true", help="Disable telemetry for this command.")
637+
return sub_parser
638+
639+
634640
def update_search_options(args, config):
635641
to_replace = []
636642
to_replace.extend(

olive/cli/benchmark.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
add_logging_options,
1212
add_save_config_file_options,
1313
add_shared_cache_options,
14+
add_telemetry_options,
1415
get_input_model_config,
1516
update_shared_cache_options,
1617
)
1718
from olive.common.utils import set_nested_dict_value
19+
from olive.telemetry import action
1820

1921

2022
class BenchmarkCommand(BaseOliveCLICommand):
@@ -69,8 +71,10 @@ def register_subcommand(parser: ArgumentParser):
6971
add_logging_options(sub_parser)
7072
add_save_config_file_options(sub_parser)
7173
add_shared_cache_options(sub_parser)
74+
add_telemetry_options(sub_parser)
7275
sub_parser.set_defaults(func=BenchmarkCommand)
7376

77+
@action
7478
def run(self):
7579
return self._run_workflow()
7680

olive/cli/capture_onnx.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
add_logging_options,
1414
add_save_config_file_options,
1515
add_shared_cache_options,
16+
add_telemetry_options,
1617
get_diffusers_input_model,
1718
get_input_model_config,
1819
update_shared_cache_options,
1920
)
2021
from olive.common.utils import set_nested_dict_value
2122
from olive.model.utils.diffusers_utils import is_valid_diffusers_model
23+
from olive.telemetry import action
2224

2325

2426
class ModelBuilderAccuracyLevel(IntEnum):
@@ -170,8 +172,10 @@ def register_subcommand(parser: ArgumentParser):
170172
add_logging_options(sub_parser)
171173
add_save_config_file_options(sub_parser)
172174
add_shared_cache_options(sub_parser)
175+
add_telemetry_options(sub_parser)
173176
sub_parser.set_defaults(func=CaptureOnnxGraphCommand)
174177

178+
@action
175179
def run(self):
176180
return self._run_workflow()
177181

olive/cli/configure_qualcomm_sdk.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# --------------------------------------------------------------------------
55
from argparse import ArgumentParser
66

7-
from olive.cli.base import BaseOliveCLICommand
7+
from olive.cli.base import BaseOliveCLICommand, add_telemetry_options
8+
from olive.telemetry import action
89

910

1011
class ConfigureQualcommSDKCommand(BaseOliveCLICommand):
@@ -21,9 +22,10 @@ def register_subcommand(parser: ArgumentParser):
2122
required=True,
2223
choices=["3.6", "3.8"],
2324
)
24-
25+
add_telemetry_options(sub_parser)
2526
sub_parser.set_defaults(func=ConfigureQualcommSDKCommand)
2627

28+
@action
2729
def run(self):
2830
from olive.platform_sdk.qualcomm.configure.configure import configure
2931

olive/cli/convert_adapters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
from argparse import ArgumentParser
77
from typing import TYPE_CHECKING
88

9-
from olive.cli.base import BaseOliveCLICommand, add_logging_options
9+
from olive.cli.base import BaseOliveCLICommand, add_logging_options, add_telemetry_options
1010
from olive.common.utils import WeightsFileFormat, save_weights
11+
from olive.telemetry import action
1112

1213
if TYPE_CHECKING:
1314
from numpy.typing import NDArray
@@ -75,8 +76,10 @@ def register_subcommand(parser: ArgumentParser):
7576
help="Quantization mode for int4 quantization of adapter weights. Default is symmetric.",
7677
)
7778
add_logging_options(sub_parser)
79+
add_telemetry_options(sub_parser)
7880
sub_parser.set_defaults(func=ConvertAdaptersCommand)
7981

82+
@action
8083
def run(self):
8184
import torch
8285
from peft import LoraConfig, load_peft_weights

olive/cli/diffusion_lora.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
add_logging_options,
1212
add_save_config_file_options,
1313
add_shared_cache_options,
14+
add_telemetry_options,
1415
update_shared_cache_options,
1516
)
1617
from olive.common.utils import set_nested_dict_value
1718
from olive.constants import DiffusersModelVariant
1819
from olive.passes.diffusers.lora import LRSchedulerType, MixedPrecision
20+
from olive.telemetry import action
1921

2022

2123
class DiffusionLoraCommand(BaseOliveCLICommand):
@@ -237,8 +239,10 @@ def register_subcommand(parser: ArgumentParser):
237239
add_shared_cache_options(sub_parser)
238240
add_logging_options(sub_parser)
239241
add_save_config_file_options(sub_parser)
242+
add_telemetry_options(sub_parser)
240243
sub_parser.set_defaults(func=DiffusionLoraCommand)
241244

245+
@action
242246
def run(self):
243247
return self._run_workflow()
244248

0 commit comments

Comments
 (0)