本文整理汇总了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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例5: writeQuery
import com.github.kristofa.brave.LocalTracer; //导入依赖的package包/类
private void writeQuery(LocalTracer localTracer, String query) {
if (query != null) {
localTracer.submitBinaryAnnotation(QUERY_ANNOTATION, query);
}
}
示例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));
}
}
示例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();
}