the metrics pushed to a metric handling service in your
infrastructure, implement a
torch.distributed.elastic.metrics.MetricHandler and configure it
in your custom launcher.
# my_launcher.py
import torch.distributed.elastic.metrics as metrics
class MyMetricHandler(metrics.MetricHandler):
       def emit(self, metric_data: metrics.MetricData):
           # push metric_data to your metric sink
def main():
     metrics.configure(MyMetricHandler())
 spec = WorkerSpec(...)
 agent = LocalElasticAgent(spec)
 agent.run()

Events Handler
TorchElastic supports events recording (see Events). The events module
defines API that allows you to record events and implement custom
EventHandler. EventHandler is used for publishing events produced
during torchelastic execution to different sources, e.g.  AWS
CloudWatch. By default it uses
torch.distributed.elastic.events.NullEventHandler that ignores
events. To configure custom events handler you need to implement