Skip to content

Commit

Permalink
modifications to console retrieval of metrics with same name differen…
Browse files Browse the repository at this point in the history
…t types
  • Loading branch information
angelo.andreussi authored and Coduz committed Jul 27, 2023
1 parent 6aab601 commit 5f691fd
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.app.console.module.api.client.GwtKapuaErrorCode;
import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException;
import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet;
import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler;
Expand All @@ -38,6 +39,7 @@
import org.eclipse.kapua.app.console.module.data.shared.util.KapuaGwtDataModelConverter;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.type.ObjectTypeConverter;
import org.eclipse.kapua.service.datastore.ChannelInfoFactory;
import org.eclipse.kapua.service.datastore.ChannelInfoRegistryService;
import org.eclipse.kapua.service.datastore.ClientInfoFactory;
Expand Down Expand Up @@ -437,7 +439,7 @@ private ListLoadResult<GwtHeader> findHeaders(String scopeId, StorablePredicate
MetricInfoListResult result = metricService.query(query);
if (result != null && !result.isEmpty()) {
for (MetricInfo metric : result.getItems()) {
metrics.put(metric.getName(), KapuaGwtDataModelConverter.convertToHeader(metric));
metrics.put(metric.getName() + "." + metric.getMetricType().getSimpleName(), KapuaGwtDataModelConverter.convertToHeader(metric));
}
}

Expand All @@ -464,7 +466,11 @@ private PagingLoadResult<GwtMessage> findMessages(PagingLoadConfig loadConfig, S
if (headers != null) {
OrPredicate metricsPredicate = DATASTORE_PREDICATE_FACTORY.newOrPredicate();
for (GwtHeader header : headers) {
metricsPredicate.getPredicates().add(DATASTORE_PREDICATE_FACTORY.newMetricExistsPredicate(header.getName(), null));
try {
metricsPredicate.getPredicates().add(DATASTORE_PREDICATE_FACTORY.newMetricExistsPredicate(header.getName(), (Class<? extends Comparable>) ObjectTypeConverter.fromString(header.getType().toLowerCase())));
} catch (ClassNotFoundException e) {
throw new GwtKapuaException(GwtKapuaErrorCode.INTERNAL_ERROR, e);
}
}
andPredicate.getPredicates().add(metricsPredicate);
}
Expand Down

0 comments on commit 5f691fd

Please sign in to comment.