@Test
  public void replace() throws Exception {
    List<ByteArrayOutput> nodes01 = new ArrayList<ByteArrayOutput>();
    final AtomicInteger writeTo01 = new AtomicInteger(0);
    nodes01.add(
        new ByteArrayOutput() {
          public void writeTo(OutputStream out) throws IOException {
            writeTo01.incrementAndGet();
          }
        });

    final AtomicInteger writeTo02 = new AtomicInteger(0);
    List<ByteArrayOutput> nodes02 = new ArrayList<ByteArrayOutput>();
    nodes02.add(
        new ByteArrayOutput() {
          public void writeTo(OutputStream out) throws IOException {
            writeTo02.incrementAndGet();
          }
        });

    ByteArrayOutputStreamTransport transport =
        new ByteArrayOutputStreamTransport(new ByteArrayOutputStream());
    TReplaceListProtocol protocol01 = new TReplaceListProtocol(new TCompactProtocol(transport));
    protocol01.addReplaceField("spanEventList", nodes01);
    span.write(protocol01);
    assertEquals(1, writeTo01.get());

    TReplaceListProtocol protocol02 = new TReplaceListProtocol(new TCompactProtocol(transport));
    protocol02.addReplaceField("spanEventList", nodes02);
    span.write(protocol02);
    assertEquals(1, writeTo02.get());
  }
  @Before
  public void before() {
    // add dummy span-event list
    List<TSpanEvent> spanEventList = new ArrayList<TSpanEvent>();
    spanEventList.add(new TSpanEvent());
    span.setSpanEventList(spanEventList);
    span.setSpanEventListIsSet(true);

    // init byte buffer
    Arrays.fill(buf, Byte.valueOf("0"));
  }
Esempio n. 3
0
  public SpanEventBo(TSpan tSpan, TSpanEvent tSpanEvent) {
    if (tSpan == null) {
      throw new NullPointerException("tSpan must not be null");
    }
    if (tSpanEvent == null) {
      throw new NullPointerException("tSpanEvent must not be null");
    }

    this.agentId = tSpan.getAgentId();
    this.applicationId = tSpan.getApplicationName();
    this.agentStartTime = tSpan.getAgentStartTime();

    final TransactionId transactionId =
        TransactionIdUtils.parseTransactionId(tSpan.getTransactionId());
    this.traceAgentId = transactionId.getAgentId();
    if (traceAgentId == null) {
      traceAgentId = this.agentId;
    }
    this.traceAgentStartTime = transactionId.getAgentStartTime();
    this.traceTransactionSequence = transactionId.getTransactionSequence();

    this.spanId = tSpan.getSpanId();
    this.sequence = tSpanEvent.getSequence();

    this.startElapsed = tSpanEvent.getStartElapsed();
    this.endElapsed = tSpanEvent.getEndElapsed();

    this.rpc = tSpanEvent.getRpc();
    this.serviceType = tSpanEvent.getServiceType();

    this.destinationId = tSpanEvent.getDestinationId();

    this.endPoint = tSpanEvent.getEndPoint();
    this.apiId = tSpanEvent.getApiId();

    if (tSpanEvent.isSetDepth()) {
      this.depth = tSpanEvent.getDepth();
    }

    if (tSpanEvent.isSetNextSpanId()) {
      this.nextSpanId = tSpanEvent.getNextSpanId();
    }

    setAnnotationList(tSpanEvent.getAnnotations());

    final TIntStringValue exceptionInfo = tSpanEvent.getExceptionInfo();
    if (exceptionInfo != null) {
      this.hasException = true;
      this.exceptionId = exceptionInfo.getIntValue();
      this.exceptionMessage = exceptionInfo.getStringValue();
    }

    if (tSpanEvent.isSetAsyncId()) {
      this.asyncId = tSpanEvent.getAsyncId();
    }

    if (tSpanEvent.isSetNextAsyncId()) {
      this.nextAsyncId = tSpanEvent.getNextAsyncId();
    }

    if (tSpanEvent.isSetAsyncSequence()) {
      this.asyncSequence = tSpanEvent.getAsyncSequence();
    }
  }