當前位置: 首頁>>代碼示例>>Java>>正文


Java CounterService類代碼示例

本文整理匯總了Java中org.springframework.boot.actuate.metrics.CounterService的典型用法代碼示例。如果您正苦於以下問題:Java CounterService類的具體用法?Java CounterService怎麽用?Java CounterService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CounterService類屬於org.springframework.boot.actuate.metrics包,在下文中一共展示了CounterService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ModuleService

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
public ModuleService(SpinnakerConfiguration spinnakerConfiguration,
					 CloudFoundryAppDeployerFactory appDeployerFactory,
					 ResourcePatternResolver ctx,
					 CounterService counterService,
					 TempFileManager fileManager,
					 MavenProperties mavenProperties,
					 ResourceLoader resourceLoader) {

	this.spinnakerConfiguration = spinnakerConfiguration;
	this.appDeployerFactory = appDeployerFactory;
	this.ctx = ctx;
	this.counterService = counterService;
	this.fileManager = fileManager;
	this.mavenProperties = mavenProperties;
	this.resourceLoader = resourceLoader;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-spinnaker,代碼行數:17,代碼來源:ModuleService.java

示例2: recordsHttpInteractions

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Test
public void recordsHttpInteractions() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, MetricFilterAutoConfiguration.class);
	Filter filter = context.getBean(Filter.class);
	final MockHttpServletRequest request = new MockHttpServletRequest("GET",
			"/test/path");
	final MockHttpServletResponse response = new MockHttpServletResponse();
	FilterChain chain = mock(FilterChain.class);
	willAnswer(new Answer<Object>() {
		@Override
		public Object answer(InvocationOnMock invocation) throws Throwable {
			response.setStatus(200);
			return null;
		}
	}).given(chain).doFilter(request, response);
	filter.doFilter(request, response, chain);
	verify(context.getBean(CounterService.class)).increment("status.200.test.path");
	verify(context.getBean(GaugeService.class)).submit(eq("response.test.path"),
			anyDouble());
	context.close();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:23,代碼來源:MetricFilterAutoConfigurationTests.java

示例3: records302HttpInteractionsAsSingleMetric

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Test
public void records302HttpInteractionsAsSingleMetric() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, MetricFilterAutoConfiguration.class, RedirectFilter.class);
	MetricsFilter filter = context.getBean(MetricsFilter.class);
	MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
			.addFilter(filter).addFilter(context.getBean(RedirectFilter.class))
			.build();
	mvc.perform(get("/unknownPath/1")).andExpect(status().is3xxRedirection());
	mvc.perform(get("/unknownPath/2")).andExpect(status().is3xxRedirection());
	verify(context.getBean(CounterService.class), times(2))
			.increment("status.302.unmapped");
	verify(context.getBean(GaugeService.class), times(2))
			.submit(eq("response.unmapped"), anyDouble());
	context.close();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:17,代碼來源:MetricFilterAutoConfigurationTests.java

示例4: controllerMethodThatThrowsUnhandledException

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Test
public void controllerMethodThatThrowsUnhandledException() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, MetricFilterAutoConfiguration.class);
	Filter filter = context.getBean(Filter.class);
	MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
			.addFilter(filter).build();
	try {
		mvc.perform(get("/unhandledException"))
				.andExpect(status().isInternalServerError());
	}
	catch (NestedServletException ex) {
		// Expected
	}
	verify(context.getBean(CounterService.class))
			.increment("status.500.unhandledException");
	verify(context.getBean(GaugeService.class))
			.submit(eq("response.unhandledException"), anyDouble());
	context.close();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:21,代碼來源:MetricFilterAutoConfigurationTests.java

示例5: gaugeServiceThatThrows

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Test
public void gaugeServiceThatThrows() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, MetricFilterAutoConfiguration.class);
	GaugeService gaugeService = context.getBean(GaugeService.class);
	willThrow(new IllegalStateException()).given(gaugeService).submit(anyString(),
			anyDouble());
	Filter filter = context.getBean(Filter.class);
	MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
			.addFilter(filter).build();
	mvc.perform(get("/templateVarTest/foo")).andExpect(status().isOk());
	verify(context.getBean(CounterService.class))
			.increment("status.200.templateVarTest.someVariable");
	verify(context.getBean(GaugeService.class))
			.submit(eq("response.templateVarTest.someVariable"), anyDouble());
	context.close();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:18,代碼來源:MetricFilterAutoConfigurationTests.java

示例6: correctlyRecordsMetricsForDeferredResultResponse

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Test
public void correctlyRecordsMetricsForDeferredResultResponse() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, MetricFilterAutoConfiguration.class);
	MetricsFilter filter = context.getBean(MetricsFilter.class);
	CountDownLatch latch = new CountDownLatch(1);
	MockMvc mvc = MockMvcBuilders
			.standaloneSetup(new MetricFilterTestController(latch)).addFilter(filter)
			.build();
	String attributeName = MetricsFilter.class.getName() + ".StopWatch";
	MvcResult result = mvc.perform(post("/create")).andExpect(status().isOk())
			.andExpect(request().asyncStarted())
			.andExpect(request().attribute(attributeName, is(notNullValue())))
			.andReturn();
	latch.countDown();
	mvc.perform(asyncDispatch(result)).andExpect(status().isCreated())
			.andExpect(request().attribute(attributeName, is(nullValue())));
	verify(context.getBean(CounterService.class)).increment("status.201.create");
	context.close();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:21,代碼來源:MetricFilterAutoConfigurationTests.java

示例7: records5xxxHttpInteractionsAsSingleMetric

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Test
public void records5xxxHttpInteractionsAsSingleMetric() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, MetricFilterAutoConfiguration.class,
			ServiceUnavailableFilter.class);
	MetricsFilter filter = context.getBean(MetricsFilter.class);
	MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
			.addFilter(filter)
			.addFilter(context.getBean(ServiceUnavailableFilter.class)).build();
	mvc.perform(get("/unknownPath/1")).andExpect(status().isServiceUnavailable());
	mvc.perform(get("/unknownPath/2")).andExpect(status().isServiceUnavailable());
	verify(context.getBean(CounterService.class), times(2))
			.increment("status.503.unmapped");
	verify(context.getBean(GaugeService.class), times(2))
			.submit(eq("response.unmapped"), anyDouble());
	context.close();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:18,代碼來源:MetricFilterAutoConfigurationTests.java

示例8: doesNotRecordRolledUpMetricsIfConfigured

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Test
public void doesNotRecordRolledUpMetricsIfConfigured() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	context.register(Config.class, MetricFilterAutoConfiguration.class);
	EnvironmentTestUtils.addEnvironment(context,
			"endpoints.metrics.filter.gauge-submissions=",
			"endpoints.metrics.filter.counter-submissions=");
	context.refresh();
	Filter filter = context.getBean(Filter.class);
	final MockHttpServletRequest request = new MockHttpServletRequest("PUT",
			"/test/path");
	final MockHttpServletResponse response = new MockHttpServletResponse();
	FilterChain chain = mock(FilterChain.class);
	willAnswer(new Answer<Object>() {
		@Override
		public Object answer(InvocationOnMock invocation) throws Throwable {
			response.setStatus(200);
			return null;
		}
	}).given(chain).doFilter(request, response);
	filter.doFilter(request, response, chain);
	verify(context.getBean(GaugeService.class), never()).submit(anyString(),
			anyDouble());
	verify(context.getBean(CounterService.class), never()).increment(anyString());
	context.close();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:27,代碼來源:MetricFilterAutoConfigurationTests.java

示例9: TimerAspect

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Autowired
public TimerAspect(GaugeService gaugeService,
		CounterService counterService, ObjectMapper mapper) {
	this.counterService = counterService;
	this.gaugeService = gaugeService;
	this.mapper = mapper;
}
 
開發者ID:jigsaw-projects,項目名稱:jigsaw-payment,代碼行數:8,代碼來源:TimerAspect.java

示例10: AbstractPartMetrics

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
public AbstractPartMetrics(CounterService counterService, GaugeService gaugeService, P properties) {
    this.properties = properties;
    this.prefix = properties.getPrefix() + ".";
    this.counterService = new PrefixCounterServiceDecorator(counterService, prefix);
    this.gaugeService = new PrefixGaugeServiceDecorator(gaugeService, prefix);

    this.counterService.increment("instances.active");
    this.counterService.increment("instances.total");
}
 
開發者ID:unbroken-dome,項目名稱:vertx-spring,代碼行數:10,代碼來源:VertxActuatorMetrics.java

示例11: moduleService

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Bean
ModuleService moduleService(SpinnakerConfiguration spinnakerConfiguration,
							CloudFoundryAppDeployerFactory appDeployerFactoryBean,
							ApplicationContext ctx,
							CounterService counterService,
							TempFileManager fileManager,
							MavenProperties mavenProperties,
							LRUCleaningResourceLoader resourceLoader) {
	return new ModuleService(spinnakerConfiguration, appDeployerFactoryBean, ctx, counterService, fileManager, mavenProperties, resourceLoader);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-spinnaker,代碼行數:11,代碼來源:Config.java

示例12: moduleService

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Bean
ModuleService moduleService(SpinnakerConfiguration spinnakerConfiguration,
							CloudFoundryAppDeployerFactory appDeployerFactoryBean,
							ApplicationContext ctx,
							CounterService counterService,
							TempFileManager fileManager,
							MavenProperties mavenProperties,
							LRUCleaningResourceLoader resourceLoader) {
	return new ModuleService(spinnakerConfiguration, appDeployerFactoryBean, mockPatternResolver(ctx), counterService, fileManager, mavenProperties, resourceLoader);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-spinnaker,代碼行數:11,代碼來源:ModuleServiceTests.java

示例13: DocumentController

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
public DocumentController(Client client, ChangesetService changesetService, ObjectMapper mapper, CounterService counterService) {
    this.client = client;
    this.changesetService = changesetService;
    this.mapper = mapper;
    this.counterService = counterService;
    mandatoryFields = Arrays.asList("id", "type", "name", "owner", "description");
}
 
開發者ID:pivio,項目名稱:pivio-server,代碼行數:8,代碼來源:DocumentController.java

示例14: setUp

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
@Before
public void setUp() {
    client = mock(Client.class);
    counterService = mock(CounterService.class);
    objectMapper = new ObjectMapper();
    documentController = new DocumentController(client, new ChangesetService(client, objectMapper), objectMapper, counterService);
}
 
開發者ID:pivio,項目名稱:pivio-server,代碼行數:8,代碼來源:DocumentControllerTest.java

示例15: ActuateCollectorMetrics

import org.springframework.boot.actuate.metrics.CounterService; //導入依賴的package包/類
ActuateCollectorMetrics(CounterService counterService, GaugeService gaugeService,
    @Nullable String transport) {
  this.counterService = counterService;
  this.gaugeService = gaugeService;
  String footer = transport == null ? "" : "." + transport;
  this.messages = "zipkin_collector.messages" + footer;
  this.messagesDropped = "zipkin_collector.messages_dropped" + footer;
  this.messageBytes = "zipkin_collector.message_bytes" + footer;
  this.messageSpans = "zipkin_collector.message_spans" + footer;
  this.bytes = "zipkin_collector.bytes" + footer;
  this.spans = "zipkin_collector.spans" + footer;
  this.spansDropped = "zipkin_collector.spans_dropped" + footer;
}
 
開發者ID:liaominghua,項目名稱:zipkin,代碼行數:14,代碼來源:ActuateCollectorMetrics.java


注:本文中的org.springframework.boot.actuate.metrics.CounterService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。