Class Metrics


  • public class Metrics
    extends java.lang.Object
    Logs workflow metrics to a file in the submit directory and also sends them over a HTTP connection to a Metrics Server.
    Version:
    $Revision$
    Author:
    Karan Vahi
    • Field Detail

      • METRICS_FILE_SUFFIX

        public static final java.lang.String METRICS_FILE_SUFFIX
        The suffix to use while constructing the name of the metrics file
        See Also:
        Constant Field Values
      • METRICS_SERVER_DEFAULT_URL

        public static final java.lang.String METRICS_SERVER_DEFAULT_URL
        The default URL for the metrics server to use
        See Also:
        Constant Field Values
      • COLLECT_METRICS_ENV_VARIABLE

        public static final java.lang.String COLLECT_METRICS_ENV_VARIABLE
        The name of the environment variable that sets whether to collect metrics or not
        See Also:
        Constant Field Values
      • PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE

        public static final java.lang.String PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE
        The name of the environment variable that overrides the default server url
        See Also:
        Constant Field Values
      • SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE

        public static final java.lang.String SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE
        The name of the environment variable that overrides the default server url
        See Also:
        Constant Field Values
      • METRICS_SEND_TIMEOUT

        public static final int METRICS_SEND_TIMEOUT
        The timeout in seconds for sending the metrics to the server
        See Also:
        Constant Field Values
      • mSendMetricsToServer

        private boolean mSendMetricsToServer
        boolean indicating whether to log metrics or not
      • mMetricsServers

        private java.util.List<java.lang.String> mMetricsServers
        The List of URLS for the metrics servers to report to.
      • mLogger

        private LogManager mLogger
        The logger object
    • Constructor Detail

      • Metrics

        public Metrics()
    • Method Detail

      • initialize

        public void initialize​(PegasusBag bag)
        Initializes the object
        Parameters:
        bag - bag of pegasus objects
      • logMetrics

        public void logMetrics​(PlannerMetrics metrics)
                        throws java.io.IOException
        Logs the metrics to the metrics server and to the submit directory
        Parameters:
        metrics -
        Throws:
        java.io.IOException
      • writeOutMetricsFile

        private java.io.File writeOutMetricsFile​(PlannerMetrics metrics)
                                          throws java.io.IOException
        Writes out the workflow metrics file in the submit directory
        Parameters:
        metrics - the metrics to be written out.
        Returns:
        the path to metrics file in the submit directory
        Throws:
        java.io.IOException - in case of error while writing out file.
      • sendMetricsSynchronously

        private void sendMetricsSynchronously​(PlannerMetrics metrics,
                                              java.lang.String url)
                                       throws java.io.IOException
        Sends the planner metrics to the metrics server
        Parameters:
        metrics - the metrics to log
        url - the url to send the metrics to
        Throws:
        java.io.IOException
      • sendMetricsAsynchronously

        private void sendMetricsAsynchronously​(PlannerMetrics metrics,
                                               java.lang.String url)
        Sends the planner metrics to the metrics server asynchrnously with a timeout of 5 seconds
        Parameters:
        metrics - the metrics to log
        url - the url to send the metrics to