Renames application insights keys to be more clear (#587)

* renames `telemetry_key` to `microsoft_telemetry_key`
* renames `instrumentation_key` to `instance_telemetry_key`
* renames `can_share` to `can_share_with_microsoft`
* renames the `applicationinsights-rs` instances to `internal` and `microsoft` respective of the keys used during construction.

This clarifies the underlying use of Application Insights keys and uses struct tuple to ensure the keys are used correctly via rust's type checker.
This commit is contained in:
bmc-msft
2021-02-26 12:04:49 -05:00
committed by GitHub
parent 8600a44f1f
commit 6a049db3a3
12 changed files with 121 additions and 57 deletions

View File

@ -1021,6 +1021,7 @@ version = "0.1.0"
dependencies = [
"appinsights",
"log",
"serde",
"uuid",
]

View File

@ -3,7 +3,9 @@
use crate::proxy;
use anyhow::Result;
use onefuzz_telemetry::{set_appinsights_clients, EventData, Role};
use onefuzz_telemetry::{
set_appinsights_clients, EventData, InstanceTelemetryKey, MicrosoftTelemetryKey, Role,
};
use reqwest_retry::SendRetry;
use serde::{Deserialize, Serialize};
use std::{fs::File, io::BufReader, path::PathBuf};
@ -43,8 +45,15 @@ pub struct Forward {
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
pub struct ConfigData {
pub instance_id: Uuid,
pub instrumentation_key: Option<Uuid>,
pub telemetry_key: Option<Uuid>,
// TODO: remove the alias once the service has been updated to match
#[serde(alias = "instrumentation_key")]
pub instance_telemetry_key: Option<InstanceTelemetryKey>,
// TODO: remove the alias once the service has been updated to match
#[serde(alias = "telemetry_key")]
pub microsoft_telemetry_key: Option<MicrosoftTelemetryKey>,
pub region: String,
pub url: Url,
pub notification: Url,
@ -73,7 +82,10 @@ impl Config {
let data: ConfigData =
serde_json::from_reader(r).map_err(|source| ProxyError::ParseError { source })?;
set_appinsights_clients(data.instrumentation_key, data.telemetry_key);
set_appinsights_clients(
data.instance_telemetry_key.clone(),
data.microsoft_telemetry_key.clone(),
);
onefuzz_telemetry::set_property(EventData::Region(data.region.to_owned()));
onefuzz_telemetry::set_property(EventData::Version(env!("ONEFUZZ_VERSION").to_string()));