Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix linter findings for revive:max-public-structs in plugins/inputs/[n-s]* #15878

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions plugins/inputs/nginx_plus/nginx_plus.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func getTags(addr *url.URL) map[string]string {
return map[string]string{"server": host, "port": port}
}

type ResponseStats struct {
type responseStats struct {
Responses1xx int64 `json:"1xx"`
Responses2xx int64 `json:"2xx"`
Responses3xx int64 `json:"3xx"`
Expand All @@ -132,25 +132,25 @@ type ResponseStats struct {
Total int64 `json:"total"`
}

type BasicHitStats struct {
type basicHitStats struct {
Responses int64 `json:"responses"`
Bytes int64 `json:"bytes"`
}

type ExtendedHitStats struct {
BasicHitStats
type extendedHitStats struct {
basicHitStats
ResponsesWritten int64 `json:"responses_written"`
BytesWritten int64 `json:"bytes_written"`
}

type HealthCheckStats struct {
type healthCheckStats struct {
Checks int64 `json:"checks"`
Fails int64 `json:"fails"`
Unhealthy int64 `json:"unhealthy"`
LastPassed *bool `json:"last_passed"`
}

type Status struct {
type status struct {
Version int `json:"version"`
NginxVersion string `json:"nginx_version"`
Address string `json:"address"`
Expand Down Expand Up @@ -184,7 +184,7 @@ type Status struct {
ServerZones map[string]struct { // added in version 2
Processing int `json:"processing"`
Requests int64 `json:"requests"`
Responses ResponseStats `json:"responses"`
Responses responseStats `json:"responses"`
Discarded *int64 `json:"discarded"` // added in version 6
Received int64 `json:"received"`
Sent int64 `json:"sent"`
Expand All @@ -201,12 +201,12 @@ type Status struct {
Keepalive *int `json:"keepalive"` // removed in version 5
MaxConns *int `json:"max_conns"` // added in version 3
Requests int64 `json:"requests"`
Responses ResponseStats `json:"responses"`
Responses responseStats `json:"responses"`
Sent int64 `json:"sent"`
Received int64 `json:"received"`
Fails int64 `json:"fails"`
Unavail int64 `json:"unavail"`
HealthChecks HealthCheckStats `json:"health_checks"`
HealthChecks healthCheckStats `json:"health_checks"`
Downtime int64 `json:"downtime"`
Downstart int64 `json:"downstart"`
Selected *int64 `json:"selected"` // added in version 4
Expand All @@ -226,20 +226,20 @@ type Status struct {
Size int64 `json:"size"`
MaxSize int64 `json:"max_size"`
Cold bool `json:"cold"`
Hit BasicHitStats `json:"hit"`
Stale BasicHitStats `json:"stale"`
Updating BasicHitStats `json:"updating"`
Revalidated *BasicHitStats `json:"revalidated"` // added in version 3
Miss ExtendedHitStats `json:"miss"`
Expired ExtendedHitStats `json:"expired"`
Bypass ExtendedHitStats `json:"bypass"`
Hit basicHitStats `json:"hit"`
Stale basicHitStats `json:"stale"`
Updating basicHitStats `json:"updating"`
Revalidated *basicHitStats `json:"revalidated"` // added in version 3
Miss extendedHitStats `json:"miss"`
Expired extendedHitStats `json:"expired"`
Bypass extendedHitStats `json:"bypass"`
} `json:"caches"`

Stream struct {
ServerZones map[string]struct {
Processing int `json:"processing"`
Connections int `json:"connections"`
Sessions *ResponseStats `json:"sessions"`
Sessions *responseStats `json:"sessions"`
Discarded *int64 `json:"discarded"` // added in version 7
Received int64 `json:"received"`
Sent int64 `json:"sent"`
Expand All @@ -260,7 +260,7 @@ type Status struct {
Received int64 `json:"received"`
Fails int64 `json:"fails"`
Unavail int64 `json:"unavail"`
HealthChecks HealthCheckStats `json:"health_checks"`
HealthChecks healthCheckStats `json:"health_checks"`
Downtime int64 `json:"downtime"`
Downstart int64 `json:"downstart"`
Selected int64 `json:"selected"`
Expand All @@ -272,15 +272,15 @@ type Status struct {

func gatherStatusURL(r *bufio.Reader, tags map[string]string, acc telegraf.Accumulator) error {
dec := json.NewDecoder(r)
status := &Status{}
status := &status{}
if err := dec.Decode(status); err != nil {
return errors.New("error while decoding JSON response")
}
status.Gather(tags, acc)
return nil
}

func (s *Status) Gather(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) Gather(tags map[string]string, acc telegraf.Accumulator) {
s.gatherProcessesMetrics(tags, acc)
s.gatherConnectionsMetrics(tags, acc)
s.gatherSslMetrics(tags, acc)
Expand All @@ -291,7 +291,7 @@ func (s *Status) Gather(tags map[string]string, acc telegraf.Accumulator) {
s.gatherStreamMetrics(tags, acc)
}

func (s *Status) gatherProcessesMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherProcessesMetrics(tags map[string]string, acc telegraf.Accumulator) {
var respawned int

if s.Processes.Respawned != nil {
Expand All @@ -307,7 +307,7 @@ func (s *Status) gatherProcessesMetrics(tags map[string]string, acc telegraf.Acc
)
}

func (s *Status) gatherConnectionsMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherConnectionsMetrics(tags map[string]string, acc telegraf.Accumulator) {
acc.AddFields(
"nginx_plus_connections",
map[string]interface{}{
Expand All @@ -320,7 +320,7 @@ func (s *Status) gatherConnectionsMetrics(tags map[string]string, acc telegraf.A
)
}

func (s *Status) gatherSslMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherSslMetrics(tags map[string]string, acc telegraf.Accumulator) {
acc.AddFields(
"nginx_plus_ssl",
map[string]interface{}{
Expand All @@ -332,7 +332,7 @@ func (s *Status) gatherSslMetrics(tags map[string]string, acc telegraf.Accumulat
)
}

func (s *Status) gatherRequestMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherRequestMetrics(tags map[string]string, acc telegraf.Accumulator) {
acc.AddFields(
"nginx_plus_requests",
map[string]interface{}{
Expand All @@ -343,7 +343,7 @@ func (s *Status) gatherRequestMetrics(tags map[string]string, acc telegraf.Accum
)
}

func (s *Status) gatherZoneMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherZoneMetrics(tags map[string]string, acc telegraf.Accumulator) {
for zoneName, zone := range s.ServerZones {
zoneTags := map[string]string{}
for k, v := range tags {
Expand Down Expand Up @@ -375,7 +375,7 @@ func (s *Status) gatherZoneMetrics(tags map[string]string, acc telegraf.Accumula
}
}

func (s *Status) gatherUpstreamMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherUpstreamMetrics(tags map[string]string, acc telegraf.Accumulator) {
for upstreamName, upstream := range s.Upstreams {
upstreamTags := map[string]string{}
for k, v := range tags {
Expand Down Expand Up @@ -451,7 +451,7 @@ func (s *Status) gatherUpstreamMetrics(tags map[string]string, acc telegraf.Accu
}
}

func (s *Status) gatherCacheMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherCacheMetrics(tags map[string]string, acc telegraf.Accumulator) {
for cacheName, cache := range s.Caches {
cacheTags := map[string]string{}
for k, v := range tags {
Expand Down Expand Up @@ -490,7 +490,7 @@ func (s *Status) gatherCacheMetrics(tags map[string]string, acc telegraf.Accumul
}
}

func (s *Status) gatherStreamMetrics(tags map[string]string, acc telegraf.Accumulator) {
func (s *status) gatherStreamMetrics(tags map[string]string, acc telegraf.Accumulator) {
for zoneName, zone := range s.Stream.ServerZones {
zoneTags := map[string]string{}
for k, v := range tags {
Expand Down
26 changes: 13 additions & 13 deletions plugins/inputs/nginx_plus_api/nginx_plus_api_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (n *NginxPlusAPI) gatherProcessesMetrics(addr *url.URL, acc telegraf.Accumu
return err
}

var processes = &Processes{}
var processes = &processes{}

if err := json.Unmarshal(body, processes); err != nil {
return err
Expand All @@ -114,7 +114,7 @@ func (n *NginxPlusAPI) gatherConnectionsMetrics(addr *url.URL, acc telegraf.Accu
return err
}

var connections = &Connections{}
var connections = &connections{}

if err := json.Unmarshal(body, connections); err != nil {
return err
Expand All @@ -140,7 +140,7 @@ func (n *NginxPlusAPI) gatherSlabsMetrics(addr *url.URL, acc telegraf.Accumulato
return err
}

var slabs Slabs
var slabs slabs

if err := json.Unmarshal(body, &slabs); err != nil {
return err
Expand Down Expand Up @@ -193,7 +193,7 @@ func (n *NginxPlusAPI) gatherSslMetrics(addr *url.URL, acc telegraf.Accumulator)
return err
}

var ssl = &Ssl{}
var ssl = &ssl{}

if err := json.Unmarshal(body, ssl); err != nil {
return err
Expand All @@ -218,7 +218,7 @@ func (n *NginxPlusAPI) gatherHTTPRequestsMetrics(addr *url.URL, acc telegraf.Acc
return err
}

var httpRequests = &HTTPRequests{}
var httpRequests = &httpRequests{}

if err := json.Unmarshal(body, httpRequests); err != nil {
return err
Expand All @@ -242,7 +242,7 @@ func (n *NginxPlusAPI) gatherHTTPServerZonesMetrics(addr *url.URL, acc telegraf.
return err
}

var httpServerZones HTTPServerZones
var httpServerZones httpServerZones

if err := json.Unmarshal(body, &httpServerZones); err != nil {
return err
Expand Down Expand Up @@ -290,7 +290,7 @@ func (n *NginxPlusAPI) gatherHTTPLocationZonesMetrics(addr *url.URL, acc telegra
return err
}

var httpLocationZones HTTPLocationZones
var httpLocationZones httpLocationZones

if err := json.Unmarshal(body, &httpLocationZones); err != nil {
return err
Expand Down Expand Up @@ -336,7 +336,7 @@ func (n *NginxPlusAPI) gatherHTTPUpstreamsMetrics(addr *url.URL, acc telegraf.Ac
return err
}

var httpUpstreams HTTPUpstreams
var httpUpstreams httpUpstreams

if err := json.Unmarshal(body, &httpUpstreams); err != nil {
return err
Expand Down Expand Up @@ -420,7 +420,7 @@ func (n *NginxPlusAPI) gatherHTTPCachesMetrics(addr *url.URL, acc telegraf.Accum
return err
}

var httpCaches HTTPCaches
var httpCaches httpCaches

if err := json.Unmarshal(body, &httpCaches); err != nil {
return err
Expand Down Expand Up @@ -474,7 +474,7 @@ func (n *NginxPlusAPI) gatherStreamServerZonesMetrics(addr *url.URL, acc telegra
return err
}

var streamServerZones StreamServerZones
var streamServerZones streamServerZones

if err := json.Unmarshal(body, &streamServerZones); err != nil {
return err
Expand Down Expand Up @@ -510,7 +510,7 @@ func (n *NginxPlusAPI) gatherResolverZonesMetrics(addr *url.URL, acc telegraf.Ac
return err
}

var resolverZones ResolverZones
var resolverZones resolverZones

if err := json.Unmarshal(body, &resolverZones); err != nil {
return err
Expand Down Expand Up @@ -553,7 +553,7 @@ func (n *NginxPlusAPI) gatherStreamUpstreamsMetrics(addr *url.URL, acc telegraf.
return err
}

var streamUpstreams StreamUpstreams
var streamUpstreams streamUpstreams

if err := json.Unmarshal(body, &streamUpstreams); err != nil {
return err
Expand Down Expand Up @@ -623,7 +623,7 @@ func (n *NginxPlusAPI) gatherHTTPLimitReqsMetrics(addr *url.URL, acc telegraf.Ac
return err
}

var httpLimitReqs HTTPLimitReqs
var httpLimitReqs httpLimitReqs

if err := json.Unmarshal(body, &httpLimitReqs); err != nil {
return err
Expand Down
Loading
Loading