use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.
the class MetricsEnquirerTest method oneMBeanOneMetricUnsupportedApp.
@Test
public void oneMBeanOneMetricUnsupportedApp() {
AppType appType = null;
Throwable ex = catchThrowable(() -> metricsEnquirer.getMBeanMetrics(appType));
assertThat(ex).isEqualToComparingFieldByField(new MonitoringNotSupportedException(appType));
}
use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.
the class MetricsResource method getMetrics.
@GET
@Produces("text/plain")
public Response getMetrics() {
MetricsEnquirer metricsEnquirer = new MetricsEnquirer(mbs);
final StringBuilder formattedMetrics = new StringBuilder();
for (AppType type : AppType.values()) {
List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(type);
PrometheusProtocolFormatter formatter = new PrometheusProtocolFormatter();
formattedMetrics.append(formatter.format(metrics, type));
}
return Response.status(Response.Status.OK).header(HttpHeaders.CONTENT_TYPE, TEXT_PLAIN).entity(formattedMetrics.toString()).build();
}
use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.
the class MetricsEnquirerTest method oneMBeanOneMetricQ2TApp.
@Test
public void oneMBeanOneMetricQ2TApp() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
ObjectName mBeanName = new ObjectName("domain", "key", "value");
names.add(mBeanName);
AppType appType = AppType.Q2T;
ObjectName objName = new ObjectName("org.glassfish.jersey:type=Q2TRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*");
when(mBeanServer.queryNames(objName, null)).thenReturn(names);
String attributeName = "name_total";
MBeanAttributeInfo[] mBeanAttributes = { new MBeanAttributeInfo(attributeName, "type", "desc", true, false, false) };
MBeanInfo mBeanInfo = new MBeanInfo(null, null, mBeanAttributes, null, null, null);
when(mBeanServer.getMBeanInfo(mBeanName)).thenReturn(mBeanInfo);
when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
assertThat(metrics.size()).isEqualTo(1);
assertThat(metrics.get(0).getName()).isEqualTo("name_total");
}
use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.
the class MetricsEnquirerTest method oneMBeanOneMetricThirdPartyApp.
@Test
public void oneMBeanOneMetricThirdPartyApp() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
ObjectName mBeanName = new ObjectName("domain", "key", "value");
names.add(mBeanName);
AppType appType = AppType.THIRD_PARTY;
ObjectName objName = new ObjectName("org.glassfish.jersey:type=ThirdPartyRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*");
when(mBeanServer.queryNames(objName, null)).thenReturn(names);
String attributeName = "name_total";
MBeanAttributeInfo[] mBeanAttributes = { new MBeanAttributeInfo(attributeName, "type", "desc", true, false, false) };
MBeanInfo mBeanInfo = new MBeanInfo(null, null, mBeanAttributes, null, null, null);
when(mBeanServer.getMBeanInfo(mBeanName)).thenReturn(mBeanInfo);
when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
assertThat(metrics.size()).isEqualTo(1);
assertThat(metrics.get(0).getName()).isEqualTo("name_total");
}
use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.
the class MetricsEnquirerTest method oneMBeanOneMetricP2PApp.
@Test
public void oneMBeanOneMetricP2PApp() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
ObjectName mBeanName = new ObjectName("domain", "key", "value");
names.add(mBeanName);
AppType appType = AppType.P2P;
ObjectName objName = new ObjectName("org.glassfish.jersey:type=P2PRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*");
when(mBeanServer.queryNames(objName, null)).thenReturn(names);
String attributeName = "name_total";
MBeanAttributeInfo[] mBeanAttributes = { new MBeanAttributeInfo(attributeName, "type", "desc", true, false, false) };
MBeanInfo mBeanInfo = new MBeanInfo(null, null, mBeanAttributes, null, null, null);
when(mBeanServer.getMBeanInfo(mBeanName)).thenReturn(mBeanInfo);
when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
assertThat(metrics.size()).isEqualTo(1);
assertThat(metrics.get(0).getName()).isEqualTo("name_total");
}
Aggregations