Skip to content

Commit

Permalink
[#2496] Add datasource metric collection
Browse files Browse the repository at this point in the history
1. Change to show the latest information (first  -> latest)
  • Loading branch information
koo-taejin committed Mar 29, 2017
1 parent 9a1d797 commit 4326081
Showing 1 changed file with 6 additions and 15 deletions.
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService;
import com.navercorp.pinpoint.common.util.CollectionUtils;
import com.navercorp.pinpoint.rpc.util.ListUtils;
import com.navercorp.pinpoint.web.util.TimeWindow;
import com.navercorp.pinpoint.web.view.DataSourceChartGroupSerializer;
import com.navercorp.pinpoint.web.vo.chart.Chart;
Expand Down Expand Up @@ -71,25 +72,15 @@ public DataSourceChartGroup(TimeWindow timeWindow, List<SampledDataSource> sampl
this.databaseName = UNCOLLECTED_STRING_VALUE;
this.jdbcUrl = UNCOLLECTED_STRING_VALUE;
} else {
SampledDataSource defaultDataSource = sampledDataSourceList.get(0);
SampledDataSource latestSampledDataSource = ListUtils.getLast(sampledDataSourceList);

this.id = defaultDataSource.getId();
this.serviceTypeName = serviceTypeRegistryService.findServiceType(defaultDataSource.getServiceTypeCode()).getName();
this.databaseName = extractDatabaseName(sampledDataSourceList);
this.jdbcUrl = defaultDataSource.getJdbcUrl();
this.id = latestSampledDataSource.getId();
this.serviceTypeName = serviceTypeRegistryService.findServiceType(latestSampledDataSource.getServiceTypeCode()).getName();
this.databaseName = latestSampledDataSource.getDatabaseName();
this.jdbcUrl = latestSampledDataSource.getJdbcUrl();
}
}

private String extractDatabaseName(List<SampledDataSource> sampledDataSourceList) {
for (SampledDataSource sampledDataSource : sampledDataSourceList) {
if (sampledDataSource != null && sampledDataSource.getDatabaseName() != null) {
return sampledDataSource.getDatabaseName();
}
}

return null;
}

@Override
public Map<ChartType, Chart> getCharts() {
return dataSourceCharts;
Expand Down

0 comments on commit 4326081

Please sign in to comment.