class MetricRegistryHolder {

    @SuppressWarnings("unchecked")
    public <T> SimpleSensor<T> getOrCreateSimpleSensor(String metricName) {
        final Gauge sensor = metrics.gauge(metricName, SimpleSensor::new);
        if (sensor instanceof SimpleSensor) {
            return (SimpleSensor<T>) sensor;
        }
        throw new IllegalArgumentException(metricName + " is already used for a different type of metric");
    }

    private  MetricRegistryHolder();

}