提交 331ebfab 编写于 作者: L leon.li

add contact info in metric dashboard page

上级 9894cea0
......@@ -153,7 +153,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all.add(C(MetricGraphCreator.class).req(CachedMetricReportService.class, DataExtractor.class,
MetricDataFetcher.class).req(BaselineService.class, MetricConfigManager.class,
ProductLineConfigManager.class, MetricGroupConfigManager.class, AlertInfo.class));
ProductLineConfigManager.class, MetricGroupConfigManager.class, AlertInfo.class, ProjectDao.class));
all.add(C(SystemGraphCreator.class).req(CachedMetricReportService.class, DataExtractor.class,
MetricDataFetcher.class).req(BaselineService.class, MetricConfigManager.class,
......@@ -205,8 +205,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all.add(C(AlertExceptionBuilder.class).req(ExceptionConfigManager.class));
all.add(C(ExceptionAlert.class).req(ProjectDao.class, ExceptionAlertConfig.class, MailSMS.class,
ExceptionConfigManager.class, AlertExceptionBuilder.class, AlertDao.class).req(
ModelService.class, TopAnalyzer.ID));
ExceptionConfigManager.class, AlertExceptionBuilder.class, AlertDao.class).req(ModelService.class,
TopAnalyzer.ID));
all.add(C(AlertSummaryExecutor.class).req(AlertSummaryGenerator.class, AlertSummaryManager.class, MailSMS.class)
.req(AlertSummaryDecorator.class, AlertSummaryFTLDecorator.ID));
......
......@@ -11,18 +11,59 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.unidal.lookup.annotation.Inject;
import com.dianping.cat.Cat;
import com.dianping.cat.advanced.metric.config.entity.MetricItemConfig;
import com.dianping.cat.consumer.company.model.entity.ProductLine;
import com.dianping.cat.consumer.metric.model.entity.MetricReport;
import com.dianping.cat.core.dal.Project;
import com.dianping.cat.core.dal.ProjectDao;
import com.dianping.cat.core.dal.ProjectEntity;
import com.dianping.cat.helper.Chinese;
import com.dianping.cat.helper.TimeUtil;
import com.dianping.cat.home.metric.group.entity.MetricKeyConfig;
import com.dianping.cat.report.chart.AbstractGraphCreator;
import com.dianping.cat.report.page.LineChart;
import com.dianping.cat.report.task.alert.MetricType;
import com.site.lookup.util.StringUtils;
public class MetricGraphCreator extends AbstractGraphCreator {
@Inject
private ProjectDao m_projectDao;
protected String buildContactInfo(String domainName) {
try {
Project project = m_projectDao.findByDomain(domainName, ProjectEntity.READSET_FULL);
String owners = project.getOwner();
String phones = project.getPhone();
StringBuilder builder = new StringBuilder();
if (!StringUtils.isEmpty(owners)) {
builder.append("[负责人: ").append(owners);
}
if (!StringUtils.isEmpty(phones)) {
builder.append(" 手机: ").append(phones).append(" ]");
}
return builder.toString();
} catch (Exception ex) {
Cat.logError("build contact info error for doamin: " + domainName, ex);
}
return null;
}
private String extractDomain(String metricKey) {
try {
return metricKey.split(":")[0];
} catch (Exception ex) {
Cat.logError("extract domain error:" + metricKey, ex);
return null;
}
}
public Map<String, LineChart> buildChartData(final Map<String, double[]> datas, Date startDate, Date endDate,
final Map<String, double[]> dataWithOutFutures) {
Map<String, LineChart> charts = new LinkedHashMap<String, LineChart>();
......@@ -31,10 +72,11 @@ public class MetricGraphCreator extends AbstractGraphCreator {
for (Entry<String, double[]> entry : dataWithOutFutures.entrySet()) {
String key = entry.getKey();
String contactInfo = buildContactInfo(extractDomain(key));
double[] value = entry.getValue();
LineChart lineChart = new LineChart();
buildLineChartTitle(alertKeys, lineChart, key);
buildLineChartTitle(alertKeys, lineChart, key, contactInfo);
lineChart.setStart(startDate);
lineChart.setSize(value.length);
lineChart.setStep(step * TimeUtil.ONE_MINUTE);
......@@ -57,7 +99,7 @@ public class MetricGraphCreator extends AbstractGraphCreator {
Map<String, double[]> dataWithOutFutures = removeFutureData(endDate, allCurrentValues);
return buildChartData(oldCurrentValues, startDate, endDate, dataWithOutFutures);
}
private Map<String, double[]> prepareAllData(String productLine, Date startDate, Date endDate) {
long start = startDate.getTime(), end = endDate.getTime();
int totalSize = (int) ((end - start) / TimeUtil.ONE_MINUTE);
......@@ -72,7 +114,6 @@ public class MetricGraphCreator extends AbstractGraphCreator {
}
return oldCurrentValues;
}
private Map<String, double[]> queryMetricValueByDate(String productLine, long start) {
MetricReport metricReport = m_metricReportService.queryMetricReport(productLine, new Date(start));
......@@ -199,7 +240,7 @@ public class MetricGraphCreator extends AbstractGraphCreator {
}
return false;
}
private String queryMetricItemDes(String type) {
String des = "";
......@@ -213,7 +254,7 @@ public class MetricGraphCreator extends AbstractGraphCreator {
return des;
}
private void buildLineChartTitle(List<String> alertKeys, LineChart chart, String key) {
private void buildLineChartTitle(List<String> alertKeys, LineChart chart, String key, String contactInfo) {
int index = key.lastIndexOf(":");
String metricId = key.substring(0, index);
String type = key.substring(index + 1);
......@@ -226,9 +267,9 @@ public class MetricGraphCreator extends AbstractGraphCreator {
chart.setId(metricId + ":" + type);
if (alertKeys.contains(metricId)) {
chart.setHtmlTitle("<span style='color:red'>" + title + "</span>");
chart.setHtmlTitle("<span style='color:red'>" + title + "<br><small>" + contactInfo + "</small></span>");
} else {
chart.setHtmlTitle(title);
chart.setHtmlTitle(title + "<br><small>" + contactInfo + "</small>");
}
}
}
......
......@@ -291,6 +291,9 @@
<requirement>
<role>com.dianping.cat.report.task.alert.AlertInfo</role>
</requirement>
<requirement>
<role>com.dianping.cat.core.dal.ProjectDao</role>
</requirement>
</requirements>
</component>
<component>
......@@ -3145,6 +3148,9 @@
<role>com.dianping.cat.report.page.metric.graph.MetricGraphCreator</role>
<implementation>com.dianping.cat.report.page.metric.graph.MetricGraphCreator</implementation>
<requirements>
<requirement>
<role>com.dianping.cat.core.dal.ProjectDao</role>
</requirement>
<requirement>
<role>com.dianping.cat.report.baseline.BaselineService</role>
</requirement>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册