-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[Metrics]Ray java worker metric registry #9636
Merged
raulchen
merged 28 commits into
ray-project:master
from
antgroup:ray-java-worker-metric-registry
Jul 28, 2020
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
756e56e
ray worker metrics gauge init
ashione dbaac23
ray java metric mapping
ashione 8904d69
Merge branch 'master' into ray-java-worker-metric
ashione 94ac047
add jni source files for gauge and tagkey
ashione e9fbb6b
Merge branch 'ray-java-worker-metric' of https://github.com/ant-tech-…
ashione 275486d
mapping all metric classes to stats object
ashione 1120d95
check non-null for tags and name
ashione 1bba30a
lint
ashione 38b5105
add symbol for native metric JNI
ashione 07efb1b
extern c for symbol
ashione a6fe5f0
add tests for all metrics
ashione 98dc2d9
Update Metric.java
ashione 426190e
Merge branch 'master' into ray-java-worker-metric
ashione bff1905
Merge remote-tracking branch 'github/master' into ray-java-worker-metric
ashione fe4cbbb
Merge remote-tracking branch 'origin/ray-java-worker-metric' into ray…
ashione 3dbd5cf
unify metric native stuff to one class
ashione d87486f
Merge remote-tracking branch 'github/master' into ray-java-worker-metric
ashione de963d7
fix jni file
ashione ad3de09
add comments for metric transform function in jni utils
ashione 287f891
move metric function to native metric file
ashione 7e99c97
remove unused disconnect jni
ashione a08cd14
Add a metric registry for java metircs
zhongchun e7e7050
Merge remote-tracking branch 'ray/master' into ray-java-worker-metric…
zhongchun cf3a398
Restore install-bazel.sh
zhongchun 6a185b6
Add some comments for metric registry
zhongchun dc39cf1
Fix thread safe problem of metrics
zhongchun 348f818
Fix metric tests and remove sleep code from tests
zhongchun d4a617a
Fix comments of metrics
zhongchun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
java/runtime/src/main/java/io/ray/runtime/metric/MetricConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package io.ray.runtime.metric; | ||
|
||
import com.google.common.base.MoreObjects; | ||
|
||
/** | ||
* Configurations of the metric. | ||
*/ | ||
public class MetricConfig { | ||
|
||
private static final long DEFAULT_TIME_INTERVAL_MS = 5000L; | ||
private static final int DEFAULT_THREAD_POLL_SIZE = 1; | ||
private static final long DEFAULT_SHUTDOWN_WAIT_TIME_MS = 3000L; | ||
|
||
public static final MetricConfig DEFAULT_CONFIG = | ||
new MetricConfig(DEFAULT_TIME_INTERVAL_MS, DEFAULT_THREAD_POLL_SIZE, | ||
DEFAULT_SHUTDOWN_WAIT_TIME_MS); | ||
|
||
private final long timeIntervalMs; | ||
private final int threadPoolSize; | ||
private final long shutdownWaitTimeMs; | ||
|
||
public MetricConfig(long timeIntervalMs, int threadPoolSize, long shutdownWaitTimeMs) { | ||
this.timeIntervalMs = timeIntervalMs; | ||
this.threadPoolSize = threadPoolSize; | ||
this.shutdownWaitTimeMs = shutdownWaitTimeMs; | ||
} | ||
|
||
public long timeIntervalMs() { | ||
return timeIntervalMs; | ||
} | ||
|
||
public int threadPoolSize() { | ||
return threadPoolSize; | ||
} | ||
|
||
public long shutdownWaitTimeMs() { | ||
return shutdownWaitTimeMs; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("timeIntervalMs", timeIntervalMs) | ||
.add("threadPoolSize", threadPoolSize) | ||
.add("shutdownWaitTimeMs", shutdownWaitTimeMs) | ||
.toString(); | ||
} | ||
|
||
public static MetricConfigBuilder builder() { | ||
return new MetricConfigBuilder(); | ||
} | ||
|
||
public static class MetricConfigBuilder { | ||
private long timeIntervalMs = DEFAULT_TIME_INTERVAL_MS; | ||
private int threadPooSize = DEFAULT_THREAD_POLL_SIZE; | ||
private long shutdownWaitTimeMs = DEFAULT_SHUTDOWN_WAIT_TIME_MS; | ||
|
||
public MetricConfig create() { | ||
return new MetricConfig(timeIntervalMs, threadPooSize, shutdownWaitTimeMs); | ||
} | ||
|
||
public MetricConfigBuilder timeIntervalMs(long timeIntervalMs) { | ||
this.timeIntervalMs = timeIntervalMs; | ||
return this; | ||
} | ||
|
||
public MetricConfigBuilder threadPoolSize(int threadPooSize) { | ||
this.threadPooSize = threadPooSize; | ||
return this; | ||
} | ||
|
||
public MetricConfigBuilder shutdownWaitTimeMs(long shutdownWaitTimeMs) { | ||
this.shutdownWaitTimeMs = shutdownWaitTimeMs; | ||
return this; | ||
} | ||
} | ||
|
||
|
||
} |
64 changes: 64 additions & 0 deletions
64
java/runtime/src/main/java/io/ray/runtime/metric/MetricId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.ray.runtime.metric; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* MetricId represents a metric with a given type, name and tags. | ||
* If two metrics have the same type and name but different tags(including key and value), they have | ||
* a different MetricId. And in this way, {@link MetricRegistry} can register two metrics with same | ||
* name but different tags. | ||
*/ | ||
public class MetricId { | ||
|
||
private final MetricType type; | ||
private final String name; | ||
private final Map<TagKey, String> tags; | ||
|
||
public MetricId(MetricType type, String name, Map<TagKey, String> tags) { | ||
this.type = type; | ||
this.name = name; | ||
this.tags = tags; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof MetricId)) { | ||
return false; | ||
} | ||
MetricId metricId = (MetricId) o; | ||
return type == metricId.type && | ||
Objects.equals(name, metricId.name) && | ||
Objects.equals(tags, metricId.tags); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(type, name, tags); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("type", type) | ||
.add("name", name) | ||
.add("tags", tags) | ||
.toString(); | ||
} | ||
|
||
public MetricType getType() { | ||
return type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Map<TagKey, String> getTags() { | ||
return tags; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the metric id used for? Could you add some comments?
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.