@@ -174,7 +174,16 @@ func doAddCounter(gitpodHost string, name string, labels map[string]string, valu
174
174
return
175
175
}
176
176
url := fmt .Sprintf ("https://ide.%s/metrics-api/metrics/counter/add/%s" , gitpodHost , name )
177
- resp , err := http .Post (url , "application/json" , bytes .NewReader (body ))
177
+ ctx , cancel := context .WithTimeout (context .Background (), time .Second * 5 )
178
+ defer cancel ()
179
+ request , err := http .NewRequestWithContext (ctx , http .MethodPost , url , bytes .NewReader (body ))
180
+ if err != nil {
181
+ log .WithError (err ).Error ("supervisor: grpc metric: failed to create request" )
182
+ return
183
+ }
184
+ request .Header .Set ("Content-Type" , "application/json" )
185
+ request .Header .Set ("X-Client" , "supervisor" )
186
+ resp , err := http .DefaultClient .Do (request )
178
187
var statusCode int
179
188
if resp != nil {
180
189
statusCode = resp .StatusCode
@@ -217,7 +226,16 @@ func doAddHistogram(gitpodHost string, name string, labels map[string]string, co
217
226
return
218
227
}
219
228
url := fmt .Sprintf ("https://ide.%s/metrics-api/metrics/histogram/add/%s" , gitpodHost , name )
220
- resp , err := http .Post (url , "application/json" , bytes .NewReader (body ))
229
+ ctx , cancel := context .WithTimeout (context .Background (), time .Second * 5 )
230
+ defer cancel ()
231
+ request , err := http .NewRequestWithContext (ctx , http .MethodPost , url , bytes .NewReader (body ))
232
+ if err != nil {
233
+ log .WithError (err ).Error ("supervisor: grpc metric: failed to create request" )
234
+ return
235
+ }
236
+ request .Header .Set ("Content-Type" , "application/json" )
237
+ request .Header .Set ("X-Client" , "supervisor" )
238
+ resp , err := http .DefaultClient .Do (request )
221
239
var statusCode int
222
240
if resp != nil {
223
241
statusCode = resp .StatusCode
0 commit comments