Converts {@code SpanContext} to AppEngine {@code CloudTraceContext}.

@param spanContext the {@code SpanContext}.
@return the converted AppEngine {@code CloudTraceContext}.
@since 0.14
163211
public static CloudTraceContext toCloudTraceContext(SpanContext spanContext) {
    checkNotNull(spanContext, "spanContext");

    ByteBuffer traceIdBuf = ByteBuffer.wrap(spanContext.getTraceId().getBytes());
    TraceIdProto traceIdProto =
        TraceIdProto.newBuilder().setHi(traceIdBuf.getLong()).setLo(traceIdBuf.getLong()).build();
    ByteBuffer spanIdBuf = ByteBuffer.wrap(spanContext.getSpanId().getBytes());

    return new CloudTraceContext(
        traceIdProto.toByteArray(),
        spanIdBuf.getLong(),
        spanContext.getTraceOptions().isSampled() ? 1L : 0L);
  }
310075
public function spanContext()
    {
        $context = Context::current();
        return new SpanContext(
            $context->value('traceId'),
            $context->value('spanId'),
            $context->value('enabled'),
            $context->value('fromHeader')
        );
    }
533280
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public SpanContext fromBinarySpanContext(Data data) throws SpanContextParseException {
    return data.binaryFormat.fromByteArray(data.spanContextBinary);
  }
1349098
@Override
  public SpanConsumer spanConsumer() {
    if (spanConsumer == null) {
      synchronized (this) {
        if (spanConsumer == null) {
          spanConsumer = new CassandraSpanConsumer(this, indexCacheSpec);
        }
      }
    }
    return spanConsumer;
  }
572687
public static HtmlTree SPAN(HtmlStyle styleClass, Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
        if (styleClass != null)
            htmltree.addStyle(styleClass);
        return htmltree;
    }
635404
public static JsonObject serialize(InstanceContext context) {
    return serialize(context.uri(), context.component().network());
  }
417106
public AbstractEndpointBuilder<T> applicationContext(ApplicationContext applicationContext) {
        if (getEndpoint() instanceof ApplicationContextAware) {
            ((ApplicationContextAware) getEndpoint()).setApplicationContext(applicationContext);
        }

        if (getEndpoint() instanceof BeanFactoryAware) {
            ((BeanFactoryAware) getEndpoint()).setBeanFactory(applicationContext);
        }

        return this;
    }
227156
public static ClassWriter instance(Context context) {
        ClassWriter instance = context.get(classWriterKey);
        if (instance == null)
            instance = new ClassWriter(context);
        return instance;
    }
38529
protected static <T extends Annotation> T getAnnotationFromContext(InvocationContext context, Class<T> clazz) {
        T result = context.getMethod().getAnnotation(clazz);
        return result != null ? result : context.getTarget().getClass().getAnnotation(clazz);
    }
877116
public static AppEngineDescriptor parse(InputStream in) throws IOException, SAXException {
    Preconditions.checkNotNull(in, "Null input");
    try {
      DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
      documentBuilderFactory.setNamespaceAware(true);
      return new AppEngineDescriptor(documentBuilderFactory.newDocumentBuilder().parse(in));
    } catch (ParserConfigurationException exception) {
      throw new SAXException("Cannot parse appengine-web.xml", exception);
    }
  }
1053169
public <T> T convert(ConversionContext context, Object source,
			Class<T> clazz) throws ConverterException {
		return (T) convert(context, source, TypeReference.get(clazz));
	}
978106
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public static NsdManager getNsdManager(Context context) {
        return (NsdManager) context.getSystemService(Context.NSD_SERVICE);
    }
626948
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public StatsTraceContext newClientContext() {
    return StatsTraceContext.newClientContext(CallOptions.DEFAULT, Attributes.EMPTY, emptyMetadata);
  }
1022278
public static Link fromSpanContext(
      SpanContext context, Type type, Map<String, AttributeValue> attributes) {
    return new AutoValue_Link(
        context.getTraceId(),
        context.getSpanId(),
        type,
        Collections.unmodifiableMap(new HashMap<String, AttributeValue>(attributes)));
  }
1364301
protected Tracer.SpanBuilder newSpan(HttpRequest<?> request, SpanContext spanContext) {
        String spanName = resolveSpanName(request);
        Tracer.SpanBuilder spanBuilder = tracer.buildSpan(
                spanName
        ).asChildOf(spanContext);

        spanBuilder.withTag(TAG_METHOD, request.getMethod().name());
        String path = request.getPath();
        spanBuilder.withTag(TAG_PATH, path);
        return spanBuilder;
    }
163306
public static Credential getCredential(final RequestContext context) {
        val cFromRequest = (Credential) context.getRequestScope().get(PARAMETER_CREDENTIAL);
        val cFromFlow = (Credential) context.getFlowScope().get(PARAMETER_CREDENTIAL);
        val cFromConversation = (Credential) context.getConversationScope().get(PARAMETER_CREDENTIAL);

        var credential = cFromRequest;
        if (credential == null || StringUtils.isBlank(credential.getId())) {
            credential = cFromFlow;
        }
        if (credential == null || StringUtils.isBlank(credential.getId())) {
            credential = cFromConversation;
            if (credential != null && !StringUtils.isBlank(credential.getId())) {
                context.getFlowScope().put(PARAMETER_CREDENTIAL, credential);
            }
        }

        if (credential == null) {
            val session = context.getFlowExecutionContext().getActiveSession();
            credential = session.getScope().get(PARAMETER_CREDENTIAL, Credential.class);
        }
        if (credential != null && StringUtils.isBlank(credential.getId())) {
            return null;
        }
        return credential;
    }
695723
public B importContext(AbstractContext context){
        Objects.requireNonNull(context);
        return importContext(context, false);
    }