mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 16:23:54 +08:00
[Stats] metrics agent exporter (#9361)
This commit is contained in:
+14
-3
@@ -55,6 +55,10 @@ class ReporterServer(reporter_pb2_grpc.ReporterServiceServicer):
|
||||
return reporter_pb2.GetProfilingStatsReply(
|
||||
profiling_stats=profiling_stats, stdout=stdout, stderr=stderr)
|
||||
|
||||
def ReportMetrics(self, request, context):
|
||||
# TODO(sang): Process metrics here.
|
||||
return reporter_pb2.ReportMetricsReply()
|
||||
|
||||
|
||||
def recursive_asdict(o):
|
||||
if isinstance(o, tuple) and hasattr(o, "_asdict"):
|
||||
@@ -94,11 +98,12 @@ class Reporter:
|
||||
redis_client: A client used to communicate with the Redis server.
|
||||
"""
|
||||
|
||||
def __init__(self, redis_address, redis_password=None):
|
||||
def __init__(self, redis_address, port, redis_password=None):
|
||||
"""Initialize the reporter object."""
|
||||
self.cpu_counts = (psutil.cpu_count(), psutil.cpu_count(logical=False))
|
||||
self.ip = ray.services.get_node_ip_address()
|
||||
self.hostname = platform.node()
|
||||
self.port = port
|
||||
|
||||
_ = psutil.cpu_percent() # For initialization
|
||||
|
||||
@@ -225,7 +230,7 @@ class Reporter:
|
||||
server = grpc.server(thread_pool, options=(("grpc.so_reuseport", 0), ))
|
||||
reporter_pb2_grpc.add_ReporterServiceServicer_to_server(
|
||||
ReporterServer(), server)
|
||||
port = server.add_insecure_port("[::]:0")
|
||||
port = server.add_insecure_port("[::]:{}".format(self.port))
|
||||
server.start()
|
||||
self.redis_client.set("REPORTER_PORT:{}".format(self.ip), port)
|
||||
"""Run the reporter."""
|
||||
@@ -248,6 +253,11 @@ if __name__ == "__main__":
|
||||
required=True,
|
||||
type=str,
|
||||
help="The address to use for Redis.")
|
||||
parser.add_argument(
|
||||
"--port",
|
||||
required=True,
|
||||
type=int,
|
||||
help="The port to bind the reporter process.")
|
||||
parser.add_argument(
|
||||
"--redis-password",
|
||||
required=False,
|
||||
@@ -270,7 +280,8 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
ray.utils.setup_logger(args.logging_level, args.logging_format)
|
||||
|
||||
reporter = Reporter(args.redis_address, redis_password=args.redis_password)
|
||||
reporter = Reporter(
|
||||
args.redis_address, args.port, redis_password=args.redis_password)
|
||||
|
||||
try:
|
||||
reporter.run()
|
||||
|
||||
Reference in New Issue
Block a user