nginxinc / nginx-prometheus-exporter

NGINX Prometheus Exporter for NGINX and NGINX Plus
Apache License 2.0
1.65k stars 342 forks source link

Use appropriate context to call NGINX Plus API #858

Open lucacome opened 2 months ago

lucacome commented 2 months ago

https://github.com/nginxinc/nginx-plus-go-client/releases/tag/v2.0.0 now supports passing a context to the API calls, so we need to pass a context to c.nginxClient.GetStats()

https://github.com/nginxinc/nginx-prometheus-exporter/blob/262228e3d7e89c88433a627b0c5df779fa08b876/collector/nginx_plus.go#L621-L625

Figure out if we want to pass a context or a timeout. We already have a timeout that users can set for scraping metrics https://github.com/nginxinc/nginx-prometheus-exporter/blob/262228e3d7e89c88433a627b0c5df779fa08b876/exporter.go#L95 it probably makes sense to use the same value.

sjberman commented 1 month ago

I think that makes sense to use as the same timeout.