001/* 002 * Copyright 2013 Prometheus Team Licensed under the Apache License, Version 2.0 003 * (the "License"); you may not use this file except in compliance with the 004 * License. You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 010 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 011 * License for the specific language governing permissions and limitations under 012 * the License. 013 */ 014 015package io.prometheus.client.examples.simple; 016 017import io.prometheus.client.Prometheus; 018import io.prometheus.client.utility.servlet.MetricsServlet; 019import org.eclipse.jetty.server.Server; 020import org.eclipse.jetty.servlet.ServletContextHandler; 021import org.eclipse.jetty.servlet.ServletHolder; 022 023/** 024 * @author matt.proud@gmail.com (Matt T. Proud) 025 */ 026public class Main { 027 public static void main(String[] arguments) { 028 Prometheus.defaultInitialize(); 029 030 final Server server = new Server(8080); 031 final ServletContextHandler context = new ServletContextHandler(); 032 context.setContextPath("/"); 033 server.setHandler(context); 034 context.addServlet(new ServletHolder(new MetricsServlet()), "/"); 035 try { 036 server.start(); 037 server.join(); 038 } catch (Exception e) { 039 e.printStackTrace(); 040 } 041 } 042}