Java Code Examples for org.apache.htrace.Span#addKVAnnotation()

The following examples show how to use org.apache.htrace.Span#addKVAnnotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TraceMetricsSourceTest.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * For PHOENIX-1126, Phoenix originally assumed all the annotation values were integers,
 * but HBase writes some strings as well, so we need to be able to handle that too
 */
@Test
public void testNonIntegerAnnotations(){
  Span span = getSpan();
  // make sure its less than the length of an integer
  byte[] value = Bytes.toBytes("a");
  byte[] someInt = Bytes.toBytes(1);
  assertTrue(someInt.length >value.length);

  // an annotation that is not an integer
  span.addKVAnnotation(Bytes.toBytes("key"), value);

  // Create the sink and write the span
  TraceMetricSource source = new TraceMetricSource();
  source.receiveSpan(span);
}
 
Example 2
Source File: TraceSpanReceiverTest.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * For PHOENIX-1126, Phoenix originally assumed all the annotation values were integers,
 * but HBase writes some strings as well, so we need to be able to handle that too
 */
@Test
public void testNonIntegerAnnotations(){
  Span span = getSpan();
  // make sure its less than the length of an integer

  byte[] value = Bytes.toBytes("a");
  byte[] someInt = Bytes.toBytes(1);
  assertTrue(someInt.length > value.length);

  // an annotation that is not an integer
  span.addKVAnnotation(Bytes.toBytes("key"), value);

  // Create the sink and write the span
  TraceSpanReceiver source = new TraceSpanReceiver();
  Trace.addReceiver(source);

  Tracer.getInstance().deliver(span);

  assertTrue(source.getNumSpans() == 1);
}
 
Example 3
Source File: DFSClient.java    From hadoop with Apache License 2.0 5 votes vote down vote up
TraceScope getPathTraceScope(String description, String path) {
  TraceScope scope = Trace.startSpan(description, traceSampler);
  Span span = scope.getSpan();
  if (span != null) {
    if (path != null) {
      span.addKVAnnotation(PATH,
          path.getBytes(Charset.forName("UTF-8")));
    }
  }
  return scope;
}
 
Example 4
Source File: DFSClient.java    From hadoop with Apache License 2.0 5 votes vote down vote up
TraceScope getSrcDstTraceScope(String description, String src, String dst) {
  TraceScope scope = Trace.startSpan(description, traceSampler);
  Span span = scope.getSpan();
  if (span != null) {
    if (src != null) {
      span.addKVAnnotation(SRC,
          src.getBytes(Charset.forName("UTF-8")));
    }
    if (dst != null) {
      span.addKVAnnotation(DST,
          dst.getBytes(Charset.forName("UTF-8")));
    }
  }
  return scope;
}
 
Example 5
Source File: DFSClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
TraceScope getPathTraceScope(String description, String path) {
  TraceScope scope = Trace.startSpan(description, traceSampler);
  Span span = scope.getSpan();
  if (span != null) {
    if (path != null) {
      span.addKVAnnotation(PATH,
          path.getBytes(Charset.forName("UTF-8")));
    }
  }
  return scope;
}
 
Example 6
Source File: DFSClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
TraceScope getSrcDstTraceScope(String description, String src, String dst) {
  TraceScope scope = Trace.startSpan(description, traceSampler);
  Span span = scope.getSpan();
  if (span != null) {
    if (src != null) {
      span.addKVAnnotation(SRC,
          src.getBytes(Charset.forName("UTF-8")));
    }
    if (dst != null) {
      span.addKVAnnotation(DST,
          dst.getBytes(Charset.forName("UTF-8")));
    }
  }
  return scope;
}
 
Example 7
Source File: Tracing.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private static void addCustomAnnotationsToSpan(@Nullable Span span, @NotNull PhoenixConnection conn) {
      Preconditions.checkNotNull(conn);

      if (span == null) {
      	return;
      }
Map<String, String> annotations = conn.getCustomTracingAnnotations();
// copy over the annotations as bytes
for (Map.Entry<String, String> annotation : annotations.entrySet()) {
	span.addKVAnnotation(toBytes(annotation.getKey()), toBytes(annotation.getValue()));
      }
  }
 
Example 8
Source File: Tracing.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private static void addCustomAnnotationsToSpan(@Nullable Span span, @NonNull PhoenixConnection conn) {
      Preconditions.checkNotNull(conn);

      if (span == null) {
      	return;
      }
Map<String, String> annotations = conn.getCustomTracingAnnotations();
// copy over the annotations as bytes
for (Map.Entry<String, String> annotation : annotations.entrySet()) {
	span.addKVAnnotation(toBytes(annotation.getKey()), toBytes(annotation.getValue()));
      }
  }
 
Example 9
Source File: BaseTracingTestIT.java    From phoenix with Apache License 2.0 5 votes vote down vote up
protected Span createNewSpan(long traceid, long parentid, long spanid, String description,
        long startTime, long endTime, String processid, String... tags) {

    Span span =
            new MilliSpan.Builder().description(description).traceId(traceid)
                    .parents(new long[] { parentid }).spanId(spanid).processId(processid)
                    .begin(startTime).end(endTime).build();

    int tagCount = 0;
    for (String annotation : tags) {
        span.addKVAnnotation((Integer.toString(tagCount++)).getBytes(), annotation.getBytes());
    }
    return span;
}
 
Example 10
Source File: TracingUtils.java    From phoenix with Apache License 2.0 4 votes vote down vote up
public static void addAnnotation(Span span, String message, int value) {
    span.addKVAnnotation(message.getBytes(), Bytes.toBytes(Integer.toString(value)));
}
 
Example 11
Source File: TracingUtils.java    From phoenix with Apache License 2.0 4 votes vote down vote up
public static void addAnnotation(Span span, String message, int value) {
    span.addKVAnnotation(message.getBytes(), Bytes.toBytes(Integer.toString(value)));
}