Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Telemetry/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public enum TelemetryPropertyName
ExceptionType,
HasIdentityColumn,
HasConfiguredBatchSize,
HasConfiguredMaxChangesPerWorker,
HasConfiguredPollingInterval,
LeasesTableName,
QueryType,
Expand Down Expand Up @@ -392,6 +393,7 @@ public enum TelemetryMeasureName
GetPrimaryKeysDurationMs,
GetUnprocessedChangesDurationMs,
InsertGlobalStateTableRowDurationMs,
MaxChangesPerWorker,
PollingIntervalMs,
ReleaseLeasesDurationMs,
RetryAttemptNumber,
Expand Down
19 changes: 13 additions & 6 deletions src/TriggerBinding/SqlTableChangeMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,26 @@ public SqlTableChangeMonitor(
int? configuredBatchSize = configuration.GetValue<int?>(ConfigKey_SqlTrigger_BatchSize);
int? configuredPollingInterval = configuration.GetValue<int?>(ConfigKey_SqlTrigger_PollingInterval);
this._batchSize = configuredBatchSize ?? this._batchSize;
if (this._batchSize <= 0)
{
throw new InvalidOperationException($"Invalid value for configuration setting '{ConfigKey_SqlTrigger_BatchSize}'. Ensure that the value is a positive integer.");
}
this._pollingIntervalInMs = configuredPollingInterval ?? this._pollingIntervalInMs;
var monitorStartProps = new Dictionary<TelemetryPropertyName, string>(telemetryProps)
if (this._pollingIntervalInMs <= 0)
{
{ TelemetryPropertyName.HasConfiguredBatchSize, (configuredBatchSize != null).ToString() },
{ TelemetryPropertyName.HasConfiguredPollingInterval, (configuredPollingInterval != null).ToString() },
};
throw new InvalidOperationException($"Invalid value for configuration setting '{ConfigKey_SqlTrigger_PollingInterval}'. Ensure that the value is a positive integer.");
}
TelemetryInstance.TrackEvent(
TelemetryEventName.TriggerMonitorStart,
monitorStartProps,
new Dictionary<TelemetryPropertyName, string>(telemetryProps) {
{ TelemetryPropertyName.HasConfiguredBatchSize, (configuredBatchSize != null).ToString() },
{ TelemetryPropertyName.HasConfiguredPollingInterval, (configuredPollingInterval != null).ToString() },
},
new Dictionary<TelemetryMeasureName, double>() {
{ TelemetryMeasureName.BatchSize, this._batchSize },
{ TelemetryMeasureName.PollingIntervalMs, this._pollingIntervalInMs }
});
}
);

// Prep search-conditions that will be used besides WHERE clause to match table rows.
this._rowMatchConditions = Enumerable.Range(0, this._batchSize)
Expand Down
13 changes: 11 additions & 2 deletions src/TriggerBinding/SqlTriggerListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal sealed class SqlTriggerListener<T> : IListener, IScaleMonitor<SqlTrigge

private readonly IDictionary<TelemetryPropertyName, string> _telemetryProps = new Dictionary<TelemetryPropertyName, string>();
private readonly int _maxChangesPerWorker;
private readonly bool _hasConfiguredMaxChangesPerWorker = false;

private SqlTableChangeMonitor<T> _changeMonitor;
private int _listenerState = ListenerNotStarted;
Expand Down Expand Up @@ -74,13 +75,13 @@ public SqlTriggerListener(string connectionString, string tableName, string user
// Do not convert the scale-monitor ID to lower-case string since SQL table names can be case-sensitive
// depending on the collation of the current database.
this._scaleMonitorDescriptor = new ScaleMonitorDescriptor($"{userFunctionId}-SqlTrigger-{tableName}");

configuredMaxChangesPerWorker = configuration.GetValue<int?>(ConfigKey_SqlTrigger_MaxChangesPerWorker);
this._maxChangesPerWorker = configuredMaxChangesPerWorker ?? DefaultMaxChangesPerWorker;
if (this._maxChangesPerWorker <= 0)
{
throw new InvalidOperationException($"Invalid value for configuration setting '{ConfigKey_SqlTrigger_MaxChangesPerWorker}'. Ensure that the value is a positive integer.");
}
this._hasConfiguredMaxChangesPerWorker = configuredMaxChangesPerWorker != null;
}

public void Cancel()
Expand All @@ -105,7 +106,15 @@ public async Task StartAsync(CancellationToken cancellationToken)
}

this.InitializeTelemetryProps();
TelemetryInstance.TrackEvent(TelemetryEventName.StartListenerStart, this._telemetryProps);
TelemetryInstance.TrackEvent(
TelemetryEventName.StartListenerStart,
new Dictionary<TelemetryPropertyName, string>(this._telemetryProps) {
{ TelemetryPropertyName.HasConfiguredMaxChangesPerWorker, this._hasConfiguredMaxChangesPerWorker.ToString() }
},
new Dictionary<TelemetryMeasureName, double>() {
{ TelemetryMeasureName.MaxChangesPerWorker, this._maxChangesPerWorker }
}
);

try
{
Expand Down