use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.
the class MetricsProviderActorTest method testLimitedSystemMetricsRequest.
@Test
public void testLimitedSystemMetricsRequest() throws Exception {
final Props props = Props.create(MetricsProviderActor.class);
final TestActorRef<MetricsProviderActor> ref = TestActorRef.create(actorSystem, props, "testActorRef");
Future<Object> future = Patterns.ask(ref, new SystemMetricsRequest(null, false), Timeout.apply(1, TimeUnit.MINUTES));
Object result = Await.result(future, Duration.apply(1, TimeUnit.MINUTES));
assertTrue(future.isCompleted());
assertTrue(result instanceof SystemMetricsResponse);
SystemMetricsResponse response = (SystemMetricsResponse) result;
MetricSetDto metricSetDto = response.getMetrics();
Set<MetricDto> dtoSet = metricSetDto.getMetrics();
log.info("metricSetDto: " + metricSetDto);
for (MetricDto metricDto : dtoSet) {
// Order of entries is undefined -> Must handle by name
switch(metricDto.getName()) {
case HISTOGRAM_NAME:
Assert.fail("Should not have histrogram.");
break;
case GAUGE_NAME:
Assert.fail("Should not have histrogram gauge.");
break;
default:
Assert.fail("Unknown metric found in response.");
break;
}
}
}
use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.
the class MetricsProviderActor method onReceive.
@Override
public void onReceive(Object o) throws Exception {
if (o instanceof SystemMetricsRequest) {
final SystemMetricsRequest req = (SystemMetricsRequest) o;
log.info("Received SystemMetricsRequest: " + req);
if (req.getMetricNames() != null && req.getMetricNames().size() > 0) {
log.info("Specified metrics requested: " + req.getMetricNames());
log.info("Is owner of security server: " + req.isClientOwner());
}
MetricRegistry metrics = MetricRegistryHolder.getInstance().getMetrics();
final MetricSetDto.Builder builder = new MetricSetDto.Builder("systemMetrics");
collectMetrics(builder, metrics, req.getMetricNames(), req.isClientOwner());
if (req.isClientOwner() || !SystemProperties.getEnvMonitorLimitRemoteDataSet()) {
collectOwnerMetrics(builder, metrics, req.getMetricNames());
}
MetricSetDto metricSet = builder.build();
final SystemMetricsResponse response = new SystemMetricsResponse(metricSet);
getSender().tell(response, getSelf());
} else {
unhandled(o);
}
}
use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.
the class MetricsProviderActor method toProcessMetricSetDto.
private MetricSetDto toProcessMetricSetDto(String name, Gauge<JmxStringifiedData<ProcessInfo>> processSensor) {
JmxStringifiedData<ProcessInfo> p = processSensor.getValue();
MetricSetDto.Builder mainBuilder = new MetricSetDto.Builder(name);
for (ProcessInfo process : p.getDtoData()) {
MetricSetDto.Builder processBuilder = new MetricSetDto.Builder(process.getProcessId());
mainBuilder.withMetric(processBuilder.withSimpleMetric("processId", process.getProcessId()).withSimpleMetric("command", process.getCommand()).withSimpleMetric("cpuLoad", process.getCpuLoad()).withSimpleMetric("memUsed", process.getMemUsed()).withSimpleMetric("startTime", process.getStartTime()).withSimpleMetric("userId", process.getUserId()).build());
}
return mainBuilder.build();
}
use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.
the class MetricsProviderActor method toPackageMetricSetDto.
private MetricSetDto toPackageMetricSetDto(String name, Gauge<JmxStringifiedData<PackageInfo>> packageSensor) {
JmxStringifiedData<PackageInfo> p = packageSensor.getValue();
MetricSetDto.Builder mainBuilder = new MetricSetDto.Builder(name);
for (PackageInfo pac : p.getDtoData()) {
mainBuilder.withSimpleMetric(pac.getName(), pac.getVersion());
}
return mainBuilder.build();
}
use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.
the class MetricTypes method of.
/**
* MetricSetType factory
*/
public static MetricSetType of(MetricSetDto metrics) {
final MetricSetType metricSet = new MetricSetType();
metricSet.setName(metrics.getName());
for (MetricDto metricDto : metrics.getMetrics()) {
if (metricDto instanceof MetricSetDto) {
metricSet.getMetrics().add(of((MetricSetDto) metricDto));
} else if (metricDto instanceof HistogramDto) {
metricSet.getMetrics().add(toMetricType((HistogramDto) metricDto));
} else if (metricDto instanceof SimpleMetricDto) {
metricSet.getMetrics().add(toMetricType((SimpleMetricDto<?>) metricDto));
}
}
return metricSet;
}
Aggregations