Skip to content

Commit 55e0739

Browse files
authored
set subscription id and tenant id in telemetry if it's null (#427)
* set subscription id and tenant id in telemetry if it's null * set telemetry sub id and tenant id to AzureRMCmdlet.EndProcessing * remove RequireDefaultContext
1 parent e57ee15 commit 55e0739

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/ResourceManager/Version2016_09_01/AzureRMCmdlet.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,22 @@ public virtual bool TryGetDefaultContext(out IAzureContext context)
281281
return result;
282282
}
283283

284+
protected override void EndProcessing()
285+
{
286+
IAzureContext context;
287+
_qosEvent.Uid = "defaultid";
288+
if (TryGetDefaultContext(out context) && context != null)
289+
{
290+
_qosEvent.SubscriptionId = context.Subscription?.Id;
291+
_qosEvent.TenantId = context.Tenant?.Id;
292+
if (context.Account != null && !String.IsNullOrWhiteSpace(context.Account.Id))
293+
{
294+
_qosEvent.Uid = MetricHelper.GenerateSha256HashString(context.Account.Id.ToString());
295+
}
296+
}
297+
base.EndProcessing();
298+
}
299+
284300
/// <summary>
285301
/// Gets the current default context.
286302
/// </summary>
@@ -380,17 +396,7 @@ protected override void InitializeQosEvent()
380396
{
381397
base.InitializeQosEvent();
382398

383-
IAzureContext context;
384-
_qosEvent.Uid = "defaultid";
385-
if (RequireDefaultContext() && TryGetDefaultContext(out context))
386-
{
387-
_qosEvent.SubscriptionId = context.Subscription?.Id;
388-
_qosEvent.TenantId = context.Tenant?.Id;
389-
if (context.Account != null && !String.IsNullOrWhiteSpace(context.Account.Id))
390-
{
391-
_qosEvent.Uid = MetricHelper.GenerateSha256HashString(context.Account.Id.ToString());
392-
}
393-
}
399+
394400
}
395401

396402
protected override void LogCmdletStartInvocationInfo()

0 commit comments

Comments
 (0)