io.opencensus.trace.propagation.BinaryFormat Java Examples

The following examples show how to use io.opencensus.trace.propagation.BinaryFormat. 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: CensusTracingModule.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
CensusTracingModule(
    Tracer censusTracer, final BinaryFormat censusPropagationBinaryFormat) {
  this.censusTracer = checkNotNull(censusTracer, "censusTracer");
  checkNotNull(censusPropagationBinaryFormat, "censusPropagationBinaryFormat");
  this.tracingHeader =
      Metadata.Key.of("grpc-trace-bin", new Metadata.BinaryMarshaller<SpanContext>() {
          @Override
          public byte[] toBytes(SpanContext context) {
            return censusPropagationBinaryFormat.toByteArray(context);
          }

          @Override
          public SpanContext parseBytes(byte[] serialized) {
            try {
              return censusPropagationBinaryFormat.fromByteArray(serialized);
            } catch (Exception e) {
              logger.log(Level.FINE, "Failed to parse tracing header", e);
              return SpanContext.INVALID;
            }
          }
        });
}
 
Example #2
Source File: CensusTracingModule.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
CensusTracingModule(
    Tracer censusTracer, final BinaryFormat censusPropagationBinaryFormat) {
  this.censusTracer = checkNotNull(censusTracer, "censusTracer");
  checkNotNull(censusPropagationBinaryFormat, "censusPropagationBinaryFormat");
  this.tracingHeader =
      Metadata.Key.of("grpc-trace-bin", new Metadata.BinaryMarshaller<SpanContext>() {
          @Override
          public byte[] toBytes(SpanContext context) {
            return censusPropagationBinaryFormat.toByteArray(context);
          }

          @Override
          public SpanContext parseBytes(byte[] serialized) {
            try {
              return censusPropagationBinaryFormat.fromByteArray(serialized);
            } catch (Exception e) {
              logger.log(Level.FINE, "Failed to parse tracing header", e);
              return SpanContext.INVALID;
            }
          }
        });
}
 
Example #3
Source File: PropagationComponentImpl.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Override
public BinaryFormat getBinaryFormat() {
  return binaryFormat;
}