Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 066DE200C72 for ; Fri, 12 May 2017 15:29:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 05031160BB8; Fri, 12 May 2017 13:29:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4C1C9160BA3 for ; Fri, 12 May 2017 15:29:05 +0200 (CEST) Received: (qmail 71787 invoked by uid 500); 12 May 2017 13:29:04 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 71776 invoked by uid 99); 12 May 2017 13:29:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 May 2017 13:29:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2185CDFBC8; Fri, 12 May 2017 13:29:04 +0000 (UTC) From: ok2c To: dev@hc.apache.org Reply-To: dev@hc.apache.org References: In-Reply-To: Subject: [GitHub] httpclient pull request #74: WIP: OpenTracing integration Content-Type: text/plain Message-Id: <20170512132904.2185CDFBC8@git1-us-west.apache.org> Date: Fri, 12 May 2017 13:29:04 +0000 (UTC) archived-at: Fri, 12 May 2017 13:29:06 -0000 Github user ok2c commented on a diff in the pull request: https://github.com/apache/httpclient/pull/74#discussion_r116229419 --- Diff: httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/TracingAsyncExec.java --- @@ -0,0 +1,80 @@ +package org.apache.hc.client5.http.impl.async; + +import java.io.IOException; +import java.net.URISyntaxException; + +import org.apache.hc.client5.http.async.AsyncExecCallback; +import org.apache.hc.client5.http.async.AsyncExecChain; +import org.apache.hc.client5.http.async.AsyncExecChain.Scope; +import org.apache.hc.client5.http.async.AsyncExecChainHandler; +import org.apache.hc.core5.http.EntityDetails; +import org.apache.hc.core5.http.HttpException; +import org.apache.hc.core5.http.HttpRequest; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.nio.AsyncDataConsumer; +import org.apache.hc.core5.http.nio.AsyncEntityProducer; + +import io.opentracing.Span; +import io.opentracing.Tracer; +import io.opentracing.Tracer.SpanBuilder; +import io.opentracing.contrib.spanmanager.DefaultSpanManager; +import io.opentracing.contrib.spanmanager.SpanManager.ManagedSpan; +import io.opentracing.tag.Tags; + +/** + * @author Pavol Loffay + */ +public class TracingAsyncExec implements AsyncExecChainHandler { + + private Tracer tracer; + + public TracingAsyncExec(Tracer tracer) { + this.tracer = tracer; + } + + @Override + public void execute(HttpRequest request, AsyncEntityProducer entityProducer, final Scope scope, + AsyncExecChain chain, final AsyncExecCallback asyncExecCallback) throws HttpException, IOException { + + SpanBuilder spanBuilder = tracer.buildSpan(request.getMethod()) + .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT); + + ManagedSpan current = DefaultSpanManager.getInstance().current(); --- End diff -- 1. I may be missing something obvious but what is so difficult about shoving things into HttpContext? 2. Async client has a different threading model compared to the classic one thread per socket one, like it or not. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org