File tree Expand file tree Collapse file tree 2 files changed +43
-3
lines changed
Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Original file line number Diff line number Diff line change 1919using Microsoft . Azure . ServiceManagement . Common . Models ;
2020using Microsoft . WindowsAzure . Commands . Common ;
2121using Microsoft . WindowsAzure . Commands . Common . CustomAttributes ;
22+ using Microsoft . WindowsAzure . Commands . Common . Utilities ;
2223using System ;
2324using System . Collections . Concurrent ;
2425using System . Collections . Generic ;
@@ -702,9 +703,16 @@ protected virtual void InitializeQosEvent()
702703 if ( this . MyInvocation != null && this . MyInvocation . BoundParameters != null
703704 && this . MyInvocation . BoundParameters . Keys != null )
704705 {
705- _qosEvent . Parameters = string . Join ( " " ,
706- this . MyInvocation . BoundParameters . Keys . Select (
707- s => string . Format ( CultureInfo . InvariantCulture , "-{0} ***" , s ) ) ) ;
706+ if ( AzureSession . Instance . TryGetComponent < IParameterTelemetryFormatter > ( nameof ( IParameterTelemetryFormatter ) , out var formatter ) )
707+ {
708+ _qosEvent . Parameters = formatter . FormatParameters ( MyInvocation ) ;
709+ }
710+ else
711+ {
712+ _qosEvent . Parameters = string . Join ( " " ,
713+ this . MyInvocation . BoundParameters . Keys . Select (
714+ s => string . Format ( CultureInfo . InvariantCulture , "-{0} ***" , s ) ) ) ;
715+ }
708716 }
709717 }
710718
Original file line number Diff line number Diff line change 1+ // ----------------------------------------------------------------------------------
2+ //
3+ // Copyright Microsoft Corporation
4+ // Licensed under the Apache License, Version 2.0 (the "License");
5+ // you may not use this file except in compliance with the License.
6+ // You may obtain a copy of the License at
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ // Unless required by applicable law or agreed to in writing, software
9+ // distributed under the License is distributed on an "AS IS" BASIS,
10+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+ // See the License for the specific language governing permissions and
12+ // limitations under the License.
13+ // ----------------------------------------------------------------------------------
14+
15+ using System . Collections . Generic ;
16+ using System . Management . Automation ;
17+
18+ namespace Microsoft . WindowsAzure . Commands . Common . Utilities
19+ {
20+ /// <summary>
21+ /// String formatter for bound parameters for telemetry purpose.
22+ /// </summary>
23+ public interface IParameterTelemetryFormatter
24+ {
25+ /// <summary>
26+ /// Format the bound parameters to a string without sensitive data.
27+ /// </summary>
28+ /// <param name="invocation">Info about cmdlet invocation</param>
29+ /// <returns>The formatted string.</returns>
30+ string FormatParameters ( InvocationInfo invocation ) ;
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments