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

[SCB-422] prometheus switch to new mechanism #639

Merged
merged 1 commit into from Apr 10, 2018

Conversation

wujimin
Copy link
Contributor

@wujimin wujimin commented Apr 8, 2018

image

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 87.827% when pulling 702e18d on wujimin:metrics-prometheus into f65a9b3 on apache:master.

try {
InetSocketAddress socketAddress = getSocketAddress(address);
register();
this.httpServer = new HTTPServer(socketAddress, CollectorRegistry.defaultRegistry, true);
Copy link
Contributor

@liubao68 liubao68 Apr 9, 2018

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?

Copy link
Contributor Author

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

Copy link
Contributor

@liubao68 liubao68 left a 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>
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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'

Copy link
Contributor Author

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.

@yangbor
Copy link
Member

yangbor commented Apr 9, 2018

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;
Copy link
Member

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 ?

Copy link
Contributor Author

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);
Copy link
Member

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?

Copy link
Contributor Author

@wujimin wujimin Apr 9, 2018

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.

Copy link
Member

Choose a reason for hiding this comment

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

Fine.

@wujimin wujimin merged commit 4f8f810 into apache:master Apr 10, 2018
@wujimin wujimin deleted the metrics-prometheus branch April 20, 2018 06:58
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.

None yet

5 participants