Java Code Examples for org.apache.htrace.TraceScope#getSpan()

The following examples show how to use org.apache.htrace.TraceScope#getSpan() . 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: 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 2
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 3
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 4
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 5
Source File: TraceQueryPlan.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public Tuple next() throws SQLException {
    if(!first) return null;
    TraceScope traceScope = conn.getTraceScope();
    if (traceStatement.isTraceOn()) {
        conn.setSampler(Tracing.getConfiguredSampler(traceStatement));
        if (conn.getSampler() == Sampler.NEVER) {
            closeTraceScope(conn);
        }
        if (traceScope == null && !conn.getSampler().equals(Sampler.NEVER)) {
            traceScope = Tracing.startNewSpan(conn, "Enabling trace");
            if (traceScope.getSpan() != null) {
                conn.setTraceScope(traceScope);
            } else {
                closeTraceScope(conn);
            }
        }
    } else {
        closeTraceScope(conn);
        conn.setSampler(Sampler.NEVER);
    }
    if (traceScope == null || traceScope.getSpan() == null) return null;
    first = false;
    ImmutableBytesWritable ptr = new ImmutableBytesWritable();
    ParseNodeFactory factory = new ParseNodeFactory();
    LiteralParseNode literal =
            factory.literal(traceScope.getSpan().getTraceId());
    LiteralExpression expression =
            LiteralExpression.newConstant(literal.getValue(), PLong.INSTANCE,
                Determinism.ALWAYS);
    expression.evaluate(null, ptr);
    byte[] rowKey = ByteUtil.copyKeyBytesIfNecessary(ptr);
    Cell cell =
            PhoenixKeyValueUtil
                    .newKeyValue(rowKey, HConstants.EMPTY_BYTE_ARRAY,
                        HConstants.EMPTY_BYTE_ARRAY,
                        EnvironmentEdgeManager.currentTimeMillis(),
                        HConstants.EMPTY_BYTE_ARRAY);
    List<Cell> cells = new ArrayList<Cell>(1);
    cells.add(cell);
    return new ResultTuple(Result.create(cells));
}