-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from BurtBiel/telemetry/EnableAppInsights
Telemetry/enable app insights [Finished #114911063]
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
applicationinsights==0.10.0 | ||
azure==2.0.0rc1 | ||
mock==1.3.0 | ||
pylint==1.5.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import getpass | ||
from applicationinsights import TelemetryClient | ||
from applicationinsights.exceptions import enable | ||
import azure.cli as cli | ||
|
||
client = {} | ||
|
||
def init_telemetry(): | ||
try: | ||
instrumentation_key = 'eb6e9d3a-b6ee-41a6-804f-70e152fdfc36' | ||
|
||
global client #pylint: disable=global-statement | ||
client = TelemetryClient(instrumentation_key) | ||
|
||
client.context.application.id = 'Azure CLI' | ||
client.context.application.ver = cli.__version__ | ||
client.context.user.id = hash(getpass.getuser()) | ||
|
||
enable(instrumentation_key) | ||
except Exception: #pylint: disable=broad-except | ||
# Never fail the command because of telemetry | ||
pass | ||
|
||
def user_agrees_to_telemetry(): | ||
# TODO: agreement, needs to take Y/N from the command line | ||
# and needs a "skip" param to not show (for scripts) | ||
return True | ||
|
||
def telemetry_flush(): | ||
try: | ||
client.flush() | ||
except Exception: #pylint: disable=broad-except | ||
# Never fail the command because of telemetry | ||
pass |