Attaches the provided span as the current span and returns a Scope
object which must be closed.

@param Span $span
@return Scope
773012
public function withSpan(Span $span)
    {
        $spanData = $span->spanData();
        $startTime = $spanData->startTime()
            ? (float)($spanData->startTime()->format('U.u'))
            : microtime(true);
        $info = [
            'traceId' => $spanData->traceId(),
            'spanId' => $spanData->spanId(),
            'parentSpanId' => $spanData->parentSpanId(),
            'startTime' => $startTime,
            'attributes' => $spanData->attributes(),
            'stackTrace' => $spanData->stackTrace(),
            'kind' => $spanData->kind(),
            'sameProcessAsParentSpan' => $spanData->sameProcessAsParentSpan()
        ];
        opencensus_trace_begin($spanData->name(), $info);
        $this->hasSpans = true;
        $span->attach();
        foreach ($spanData->timeEvents() as $timeEvent) {
            $this->timeEventAdded($span, $timeEvent);
        }
        foreach ($spanData->links() as $link) {
            $this->linkAdded($span, $link);
        }
        return new Scope(function () {
            opencensus_trace_finish();
        });
    }
816832
public function export(array $spans)
    {
        $spans = $this->convertSpans($spans);
        return file_put_contents($this->filename, json_encode($spans) . PHP_EOL, FILE_APPEND) !== false;
    }
160366
public function with($scope)
	{
		$scope = is_array($scope) ? $scope : [$scope];

		$this->scopes = array_merge($this->scopes, $scope);

		return $this;
	}
960570
function (span, parentNode) {
                    // updates the elements with the new content
                    update = function (newVal) {
                        // is this still part of the DOM?
                        var attached = nodes[0].parentNode;
                        // update the nodes in the DOM with the new rendered value
                        if (attached) {
                            makeAndPut(newVal);
                        }
                        teardownCheck(nodes[0].parentNode);
                    };

                    // make sure we have a valid parentNode
                    parentNode = getParentNode(span, parentNode);
                    // A helper function to manage inserting the contents
                    // and removing the old contents
                    var nodes, makeAndPut = function (val) {
                        // create the fragment, but don't hook it up
                        // we need to insert it into the document first
                        var frag = can.view.frag(val, parentNode),
                            // keep a reference to each node
                            newNodes = can.makeArray(frag.childNodes),
                            last = nodes ? nodes[nodes.length - 1] : span;

                        // Insert it in the `document` or `documentFragment`
                        if (last.nextSibling) {
                            last.parentNode.insertBefore(frag, last.nextSibling);
                        } else {
                            last.parentNode.appendChild(frag);
                        }
                        // nodes hasn't been set yet
                        if (!nodes) {
                            can.remove(can.$(span));
                            nodes = newNodes;
                            // set the teardown nodeList
                            nodeList = nodes;
                            can.view.registerNode(nodes);
                        } else {
                            // Update node Array's to point to new nodes
                            // and then remove the old nodes.
                            // It has to be in this order for Mootools
                            // and IE because somehow, after an element
                            // is removed from the DOM, it loses its
                            // expando values.
                            var nodesToRemove = can.makeArray(nodes);
                            can.view.replace(nodes, newNodes);
                            can.remove(can.$(nodesToRemove));
                        }
                    };
                    // nodes are the nodes that any updates will replace
                    // at this point, these nodes could be part of a documentFragment
                    makeAndPut(binding.value, [span]);

                    setupTeardownOnDestroy(parentNode);
                    //children have to be properly nested HTML for buildFragment to work properly
                }
972219
public function inject(SpanContext $spanContext, &$carrier)
    {
        $carrier[self::TRACE_ID_NAME] = dechex($spanContext->getTraceId());
        $carrier[self::SPAN_ID_NAME] = dechex($spanContext->getSpanId());
        if ($spanContext->getParentId() != null) {
            $carrier[self::PARENT_ID_NAME] = dechex($spanContext->getParentId());
        }
        $carrier[self::FLAGS_NAME] = (int) $spanContext->getFlags();
    }
1279848
public function setAnnotation($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span_TimeEvent_Annotation::class);
        $this->writeOneof(2, $var);

        return $this;
    }
514711
def start_span(self, name='span'):
        
        parent_span = self.current_span()

        # If a span has remote parent span, then the parent_span.span_id
        # should be the span_id from the request header.
        if parent_span is None:
            parent_span = base.NullContextManager(
                span_id=self.span_context.span_id)

        span = trace_span.Span(
            name,
            parent_span=parent_span,
            context_tracer=self)
        with self._spans_list_condition:
            self._spans_list.append(span)
        self.span_context.span_id = span.span_id
        execution_context.set_current_span(span)
        span.start()
        return span
409613
public static function span( array $attributes = array(), $value = null, $close = true )
    {
        return static::tag( 'span', $attributes, $value, $close );
    }
1068424
@SuppressWarnings("deprecation")
  private static SpanContext fromSleuthSpan(org.springframework.cloud.sleuth.Span span) {
    return SpanContext.create(
        TraceId.fromBytes(
            ByteBuffer.allocate(TraceId.SIZE)
                .putLong(span.getTraceIdHigh())
                .putLong(span.getTraceId())
                .array()),
        SpanId.fromBytes(ByteBuffer.allocate(SpanId.SIZE).putLong(span.getSpanId()).array()),
        Boolean.TRUE.equals(span.isExportable()) ? sampledOptions : notSampledOptions);
  }
1056729
public function wrapAll($input): self {
        if (!$this->collection()->count()) {
            return $this;
        }

        if (is_callable($input)) {
            $input = $input($this->collection()->first());
        }

        $inputNode = $this->inputAsFirstNode($input);

        if (!($inputNode instanceof Element)) {
            return $this;
        }

        $stackNodes = $this->_prepareWrapStack($inputNode);

        // Add the new bottom (root) node before the first matched node
        $this->collection()->first()->before($stackNodes->bottom());

        $this->collection()->each(function($node) use ($stackNodes) {
            // Detach and add node back inside the new wrappers top (leaf) node.
            $stackNodes->top()->append($node->detach());
        });

        return $this;
    }
604991
public static function spanContext()
    {
        if (!isset(self::$instance)) {
            return new SpanContext(null, null, false);
        }
        return self::$instance->tracer()->spanContext();
    }
1252921
public static SpanContextInformation forSpan(Span span) {
		if (span != null) {
			if (!spanContextMap.containsKey(span)) {
				spanContextMap.putIfAbsent(span, new SpanContextInformation());
			}
			return spanContextMap.get(span);
		}
		return null;
	}
984560
public function setClosed($flag = true) {
		$this->_closed    = (bool) $flag;
		$this->_tagCached = null;
		
		return $this;
	}
1319312
public void addSpan(@NonNull Object span) {
    if (spans != null) {
      this.spans.add(new Span(span));
      isDecorated = true;
    }
  }
608996
def inject(cls, span, obj):
        
        obj.metadata['__parent-span__'] = dict()
        cls.inject_span(span, obj.metadata['__parent-span__'])
325866
public function setScope(string $value) : Setting
    {

        if ($this->data['scope'] !== $value) {
            $this->data['scope'] = $value;
            $this->setModified('scope');
        }

        return $this;
    }
93214
function scope($scope) {
        $styles  = (array) Arr::get($this->scopes, $scope . '.css', []);
        $scripts = (array) Arr::get($this->scopes, $scope . '.js', []);
        foreach($styles as $style) {
            $this->css($style);
        }
        foreach($scripts as $script) {
            $this->js($script);
        }
        
        return $this;
    }