项目作者: opentracing-contrib

项目描述 :
OpenTracing instrumentation for Grizzly HttpServer
高级语言: Java
项目地址: git://github.com/opentracing-contrib/java-grizzly-http-server.git
创建时间: 2018-09-24T04:23:30Z
项目社区:https://github.com/opentracing-contrib/java-grizzly-http-server

开源协议:Apache License 2.0

下载


OpenTracing Grizzly HTTP Server Instrumentation

OpenTracing instrumentation for Grizzly HTTP Server.

OpenTracing Agents

When using a runtime agent like java-agent or java-specialagent TCPNIOTransports will be automatically instrumented as long as their FilterChain contains an HttpServerFilter. This is the case with the plain HttpServer through its constructor or HttpServer.createSimpleServer static factory methods:

  1. HttpServer httpServer = new HttpServer();
  2. NetworkListener listener = new NetworkListener("grizzly", "localhost", "8080");
  3. httpServer.addListener(listener);
  4. httpServer.start();

or

  1. HttpServer httpServer = HttpServer.createSimpleServer();
  2. httpServer.start();

Alternatively, chains created directly will also be instrumented automatically under the same condition:

  1. FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  2. filterChainBuilder.add(new TransportFilter());
  3. filterChainBuilder.add(new HttpServerFilter());
  4. filterChainBuilder.add(new SomeWorkerFilter());
  5. TCPNIOTransport transport = TCPNIOTransportBuilder.newInstance().build();
  6. transport.setProcessor(filterChainBuilder.build());
  7. transport.bind("localhost", "8080");
  8. transport.start();

Refer to the agents’ documentation for how to include this library as an instrumentation plugin.

Non-Agent Configuration

When not using any of the OpenTracing Agents the traced filter chain instance must be instantiated directly. Use of the plain HttpServer without a runtime Agent is not currently supported.

  1. FilterChainBuilder filterChainBuilder = new TracedFilterChainBuilder();
  2. filterChainBuilder.add(new TransportFilter());
  3. filterChainBuilder.add(new HttpServerFilter());
  4. filterChainBuilder.add(new SomeWorkFilter());
  5. ...