public synchronized void removeSpanReceiver(long spanReceiverId) throws IOException { SpanReceiver[] receivers = TracerPool.getGlobalTracerPool().getReceivers(); for (SpanReceiver receiver : receivers) { if (receiver.getId() == spanReceiverId) { TracerPool.getGlobalTracerPool().removeAndCloseReceiver(receiver); LOG.info("Successfully removed SpanReceiver " + spanReceiverId + " with class " + receiver.getClass().getName()); return; } } throw new IOException("There is no span receiver with id " + spanReceiverId); } }
public synchronized SpanReceiverInfo[] listSpanReceivers() throws IOException { TracerPool pool = TracerPool.getGlobalTracerPool(); SpanReceiver[] receivers = pool.getReceivers(); SpanReceiverInfo[] info = new SpanReceiverInfo[receivers.length]; for (int i = 0; i < receivers.length; i++) { SpanReceiver receiver = receivers[i]; info[i] = new SpanReceiverInfo(receiver.getId(), receiver.getClass().getName()); } return info; }
public synchronized SpanReceiverInfo[] listSpanReceivers() throws IOException { TracerPool pool = TracerPool.getGlobalTracerPool(); SpanReceiver[] receivers = pool.getReceivers(); SpanReceiverInfo[] info = new SpanReceiverInfo[receivers.length]; for (int i = 0; i < receivers.length; i++) { SpanReceiver receiver = receivers[i]; info[i] = new SpanReceiverInfo(receiver.getId(), receiver.getClass().getName()); } return info; }
public synchronized void removeSpanReceiver(long spanReceiverId) throws IOException { SpanReceiver[] receivers = TracerPool.getGlobalTracerPool().getReceivers(); for (SpanReceiver receiver : receivers) { if (receiver.getId() == spanReceiverId) { TracerPool.getGlobalTracerPool().removeAndCloseReceiver(receiver); LOG.info("Successfully removed SpanReceiver " + spanReceiverId + " with class " + receiver.getClass().getName()); return; } } throw new IOException("There is no span receiver with id " + spanReceiverId); } }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
private List<SpanReceiver> createSpanReceivers(String classes) { Tracer tracer = new Tracer.Builder(). name("MyTracer"). tracerPool(new TracerPool("createSpanReceivers")). conf(HTraceConfiguration.fromKeyValuePairs( "span.receiver.classes", classes)). build(); SpanReceiver[] receivers = tracer.getTracerPool().getReceivers(); tracer.close(); LinkedList<SpanReceiver> receiverList = new LinkedList<SpanReceiver>(); for (SpanReceiver item: receivers) { receiverList.add(item); } return receiverList; }