in src/Common/AzurePSCmdlet.cs [735:804]
protected virtual void InitializeQosEvent()
{
_qosEvent = new AzurePSQoSEvent()
{
ClientRequestId = this._clientRequestId,
// Use SessionId from MetricHelper so that generated cmdlet and handcrafted cmdlet could share the same Id
SessionId = MetricHelper.SessionId,
IsSuccess = true,
ParameterSetName = this.ParameterSetName,
PreviousEndTime = _previousEndTime
};
if (AzVersion == null)
{
AzVersion = this.LoadModuleVersion("Az", true);
PowerShellVersion = this.LoadPowerShellVersion();
PSHostName = this.Host?.Name;
PSHostVersion = this.Host?.Version?.ToString();
}
UserAgent = new ProductInfoHeaderValue("AzurePowershell", string.Format("Az{0}", AzVersion)).ToString();
string hostEnv = AzurePSCmdlet.getEnvUserAgent();
if (!String.IsNullOrWhiteSpace(hostEnv))
UserAgent += string.Format(" {0}", hostEnv);
if (AzAccountsVersion == null)
{
AzAccountsVersion = this.LoadModuleVersion("Az.Accounts", false);
}
_qosEvent.AzVersion = AzVersion;
_qosEvent.AzAccountsVersion = AzAccountsVersion;
_qosEvent.UserAgent = UserAgent;
_qosEvent.PSVersion = PowerShellVersion;
_qosEvent.HostVersion = PSHostVersion;
_qosEvent.PSHostName = PSHostName;
_qosEvent.ModuleName = this.ModuleName;
_qosEvent.ModuleVersion = this.ModuleVersion;
_qosEvent.SourceScript = MyInvocation.ScriptName;
_qosEvent.ScriptLineNumber = MyInvocation.ScriptLineNumber;
if (this.MyInvocation != null && this.MyInvocation.MyCommand != null)
{
_qosEvent.CommandName = this.MyInvocation.MyCommand.Name;
}
else
{
_qosEvent.CommandName = this.GetType().Name;
}
if (this.MyInvocation != null && !string.IsNullOrWhiteSpace(this.MyInvocation.InvocationName))
{
_qosEvent.InvocationName = this.MyInvocation.InvocationName;
}
if (this.MyInvocation != null && this.MyInvocation.BoundParameters != null
&& this.MyInvocation.BoundParameters.Keys != null)
{
if (AzureSession.Instance.TryGetComponent<IParameterTelemetryFormatter>(nameof(IParameterTelemetryFormatter), out var formatter))
{
_qosEvent.Parameters = formatter.FormatParameters(MyInvocation);
}
else
{
_qosEvent.Parameters = string.Join(" ",
this.MyInvocation.BoundParameters.Keys.Select(
s => string.Format(CultureInfo.InvariantCulture, "-{0} ***", s)));
}
}
_qosEvent.SanitizerInfo = new SanitizerTelemetry(OutputSanitizer?.RequireSecretsDetection == true);
}