/** * Create a new instance with default configuration. * * @param baseUrl URL of the zipkin query server instance. Like: http://localhost:9411/ * @param metrics Gets notified when spans are accepted or dropped. If you are not interested in * these events you can use {@linkplain EmptySpanCollectorMetricsHandler} */ public static HttpSpanCollector create(String baseUrl, SpanCollectorMetricsHandler metrics) { return new HttpSpanCollector(baseUrl, Config.builder().build(), metrics); }
public static Builder builder() { return new AutoValue_HttpSpanCollector_Config.Builder() .connectTimeout(10 * 1000) .readTimeout(60 * 1000) .compressionEnabled(false) .flushInterval(1); }
@Override public String spanName(HttpRequest request) { return request.getHttpMethod(); } }
@Bean public SpanCollector spanCollector() { HttpSpanCollector.Config config = HttpSpanCollector.Config.builder().connectTimeout(properties.getConnectTimeout()).readTimeout(properties.getReadTimeout()) .compressionEnabled(properties.isCompressionEnabled()).flushInterval(properties.getFlushInterval()).build(); return HttpSpanCollector.create(properties.getUrl(), config, new EmptySpanCollectorMetricsHandler()); }
/** * Intercepts the server request flow and extract request information * to be published to the Zipkin server for tracing. */ @Override public boolean preCall(Request request, Response responder, ServiceMethodInfo serviceMethodInfo) throws Exception { serviceMethodInfo.setAttribute(RESPONDER_ATTRIBUTE, responder); HttpServerRequest req = new TraceableHttpServerRequest(request); HttpServerRequestAdapter reqAdapter = new HttpServerRequestAdapter(req, new DefaultSpanNameProvider()); reqInterceptor.handle(reqAdapter); return true; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof HttpSpanCollector.Config) { HttpSpanCollector.Config that = (HttpSpanCollector.Config) o; return (this.connectTimeout == that.connectTimeout()) && (this.readTimeout == that.readTimeout()) && (this.flushInterval == that.flushInterval()) && (this.compressionEnabled == that.compressionEnabled()); } return false; }
/** recreate the server if needed */ protected abstract void init(Brave brave, SpanNameProvider spanNameProvider) throws Exception;
@Override public String spanName(HttpRequest request) { return request.getUri().getPath(); } }
@Override public String getSpanName() { return spanNameProvider.spanName(request); }
/** * @param baseUrl URL of the zipkin query server instance. Like: http://localhost:9411/ * @param config includes flush interval and timeouts * @param metrics Gets notified when spans are accepted or dropped. If you are not interested in * these events you can use {@linkplain EmptySpanCollectorMetricsHandler} */ public static HttpSpanCollector create(String baseUrl, Config config, SpanCollectorMetricsHandler metrics) { return new HttpSpanCollector(baseUrl, config, metrics); }
HttpSpanCollector(String baseUrl, Config config, SpanCollectorMetricsHandler metrics) { super(SpanCodec.JSON, metrics, config.flushInterval()); this.url = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + "api/v1/spans"; this.config = config; }
static TraceData tryParseSamplingFlags(String b3, int pos) { int flags = parseFlags(b3, pos); if (flags == 0) return null; if ((flags & FLAG_DEBUG) == FLAG_DEBUG // brave 3 doesn't support debug || (flags & FLAG_SAMPLED) == FLAG_SAMPLED) { return TraceData.SAMPLED; } return TraceData.NOT_SAMPLED; }
public static Builder builder() { return new AutoValue_HttpSpanCollector_Config.Builder() .connectTimeout(10 * 1000) .readTimeout(60 * 1000) .compressionEnabled(false) .flushInterval(1); }
/** * Create a new instance with default configuration. * * @param baseUrl URL of the zipkin query server instance. Like: http://localhost:9411/ * @param metrics Gets notified when spans are accepted or dropped. If you are not interested in * these events you can use {@linkplain EmptySpanCollectorMetricsHandler} */ public static HttpSpanCollector create(String baseUrl, SpanCollectorMetricsHandler metrics) { return new HttpSpanCollector(baseUrl, Config.builder().build(), metrics); }
@Override public String spanName(HttpRequest request) { return request.getHttpMethod(); } }
@Override public String getSpanName() { return spanNameProvider.spanName(request); }
/** * @param baseUrl URL of the zipkin query server instance. Like: http://localhost:9411/ * @param config includes flush interval and timeouts * @param metrics Gets notified when spans are accepted or dropped. If you are not interested in * these events you can use {@linkplain EmptySpanCollectorMetricsHandler} */ public static HttpSpanCollector create(String baseUrl, Config config, SpanCollectorMetricsHandler metrics) { return new HttpSpanCollector(baseUrl, config, metrics); }
HttpSpanCollector(String baseUrl, Config config, SpanCollectorMetricsHandler metrics) { super(SpanCodec.JSON, metrics, config.flushInterval()); this.url = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + "api/v1/spans"; this.config = config; }
@Override public String getSpanName() { return spanNameProvider.spanName(request); }
@Override public String getSpanName() { return spanNameProvider.spanName(serverRequest); }