Skip to content

Commit 263b747

Browse files
committed
Merge branch 'v3' into fix-panic-with-multiple-logs
2 parents 348f7c8 + 0de3ba3 commit 263b747

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

internal/collector/nginxplusreceiver/scraper.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type NginxPlusScraper struct {
4646
logger *zap.Logger
4747
settings receiver.Settings
4848
init sync.Once
49+
previousHTTPRequestsTotal uint64
4950
}
5051

5152
type ResponseStatuses struct {
@@ -107,6 +108,8 @@ func (nps *NginxPlusScraper) Scrape(ctx context.Context) (pmetric.Metrics, error
107108
nps.logger.Error("Failed to get stats from plus API", zap.Error(err))
108109
return
109110
}
111+
112+
nps.previousHTTPRequestsTotal = stats.HTTPRequests.Total
110113
nps.createPreviousServerZoneResponses(stats)
111114
nps.createPreviousLocationZoneResponses(stats)
112115
})
@@ -194,7 +197,10 @@ func (nps *NginxPlusScraper) recordMetrics(stats *plusapi.Stats) {
194197

195198
// HTTP Requests
196199
nps.mb.RecordNginxHTTPRequestsDataPoint(now, int64(stats.HTTPRequests.Total), "", 0)
197-
nps.mb.RecordNginxHTTPRequestCountDataPoint(now, int64(stats.HTTPRequests.Current))
200+
201+
requestsDiff := int64(stats.HTTPRequests.Total) - int64(nps.previousHTTPRequestsTotal)
202+
nps.mb.RecordNginxHTTPRequestCountDataPoint(now, requestsDiff)
203+
nps.previousHTTPRequestsTotal = stats.HTTPRequests.Total
198204

199205
nps.recordCacheMetrics(stats, now)
200206
nps.recordHTTPLimitMetrics(stats, now)

internal/collector/nginxplusreceiver/scraper_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ func TestScraper(t *testing.T) {
5858
},
5959
}
6060

61+
scraper.previousHTTPRequestsTotal = 3
62+
6163
actualMetrics, err := scraper.Scrape(context.Background())
6264
require.NoError(t, err)
6365

internal/collector/nginxplusreceiver/testdata/expected.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ resourceMetrics:
295295
gauge:
296296
aggregationTemporality: 2
297297
dataPoints:
298-
- asInt: "3"
298+
- asInt: "44"
299299
timeUnixNano: "1000000"
300300
isMonotonic: true
301301
unit: requests

scripts/packages/postremove.sh

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,46 @@ cleanup() {
2424
rm -rf "/var/run/nginx-agent"
2525
}
2626

27+
full_cleanup() {
28+
echo "Purging all nginx-agent data"
29+
cleanup
30+
rm -rf "/etc/nginx-agent"
31+
rm -rf "/var/log/nginx-agent"
32+
rm -rf "/var/lib/nginx-agent"
33+
}
34+
2735
case "$ID" in
2836
debian|ubuntu)
29-
if [ "$1" = "remove" ]; then
30-
stop_agent_systemd
31-
disable_agent_systemd
32-
systemd_daemon_reload
33-
cleanup
34-
fi
37+
case "$1" in
38+
remove)
39+
stop_agent_systemd
40+
disable_agent_systemd
41+
systemd_daemon_reload
42+
cleanup
43+
;;
44+
purge)
45+
stop_agent_systemd
46+
disable_agent_systemd
47+
systemd_daemon_reload
48+
full_cleanup
49+
;;
50+
esac
3551
;;
3652
rhel|fedora|centos|amzn|almalinux|rocky)
3753
if [ "$1" = "0" ]; then
3854
stop_agent_systemd
3955
disable_agent_systemd
4056
systemd_daemon_reload
41-
cleanup
57+
full_cleanup
4258
fi
4359
;;
4460
alpine)
45-
cleanup
61+
full_cleanup
4662
;;
4763
*)
4864
stop_agent_systemd
4965
disable_agent_systemd
5066
systemd_daemon_reload
51-
cleanup
67+
full_cleanup
5268
;;
5369
esac

0 commit comments

Comments
 (0)