Skip to content

Instantly share code, notes, and snippets.

public static class TracingHandler extends SimpleChannelUpstreamHandler {
private Tagging tagging;
public TracingHandler(Tagging tagging) {
this.tagging = tagging;
}
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
HttpRequest httpRequest = (HttpRequest)e.getMessage();
/* create the collector wrapper, passing the dT tagging and trace ID */
private TracingCollector createCollector( byte[] traceId) {
DynaTraceADKFactory.initialize();
Tagging tagging = DynaTraceADKFactory.createTagging();
tagging.setTag(traceId); //use traceId to "join" the purepath
tagging.startServerPurePath(); //start the sub path for this bolt
byte[] newTag = tagging.getTag(); //create a new traceId which will be emitted to subsequent bolts
return new TracingCollector(collector, tagging, newTag);
}
package au.com.msquare.storm.base;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import com.dynatrace.adk.DynaTraceADKFactory;
import com.dynatrace.adk.Tagging;