public class Metrics extends Object
Modifier and Type | Field and Description |
---|---|
static String |
COLLECT_METRICS_ENV_VARIABLE
The name of the environment variable that sets whether to collect metrics or not
|
static 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 String |
METRICS_SERVER_DEFAULT_URL
The default URL for the metrics server to use
|
private LogManager |
mLogger
The logger object
|
private List<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 String |
PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE
The name of the environment variable that overrides the default server url
|
static String |
SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE
The name of the environment variable that overrides the default server url
|
Constructor and Description |
---|
Metrics() |
Modifier and Type | Method and Description |
---|---|
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,
String url)
Sends the planner metrics to the metrics server asynchrnously with a
timeout of 5 seconds
|
private void |
sendMetricsSynchronously(PlannerMetrics metrics,
String url)
Sends the planner metrics to the metrics server
|
private File |
writeOutMetricsFile(PlannerMetrics metrics)
Writes out the workflow metrics file in the submit directory
|
public static final String METRICS_FILE_SUFFIX
public static final String METRICS_SERVER_DEFAULT_URL
public static final String COLLECT_METRICS_ENV_VARIABLE
public static final String PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE
public static final String SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE
public static final int METRICS_SEND_TIMEOUT
private boolean mSendMetricsToServer
private List<String> mMetricsServers
private LogManager mLogger
public void initialize(PegasusBag bag)
bag
- bag of pegasus objectspublic void logMetrics(PlannerMetrics metrics) throws IOException
metrics
- IOException
private File writeOutMetricsFile(PlannerMetrics metrics) throws IOException
metrics
- the metrics to be written out.IOException
- in case of error while writing out file.private void sendMetricsSynchronously(PlannerMetrics metrics, String url) throws IOException
metrics
- the metrics to logurl
- the url to send the metrics toIOException
private void sendMetricsAsynchronously(PlannerMetrics metrics, String url)
metrics
- the metrics to logurl
- the url to send the metrics to