metrics: build from one Params in place of seven Add calls (closes #438) #456
Open
clawbot
wants to merge 1 commits from
issue-438-metrics-params into next
pull from: issue-438-metrics-params
merge into: sneak:next
sneak:main
sneak:next
sneak:issue-426-chi-routes
sneak:issue-440-cobra-commands
sneak:issue-441-heuristic-structs
sneak:issue-425-wafprotocol-package
sneak:issue-428-named-value-types
sneak:issue-439-stop-asks-at-stop
sneak:issue-429-dirwatch
sneak:issue-436-server-exports-no-parts
sneak:issue-434-core-rule-set-in-sww
sneak:issue-430-app-fixes-directory
sneak:issue-431-body-wrapper-fields
sneak:issue-433-report-goroutines
sneak:issue-427-typed-fixed-value-settings
sneak:issue-411-abuseipdb-blacklist
sneak:issue-414-fx-wiring
sneak:issue-420-tests-under-load
sneak:issue-381-compose-waf-settings
sneak:issue-412-anomaly-alert-only
sneak:issue-418-test-time-limits
sneak:issue-415-header-limit-test
sneak:issue-406-parallel-tests
sneak:issue-405-decide-beside-lookup
sneak:issue-404-geojs-package
sneak:issue-401-one-cookie-line
sneak:issue-400-coreruleset-timing-ref
sneak:issue-398-breaker-test-without-questions
sneak:issue-400-coreruleset-timing
sneak:issue-396-no-own-hosts
sneak:issue-394-decide-in-time
sneak:issue-392-rproxy-circuit-breaker
sneak:issue-388-any-tls-proxy
sneak:issue-386-readme-rproxy-alone
sneak:issue-387-readme-scraper-policy
sneak:issue-339-long-line-limits
sneak:issue-379-lookup-headers-by-default
sneak:issue-315-remove-crowdsec
sneak:issue-354-package-registry-searches
sneak:issue-353-api-searches
sneak:issue-234-rename-settings
sneak:issue-359-ghost-remaining-fields
sneak:issue-373-read-rest-after-connection-close
sneak:issue-374-ghost-canonical-url
sneak:issue-371-body-over-limit-test-reset
sneak:issue-358-ghost-scripts
sneak:issue-211-viper-config
sneak:issue-357-ghost
sneak:issue-346-names-in-bodies
sneak:issue-365-adopt-form-repository-names
sneak:issue-220-apps-by-hostname
sneak:issue-352-shared-searches
sneak:issue-215-golines
sneak:issue-227-settings-file-per-daemon
sneak:issue-350-forgejo-searches
sneak:issue-349-gitea-user-page-ls
sneak:issue-287-crs-test-cpu
sneak:issue-284-wordpress-recorded-both-ways
sneak:readme-rewrite-155
No Reviewers
Labels
Clear labels
critical
merge-ready
needs-checks
needs-decision
needs-decision
needs-decision
needs-rebase
needs-review
needs-rework
not-one-pr
post-1.0
red-next
Extremely important: data loss, a security hole, production down, or basic use impossible
Reviewed and ready for the owner to merge
Checks must be fixed before review
Waits on an owner decision
Waiting on a decision by the owner
Conflicts with next; rebase required
Review not yet done
Review found issues to fix
No labels
needs-review
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/smallwebwaf#456
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
closes #438
metrics.Newtakes onemetrics.Params; the sevenAdd…methods are gone. Each part sits behind a small interface ininternal/metrics/metrics.go, beside the metrics it feeds. A part left nil adds no metric.ruleMatchesandreputationHitsare made inNew, so no field is nil before a call.metricsdrops itsremotelogandrulesimports. It keepsalertsforalerts.Counts,bansfor the cause names, andreputationforAbuseIPDBSource.New fields of
Params:BusiestCount,InstanceName: the two former arguments ofNew.Now: the time at which the ban ledger counts active bans.Bans banLedger: the ledger of bans (Made,Count).Clients sized,Rules sized: the table of clients and the rule files.sizedis one interface withLen, since the linter refuses two identical ones.Lists fetchedLists: the lists fetched from URLs (URLs,Failures,Fetched).DNSBL dnsblZones: what asks the DNSBL zones (Zones,Queries,Failures).AbuseIPDB abuseIPDBChecker: what checks clients with AbuseIPDB (Checked,Failures,BudgetLeft).Alerts alertQueue: the queue of alerts (DestinationsSet,Counts,Suppressed).LookupFile lookupDatabase: the lookup database (LastRead,ReadFailures).RemoteLog remoteLogSender: what sends log lines toSWW_WAF_LOG_REMOTE_URL(Sent,Dropped,Depth).Things the diff does not show:
newMetricsininternal/sww/waf.gosetsAbuseIPDB,LookupFileandRemoteLogonly while the part is on. A nil pointer stored in an interface field is not a nil interface.internal/waf/proxy_test.gonow builds the metrics after AbuseIPDB and before GeoJS.internal/metrics/metrics_test.go: one test reads a metric from each stand-in part, and one checks that nil parts add none.Model: opus-5-5
Verdict: PASS
Head:
7697162a6ametrics.Newnow builds everything from oneParamsof small interfaces, theAdd…methods are gone, and behaviour is unchanged, as #438 asks.alertsimport foralerts.Countsmeets "no import only for a part's concrete type", sinceCountsis what the alert queue returns, not the queue's own type.Model: opus-5-5
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.