Java 类org.springframework.boot.actuate.endpoint.MetricsEndpoint 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
public MetricsEndpoint metricsEndpoint() {
    List<PublicMetrics> publicMetrics = new ArrayList<PublicMetrics>();
    if (this.publicMetrics != null) {
        publicMetrics.addAll(this.publicMetrics);
    }
    Collections.sort(publicMetrics, AnnotationAwareOrderComparator.INSTANCE);
    return new MetricsEndpoint(publicMetrics);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointAutoConfigurationTests.java   
@Test
public void endpoints() throws Exception {
    load(EndpointAutoConfiguration.class);
    assertThat(this.context.getBean(BeansEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(DumpEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(EnvironmentEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(HealthEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(InfoEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(MetricsEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(ShutdownEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(TraceEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(RequestMappingEndpoint.class)).isNotNull();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointAutoConfigurationTests.java   
@Test
public void metricEndpointsHasSystemMetricsByDefault() {
    load(PublicMetricsAutoConfiguration.class, EndpointAutoConfiguration.class);
    MetricsEndpoint endpoint = this.context.getBean(MetricsEndpoint.class);
    Map<String, Object> metrics = endpoint.invoke();
    assertThat(metrics.containsKey("mem")).isTrue();
    assertThat(metrics.containsKey("heap.used")).isTrue();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointAutoConfigurationTests.java   
@Test
public void metricEndpointCustomPublicMetrics() {
    load(CustomPublicMetricsConfig.class, PublicMetricsAutoConfiguration.class,
            EndpointAutoConfiguration.class);
    MetricsEndpoint endpoint = this.context.getBean(MetricsEndpoint.class);
    Map<String, Object> metrics = endpoint.invoke();

    // Custom metrics
    assertThat(metrics.containsKey("foo")).isTrue();

    // System metrics still available
    assertThat(metrics.containsKey("mem")).isTrue();
    assertThat(metrics.containsKey("heap.used")).isTrue();

}
项目:spring-boot-concourse    文件:EndpointAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
public MetricsEndpoint metricsEndpoint() {
    List<PublicMetrics> publicMetrics = new ArrayList<PublicMetrics>();
    if (this.publicMetrics != null) {
        publicMetrics.addAll(this.publicMetrics);
    }
    Collections.sort(publicMetrics, AnnotationAwareOrderComparator.INSTANCE);
    return new MetricsEndpoint(publicMetrics);
}
项目:spring-boot-concourse    文件:EndpointAutoConfigurationTests.java   
@Test
public void endpoints() throws Exception {
    load(EndpointAutoConfiguration.class);
    assertThat(this.context.getBean(BeansEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(DumpEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(EnvironmentEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(HealthEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(InfoEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(MetricsEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(ShutdownEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(TraceEndpoint.class)).isNotNull();
    assertThat(this.context.getBean(RequestMappingEndpoint.class)).isNotNull();
}
项目:spring-boot-concourse    文件:EndpointAutoConfigurationTests.java   
@Test
public void metricEndpointsHasSystemMetricsByDefault() {
    load(PublicMetricsAutoConfiguration.class, EndpointAutoConfiguration.class);
    MetricsEndpoint endpoint = this.context.getBean(MetricsEndpoint.class);
    Map<String, Object> metrics = endpoint.invoke();
    assertThat(metrics.containsKey("mem")).isTrue();
    assertThat(metrics.containsKey("heap.used")).isTrue();
}
项目:spring-boot-concourse    文件:EndpointAutoConfigurationTests.java   
@Test
public void metricEndpointCustomPublicMetrics() {
    load(CustomPublicMetricsConfig.class, PublicMetricsAutoConfiguration.class,
            EndpointAutoConfiguration.class);
    MetricsEndpoint endpoint = this.context.getBean(MetricsEndpoint.class);
    Map<String, Object> metrics = endpoint.invoke();

    // Custom metrics
    assertThat(metrics.containsKey("foo")).isTrue();

    // System metrics still available
    assertThat(metrics.containsKey("mem")).isTrue();
    assertThat(metrics.containsKey("heap.used")).isTrue();

}
项目:contestparser    文件:EndpointAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
public MetricsEndpoint metricsEndpoint() {
    List<PublicMetrics> publicMetrics = new ArrayList<PublicMetrics>();
    if (this.publicMetrics != null) {
        publicMetrics.addAll(this.publicMetrics);
    }
    Collections.sort(publicMetrics, AnnotationAwareOrderComparator.INSTANCE);
    return new MetricsEndpoint(publicMetrics);
}
项目:contestparser    文件:EndpointAutoConfigurationTests.java   
@Test
public void endpoints() throws Exception {
    load(EndpointAutoConfiguration.class);
    assertNotNull(this.context.getBean(BeansEndpoint.class));
    assertNotNull(this.context.getBean(DumpEndpoint.class));
    assertNotNull(this.context.getBean(EnvironmentEndpoint.class));
    assertNotNull(this.context.getBean(HealthEndpoint.class));
    assertNotNull(this.context.getBean(InfoEndpoint.class));
    assertNotNull(this.context.getBean(MetricsEndpoint.class));
    assertNotNull(this.context.getBean(ShutdownEndpoint.class));
    assertNotNull(this.context.getBean(TraceEndpoint.class));
    assertNotNull(this.context.getBean(RequestMappingEndpoint.class));
}
项目:contestparser    文件:EndpointAutoConfigurationTests.java   
@Test
public void metricEndpointsHasSystemMetricsByDefault() {
    load(PublicMetricsAutoConfiguration.class, EndpointAutoConfiguration.class);
    MetricsEndpoint endpoint = this.context.getBean(MetricsEndpoint.class);
    Map<String, Object> metrics = endpoint.invoke();
    assertTrue(metrics.containsKey("mem"));
    assertTrue(metrics.containsKey("heap.used"));
}
项目:contestparser    文件:EndpointAutoConfigurationTests.java   
@Test
public void metricEndpointCustomPublicMetrics() {
    load(CustomPublicMetricsConfig.class, PublicMetricsAutoConfiguration.class,
            EndpointAutoConfiguration.class);
    MetricsEndpoint endpoint = this.context.getBean(MetricsEndpoint.class);
    Map<String, Object> metrics = endpoint.invoke();

    // Custom metrics
    assertTrue(metrics.containsKey("foo"));

    // System metrics still available
    assertTrue(metrics.containsKey("mem"));
    assertTrue(metrics.containsKey("heap.used"));

}
项目:statful-client-springboot    文件:SpringbootClientConfiguration.java   
/**
 * Enable a metrics reader.
 * @param metricsEndpoint {@link MetricsEndpoint}
 * @return {@link MetricsEndpointMetricReader}
 */
@Bean
@ConditionalOnProperty(value = "statful.client.springboot.metrics.enabled", havingValue = "true")
public MetricsEndpointMetricReader metricsEndpointMetricReader(final MetricsEndpoint metricsEndpoint) {
    return new MetricsEndpointMetricReader(metricsEndpoint);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcManagementContextConfiguration.java   
@Bean
@ConditionalOnBean(MetricsEndpoint.class)
@ConditionalOnEnabledEndpoint("metrics")
public MetricsMvcEndpoint metricsMvcEndpoint(MetricsEndpoint delegate) {
    return new MetricsMvcEndpoint(delegate);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricsMvcEndpoint.java   
public MetricsMvcEndpoint(MetricsEndpoint delegate) {
    super(delegate);
    this.delegate = delegate;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricsMvcEndpointTests.java   
@Before
public void setUp() {
    this.context.getBean(MetricsEndpoint.class).setEnabled(true);
    this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricsMvcEndpointTests.java   
@Test
public void homeWhenDisabled() throws Exception {
    this.context.getBean(MetricsEndpoint.class).setEnabled(false);
    this.mvc.perform(get("/metrics")).andExpect(status().isNotFound());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricsMvcEndpointTests.java   
@Test
public void specificMetricWhenDisabled() throws Exception {
    this.context.getBean(MetricsEndpoint.class).setEnabled(false);
    this.mvc.perform(get("/metrics/foo")).andExpect(status().isNotFound());
}
项目:spring-boot-concourse    文件:EndpointWebMvcManagementContextConfiguration.java   
@Bean
@ConditionalOnBean(MetricsEndpoint.class)
@ConditionalOnEnabledEndpoint("metrics")
public MetricsMvcEndpoint metricsMvcEndpoint(MetricsEndpoint delegate) {
    return new MetricsMvcEndpoint(delegate);
}
项目:spring-boot-concourse    文件:MetricsMvcEndpoint.java   
public MetricsMvcEndpoint(MetricsEndpoint delegate) {
    super(delegate);
    this.delegate = delegate;
}
项目:spring-boot-concourse    文件:MetricsMvcEndpointTests.java   
@Before
public void setUp() {
    this.context.getBean(MetricsEndpoint.class).setEnabled(true);
    this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}
项目:spring-boot-concourse    文件:MetricsMvcEndpointTests.java   
@Test
public void homeWhenDisabled() throws Exception {
    this.context.getBean(MetricsEndpoint.class).setEnabled(false);
    this.mvc.perform(get("/metrics")).andExpect(status().isNotFound());
}
项目:spring-boot-concourse    文件:MetricsMvcEndpointTests.java   
@Test
public void specificMetricWhenDisabled() throws Exception {
    this.context.getBean(MetricsEndpoint.class).setEnabled(false);
    this.mvc.perform(get("/metrics/foo")).andExpect(status().isNotFound());
}
项目:contestparser    文件:EndpointWebMvcManagementContextConfiguration.java   
@Bean
@ConditionalOnBean(MetricsEndpoint.class)
@ConditionalOnEnabledEndpoint("metrics")
public MetricsMvcEndpoint metricsMvcEndpoint(MetricsEndpoint delegate) {
    return new MetricsMvcEndpoint(delegate);
}
项目:contestparser    文件:MetricsMvcEndpoint.java   
public MetricsMvcEndpoint(MetricsEndpoint delegate) {
    super(delegate);
    this.delegate = delegate;
}
项目:contestparser    文件:MetricsMvcEndpointTests.java   
@Before
public void setUp() {
    this.context.getBean(MetricsEndpoint.class).setEnabled(true);
    this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}
项目:contestparser    文件:MetricsMvcEndpointTests.java   
@Test
public void homeWhenDisabled() throws Exception {
    this.context.getBean(MetricsEndpoint.class).setEnabled(false);
    this.mvc.perform(get("/metrics")).andExpect(status().isNotFound());
}
项目:contestparser    文件:MetricsMvcEndpointTests.java   
@Test
public void specificMetricWhenDisabled() throws Exception {
    this.context.getBean(MetricsEndpoint.class).setEnabled(false);
    this.mvc.perform(get("/metrics/foo")).andExpect(status().isNotFound());
}
项目:spring-cloud-stream    文件:ApplicationMetricsExporter.java   
public ApplicationMetricsExporter(MetricsEndpoint endpoint, MessageChannel source,
        ApplicationMetricsProperties properties) {
    this.source = source;
    this.properties = properties;
    this.metricsReader = new MetricsEndpointMetricReader(endpoint);
}