Class JettyConnectionMetrics

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics
All Implemented Interfaces:
org.eclipse.jetty.io.Connection.Listener, org.eclipse.jetty.util.component.LifeCycle

public class JettyConnectionMetrics extends org.eclipse.jetty.util.component.AbstractLifeCycle implements org.eclipse.jetty.io.Connection.Listener
Jetty connection metrics.

Usage example:


 MeterRegistry registry = ...;
 Server server = new Server(0);
 Connector connector = new ServerConnector(server);
 connector.addBean(new JettyConnectionMetrics(registry));
 server.setConnectors(new Connector[] { connector });
 
Alternatively, configure on all connectors with addToAllConnectors(Server, MeterRegistry, Iterable).
Since:
1.4.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Connection.Listener

    org.eclipse.jetty.io.Connection.Listener.Adapter

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
    JettyConnectionMetrics(MeterRegistry registry, org.eclipse.jetty.server.Connector connector)
    Create a JettyConnectionMetrics instance.
    JettyConnectionMetrics(MeterRegistry registry, org.eclipse.jetty.server.Connector connector, Iterable<Tag> tags)
    Create a JettyConnectionMetrics instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addToAllConnectors(org.eclipse.jetty.server.Server server, MeterRegistry registry)
     
    static void
    addToAllConnectors(org.eclipse.jetty.server.Server server, MeterRegistry registry, Iterable<Tag> tags)
     
    void
    onClosed(org.eclipse.jetty.io.Connection connection)
     
    void
    onOpened(org.eclipse.jetty.io.Connection connection)
     

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    addLifeCycleListener, doStart, doStop, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • JettyConnectionMetrics

      public JettyConnectionMetrics(MeterRegistry registry)
    • JettyConnectionMetrics

      public JettyConnectionMetrics(MeterRegistry registry, Iterable<Tag> tags)
    • JettyConnectionMetrics

      public JettyConnectionMetrics(MeterRegistry registry, org.eclipse.jetty.server.Connector connector)
      Create a JettyConnectionMetrics instance. Connector.getName() will be used for connector.name tag.
      Parameters:
      registry - registry to use
      connector - connector to instrument
      Since:
      1.8.0
    • JettyConnectionMetrics

      public JettyConnectionMetrics(MeterRegistry registry, org.eclipse.jetty.server.Connector connector, Iterable<Tag> tags)
      Create a JettyConnectionMetrics instance. Connector.getName() will be used for connector.name tag.
      Parameters:
      registry - registry to use
      connector - connector to instrument
      tags - tags to add to metrics
      Since:
      1.8.0
  • Method Details

    • onOpened

      public void onOpened(org.eclipse.jetty.io.Connection connection)
      Specified by:
      onOpened in interface org.eclipse.jetty.io.Connection.Listener
    • onClosed

      public void onClosed(org.eclipse.jetty.io.Connection connection)
      Specified by:
      onClosed in interface org.eclipse.jetty.io.Connection.Listener
    • addToAllConnectors

      public static void addToAllConnectors(org.eclipse.jetty.server.Server server, MeterRegistry registry, Iterable<Tag> tags)
    • addToAllConnectors

      public static void addToAllConnectors(org.eclipse.jetty.server.Server server, MeterRegistry registry)