@Test public void getAllMetrics() throws Exception { registry.counter(name("foo").tag("bar", "baz").build()).inc(); registry.counter(name("qux").tag("quux", "foo").build()).inc(); final MockHttpServletResponse resp = new MockHttpServletResponse(); servlet.doGet(new MockHttpServletRequest(), resp); assertEquals("[" + "{\"name\":\"foo\",\"tags\":{\"bar\":\"baz\"},\"values\":{\"count\":1}}," + "{\"name\":\"qux\",\"tags\":{\"quux\":\"foo\"},\"values\":{\"count\":1}}" + "]", resp.getContentAsString()); }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); if (servletPlugin.getMetricsServletAllowedOrigin() != null) { resp.setHeader("Access-Control-Allow-Origin", servletPlugin.getMetricsServletAllowedOrigin()); } resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); try (OutputStream output = resp.getOutputStream()) { String jsonpParamName = servletPlugin.getMetricsServletJsonpParamName(); if (jsonpParamName != null && req.getParameter(jsonpParamName) != null) { getWriter(req).writeValue(output, new JSONPObject(req.getParameter(jsonpParamName), registry)); } else { getWriter(req).writeValue(output, registry); } } }
StagemonitorMetricsServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); if (servletPlugin.getMetricsServletAllowedOrigin() != null) { resp.setHeader("Access-Control-Allow-Origin", servletPlugin.getMetricsServletAllowedOrigin()); } resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); try (OutputStream output = resp.getOutputStream()) { String jsonpParamName = servletPlugin.getMetricsServletJsonpParamName(); if (jsonpParamName != null && req.getParameter(jsonpParamName) != null) { getWriter(req).writeValue(output, new JSONPObject(req.getParameter(jsonpParamName), registry)); } else { getWriter(req).writeValue(output, registry); } } } }
StagemonitorMetricsServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); if (servletPlugin.getMetricsServletAllowedOrigin() != null) { resp.setHeader("Access-Control-Allow-Origin", servletPlugin.getMetricsServletAllowedOrigin()); } resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); try (OutputStream output = resp.getOutputStream()) { String jsonpParamName = servletPlugin.getMetricsServletJsonpParamName(); if (jsonpParamName != null && req.getParameter(jsonpParamName) != null) { getWriter(req).writeValue(output, new JSONPObject(req.getParameter(jsonpParamName), registry)); } else { getWriter(req).writeValue(output, registry); } } } StagemonitorMetricsServlet();  StagemonitorMetricsServlet(Metric2Registry registry, ServletPlugin servletPlugin, ObjectMapper mapper); }
StagemonitorMetricsServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); if (servletPlugin.getMetricsServletAllowedOrigin() != null) { resp.setHeader("Access-Control-Allow-Origin", servletPlugin.getMetricsServletAllowedOrigin()); } resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); try (OutputStream output = resp.getOutputStream()) { String jsonpParamName = servletPlugin.getMetricsServletJsonpParamName(); if (jsonpParamName != null && req.getParameter(jsonpParamName) != null) { getWriter(req).writeValue(output, new JSONPObject(req.getParameter(jsonpParamName), registry)); } else { getWriter(req).writeValue(output, registry); } } } StagemonitorMetricsServlet();  StagemonitorMetricsServlet(Metric2Registry registry, ServletPlugin servletPlugin, ObjectMapper mapper);  }
StagemonitorMetricsServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); if (servletPlugin.getMetricsServletAllowedOrigin() != null) { resp.setHeader("Access-Control-Allow-Origin", servletPlugin.getMetricsServletAllowedOrigin()); } resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); try (OutputStream output = resp.getOutputStream()) { String jsonpParamName = servletPlugin.getMetricsServletJsonpParamName(); if (jsonpParamName != null && req.getParameter(jsonpParamName) != null) { getWriter(req).writeValue(output, new JSONPObject(req.getParameter(jsonpParamName), registry)); } else { getWriter(req).writeValue(output, registry); } } } StagemonitorMetricsServlet();  StagemonitorMetricsServlet(Metric2Registry registry, ServletPlugin servletPlugin, ObjectMapper mapper);   }