OpenTracing instrumentation for the Hprose Remote Object Service Engine
This repo support the opentracing in hprose-java, if hprose-java use http or https as network protocol.
- If you use
hprose servletto open hprose services. Addinit-paramon thehprose servlet.
<init-param>
<param-name>invoke</param-name>
<param-value>io.opentracing.contrib.hprose.HttpServiceTracingInvokeHandler</param-value>
</init-param>If you use other InvokeHandlers, except HttpServiceTracingInvokeHandler, you should use comma(,) between these InvokeHandlers.
package hprose.exam.server;
import hprose.common.HproseMethods;
import hprose.server.HproseServlet;
import io.opentracing.contrib.hprose.HttpServiceTracingInvokeHandler;
public class MyHproseServlet extends HproseServlet {
public String hello(String name) {
return "Hello " + name;
}
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
service.use(new HttpServiceTracingInvokeHandler());
service.add("hello", this);
}
}- By default,
HttpServiceTracingInvokeHandleruse javaServiceLoaderto locate OpenTracing tracer implementation. The implementation must be unique, if more than one implemetations are found,HttpServiceTracingInvokeHandlerdon't use any of them, but swtich to NoopTracer. - if you want to use the particular tracer implementation, you can use
HttpServiceTracingInvokeHandler'constructor to set the tracer instance. like this:
service.use(new HttpServiceTracingInvokeHandler(tracer));- Use hprose_for_java_x edition, choose
HttpClientTracingExInvokeHandler.
client.use(new HttpClientTracingExInvokeHandler(tracer));- Use pure client edition, hprose_client_for_java_x edition, choose
HttpClientTracingInvokeHandler.
client.use(new HttpClientTracingInvokeHandler(tracer));- Also, like server side, you can use java
ServiceLoaderto locate OpenTracing tracer implementation, or useHttpClientTracingExInvokeHandlerorHttpClientTracingInvokeHandlerconstructor to set the tracer instance.