Skip to content

User/xinzed/telemetry setup#27

Merged
cindydeng1998 merged 7 commits intomainfrom
user/xinzed/telemetry-setup
May 26, 2021
Merged

User/xinzed/telemetry setup#27
cindydeng1998 merged 7 commits intomainfrom
user/xinzed/telemetry-setup

Conversation

@cindydeng1998
Copy link
Contributor

@cindydeng1998 cindydeng1998 commented May 25, 2021

  • add function send_appinsight_telemetry to send to app insight endpoint
  • generate GUID if no correlation id is supplied during usage
  • only send telemetry if user opts in
  • sends telemetry as part of handle_exit function to send exit code
  • TODO: add unique device ID

add_option_args "SCOPE_ID" -s --scope-id
add_option_args "REGISTRATION_ID" -r --registration-id
add_option_args "SYMMETRIC_KEY" -k --symmetric-key
add_option_args "SYMMETRIC_KEY" -cv --correlation-vector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"CORRELATION_VECTOR"?

src/utils.sh Outdated
local e_code=$?
log_info "Exit %d\n" $e_code

send_appinsight_telemetry e_code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$e_code

src/utils.sh Outdated
IngestionEndpoint="https://dc.services.visualstudio.com/v2/track"
EventName="Azure-IoT-Edge-Installer-Summary"
DeviceUniqueID="xinzedPC"
CurrentTime=$(echo `date '+%Y-%m-%dT%H:%M:%S.%N'`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CurrentTime should be generated immediately before the send command

src/utils.sh Outdated
fi
}

export -f send_appinsight_telemetry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export is not needed since we are only using it in the same file?

src/utils.sh Outdated
# handle correlation vector
if [ -z $2 ];
then
CORRELATION_VECTOR=$(uuidgen)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuidgen requires the package 'uuid-runtime' and is not installed on all distributions by default. can we use uuid instead?

src/utils.sh Outdated
local optin=$(get_opt_in_selection )
if [[ $optin == true ]];
then
wget --header='Content-Type: application/json' --header='Accept-Charset: UTF-8' --post-data '{"name":"Microsoft.ApplicationInsights.'$InstrumentationKey'.Event","time": "'$CurrentTime'","iKey": "'$InstrumentationKey'","tags":{"ai.cloud.roleInstance": "'$DeviceUniqueID'"},"data":{"baseType": "EventData","baseData": {"ver": "'$SchemaVersion'","name": "'$EventName'","cv": "'$CORRELATION_VECTOR'","properties":{'$customPropertiesObj'},"measurements":{"duration":57}}}}' $IngestionEndpoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

57

should be $2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is needed. By the time we get here we already know that is is '18.04' :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as ubuntu

VERSION_TAG="v0.0.1"

# where am i
# where am I
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/utils.sh Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we need this for other functions, please move it outside of the function scope in case it causes side effects...

@cindydeng1998 cindydeng1998 merged commit 1504643 into main May 26, 2021
@cindydeng1998 cindydeng1998 deleted the user/xinzed/telemetry-setup branch May 26, 2021 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants