1
0
mirror of https://github.com/nginxinc/nginx-prometheus-exporter.git synced 2025-07-30 10:03:04 +03:00

Don't try to connect to nginx on client creation (#504)

The client now is created without making a call to nginx.
When Collect() is called we try to get the metrics from nginx and if
it's not available it will set 'up' to 0 and not fail anymore.
This commit is contained in:
Luca Comellini
2023-10-09 18:09:38 +02:00
committed by GitHub
parent 06af414484
commit 2ab961100c
3 changed files with 8 additions and 117 deletions

View File

@ -37,14 +37,13 @@ type StubConnections struct {
}
// NewNginxClient creates an NginxClient.
func NewNginxClient(httpClient *http.Client, apiEndpoint string) (*NginxClient, error) {
func NewNginxClient(httpClient *http.Client, apiEndpoint string) *NginxClient {
client := &NginxClient{
apiEndpoint: apiEndpoint,
httpClient: httpClient,
}
_, err := client.GetStubStats()
return client, err
return client
}
// GetStubStats fetches the stub_status metrics.