You've already forked nginx_exporter
mirror of
https://github.com/nginxinc/nginx-prometheus-exporter.git
synced 2025-07-31 21:04:21 +03:00
Use timeout flag for context cancelation
This commit is contained in:
@ -47,10 +47,7 @@ func NewNginxClient(httpClient *http.Client, apiEndpoint string) *NginxClient {
|
||||
}
|
||||
|
||||
// GetStubStats fetches the stub_status metrics.
|
||||
func (client *NginxClient) GetStubStats() (*StubStats, error) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
func (client *NginxClient) GetStubStats(ctx context.Context) (*StubStats, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, client.apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create a get request: %w", err)
|
||||
|
Reference in New Issue
Block a user