@@ -120,9 +120,9 @@ public void TrackException(TelemetryErrorName errorName, Exception exception, ID
120120 return ;
121121 }
122122 this . _logger . LogInformation ( $ "Sending exception event: { exception . Message } ") ;
123- properties = properties ?? new Dictionary < TelemetryPropertyName , string > ( ) ;
124- properties . Add ( TelemetryPropertyName . ErrorName , errorName . ToString ( ) ) ;
125- properties . Add ( TelemetryPropertyName . ErrorCode , ExtractErrorCode ( exception ) ) ;
123+ properties = properties != null ? new Dictionary < TelemetryPropertyName , string > ( properties ) : new Dictionary < TelemetryPropertyName , string > ( ) ;
124+ properties [ TelemetryPropertyName . ErrorName ] = errorName . ToString ( ) ;
125+ properties [ TelemetryPropertyName . ErrorCode ] = ExtractErrorCode ( exception ) ;
126126 //continue task in existing parallel thread
127127 this . _trackEventTask = this . _trackEventTask . ContinueWith (
128128 x => this . TrackExceptionTask ( exception , properties , measurements )
@@ -147,8 +147,8 @@ public void TrackDuration(TelemetryEventName eventName, long durationMs, IDictio
147147 {
148148 try
149149 {
150- measurements = measurements ?? new Dictionary < TelemetryMeasureName , double > ( ) ;
151- measurements . Add ( TelemetryMeasureName . DurationMs , durationMs ) ;
150+ measurements = measurements != null ? new Dictionary < TelemetryMeasureName , double > ( measurements ) : new Dictionary < TelemetryMeasureName , double > ( ) ;
151+ measurements [ TelemetryMeasureName . DurationMs ] = durationMs ;
152152 this . TrackEvent ( eventName , properties , measurements ) ;
153153 }
154154 catch ( Exception ex )
@@ -169,8 +169,8 @@ public void TrackCreate(CreateType type, IDictionary<TelemetryPropertyName, stri
169169 {
170170 try
171171 {
172- properties = properties ?? new Dictionary < TelemetryPropertyName , string > ( ) ;
173- properties . Add ( TelemetryPropertyName . Type , type . ToString ( ) ) ;
172+ properties = properties != null ? new Dictionary < TelemetryPropertyName , string > ( properties ) : new Dictionary < TelemetryPropertyName , string > ( ) ;
173+ properties [ TelemetryPropertyName . Type ] = type . ToString ( ) ;
174174 this . TrackEvent ( TelemetryEventName . Create , properties , measurements ) ;
175175 }
176176 catch ( Exception ex )
@@ -191,8 +191,8 @@ public void TrackConvert(ConvertType type, IDictionary<TelemetryPropertyName, st
191191 {
192192 try
193193 {
194- properties = properties ?? new Dictionary < TelemetryPropertyName , string > ( ) ;
195- properties . Add ( TelemetryPropertyName . Type , type . ToString ( ) ) ;
194+ properties = properties != null ? new Dictionary < TelemetryPropertyName , string > ( properties ) : new Dictionary < TelemetryPropertyName , string > ( ) ;
195+ properties [ TelemetryPropertyName . Type ] = type . ToString ( ) ;
196196 this . TrackEvent ( TelemetryEventName . Convert , properties , measurements ) ;
197197 }
198198 catch ( Exception ex )
0 commit comments