Skip to content

Commit c9d4de6

Browse files
committed
feat: add and expose new ConfigSnapshotIntervalInMins config
1 parent 5011d9a commit c9d4de6

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

cns/configuration/cns_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"HeartBeatIntervalInMins": 30,
66
"RefreshIntervalInSecs": 15,
77
"SnapshotIntervalInMins": 60,
8+
"ConfigSnapshotIntervalInMins": 60,
89
"TelemetryBatchIntervalInSecs": 15,
910
"TelemetryBatchSizeBytes": 16384
1011
},

cns/configuration/configuration.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ type TelemetrySettings struct {
7979
DebugMode bool
8080
// Interval for sending snapshot events.
8181
SnapshotIntervalInMins int
82+
// Interval for sending config snapshot events.
83+
ConfigSnapshotIntervalInMins int
8284
// AppInsightsInstrumentationKey allows the user to override the default appinsights ikey
8385
AppInsightsInstrumentationKey string
8486
}
@@ -176,6 +178,10 @@ func setTelemetrySettingDefaults(telemetrySettings *TelemetrySettings) {
176178
if telemetrySettings.SnapshotIntervalInMins == 0 {
177179
telemetrySettings.SnapshotIntervalInMins = 60
178180
}
181+
182+
if telemetrySettings.ConfigSnapshotIntervalInMins == 0 {
183+
telemetrySettings.ConfigSnapshotIntervalInMins = 60
184+
}
179185
}
180186

181187
// set managed setting defaults

cns/configuration/configuration_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func TestReadConfigFromFile(t *testing.T) {
8080
HeartBeatIntervalInMins: 30,
8181
RefreshIntervalInSecs: 15,
8282
SnapshotIntervalInMins: 60,
83+
ConfigSnapshotIntervalInMins: 60,
8384
TelemetryBatchIntervalInSecs: 15,
8485
TelemetryBatchSizeBytes: 16384,
8586
},
@@ -122,6 +123,7 @@ func TestSetTelemetrySettingDefaults(t *testing.T) {
122123
TelemetryBatchSizeBytes: 32768,
123124
HeartBeatIntervalInMins: 30,
124125
SnapshotIntervalInMins: 60,
126+
ConfigSnapshotIntervalInMins: 60,
125127
},
126128
},
127129
{
@@ -132,13 +134,15 @@ func TestSetTelemetrySettingDefaults(t *testing.T) {
132134
TelemetryBatchSizeBytes: 5,
133135
HeartBeatIntervalInMins: 6,
134136
SnapshotIntervalInMins: 7,
137+
ConfigSnapshotIntervalInMins: 8,
135138
},
136139
want: TelemetrySettings{
137140
RefreshIntervalInSecs: 3,
138141
TelemetryBatchIntervalInSecs: 4,
139142
TelemetryBatchSizeBytes: 5,
140143
HeartBeatIntervalInMins: 6,
141144
SnapshotIntervalInMins: 7,
145+
ConfigSnapshotIntervalInMins: 8,
142146
},
143147
},
144148
}
@@ -206,6 +210,7 @@ func TestSetCNSConfigDefaults(t *testing.T) {
206210
HeartBeatIntervalInMins: 30,
207211
RefreshIntervalInSecs: 15,
208212
SnapshotIntervalInMins: 60,
213+
ConfigSnapshotIntervalInMins: 60,
209214
},
210215
KeyVaultSettings: KeyVaultSettings{
211216
RefreshIntervalInHrs: 12,
@@ -238,6 +243,7 @@ func TestSetCNSConfigDefaults(t *testing.T) {
238243
HeartBeatIntervalInMins: 3,
239244
RefreshIntervalInSecs: 1,
240245
SnapshotIntervalInMins: 6,
246+
ConfigSnapshotIntervalInMins: 7,
241247
},
242248
KeyVaultSettings: KeyVaultSettings{
243249
RefreshIntervalInHrs: 3,
@@ -265,6 +271,7 @@ func TestSetCNSConfigDefaults(t *testing.T) {
265271
HeartBeatIntervalInMins: 3,
266272
RefreshIntervalInSecs: 1,
267273
SnapshotIntervalInMins: 6,
274+
ConfigSnapshotIntervalInMins: 7,
268275
},
269276
KeyVaultSettings: KeyVaultSettings{
270277
RefreshIntervalInHrs: 3,

cns/configuration/testdata/good.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"HeartBeatIntervalInMins": 30,
2727
"RefreshIntervalInSecs": 15,
2828
"SnapshotIntervalInMins": 60,
29+
"ConfigSnapshotIntervalInMins": 60,
2930
"TelemetryBatchIntervalInSecs": 15,
3031
"TelemetryBatchSizeBytes": 16384
3132
},

cns/logger/constants.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package logger
33

44
const (
55
// Metrics
6-
HeartBeatMetricStr = "HeartBeat"
6+
HeartBeatMetricStr = "HeartBeat"
7+
ConfigSnapshotMetricsStr = "ConfigSnapshot"
78

89
// Dimensions
910
OrchestratorTypeStr = "OrchestratorType"
@@ -13,7 +14,7 @@ const (
1314
HomeAZErrorCodeStr = "HomeAZErrorCode"
1415
HomeAZErrorMsgStr = "HomeAZErrorMsg"
1516

16-
// CNS Snspshot properties
17+
// CNS NC Snspshot properties
1718
CnsNCSnapshotEventStr = "CNSNCSnapshot"
1819
IpConfigurationStr = "IPConfiguration"
1920
LocalIPConfigurationStr = "LocalIPConfiguration"

0 commit comments

Comments
 (0)