use of com.vmware.xenon.common.ServiceStats.ServiceStat in project photon-model by vmware.
the class AzureCostStatsService method createStatsForAzureService.
private Map<String, List<ServiceStat>> createStatsForAzureService(Context context, AzureService service, List<ComputeStats> resourceCostStats) {
String currencyUnit = AzureStatsNormalizer.getNormalizedUnitValue(AzureCostConstants.DEFAULT_CURRENCY_VALUE);
String serviceCode = service.meterCategory.replaceAll(" ", "");
Map<String, List<ServiceStat>> stats = new HashMap<>();
// Create stats for daily service cost
List<ServiceStat> serviceStats = new ArrayList<>();
String serviceResourceCostMetric = String.format(AzureCostConstants.SERVICE_RESOURCE_COST, serviceCode);
for (Entry<Long, Double> cost : service.directCosts.entrySet()) {
ServiceStat resourceCostStat = AzureCostHelper.createServiceStat(serviceResourceCostMetric, cost.getValue(), currencyUnit, cost.getKey());
serviceStats.add(resourceCostStat);
}
if (!serviceStats.isEmpty()) {
stats.put(serviceResourceCostMetric, serviceStats);
}
// Create daily cost stats for resources
createStatsForAzureResources(context, service, resourceCostStats);
return stats;
}
use of com.vmware.xenon.common.ServiceStats.ServiceStat in project photon-model by vmware.
the class AzureCostHelper method createMonthlyEaAccountCostStats.
static List<ComputeStats> createMonthlyEaAccountCostStats(Map<LocalDate, EaAccountCost> monthlyEaAccountCosts, Map<LocalDate, Double> monthlyTotalCosts, ComputeStateWithDescription computeHostDesc) {
List<ComputeStats> accountStats = new ArrayList<>();
String usageCostStatName = AzureCostConstants.USAGE_COST;
String marketplaceCostStatName = AzureCostConstants.MARKETPLACE_COST;
String separatelyBilledCostStatName = AzureCostConstants.SEPARATELY_BILLED_COST;
String costUnit = AzureStatsNormalizer.getNormalizedUnitValue(AzureCostConstants.DEFAULT_CURRENCY_VALUE);
for (Entry<LocalDate, Double> monthlyTotalCost : monthlyTotalCosts.entrySet()) {
ComputeStats accountStat = new ComputeStats();
accountStat.computeLink = computeHostDesc.documentSelfLink;
accountStat.statValues = new ConcurrentSkipListMap<>();
LocalDate month = monthlyTotalCost.getKey();
long timeStamp = adaptMonthToCostTimeStamp(month);
EaAccountCost eaAccountCost = monthlyEaAccountCosts.get(month);
ServiceStat usageCostServiceStat = AzureCostHelper.createServiceStat(usageCostStatName, eaAccountCost.monthlyEaAccountUsageCost, costUnit, timeStamp);
ServiceStat marketplaceCostServiceStat = AzureCostHelper.createServiceStat(marketplaceCostStatName, eaAccountCost.monthlyEaAccountMarketplaceCost, costUnit, timeStamp);
ServiceStat separatelyBilledCostServiceStat = AzureCostHelper.createServiceStat(separatelyBilledCostStatName, eaAccountCost.monthlyEaAccountSeparatelyBilledCost, costUnit, timeStamp);
accountStat.statValues.put(usageCostStatName, Collections.singletonList(usageCostServiceStat));
accountStat.statValues.put(marketplaceCostStatName, Collections.singletonList(marketplaceCostServiceStat));
accountStat.statValues.put(separatelyBilledCostStatName, Collections.singletonList(separatelyBilledCostServiceStat));
accountStats.add(accountStat);
}
return accountStats;
}
use of com.vmware.xenon.common.ServiceStats.ServiceStat in project photon-model by vmware.
the class AzureCostHelper method createOldestBillDownloadedStat.
static ComputeStats createOldestBillDownloadedStat(ComputeStateWithDescription computeHostDesc, long billParsedMillis, long currentMonthBillParsedMillis) {
ComputeStats stats = new ComputeStats();
stats.computeLink = computeHostDesc.documentSelfLink;
stats.statValues = new ConcurrentSkipListMap<>();
stats.addCustomProperty(PhotonModelConstants.CONTAINS_BILL_PROCESSED_TIME_STAT, Boolean.TRUE.toString());
ServiceStat oldestBillDownloadedStat = AzureCostHelper.createServiceStat(AzureCostConstants.OLDEST_BILL_PROCESSED_MILLIS, billParsedMillis, PhotonModelConstants.UNIT_MILLISECONDS, currentMonthBillParsedMillis);
stats.statValues.put(oldestBillDownloadedStat.name, Collections.singletonList(oldestBillDownloadedStat));
return stats;
}
use of com.vmware.xenon.common.ServiceStats.ServiceStat in project photon-model by vmware.
the class AzureCostHelper method createApiKeyExpiresTimeStat.
static ComputeStats createApiKeyExpiresTimeStat(ComputeStateWithDescription computeHostDesc, long keyExpiryTime) {
ComputeStats accountStats = new ComputeStats();
accountStats.computeLink = computeHostDesc.documentSelfLink;
accountStats.statValues = new ConcurrentSkipListMap<>();
ServiceStat keyExpiryTimeMillis = AzureCostHelper.createServiceStat(AzureCostConstants.EA_ACCOUNT_USAGE_KEY_EXPIRY_TIME_MILLIS, keyExpiryTime, PhotonModelConstants.UNIT_MILLISECONDS, AzureCostHelper.getMillisNow());
accountStats.statValues.put(keyExpiryTimeMillis.name, Collections.singletonList(keyExpiryTimeMillis));
return accountStats;
}
use of com.vmware.xenon.common.ServiceStats.ServiceStat in project photon-model by vmware.
the class AzureCostHelper method createServiceStat.
static ServiceStat createServiceStat(String metricName, Number value, String currencyUnit, Long timestamp) {
ServiceStat stat = new ServiceStat();
stat.name = metricName;
stat.latestValue = value != null ? value.doubleValue() : 0.0d;
stat.sourceTimeMicrosUtc = TimeUnit.MILLISECONDS.toMicros(timestamp);
stat.unit = currencyUnit;
return stat;
}
Aggregations