<commit_before><commit_msg>add health check servlet<commit_after>package com.github.digital_wonderland.sling_metrics.servlets;

import com.github.digital_wonderland.sling_metrics.service.HealthCheckService;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.sling.SlingServlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;

@SlingServlet(paths = "/bin/sling-metrics/healthcheck", methods = "GET")
public class HealthCheckServlet extends com.codahale.metrics.servlets.HealthCheckServlet {

    @Reference
    private HealthCheckService healthCheckService;

    private ServletConfig servletConfig;

    @Override
    public void init(final ServletConfig config) throws ServletException {
        servletConfig = config;
        servletConfig.getServletContext().setAttribute(HEALTH_CHECK_REGISTRY, healthCheckService.getRegistry());
        super.init(servletConfig);
    }

    @Deactivate
    protected void deactivate() {
        servletConfig.getServletContext().removeAttribute(HEALTH_CHECK_REGISTRY);
    }

}
{'fraction_non_alphanumeric': 0.0870712401055409, 'fraction_numerical': 0.0, 'mean_word_length': 5.35754189944134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '836697', 'n_tokens_mistral': 324, 'n_tokens_neox': 311, 'n_words': 51}