-
Notifications
You must be signed in to change notification settings - Fork 949
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
feature: optimise the logic of using prometheus #2429
feature: optimise the logic of using prometheus #2429
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2429 +/- ##
==========================================
- Coverage 68.8% 68.57% -0.24%
==========================================
Files 272 272
Lines 18159 18175 +16
==========================================
- Hits 12495 12464 -31
- Misses 4248 4279 +31
- Partials 1416 1432 +16
|
@starnop After I developed this PR and thought deeply about metrics of gRPC server. I considered that we should save the gRPC metrics. That was beneficial for developers when they want to develop some functions, which perhaps were associated with communication between kubelet and pouchd. |
Request review. |
By the way, the main reason I upgrade the package called |
b7e0b70
to
ced1703
Compare
Sorry, I din't get the point about this PR. Could you explain more detail about what is good from using customize registry? Thanks |
|
Good to know. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
vendor/vendor.json
Outdated
@@ -1930,4 +1936,4 @@ | |||
} | |||
], | |||
"rootPath": "github.com/alibaba/pouch" | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should not be a change, please handle it, THX.
Except for the little problem above, LGTM. Thanks for your contribution. :) |
apis/server/router.go
Outdated
@@ -88,8 +89,8 @@ func initRoute(s *Server) http.Handler { | |||
s.addRoute(r, http.MethodPost, "/networks/{id:.*}/disconnect", s.disconnectNetwork) | |||
|
|||
// metrics | |||
r.Path(versionMatcher + "/metrics").Methods(http.MethodGet).Handler(prometheus.Handler()) | |||
r.Path("/metrics").Methods(http.MethodGet).Handler(prometheus.Handler()) | |||
r.Path(versionMatcher + "/metrics").Methods(http.MethodGet).Handler(promhttp.HandlerFor(util_metrics.GetCustomPrometheusRegistry(), promhttp.HandlerOpts{})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to make the function length short?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Let me fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if you could set the prometheus handler using s.addRoute
?
It would be the similar style as the other handler.
1. use the custom registry to replace the default. 2. upgrade the package called client-go of prometheus 3. add the new dependent package called promhttp Related to: AliyunContainerService#2395 Signed-off-by: fengzixu <[email protected]>
ced1703
to
5f04755
Compare
@HusterWan @starnop Request review again. I have fixed some problems above. |
@@ -63,3 +80,21 @@ func NewLabelTimer(subsystem, name, help string, labels ...string) *prometheus.H | |||
ConstLabels: nil, | |||
}, labels) | |||
} | |||
|
|||
// GetCustomPrometheusRegistry create a custom resigtry of Prometheus. | |||
func GetCustomPrometheusRegistry() *prometheus.Registry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use GetPrometheusRegistry
here. The Custom
is for the prometheus package, not for pouch. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, that is right. As a developer of pouch, he(she) should not care about custom or default.
lgtm |
Thanks for your contribution. @fengzixu |
@fengzixu could you follow up to change the name? thanks |
feature: modify the function name about prometheus registry 1. change function name `GetCustomPrometheusRegistry` to `GetPrometheusRegistry` Related to: AliyunContainerService#2429
feature: modify the function name about prometheus registry 1. change function name `GetCustomPrometheusRegistry` to `GetPrometheusRegistry` Related to: AliyunContainerService#2429
feature: modify the function name about prometheus registry 1. change function name `GetCustomPrometheusRegistry` to `GetPrometheusRegistry` Related to: AliyunContainerService#2429
feature: modify the function name about prometheus registry 1. change function name `GetCustomPrometheusRegistry` to `GetPrometheusRegistry` Related to: #2429
Signed-off-by: fengzixu [email protected]
Ⅰ. Describe what this PR did
Related to: #2395
Ⅱ. Does this pull request fix one issue?
#2395 #2414
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Ⅳ. Describe how to verify it
First, I complied a new binary pouchd, and I run it with parameters:
Second, I visted successfully the url:
http://<hostIP>:4243/metrics
so that I can capture metrics produced by pouchd.And then, I check some points about metrics:
Is there all metrics was registered successfully?
I saved the result about metrics: https://gist.github.com/fengzixu/ab018bd1d1fa8ddc56a6fe9150d36feb. I picked up some samples and compared with original metrics in code. There is no any difference.
Are the active metrics show commonly after I process some operations ?
I use the command
pouch pull nginx
to pull a image, and I re-captured the metrics from pouch. The figure of metrics about image has a little increase.Whether the metrics about gRPC server show commonly?
I started up a k8s cluster together with pouch. And I created some pods. After that I found that the metrics about gRPC between pouchd and kubelet has some figures. It was beneficial for me when I debug this function.
Ⅴ. Special notes for reviews