Made metricsFactory optional