当前位置: 首页>>代码示例>>Java>>正文


Java LocalTracer类代码示例

本文整理汇总了Java中com.github.kristofa.brave.LocalTracer的典型用法代码示例。如果您正苦于以下问题:Java LocalTracer类的具体用法?Java LocalTracer怎么用?Java LocalTracer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalTracer类属于com.github.kristofa.brave包,在下文中一共展示了LocalTracer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filterRequest

import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
@Override
public JsonApiResponse filterRequest(RepositoryFilterContext context, RepositoryRequestFilterChain chain) {
	long s = System.nanoTime();

	LocalTracer localTracer = brave.localTracer();
	RepositoryRequestSpec request = context.getRequest();

	String componentName = BraveUtil.getComponentName(request);
	String query = BraveUtil.getQuery(request, moduleContext.getResourceRegistry());

	localTracer.startNewSpan(COMPONENT_NAME, componentName);

	JsonApiResponse result = null;
	Exception exception = null;
	try {
		result = chain.doFilter(context);
		return result;
	}
	catch (RuntimeException e) {
		exception = e;
		throw e;
	}
	finally {
		boolean resultError = result != null && result.getErrors() != null && result.getErrors().iterator().hasNext();
		boolean failed = exception != null || resultError;
		long duration = (System.nanoTime() - s) / 1000;
		String status = failed ? STRING_EXCEPTION : STRING_OK;

		localTracer.submitBinaryAnnotation(STATUS_CODE_ANNOTATION, status);
		writeQuery(localTracer, query);
		writeResults(localTracer, result);
		localTracer.finishSpan(duration);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:35,代码来源:BraveRepositoryFilter.java

示例2: setup

import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
@Before
public void setup() {
	boot = new CrnkBoot();
	boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.test.mock.repository", new SampleJsonServiceLocator
			()));
	boot.boot();

	localTracer = Mockito.mock(LocalTracer.class);
	brave = Mockito.mock(Brave.class);
	Mockito.when(brave.localTracer()).thenReturn(localTracer);

	moduleContext = Mockito.mock(Module.ModuleContext.class);
	Mockito.when(moduleContext.getResourceRegistry()).thenReturn(boot.getResourceRegistry());

	QuerySpec querySpec = new QuerySpec(Task.class);
	queryAdapter = new QuerySpecAdapter(querySpec, boot.getResourceRegistry());

	ResourceInformation taskResourceInformation = boot.getResourceRegistry().getEntry(Task.class).getResourceInformation();
	requestSpec = Mockito.mock(RepositoryRequestSpec.class);
	Mockito.when(requestSpec.getMethod()).thenReturn(HttpMethod.GET);
	Mockito.when(requestSpec.getQueryAdapter()).thenReturn(queryAdapter);
	Mockito.when(requestSpec.getQuerySpec(taskResourceInformation))
			.thenReturn(querySpec);

	filter = new BraveRepositoryFilter(brave, moduleContext);
	filterContext = Mockito.mock(RepositoryFilterContext.class);
	Mockito.when(filterContext.getRequest()).thenReturn(requestSpec);

	filterChain = Mockito.mock(RepositoryRequestFilterChain.class);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:31,代码来源:BraveResponseFilterTest.java

示例3: ZipkinEventBusClientInterceptor

import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
public ZipkinEventBusClientInterceptor(final ServerSpanThreadBinder serverSpanThreadBinder,
                                       final ClientSpanThreadBinder spanThreadBinder,
                                       final ClientRequestInterceptor requestInterceptor,
                                       final ClientResponseInterceptor responseInterceptor,
                                       final LocalTracer localTracer) {

  this.serverSpanThreadBinder = serverSpanThreadBinder;
  this.spanThreadBinder = spanThreadBinder;
  this.requestInterceptor = requestInterceptor;
  this.responseInterceptor = responseInterceptor;
  this.localTracer = localTracer;
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:13,代码来源:ZipkinEventBusClientInterceptor.java

示例4: ZipkinEventBusServerInterceptor

import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
public ZipkinEventBusServerInterceptor(final ServerSpanThreadBinder spanThreadBinder,
                                       final ServerRequestInterceptor requestInterceptor,
                                       final ServerResponseInterceptor responseInterceptor,
                                       final LocalTracer localTracer) {
  this.spanThreadBinder = spanThreadBinder;
  this.requestInterceptor = requestInterceptor;
  this.responseInterceptor = responseInterceptor;
  this.localTracer = localTracer;
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:10,代码来源:ZipkinEventBusServerInterceptor.java

示例5: writeQuery

import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
private void writeQuery(LocalTracer localTracer, String query) {
	if (query != null) {
		localTracer.submitBinaryAnnotation(QUERY_ANNOTATION, query);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:6,代码来源:BraveRepositoryFilter.java

示例6: writeResults

import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
private void writeResults(LocalTracer localTracer, JsonApiResponse result) {
	if (result != null && result.getEntity() != null) {
		int numResults = getResultCount(result);
		localTracer.submitBinaryAnnotation(QUERY_RESULTS, Integer.toString(numResults));
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:7,代码来源:BraveRepositoryFilter.java

示例7: TracedSpanStore

import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
TracedSpanStore(LocalTracer tracer, StorageComponent component) {
  this.tracer = tracer;
  this.delegate = component.spanStore();
  this.component = component.getClass().getSimpleName();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:6,代码来源:TracedSpanStore.java


注:本文中的com.github.kristofa.brave.LocalTracer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。