use of org.platformlayer.metrics.model.MetricDataSource in project platformlayer by platformlayer.
the class MetricsResource method getMetrics.
@POST
@Produces({ XML, JSON })
public MetricDataSource getMetrics(final MetricQuery query) throws RepositoryException, OpsException {
final ItemBase managedItem = getManagedItem();
final ServiceProvider serviceProvider = getServiceProvider();
OpsContextBuilder opsContextBuilder = objectInjector.getInstance(OpsContextBuilder.class);
final OpsContext opsContext = opsContextBuilder.buildTemporaryOpsContext(getServiceType(), getProjectAuthorization());
return OpsContext.runInContext(opsContext, new CheckedCallable<MetricDataSource, Exception>() {
@Override
public MetricDataSource call() throws Exception {
BindingScope bindingScope = BindingScope.push(managedItem, managedItem);
try {
MetricDataSource metrics = serviceProvider.getMetricValues(managedItem, query);
return metrics;
} finally {
bindingScope.pop();
}
}
});
}
Aggregations