示例#1
0
  public static String toString(Span span) {
    StringBuilder builder = new StringBuilder();
    builder.append('(');
    builder.append(span.getServiceType());
    builder.append(", [");
    appendAnnotations(builder, span.getAnnotations());
    builder.append("])");

    return builder.toString();
  }
  private Span createSpan(List<SpanEvent> spanEventList) {
    DefaultTraceId traceId = new DefaultTraceId("test", 0, 1);
    Span span = new Span();

    for (SpanEvent spanEvent : spanEventList) {
      span.addToSpanEventList(spanEvent);
    }

    span.setAgentId("agentId");
    span.recordTraceId(traceId);
    return span;
  }
  private Span createSpan(int spanEventSize) throws InterruptedException {
    AgentInformation agentInformation =
        new AgentInformation(
            "agentId",
            "applicationName",
            0,
            0,
            "machineName",
            "127.0.0.1",
            ServiceType.STAND_ALONE,
            JvmUtils.getSystemProperty(SystemPropertyKey.JAVA_VERSION),
            Version.VERSION);
    SpanChunkFactory spanChunkFactory = new SpanChunkFactory(agentInformation);

    List<SpanEvent> spanEventList = createSpanEventList(spanEventSize);
    Span span = new Span();

    List<TSpanEvent> tSpanEventList = new ArrayList<TSpanEvent>();
    for (SpanEvent spanEvent : spanEventList) {
      tSpanEventList.add(spanEvent);
    }
    span.setSpanEventList(tSpanEventList);
    return span;
  }