Skip to content

Commit e393d61

Browse files
committed
Use nginx plus go sdk
Replace the NGINX Plus Client from the client package with the NGINX Plus client from https://github.com/nginxinc/nginx-plus-go-sdk
1 parent fd86688 commit e393d61

File tree

21 files changed

+1649
-61
lines changed

21 files changed

+1649
-61
lines changed

collector/nginx_plus.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import (
44
"log"
55
"sync"
66

7-
"github.com/nginxinc/nginx-prometheus-exporter/client"
7+
plusclient "github.com/nginxinc/nginx-plus-go-sdk/client"
88
"github.com/prometheus/client_golang/prometheus"
99
)
1010

1111
// NginxPlusCollector collects NGINX Plus metrics. It implements prometheus.Collector interface.
1212
type NginxPlusCollector struct {
13-
nginxClient *client.NginxPlusClient
13+
nginxClient *plusclient.NginxClient
1414
totalMetrics, serverZoneMetrics, upstreamMetrics, upstreamServerMetrics map[string]*prometheus.Desc
1515
mutex sync.Mutex
1616
}
1717

1818
// NewNginxPlusCollector creates an NginxPlusCollector.
19-
func NewNginxPlusCollector(nginxClient *client.NginxPlusClient, namespace string) *NginxPlusCollector {
19+
func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string) *NginxPlusCollector {
2020
return &NginxPlusCollector{
2121
nginxClient: nginxClient,
2222
totalMetrics: map[string]*prometheus.Desc{
@@ -169,7 +169,7 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
169169
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["response_time"],
170170
prometheus.GaugeValue, float64(peer.ResponseTime), name, peer.Server)
171171

172-
if peer.HealthChecks != (client.HealthChecks{}) {
172+
if peer.HealthChecks != (plusclient.HealthChecks{}) {
173173
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["health_checks_checks"],
174174
prometheus.CounterValue, float64(peer.HealthChecks.Checks), name, peer.Server)
175175
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["health_checks_fails"],

exporter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"strconv"
99

10+
plusclient "github.com/nginxinc/nginx-plus-go-sdk/client"
1011
"github.com/nginxinc/nginx-prometheus-exporter/client"
1112
"github.com/nginxinc/nginx-prometheus-exporter/collector"
1213
"github.com/prometheus/client_golang/prometheus"
@@ -64,7 +65,7 @@ func main() {
6465
registry := prometheus.NewRegistry()
6566

6667
if *nginxPlus {
67-
client, err := client.NewNginxPlusClient(&http.Client{}, *scrapeURI)
68+
client, err := plusclient.NewNginxClient(&http.Client{}, *scrapeURI)
6869
if err != nil {
6970
log.Fatalf("Could not create Nginx Plus Client: %v", err)
7071
}

glide.lock

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ import:
44
subpackages:
55
- prometheus
66
- prometheus/promhttp
7+
- package: github.com/nginxinc/nginx-plus-go-sdk
8+
version: v0.2
9+
subpackages:
10+
- client

vendor/github.com/nginxinc/nginx-plus-go-sdk/.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/nginxinc/nginx-plus-go-sdk/.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/nginxinc/nginx-plus-go-sdk/.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/nginxinc/nginx-plus-go-sdk/.gitignore

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/nginxinc/nginx-plus-go-sdk/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/nginxinc/nginx-plus-go-sdk/CONTRIBUTING.md

Lines changed: 138 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)