Does a metric repeat every 7 days? Every 24 hours? The autocorrelation function (ACF) measures how correlated a series is with a lagged copy of itself:
(the standard estimator, dividing by the full-series variance).
Implement acf(x, max_lag) returning an array for lags 0..max_lag (lag 0 is always 1), and dominant_period(x, min_lag=2, max_lag=None): the lag in [min_lag, max_lag] with the highest ACF (lowest lag on ties), where max_lag defaults to len(x) // 2. Return 0.0s for a constant series' non-zero lags.