Java Code Examples for org.springframework.cloud.sleuth.Span#tag()
The following examples show how to use
org.springframework.cloud.sleuth.Span#tag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrganizationService.java From spring-microservices-in-action with Apache License 2.0 | 5 votes |
/** * Query an organization by the organization ID. * * @param orgId * The organization ID for looking up. * * @return The matched organization record. */ public Organization getOrg(String orgId) { Span newSpan = tracer.createSpan("getOrgDBCall"); // create a new span for send custom span to zipkin server try { return orgRepository.findById(orgId); } finally { newSpan.tag("peer.service", "mysql"); newSpan.logEvent(Span.CLIENT_RECV); tracer.close(newSpan); } }
Example 2
Source File: OrganizationRestTemplateClient.java From spring-microservices-in-action with Apache License 2.0 | 5 votes |
/** * Check Redis has a certain organization record or not. * * @param organizationId * The organization ID for looking up. * * @return The match organization record if found; * Otherwise, return {@code null}. */ private Organization checkRedisCache(String organizationId) { Span newSpan = tracer.createSpan("readLicensingDataFromRedis"); // create a new span for send custom span to zipkin server try { return orgRedisRepo.findOrganization(organizationId); } catch (Exception ex){ logger.error("Error encountered while trying to retrieve organization {} check Redis Cache. Exception {}", organizationId, ex); return null; } finally { newSpan.tag("peer.service", "redis"); newSpan.logEvent(Span.CLIENT_RECV); tracer.close(newSpan); } }
Example 3
Source File: OpenCensusSleuthTracer.java From opencensus-java with Apache License 2.0 | 5 votes |
@Override public void addTag(String key, String value) { Span s = getCurrentSpan(); if (s != null && s.isExportable()) { s.tag(key, value); } }
Example 4
Source File: SleuthDbmInterceptor.java From onetwo with Apache License 2.0 | 5 votes |
@Override public Object intercept(DbmInterceptorChain chain) { final Span span = tracer.createSpan(SPAN_NAME); try { span.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, SPAN_NAME); span.logEvent(Span.CLIENT_SEND); return chain.invoke(); } finally{ // span.tag(Span.SPAN_PEER_SERVICE_TAG_NAME, SPAN_NAME); span.logEvent(Span.CLIENT_RECV); tracer.close(span); } }
Example 5
Source File: SleuthRocketmqInterceptor.java From onetwo with Apache License 2.0 | 5 votes |
@Override public Object intercept(SendMessageInterceptorChain chain) { if (tracer!=null) { return chain.invoke(); } final Span span = tracer.createSpan(SPAN_NAME); try { span.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, SPAN_NAME); span.logEvent(Span.CLIENT_SEND); return chain.invoke(); } finally{ span.logEvent(Span.CLIENT_RECV); tracer.close(span); } }
Example 6
Source File: GenericCommand.java From data-prep with Apache License 2.0 | 5 votes |
private Span addTrackingHeaders(HttpRequestBase request) { final Package commandPackage = this.getClass().getPackage(); final StringTokenizer tokenizer = new StringTokenizer(commandPackage.getName(), "."); final StringBuilder spanName = new StringBuilder(); while (tokenizer.hasMoreTokens()) { spanName.append(String.valueOf(tokenizer.nextToken().charAt(0) + ".")); } spanName.append(this.getClass().getSimpleName()); final Span requestSpan = tracer.createSpan(spanName.toString(), tracer.getCurrentSpan()); requestSpan.tag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, this.getClass().getName()); final SpanInjector<HttpRequestBase> injector = new HttpRequestBaseSpanInjector(this.getClass()); injector.inject(requestSpan, request); return requestSpan; }