@@ -35,7 +35,7 @@ internal sealed class SqlTriggerListener<T> : IListener
3535 private readonly ITriggeredFunctionExecutor _executor ;
3636 private readonly ILogger _logger ;
3737
38- private readonly IDictionary < TelemetryPropertyName , string > _telemetryProps ;
38+ private readonly IDictionary < TelemetryPropertyName , string > _telemetryProps = new Dictionary < TelemetryPropertyName , string > ( ) ;
3939
4040 private SqlTableChangeMonitor < T > _changeMonitor ;
4141 private int _listenerState ;
@@ -62,11 +62,6 @@ public SqlTriggerListener(string connectionString, string tableName, string user
6262 this . _executor = executor ;
6363 this . _logger = logger ;
6464 this . _listenerState = ListenerNotStarted ;
65-
66- this . _telemetryProps = new Dictionary < TelemetryPropertyName , string >
67- {
68- [ TelemetryPropertyName . UserFunctionId ] = this . _userFunctionId ,
69- } ;
7065 }
7166
7267 public void Cancel ( )
@@ -81,6 +76,7 @@ public void Dispose()
8176
8277 public async Task StartAsync ( CancellationToken cancellationToken )
8378 {
79+ this . InitializeTelemetryProps ( ) ;
8480 TelemetryInstance . TrackEvent ( TelemetryEventName . StartListenerStart , this . _telemetryProps ) ;
8581
8682 int previousState = Interlocked . CompareExchange ( ref this . _listenerState , ListenerStarting , ListenerNotStarted ) ;
@@ -439,5 +435,14 @@ PRIMARY KEY ({primaryKeys})
439435 return stopwatch . ElapsedMilliseconds ;
440436 }
441437 }
438+
439+ /// <summary>
440+ /// Clears the current telemetry property dictionary and initializes the default initial properties.
441+ /// </summary>
442+ private void InitializeTelemetryProps ( )
443+ {
444+ this . _telemetryProps . Clear ( ) ;
445+ this . _telemetryProps [ TelemetryPropertyName . UserFunctionId ] = this . _userFunctionId ;
446+ }
442447 }
443448}
0 commit comments