Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As it was mentioned before, you may use GlobalTracer utility class to pass the tracer around so, for example, any JAX-WS service will be able to retrieve the current tracer by invoking GlobalTracer.get() method.

Distributed Tracing with OpenTracing and OSGi

Code Block
java
java
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cxf="http://cxf.apache.org/blueprint/core"
       xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"

       xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                           http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
                           http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd">

    <bean id="tracingFeature" class="org.apache.cxf.tracing.opentracing.jaxrs.OpenTracingFeature">
        <argument index="0">
            <bean factory-ref="builder" factory-method="build" />
        </argument>
    </bean>
    
    <bean id="metrics" class="com.uber.jaeger.metrics.Metrics">
        <argument index="0">
            <bean class="com.uber.jaeger.metrics.StatsFactoryImpl">
                <argument index="0">
                    <bean class="com.uber.jaeger.metrics.NullStatsReporter" />
                </argument>
            </bean>
        </argument>
    </bean>
    
    <bean id="builder" class="com.uber.jaeger.Tracer.Builder">
        <argument index="0" value="cxf-server" />
        <argument index="1">
            <bean class="com.uber.jaeger.reporters.RemoteReporter">
                <argument index="0" ref="sender" />
                <argument index="1" value="1000"/>
                <argument index="2" value="100"/>
                <argument index="3" ref="metrics"/>
            </bean>
        </argument>
        <argument index="2">
            <bean class="com.uber.jaeger.samplers.ConstSampler">
                <argument index="0" value="true" />
            </bean>
        </argument>
    </bean>
    
    <bean id="sender" class="com.uber.jaeger.senders.HttpSender">
        <argument index="0" value="http://localhost:14268/api/traces" />
    </bean>
    
    <cxf:bus>
        <cxf:features>
            <cxf:logging />
        </cxf:features>
    </cxf:bus>

    <jaxrs:server id="catalogServer" address="/">
        <jaxrs:serviceBeans>
            ...
        </jaxrs:serviceBeans>
        <jaxrs:providers>
            <ref component-id="tracingFeature" />
        </jaxrs:providers>
    </jaxrs:server>
</blueprint>