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

using promauto package to ensure all created metrics are properly registered #4025

Merged
merged 2 commits into from Jul 25, 2020

Conversation

zouyee
Copy link
Member

@zouyee zouyee commented Jul 24, 2020

1. Why is this pull request needed and what does it do?

check if metric is registererd

2. Which issues (if any) are related?

fix #4024

3. Which documentation changes (if any) need to be made?

none

4. Does this introduce a backward incompatible change or deprecation?

none

@codecov-commenter
Copy link

Codecov Report

Merging #4025 into master will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4025      +/-   ##
==========================================
- Coverage   56.82%   56.77%   -0.06%     
==========================================
  Files         224      224              
  Lines       11352    11341      -11     
==========================================
- Hits         6451     6439      -12     
- Misses       4404     4406       +2     
+ Partials      497      496       -1     
Impacted Files Coverage Δ
plugin/health/overloaded.go 57.89% <ø> (ø)
plugin/kubernetes/metrics.go 100.00% <ø> (+21.42%) ⬆️
plugin/template/metrics.go 33.33% <ø> (ø)
plugin/metrics/metrics.go 64.06% <100.00%> (-7.94%) ⬇️
plugin/file/reload.go 69.44% <0.00%> (-5.56%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b09d62...2799d8c. Read the comment docs.

@zouyee zouyee marked this pull request as ready for review July 25, 2020 06:16
@zouyee
Copy link
Member Author

zouyee commented Jul 25, 2020

/assign @miekg

@corbot corbot bot assigned miekg Jul 25, 2020
Copy link
Member

@miekg miekg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@SuperQ
Copy link
Collaborator

SuperQ commented Jul 25, 2020

Nice. There are a number of additional MustRegister() instances that can probably be removed.

@miekg
Copy link
Member

miekg commented Jul 25, 2020

oh yeah, was wondering that during review, but:

lugin/dnssec/setup.go:		metrics.MustRegister(c, cacheSize, cacheHits, cacheMisses)
plugin/forward/setup.go:		metrics.MustRegister(c, RequestCount, RcodeCount, RequestDuration, HealthcheckFailureCount, SocketGauge, MaxConcurrentRejectCount)
plugin/reload/setup.go:			metrics.MustRegister(c, reloadInfo, failedCount)
plugin/acl/setup.go:		metrics.MustRegister(c, RequestBlockCount, RequestAllowCount)
plugin/hosts/setup.go:		metrics.MustRegister(c, hostsEntries)
plugin/hosts/setup.go:		metrics.MustRegister(c, hostsReloadTime)
plugin/grpc/setup.go:		metrics.MustRegister(c, RequestCount, RcodeCount, RequestDuration)
plugin/metrics/register.go:// MustRegister registers the prometheus Collectors when the metrics plugin is used.
plugin/metrics/register.go:func MustRegister(c *caddy.Controller, cs ...prometheus.Collector) {
plugin/metrics/register.go:		x.MustRegister(c)
plugin/metrics/metrics.go:// MustRegister wraps m.Reg.MustRegister.
plugin/metrics/metrics.go:func (m *Metrics) MustRegister(c prometheus.Collector) {
plugin/health/setup.go:		metrics.MustRegister(c, HealthDuration)
plugin/template/metrics.go:		metrics.MustRegister(c, templateMatchesCount, templateFailureCount, templateRRFailureCount)
plugin/kubernetes/setup.go:		metrics.MustRegister(c, DnsProgrammingLatency)
plugin/autopath/setup.go:		metrics.MustRegister(c, autoPathCount)
plugin/cache/setup.go:		metrics.MustRegister(c,
plugin/dns64/setup.go:		metrics.MustRegister(c, RequestsTranslatedCount)

@miekg
Copy link
Member

miekg commented Jul 25, 2020

maybe we can add a smaller test in presubmit_test that check for MustRegister (instead of the Makefile test added here?)?

…istered

Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
@zouyee
Copy link
Member Author

zouyee commented Jul 25, 2020

maybe we can add a smaller test in presubmit_test that check for MustRegister (instead of the Makefile test added here?)?

The promauto functions contains the registration function, the MustRegister method could be removed or discarded?

Copy link
Collaborator

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@yongtang yongtang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@yongtang yongtang merged commit 4166dcc into coredns:master Jul 25, 2020
@zouyee zouyee deleted the promauto branch July 25, 2020 15:47
nyodas pushed a commit to DataDog/coredns that referenced this pull request Oct 26, 2020
…istered (coredns#4025)

Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check if metric is registererd
5 participants