Skip to content

Commit 2a9d2f0

Browse files
committed
PR feedback
1 parent 2ceac4e commit 2a9d2f0

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

internal/collector/nginxplusreceiver/scraper.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -82,40 +82,6 @@ func (nps *NginxPlusScraper) ID() component.ID {
8282
return component.NewID(metadata.Type)
8383
}
8484

85-
func (nps *NginxPlusScraper) createPreviousLocationZoneResponses(stats *plusapi.Stats) {
86-
previousLocationZoneResponses := make(map[string]ResponseStatuses)
87-
for lzName, lz := range stats.LocationZones {
88-
respStatus := ResponseStatuses{
89-
oneHundredStatusRange: int64(lz.Responses.Responses1xx),
90-
twoHundredStatusRange: int64(lz.Responses.Responses2xx),
91-
threeHundredStatusRange: int64(lz.Responses.Responses3xx),
92-
fourHundredStatusRange: int64(lz.Responses.Responses4xx),
93-
fiveHundredStatusRange: int64(lz.Responses.Responses5xx),
94-
}
95-
96-
previousLocationZoneResponses[lzName] = respStatus
97-
}
98-
99-
nps.previousLocationZoneResponses = previousLocationZoneResponses
100-
}
101-
102-
func (nps *NginxPlusScraper) createPreviousServerZoneResponses(stats *plusapi.Stats) {
103-
previousServerZoneResponses := make(map[string]ResponseStatuses)
104-
for szName, sz := range stats.ServerZones {
105-
respStatus := ResponseStatuses{
106-
oneHundredStatusRange: int64(sz.Responses.Responses1xx),
107-
twoHundredStatusRange: int64(sz.Responses.Responses2xx),
108-
threeHundredStatusRange: int64(sz.Responses.Responses3xx),
109-
fourHundredStatusRange: int64(sz.Responses.Responses4xx),
110-
fiveHundredStatusRange: int64(sz.Responses.Responses5xx),
111-
}
112-
113-
previousServerZoneResponses[szName] = respStatus
114-
}
115-
116-
nps.previousServerZoneResponses = previousServerZoneResponses
117-
}
118-
11985
func (nps *NginxPlusScraper) Start(_ context.Context, _ component.Host) error {
12086
endpoint := strings.TrimPrefix(nps.cfg.APIDetails.URL, "unix:")
12187
httpClient := http.DefaultClient
@@ -164,6 +130,44 @@ func (nps *NginxPlusScraper) Scrape(ctx context.Context) (pmetric.Metrics, error
164130
return nps.mb.Emit(metadata.WithResource(nps.rb.Emit())), nil
165131
}
166132

133+
func (nps *NginxPlusScraper) Shutdown(ctx context.Context) error {
134+
return nil
135+
}
136+
137+
func (nps *NginxPlusScraper) createPreviousLocationZoneResponses(stats *plusapi.Stats) {
138+
previousLocationZoneResponses := make(map[string]ResponseStatuses)
139+
for lzName, lz := range stats.LocationZones {
140+
respStatus := ResponseStatuses{
141+
oneHundredStatusRange: int64(lz.Responses.Responses1xx),
142+
twoHundredStatusRange: int64(lz.Responses.Responses2xx),
143+
threeHundredStatusRange: int64(lz.Responses.Responses3xx),
144+
fourHundredStatusRange: int64(lz.Responses.Responses4xx),
145+
fiveHundredStatusRange: int64(lz.Responses.Responses5xx),
146+
}
147+
148+
previousLocationZoneResponses[lzName] = respStatus
149+
}
150+
151+
nps.previousLocationZoneResponses = previousLocationZoneResponses
152+
}
153+
154+
func (nps *NginxPlusScraper) createPreviousServerZoneResponses(stats *plusapi.Stats) {
155+
previousServerZoneResponses := make(map[string]ResponseStatuses)
156+
for szName, sz := range stats.ServerZones {
157+
respStatus := ResponseStatuses{
158+
oneHundredStatusRange: int64(sz.Responses.Responses1xx),
159+
twoHundredStatusRange: int64(sz.Responses.Responses2xx),
160+
threeHundredStatusRange: int64(sz.Responses.Responses3xx),
161+
fourHundredStatusRange: int64(sz.Responses.Responses4xx),
162+
fiveHundredStatusRange: int64(sz.Responses.Responses5xx),
163+
}
164+
165+
previousServerZoneResponses[szName] = respStatus
166+
}
167+
168+
nps.previousServerZoneResponses = previousServerZoneResponses
169+
}
170+
167171
func (nps *NginxPlusScraper) recordMetrics(stats *plusapi.Stats) {
168172
now := pcommon.NewTimestampFromTime(time.Now())
169173

@@ -1187,10 +1191,6 @@ func socketClient(socketPath string) *http.Client {
11871191
}
11881192
}
11891193

1190-
func (nps *NginxPlusScraper) Shutdown(ctx context.Context) error {
1191-
return nil
1192-
}
1193-
11941194
// nolint: revive
11951195
func boolToInt64(booleanValue bool) int64 {
11961196
if booleanValue {

0 commit comments

Comments
 (0)