edu.isi.pegasus.planner.code.generator

## Class Metrics

- java.lang.Object
- - edu.isi.pegasus.planner.code.generator.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 Summary

Fields
`static java.lang.String` `COLLECT_METRICS_ENV_VARIABLE` The name of the environment variable that sets whether to collect metrics or not
`static java.lang.String` `METRICS_FILE_SUFFIX` The suffix to use while constructing the name of the metrics file
`static int` `METRICS_SEND_TIMEOUT` The timeout in seconds for sending the metrics to the server
`static java.lang.String` `METRICS_SERVER_DEFAULT_URL` The default URL for the metrics server to use
`private LogManager` `mLogger` The logger object
`private java.util.List<java.lang.String>` `mMetricsServers` The List of URLS for the metrics servers to report to.
`private boolean` `mSendMetricsToServer` boolean indicating whether to log metrics or not
`static java.lang.String` `PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE` The name of the environment variable that overrides the default server url
`static java.lang.String` `SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE` The name of the environment variable that overrides the default server url

### Constructor Summary

Constructors
Constructor and Description
`Metrics()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `initialize(PegasusBag bag)` Initializes the object
`void` `logMetrics(PlannerMetrics metrics)` Logs the metrics to the metrics server and to the submit directory
`private void` `sendMetricsAsynchronously(PlannerMetrics metrics, java.lang.String url)` Sends the planner metrics to the metrics server asynchrnously with a timeout of 5 seconds
`private void` `sendMetricsSynchronously(PlannerMetrics metrics, java.lang.String url)` Sends the planner metrics to the metrics server
`private java.io.File` `writeOutMetricsFile(PlannerMetrics metrics)` Writes out the workflow metrics file in the submit directory

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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