Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

Commit

Permalink
use one API call for all folders
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossbe committed Feb 25, 2019
1 parent 9975a58 commit 61c3ad4
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 103 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ Version | Author | Comment
1.2 | Alex Bradley, Martin Macura, Guenter Grossberger | Download new HAR file format, add JMeter label to metric path (optional), by default don't download 'full' logs, avoid high cpu in unzip
1.2.1 | Guenter Grossberger | added asm.skipNoCheckpointAvailable property and changed artifact and file names
1.3 | Guenter Grossberger | changed some metric types for better/correct aggregation - this may lead to error messages after restart with the new version
1.4 | Martin Macura | Prevent gaps in metrics on ASM API timeouts.
1.4 | Martin Macura | Prevent gaps in metrics on ASM API timeouts.
1.5 | Martin Macura, Roderick Olliver | Added HAR parser. Various bugfixes and improvements.
1.6 | Guenter Grossberger | Use one API call for all folders.
14 changes: 7 additions & 7 deletions asm-monitor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.ca.apm.extensions</groupId>
<artifactId>asm-monitor</artifactId>
<version>1.5.8</version>
<version>1.6.0</version>
<name>ASMMonitor</name>
<description>Extension to integrate App Synthetic Monitor (fka Cloud Monitor, WatchMouse) into CA APM.</description>

Expand Down Expand Up @@ -43,12 +43,12 @@
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,35 @@ private void startThreads(HashMap<String, List<Monitor>> folderMap) {

futureMap = new HashMap<ScheduledFuture<?>, String>();

for (Iterator<String> it = folderMap.keySet().iterator(); it.hasNext(); ) {
String folder = it.next();
if (EpaUtils.getBooleanProperty(QUERY_BY_FOLDERS, false)) {
for (Iterator<String> it = folderMap.keySet().iterator(); it.hasNext(); ) {
String folder = it.next();
AsmReaderThread rt = new AsmReaderThread(
folder,
requestHelper,
folderMap,
metricWriter,
reporterService);
ScheduledFuture<?> future = folderService.scheduleAtFixedRate(rt,
delay,
epaWaitTime,
TimeUnit.MILLISECONDS);
futureMap.put(future, folder);
delay += stagger;
}
} else {
// query all folders in one call
AsmReaderThread rt = new AsmReaderThread(
folder,
requestHelper,
folderMap,
metricWriter,
reporterService);
AsmProperties.ALL_FOLDERS,
requestHelper,
folderMap,
metricWriter,
reporterService);
ScheduledFuture<?> future = folderService.scheduleAtFixedRate(rt,
delay,
epaWaitTime,
TimeUnit.MILLISECONDS);
futureMap.put(future, folder);
delay += stagger;
0,
epaWaitTime,
TimeUnit.MILLISECONDS);
futureMap.put(future, null);
}

stopped = false;
Expand Down Expand Up @@ -752,4 +767,12 @@ private static void log(SeverityLevel level, String key, Object... params) {
private static void error(String message, Throwable throwable) {
EpaUtils.getFeedback().error(module, message, throwable);
}

/**
* Trigger reload of the configuration at the next possible time (async).
*/
public void reloadConfiguration() {
lastConfigUpdateTimestamp = 0;
log(SeverityLevel.VERBOSE, "triggered async reload of configuration");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.ca.apm.swat.epaplugins.utils.AsmProperties;
import com.ca.apm.swat.epaplugins.utils.ErrorUtils;
import com.wily.introscope.epagent.EpaUtils;
import com.wily.util.feedback.IModuleFeedbackChannel;
import com.wily.util.feedback.Module;

/**
Expand Down Expand Up @@ -95,55 +96,64 @@ public void run() {
* @throws Exception errors
*/
public HashMap<String, String> getFolderMetrics() throws Exception {
IModuleFeedbackChannel log = EpaUtils.getFeedback();
MetricMap resultMetricMap = new MetricMap();

List<Monitor> folderMonitors = this.folderMap.get(folder);
String folderPrefix = null;
int monitorCount = requestHelper.getActiveMonitorCount();

if ((null == folderMonitors) || (0 == folderMonitors.size())) {
return resultMetricMap;
}
if (!folder.equals(ALL_FOLDERS)) {
List<Monitor> folderMonitors = this.folderMap.get(folder);

if (EpaUtils.getFeedback().isVerboseEnabled(module)) {
EpaUtils.getFeedback().verbose(module,
AsmMessages.getMessage(AsmMessages.GET_FOLDER_DATA_301,
folderMonitors.size(), folder));
}
if ((null == folderMonitors) || (0 == folderMonitors.size())) {
return resultMetricMap;
}

if (log.isVerboseEnabled(module)) {
log.verbose(module,
AsmMessages.getMessage(AsmMessages.GET_FOLDER_DATA_301,
folderMonitors.size(), folder));
}

// prefix for metric name
String folderPrefix = MONITOR_METRIC_PREFIX + folder;
// prefix for metric name
folderPrefix = MONITOR_METRIC_PREFIX + folder;
monitorCount = folderMonitors.size();

if (ROOT_FOLDER.equals(folder)) {
folder = EMPTY_STRING;
// remove trailing '|'
folderPrefix = MONITOR_METRIC_PREFIX.substring(0, MONITOR_METRIC_PREFIX.length() - 1);
if (ROOT_FOLDER.equals(folder)) {
folder = EMPTY_STRING;
// remove trailing '|'
folderPrefix = MONITOR_METRIC_PREFIX.substring(0,
MONITOR_METRIC_PREFIX.length() - 1);
}
}

// get stats for folder
try {
if (EpaUtils.getBooleanProperty(METRICS_STATS_FOLDER, false)) {
if (EpaUtils.getFeedback().isVerboseEnabled(module)) {
EpaUtils.getFeedback()
if (log.isVerboseEnabled(module)) {
log
.verbose(module,
AsmMessages.getMessage(AsmMessages.GET_STATS_DATA_302,
folderMonitors.size(), folder));
monitorCount, folder));
}

// get aggregated folder stats
resultMetricMap.putAll(requestHelper.getStats(folder, folderPrefix, true));
} else {
EpaUtils.getFeedback()
.verbose(module,
AsmMessages.getMessage(AsmMessages.GET_NO_STATS_DATA_303, folder));
log.verbose(module,
AsmMessages.getMessage(AsmMessages.GET_NO_STATS_DATA_303, folder));
}
} catch (Exception e) {
EpaUtils.getFeedback().warn(module, AsmMessages
log.warn(module, AsmMessages
.getMessage(AsmMessages.METRIC_READ_WARN_704,
folder, STATS_CMD, e.getMessage()));
if (log.isDebugEnabled(module)) {
log.debug(module, ErrorUtils.getStackTrace(e));
}
}

if (Thread.currentThread().isInterrupted()) {
EpaUtils.getFeedback()
.verbose(module,
log.verbose(module,
"thread interrupted - "
+ AsmMessages.getMessage(AsmMessages.GET_FOLDER_METRICS_304,
folder, resultMetricMap.size()));
Expand All @@ -158,14 +168,15 @@ public HashMap<String, String> getFolderMetrics() throws Exception {
resultMetricMap.putAll(requestHelper.getStats(folder, folderPrefix, false));
}
} catch (Exception e) {
EpaUtils.getFeedback().warn(module, AsmMessages
.getMessage(AsmMessages.METRIC_READ_WARN_704,
log.warn(module, AsmMessages.getMessage(AsmMessages.METRIC_READ_WARN_704,
folder, STATS_CMD, e.getMessage()));
if (log.isDebugEnabled(module)) {
log.debug(module, ErrorUtils.getStackTrace(e));
}
}

if (Thread.currentThread().isInterrupted()) {
EpaUtils.getFeedback()
.verbose(module,
log.verbose(module,
"thread interrupted - "
+ AsmMessages.getMessage(AsmMessages.GET_FOLDER_METRICS_304,
folder, resultMetricMap.size()));
Expand All @@ -176,7 +187,7 @@ public HashMap<String, String> getFolderMetrics() throws Exception {
try {
if (EpaUtils.getBooleanProperty(METRICS_LOGS, false)) {
LogResult result = requestHelper.getLogs(folder,
folderMonitors.size(),
monitorCount,
folderPrefix,
lastId);
if (result.getLastId() != null) {
Expand All @@ -185,13 +196,13 @@ public HashMap<String, String> getFolderMetrics() throws Exception {
resultMetricMap.putAll(result.getMap());
}
} catch (Exception e) {
EpaUtils.getFeedback().warn(module, AsmMessages
.getMessage(AsmMessages.METRIC_READ_WARN_704,
log.warn(module, AsmMessages.getMessage(AsmMessages.METRIC_READ_WARN_704,
folder, LOGS_CMD, e.getMessage()));
log.debug(module, ErrorUtils.getStackTrace(e));
}

if (Thread.currentThread().isInterrupted()) {
EpaUtils.getFeedback()
log
.verbose(module,
"thread interrupted - "
+ AsmMessages.getMessage(AsmMessages.GET_FOLDER_METRICS_304,
Expand All @@ -205,17 +216,19 @@ public HashMap<String, String> getFolderMetrics() throws Exception {
resultMetricMap.putAll(requestHelper.getPsp(folder, folderPrefix));
}
} catch (Exception e) {
EpaUtils.getFeedback().warn(module, AsmMessages
.getMessage(AsmMessages.METRIC_READ_WARN_704,
folder, PSP_CMD, e.getMessage()));
log.warn(module, AsmMessages.getMessage(AsmMessages.METRIC_READ_WARN_704,
folder, PSP_CMD, e.getMessage()));
if (log.isDebugEnabled(module)) {
log.debug(module, ErrorUtils.getStackTrace(e));
}
}
}

if (EpaUtils.getFeedback().isVerboseEnabled(module)) {
EpaUtils.getFeedback().verbose(module,
AsmMessages
.getMessage(AsmMessages.GET_FOLDER_METRICS_304,
folder, resultMetricMap.size()));
if (log.isVerboseEnabled(module)) {
log.verbose(module,
AsmMessages.getMessage(AsmMessages.GET_FOLDER_METRICS_304,
folder,
resultMetricMap.size()));
}
return resultMetricMap;
}
Expand Down
Loading

0 comments on commit 61c3ad4

Please sign in to comment.