cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r1038594 - in /websites/production/cxf/content: cache/docs.pageCache docs/using-opentracing.html
Date Sat, 05 Jan 2019 21:57:38 GMT
Author: buildbot
Date: Sat Jan  5 21:57:38 2019
New Revision: 1038594

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/using-opentracing.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/using-opentracing.html
==============================================================================
--- websites/production/cxf/content/docs/using-opentracing.html (original)
+++ websites/production/cxf/content/docs/using-opentracing.html Sat Jan  5 21:57:38 2019
@@ -118,13 +118,13 @@ Apache CXF -- Using OpenTracing
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div id="ConfluenceContent"><h1 id="UsingOpenTracing-/*&lt;![CDATA[*/div.rbtoc1534403264209{padding:0px;}div.rbtoc1534403264209ul{list-style:disc;margin-left:0px;}div.rbtoc1534403264209li{margin-left:0px;padding-left:0px;}/*]]&gt;*/#UsingOpenTracing-Overview#UsingOpenTracing-OverviewDistributedTr"><style
type="text/css">/*<![CDATA[*/
-div.rbtoc1534403264209 {padding: 0px;}
-div.rbtoc1534403264209 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1534403264209 li {margin-left: 0px;padding-left: 0px;}
+<div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/
+div.rbtoc1546725419019 {padding: 0px;}
+div.rbtoc1546725419019 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1546725419019 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></h1><div class="toc-macro rbtoc1534403264209">
-<ul class="toc-indentation"><li><a shape="rect" href="#UsingOpenTracing-"></a></li><li><a
shape="rect" href="#UsingOpenTracing-Overview">Overview</a></li><li><a
shape="rect" href="#UsingOpenTracing-DistributedTracinginApacheCXFusingOpenTracing">Distributed
Tracing in Apache CXF using OpenTracing</a></li><li><a shape="rect" href="#UsingOpenTracing-ANoteonOpenTracingAPIs">A
Note on OpenTracing APIs</a></li><li><a shape="rect" href="#UsingOpenTracing-OpenTracingAPIv0.30.0andApacheCXF3.2.x">OpenTracing
API v0.30.0 and Apache CXF 3.2.x</a>
+/*]]>*/</style></p><div class="toc-macro rbtoc1546725419019">
+<ul class="toc-indentation"><li><a shape="rect" href="#UsingOpenTracing-Overview">Overview</a></li><li><a
shape="rect" href="#UsingOpenTracing-DistributedTracinginApacheCXFusingOpenTracing">Distributed
Tracing in Apache CXF using OpenTracing</a></li><li><a shape="rect" href="#UsingOpenTracing-ANoteonOpenTracingAPIs">A
Note on OpenTracing APIs</a></li><li><a shape="rect" href="#UsingOpenTracing-OpenTracingAPIv0.30.0andApacheCXF3.2.x">OpenTracing
API v0.30.0 and Apache CXF 3.2.x</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#UsingOpenTracing-ConfiguringClient">Configuring
Client</a></li><li><a shape="rect" href="#UsingOpenTracing-ConfiguringServer">Configuring
Server</a></li><li><a shape="rect" href="#UsingOpenTracing-DistributedTracingInAction:UsageScenarios">Distributed
Tracing In Action: Usage Scenarios</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#UsingOpenTracing-Example#1:ClientandServerwithdefaultdistributedtracingconfigured">Example
#1: Client and Server with default distributed tracing configured</a></li><li><a
shape="rect" href="#UsingOpenTracing-Example#2:ClientandServerwithnestedtrace">Example
#2: Client and Server with nested trace</a></li><li><a shape="rect" href="#UsingOpenTracing-Example#3:ClientandServertracewithtimeline">Example
#3: Client and Server trace with timeline</a></li><li><a shape="rect"
href="#UsingOpenTracing-Example#4:ClientandServerwithbinaryannotations(key/value)">Example
#4: Client and Server with binary annotations (key/value)</a></li><li><a
shape="rect" href="#UsingOpenTracing-Example#5:ClientandServerwithparalleltrace(involvingthreadpools)">Example
#5: Client and Server with parallel trace (involving thread pools)</a></li><li><a
shape="rect" href="#UsingOpenTracing-Example#6:ClientandServerwithasynchronousJAX-RSservice(server-side)">Exampl
 e #6: Client and Server with asynchronous JAX-RS service (server-side)</a></li><li><a
shape="rect" href="#UsingOpenTracing-Example#7:ClientandServerwithasynchronousinvocation(client-side)">Example
#7: Client and Server with asynchronous invocation (client-side)</a></li></ul>
 </li><li><a shape="rect" href="#UsingOpenTracing-DistributedTracingwithOpenTracingandJAX-WSsupport">Distributed
Tracing with OpenTracing and JAX-WS support</a></li><li><a shape="rect"
href="#UsingOpenTracing-DistributedTracingwithOpenTracingandOSGi">Distributed Tracing with
OpenTracing and OSGi</a></li><li><a shape="rect" href="#UsingOpenTracing-Samples">Samples</a></li></ul>
@@ -132,7 +132,7 @@ div.rbtoc1534403264209 li {margin-left:
 <ul class="toc-indentation"><li><a shape="rect" href="#UsingOpenTracing-ConfiguringClient.1">Configuring
Client</a></li><li><a shape="rect" href="#UsingOpenTracing-ConfiguringServer.1">Configuring
Server</a></li><li><a shape="rect" href="#UsingOpenTracing-DistributedTracingInAction:UsageScenarios.1">Distributed
Tracing In Action: Usage Scenarios</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#UsingOpenTracing-Example#1:ClientandServerwithdefaultdistributedtracingconfigured.1">Example
#1: Client and Server with default distributed tracing configured</a></li><li><a
shape="rect" href="#UsingOpenTracing-Example#2:ClientandServerwithnestedtrace.1">Example
#2: Client and Server with nested trace</a></li><li><a shape="rect" href="#UsingOpenTracing-Example#3:ClientandServertracewithtimeline.1">Example
#3: Client and Server trace with timeline</a></li><li><a shape="rect"
href="#UsingOpenTracing-Example#4:ClientandServerwithannotations(key/value)">Example #4:
Client and Server with annotations (key/value)</a></li><li><a shape="rect"
href="#UsingOpenTracing-Example#5:ClientandServerwithparalleltrace(involvingthreadpools).1">Example
#5: Client and Server with parallel trace (involving thread pools)</a></li><li><a
shape="rect" href="#UsingOpenTracing-Example#6:ClientandServerwithasynchronousJAX-RSservice(server-side).1">Example
#
 6: Client and Server with asynchronous JAX-RS service (server-side)</a></li><li><a
shape="rect" href="#UsingOpenTracing-Example#7:ClientandServerwithasynchronousinvocation(client-side).1">Example
#7: Client and Server with asynchronous invocation (client-side)</a></li></ul>
 </li><li><a shape="rect" href="#UsingOpenTracing-DistributedTracingwithOpenTracingandJAX-WSsupport.1">Distributed
Tracing with OpenTracing and JAX-WS support</a></li><li><a shape="rect"
href="#UsingOpenTracing-DistributedTracingwithOpenTracingandOSGi.1">Distributed Tracing
with OpenTracing and OSGi</a></li><li><a shape="rect" href="#UsingOpenTracing-Samples.1">Samples</a></li></ul>
-</li></ul>
+</li><li><a shape="rect" href="#UsingOpenTracing-AccessingOpenTracingAPIs">Accessing
OpenTracing APIs</a></li></ul>
 </div><h1 id="UsingOpenTracing-Overview">Overview</h1><p><a shape="rect"
class="external-link" href="http://opentracing.io/" rel="nofollow">OpenTracing</a>
is a vendor-neutral open standard for distributed tracing. Essentially, for Java-based projects
the specification exists as a set of <a shape="rect" class="external-link" href="https://github.com/opentracing/opentracing-java"
rel="nofollow">Java APIs</a> which any distributed tracing solution is welcome to
implement. There are<a shape="rect" class="external-link" href="http://opentracing.io/documentation/pages/supported-tracers"
rel="nofollow"> quite a few distributed tracing frameworks</a> available which are
compatible with <a shape="rect" class="external-link" href="http://opentracing.io/" rel="nofollow">OpenTracing</a>,
notably <a shape="rect" class="external-link" href="http://zipkin.io/" rel="nofollow">Zipkin</a>
(via community contributions like <a shape="rect" class="external-link" href="https://github.com/openzipkin/brav
 e-opentracing" rel="nofollow">bridge from Brave to OpenTracing</a> ), <a shape="rect"
class="external-link" href="http://lightstep.com/" rel="nofollow">Lightstep</a> and
<a shape="rect" class="external-link" href="https://uber.github.io/jaeger/" rel="nofollow">Jaeger</a>.
Starting from <strong>3.2.1</strong> release, Apache CXF fully supports integration
(through <strong>cxf-integration-tracing-opentracing</strong> module) with any
distributed tracer that provides <a shape="rect" class="external-link" href="http://opentracing.io/"
rel="nofollow">OpenTracing</a>&#160;<a shape="rect" class="external-link"
href="https://github.com/opentracing/opentracing-java" rel="nofollow">Java API</a>
implementation.</p><p>The section <a shape="rect" href="https://cwiki.apache.org/confluence/display/CXF20DOC/Using+Apache+HTrace">dedicated
to Apache HTrace </a>has pretty good introduction into distributed tracing basics however
<a shape="rect" class="external-link" href="http://opentracing.io/" rel="
 nofollow">OpenTracing</a> specification abstracts a lot of things, outlining just
a general APIs to denote the <strong>Span&#160;</strong>lifecycle and injection
points to propagate the context across many distributed components. As such, the intrinsic
details about HTTP headers f.e. becomes an integral part of the distributed tracer of your
choice, out of reach for Apache CXF.</p><h1 id="UsingOpenTracing-DistributedTracinginApacheCXFusingOpenTracing">Distributed
Tracing in Apache CXF using OpenTracing</h1><p><a shape="rect" href="http://cxf.apache.org/">Apache
CXF</a> is a very popular framework for building services and web APIs. No doubts, it
is going to play even more important role in context of microservices architecture letting
developers to quickly build and deploy individual JAX-RS/JAX-WS services. Distributed tracing
is an essential technique to observe the application platform as a whole, breaking the request
to individual service traces as it goes through and crosses the
  boundaries of threads, processes and machines.</p><p>The current integration
of distributed tracing in <a shape="rect" href="http://cxf.apache.org/">Apache CXF</a>
supports&#160;<a shape="rect" class="external-link" href="http://opentracing.io/" rel="nofollow">OpenTracing</a>&#160;<a
shape="rect" class="external-link" href="https://github.com/opentracing/opentracing-java"
rel="nofollow">Java API</a> <strong class="external-link">0.30.0+</strong>
and provides full-fledged support of JAX-RS 2.x / JAX-WS applications. From high-level prospective,
the JAX-RS integration consists of three main parts:</p><ul><li><strong>TracerContext</strong>
(injectable through <strong>@Context</strong> annotation)</li><li><strong>OpenTracingProvider</strong>
(server-side JAX-RS provider) and <strong>OpenTracingClientProvider</strong> (client-side
JAX-RS provider)</li><li class="external-link"><strong>OpenTracingFeature</strong>
(server-side JAX-RS feature) to simplify the configuration and integration<
 /li></ul><p>Similarly, from high-level perspective,&#160;JAX-WS integration
includes:</p><ul><li><strong>OpenTracingStartInterceptor</strong>
/ <strong>OpenTracingStopInterceptor</strong> / <strong>OpenTracingFeature&#160;</strong><a
shape="rect" href="http://cxf.apache.org/">Apache CXF</a> feature (server-side JAX-WS
support)</li><li><strong>OpenTracingClientStartInterceptor</strong>
/ <strong>OpenTracingClientStopInterceptor</strong> / <strong>OpenTracingClientFeature&#160;</strong><a
shape="rect" href="http://cxf.apache.org/">Apache CXF</a> feature (client-side JAX-WS
support)</li></ul><p><a shape="rect" href="http://cxf.apache.org/">Apache
CXF</a> uses HTTP headers to hand off tracing context from the client to the service
and from the service to service. Those headers are specific to distributing tracing framework
you have picked and are not configurable at the moment (unless the framework itself has a
way to do that).</p><p>By default, <strong>OpenTracingClientProvider</strong
 > will try to pass the currently active <strong>span</strong> through HTTP
headers on each service invocation. If there is no active spans, the new span will be created
and passed through HTTP headers on per-invocation basis. Essentially, for JAX-RS applications
just registering <strong>OpenTracingClientProvider</strong> on the client and
<strong>OpenTracingProvider</strong> on the server is enough to have tracing context
to be properly passed everywhere. The only configuration part which is necessary are <strong>span
reporters(s)</strong> and <strong>sampler(s)</strong> which are, not surprisingly,
specific to distributing tracing framework you have chosen.</p><p>It is also worth
to mention the way <a shape="rect" href="http://cxf.apache.org/">Apache CXF</a>
attaches the description to <strong>spans</strong>. With regards to the client
integration, the description becomes a full URL being invoked prefixed by HTTP method, for
example: <strong>GET </strong><a shape="rect" class="exte
 rnal-link" href="http://localhost:8282/books" rel="nofollow"><strong>http://localhost:8282</strong>/books</a>.
On the server side integration, the description becomes a relative JAX-RS resource path prefixed
by HTTP method, f.e.: <strong>GET books, POST book/123</strong></p><h1
id="UsingOpenTracing-ANoteonOpenTracingAPIs">A Note on OpenTracing APIs</h1><p><a
shape="rect" class="external-link" href="http://opentracing.io/" rel="nofollow">OpenTracing</a>&#160;<a
shape="rect" class="external-link" href="https://github.com/opentracing/opentracing-java"
rel="nofollow">Java API</a> is evolving very fast and, sadly but not surprisingly,
often the changes being made are not backward compatible. The <a shape="rect" href="http://cxf.apache.org/">Apache
CXF</a> <strong>3.2.x</strong> release branch stays on <a shape="rect"
class="external-link" href="http://opentracing.io/" rel="nofollow">OpenTracing</a>&#160;<a
shape="rect" class="external-link" href="https://github.com/opentracing/opentracin
 g-java" rel="nofollow">Java API</a> <strong class="external-link">0.30.0&#160;</strong>as
of now, while the <a shape="rect" href="http://cxf.apache.org/">Apache CXF</a>
<strong>3.3.x</strong> is using <a shape="rect" class="external-link" href="http://opentracing.io/"
rel="nofollow">OpenTracing</a>&#160;<a shape="rect" class="external-link"
href="https://github.com/opentracing/opentracing-java" rel="nofollow">Java API</a>
<strong class="external-link">0.31.0</strong>. There are<strong class="external-link">
</strong>quite many major differences between both APIs but <a shape="rect" href="http://cxf.apache.org/">Apache
CXF</a> is trying hard to smooth it over. It is worth to mention that&#160;<a
shape="rect" class="external-link" href="http://opentracing.io/" rel="nofollow">OpenTracing</a>-compatible
clients and servers may not depend on the same APIs version, the only issue you will run into
is related to compatibility of the provided Java clients for the tracer of your choice.</p><
 h1 id="UsingOpenTracing-OpenTracingAPIv0.30.0andApacheCXF3.2.x">OpenTracing API v0.30.0
and Apache CXF 3.2.x</h1><h2 id="UsingOpenTracing-ConfiguringClient">Configuring
Client</h2><p>In this section and below, all the code snippets are going to be
based on <a shape="rect" class="external-link" href="https://uber.github.io/jaeger/" rel="nofollow">Jaeger</a>
distributed tracing framework (<strong>release 0.20.6+</strong>), although everything
we are going to discuss is equally applicable to any other existing alternatives. Essentially,
the only dependency <a shape="rect" href="http://cxf.apache.org/">Apache CXF</a>
integration relies on is the <strong>Tracer</strong> instance.</p><p>There
are a couple of ways the JAX-RS client could be configured, depending on the client implementation.
<a shape="rect" href="http://cxf.apache.org/">Apache CXF</a> provides its own
<strong>WebClient</strong> which could be configured just like that (in future
versions, there would be a simpler ways to d
 o that using client specific features):</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default">final Tracer tracer = new Configuration("web-client",

         new Configuration.SamplerConfiguration(ConstSampler.TYPE, 1), /* or any other Sampler
*/
@@ -783,7 +783,21 @@ sf.create();
         &lt;/jaxrs:providers&gt;
     &lt;/jaxrs:server&gt;
 &lt;/blueprint&gt;</pre>
-</div></div><div class="confluence-information-macro confluence-information-macro-information"><span
class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>As of now, <a shape="rect" class="external-link"
href="https://uber.github.io/jaeger/" rel="nofollow">Jaeger</a> tracer does not provide
OSGi bundles and the service loader mechanism is not working very well. It is very likely
that you may need to declare own sender configuration instance (overriding <strong>getSender</strong>
method) or use system properties to pick the right one.</p></div></div><h2
id="UsingOpenTracing-Samples.1">Samples</h2><ul><li><a shape="rect"
class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing"
rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing</a></li><li><a
shape="rec
 t" class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel"
rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel</a></li><li><a
shape="rect" class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi"
rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi</a></li></ul></div>
+</div></div><div class="confluence-information-macro confluence-information-macro-information"><span
class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>As of now, <a shape="rect" class="external-link"
href="https://uber.github.io/jaeger/" rel="nofollow">Jaeger</a> tracer does not provide
OSGi bundles and the service loader mechanism is not working very well. It is very likely
that you may need to declare own sender configuration instance (overriding <strong>getSender</strong>
method) or use system properties to pick the right one.</p></div></div><h2
id="UsingOpenTracing-Samples.1">Samples</h2><ul><li><a shape="rect"
class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing"
rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing</a></li><li><a
shape="rec
 t" class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel"
rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel</a></li><li><a
shape="rect" class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi"
rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi</a></li></ul><h1
id="UsingOpenTracing-AccessingOpenTracingAPIs">Accessing OpenTracing APIs</h1><p>The
<a shape="rect" href="http://cxf.apache.org/">Apache CXF</a>&#160; abstracts
as much of the tracer-specific APIs behind <strong>TracerContext</strong> as possible.
However, sometimes there is a need to get access to&#160;<a shape="rect" class="external-link"
href="http://opentracing.io/" rel="nofollow">OpenTracing</a> APIs i
 n order to leverages the rich set of available instrumentations. To make it possible, <strong>TracerContext</strong>
has a dedicated <strong>unwrap</strong> method which returns underlying <strong>Tracer</strong>
instance. The snippet below shows off how to use this API and use <a shape="rect" class="external-link"
href="http://opentracing.io/" rel="nofollow">OpenTracing</a> instrumentation for
<a shape="rect" class="external-link" href="https://github.com/OpenFeign/feign-opentracing"
rel="nofollow">OpenFeign client</a>.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default">@GET
+@Path("/search")
+@Produces(MediaType.APPLICATION_JSON)
+public JsonObject search(@QueryParam("q") final String query, @Context final TracerContext
tracing) throws Exception {
+    final GoogleBooksApi api = Feign.builder()
+        .client(new TracingClient(new ApacheHttpClient(), tracing.unwrap(Tracer.class)))
+        .target(GoogleBooksApi.class, "https://www.googleapis.com");
+
+    final Response response = api.search(query);
+    try (final Reader reader = response.body().asReader()) {
+        return Json.createReader(reader).readObject();
+    }
+}</pre>
+</div></div></div>
            </div>
            <!-- Content -->
          </td>



Mime
View raw message