@@ -19,6 +19,8 @@ Param (
19
19
[Parameter (Mandatory = $false )]
20
20
[string ]$ConfigLocation = ' default' ,
21
21
[Parameter (Mandatory = $false )]
22
+ [string ]$FeatureGates ,
23
+ [Parameter (Mandatory = $false )]
22
24
[switch ]$Start = $false ,
23
25
[Parameter (Mandatory = $false )]
24
26
[string ]$Mode = ' ec2' ,
@@ -37,9 +39,11 @@ $UsageString = @"
37
39
e.g.
38
40
1. start collector with a custom .yaml config file:
39
41
aws-otel-collector-ctl.ps1 -c /tmp/config.yaml -a start
40
- 2. stop the running collector:
42
+ 2. start collector with a custom .yaml config file:
43
+ aws-otel-collector-ctl.ps1 -f +adot.example.featuregate -a start
44
+ 3. stop the running collector:
41
45
aws-otel-collector-ctl.ps1 -a stop
42
- 3 . query agent status:
46
+ 4 . query agent status:
43
47
aws-otel-collector-ctl.ps1 -a status
44
48
45
49
-a: action
@@ -52,6 +56,10 @@ $UsageString = @"
52
56
- http uri. E.g.: http://example.com/config
53
57
- https uri. E.g.: https://example.com/config
54
58
- s3 uri. E.g.: s3://bucket/config
59
+ -f: <feature-gates>
60
+ - enable or disable feature gates
61
+ - E.g.: Enabling: "+adot.example.featuregate"
62
+ - disabling: "-adot.example.featuregate"
55
63
56
64
"@
57
65
@@ -81,19 +89,40 @@ Function Get-Service-Config-Uri() {
81
89
return $Matches.1
82
90
}
83
91
92
+
93
+
84
94
Function Set-Service-Config-Uri ([string ]$uri ) {
85
95
$aoc_cmd = " \"" ${AOCProgramFiles} \.aws-otel-collector.exe\"" --config=\"" ${uri} \"" "
86
96
sc.exe config " ${AOCServiceName} " binPath= " ${aoc_cmd} "
87
97
}
88
98
99
+ Function Set-Service-Config-Uri-With-FeatureGates ([string ]$uri , [string ]$featureGates ) {
100
+ Write-Output " Applying feature gate ${featureGates} "
101
+ $aoc_cmd = " \"" ${AOCProgramFiles} \.aws-otel-collector.exe\"" --config=\"" ${uri} \"" --feature-gates=\"" ${featureGates} \"" "
102
+ sc.exe config " ${AOCServiceName} " binPath= " ${aoc_cmd} "
103
+ }
104
+
89
105
Function Test-Remote-Uri ([string ]$uri ) {
90
106
return $uri -match " ^[a-zA-Z0-9]+://" -and $uri -notmatch " ^file:"
91
107
}
92
108
93
109
Function AOCStart () {
94
110
95
111
if ($ConfigLocation -and $ConfigLocation -ne ' default' ) {
112
+
113
+ # Check for feature gates before configuring service
114
+ if ($FeatureGates ) {
115
+ Write-Output " Applying feature gate"
96
116
if (Test-Remote - Uri $ConfigLocation ) {
117
+ Set-Service - Config- Uri- With- FeatureGates ${ConfigLocation} ${FeatureGates}
118
+ } else {
119
+ # Strip file scheme in case it is present
120
+ $ConfigLocation = " $ConfigLocation " -replace " ^file:" , " "
121
+
122
+ Copy-Item " ${ConfigLocation} " - Destination ${ProgramFilesYAML}
123
+ Set-Service - Config- Uri- With- FeatureGates ${ProgramFilesYAML} ${FeatureGates}
124
+ }
125
+ } elseif (Test-Remote - Uri $ConfigLocation ) {
97
126
Set-Service - Config- Uri ${ConfigLocation}
98
127
} else {
99
128
# Strip file scheme in case it is present
@@ -121,6 +150,7 @@ Function AOCStart() {
121
150
& sc.exe failureflag " ${AOCServiceName} " 1 | Out-Null
122
151
}
123
152
}
153
+
124
154
$svc | Start-Service
125
155
}
126
156
@@ -131,7 +161,6 @@ Function AOCStop() {
131
161
}
132
162
}
133
163
134
-
135
164
Function AOCStatus () {
136
165
137
166
$timefmt = ' '
@@ -150,18 +179,18 @@ Function AOCStatus() {
150
179
$timefmt = Get-Date - Date ${processStart} - Format " s"
151
180
}
152
181
}
153
-
182
+
154
183
$status = AOCRunstatus
155
184
$version = ([IO.File ]::ReadAllText(" ${VersionFile} " )).Trim()
156
-
185
+
157
186
Write-Output " {"
158
187
Write-Output " `" status`" : `" ${status} `" ,"
159
188
Write-Output " `" starttime`" : `" ${timefmt} `" ,"
160
189
Write-Output " `" version`" : `" ${version} `" "
161
190
Write-Output " }"
162
191
}
163
192
164
- # Translate platform status names to those used across all AOCgent 's platforms
193
+ # Translate platform status names to those used across all AOCAgent 's platforms
165
194
Function AOCRunstatus () {
166
195
$running = $false
167
196
$svc = Get-Service - Name " ${AOCServiceName} " - ErrorAction SilentlyContinue
0 commit comments