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
[SCB-422] prometheus switch to new mechanism #639
Conversation
wujimin
commented
Apr 8, 2018
fced737
to
702e18d
Compare
try { | ||
InetSocketAddress socketAddress = getSocketAddress(address); | ||
register(); | ||
this.httpServer = new HTTPServer(socketAddress, CollectorRegistry.defaultRegistry, true); |
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.
For future customization, I think we 'd provide way to export to servicecomb rest framework. And contribute the code to https://github.com/prometheus/client_java. If we can create a task to tracking this?
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.
By MetricsRestPublisher in previous PR, we already support metrics endpoint: /metrics
and created a issue for contribute: https://issues.apache.org/jira/browse/SCB-466
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.
This commit is fine. Future works see comments.
@@ -43,7 +42,10 @@ | |||
<groupId>org.apache.servicecomb</groupId> | |||
<artifactId>metrics-core</artifactId> | |||
</dependency> | |||
|
|||
<dependency> |
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.
Shouldn't the scope set to 'test' here?
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.
why test?
all servicecomb measurement come from metrics-core.
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 mean 'foundation-test-scaffolding'
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.
'foundation-test-scaffolding' already in 'test' scope, no need to set again.
Some files don't have proper final newline. |
import com.netflix.spectator.api.ManualClock; | ||
import com.netflix.spectator.api.Registry; | ||
import com.netflix.spectator.api.SpectatorUtils; | ||
import com.sun.net.httpserver.HttpServer; |
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.
Do we still need to use com.sun package ?
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.
prometheus depend on com.sun.net.httpserver.HttpServer
Counter counter = registry.counter("count.name", "tag1", "tag1v", "tag2", "tag2v"); | ||
counter.increment(); | ||
|
||
HTTPServer httpServer = (HTTPServer) FieldUtils.readField(publisher, "httpServer", true); |
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.
Can we find another way to find the server published address?
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.
we can use port 0 to try listen, and got the real port, and then close it
use the found real port to init prometheus.
but so complex, no need to do this, just a test case. i think reflection is enough.
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.
Fine.