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

@ -166,13 +166,11 @@ pub fn build_common_config(args: &ArgMatches<'_>) -> Result<CommonConfig> {
};
let config = CommonConfig {
heartbeat_queue: None,
instrumentation_key: None,
telemetry_key: None,
job_id,
task_id,
instance_id,
setup_dir,
..Default::default()
};
Ok(config)
}

View File

@ -23,7 +23,10 @@ pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> {
}
fn init_telemetry(config: &CommonConfig) {
onefuzz_telemetry::set_appinsights_clients(config.instrumentation_key, config.telemetry_key);
onefuzz_telemetry::set_appinsights_clients(
config.instance_telemetry_key.clone(),
config.microsoft_telemetry_key.clone(),
);
}
pub fn args(name: &str) -> App<'static, 'static> {

View File

@ -5,7 +5,10 @@
use crate::tasks::{analysis, coverage, fuzz, heartbeat::*, merge, report};
use anyhow::Result;
use onefuzz::machine_id::{get_machine_id, get_scaleset_name};
use onefuzz_telemetry::{self as telemetry, Event::task_start, EventData, Role};
use onefuzz_telemetry::{
self as telemetry, Event::task_start, EventData, InstanceTelemetryKey, MicrosoftTelemetryKey,
Role,
};
use reqwest::Url;
use serde::{self, Deserialize};
use std::path::PathBuf;
@ -26,11 +29,15 @@ pub struct CommonConfig {
pub instance_id: Uuid,
pub instrumentation_key: Option<Uuid>,
pub heartbeat_queue: Option<Url>,
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>,
#[serde(default)]
pub setup_dir: PathBuf,