public function startSpan($operationName, $options = []){

        if (is_array($options)) {
            $options = SpanOptions::create($options);
        }else{
            throw new \Exception("options is not array");
        }

        $references = $options->getReferences();

        $hasParent = false;
        $parentSpan = null;

        foreach ($references as $ref){
            if($ref->isType(Reference::CHILD_OF)){
                $hasParent = true;
                $parentSpan = $ref->getContext();
            }
        }

        if(!$hasParent || !$parentSpan->traceIdLow){
            $low = $this->generateId();
            $spanId = $low;
            $flags = $this->sampler->IsSampled();
            $newSpan = new \Jaeger\SpanContext($spanId, 0, $flags, null, 0);
            $newSpan->traceIdLow = $low;
            if($this->gen128bit == true){
                $newSpan->traceIdHigh = $this->generateId();
            }
        }else{
            $newSpan = new \Jaeger\SpanContext($this->generateId(),
                $parentSpan->spanId, $parentSpan->flags, null, 0);
            $newSpan->traceIdLow = $parentSpan->traceIdLow;
            if($parentSpan->traceIdHigh){
                $newSpan->traceIdHigh = $parentSpan->traceIdHigh;
            }
        }

        $span = new Span($operationName, $newSpan, $references);
        $span->setTags($options->getTags());

        if($newSpan->isSampled() == 1) {
            $this->spans[] = $span;
        }

        return $span;
    }
public function startSpan($operationName, $options = []){

        if (is_array($options)) {
            $options = SpanOptions::create($options);
        }else{
            throw new \Exception("options is not array");
        }

        $references = $options->getReferences();

        $hasParent = false;
        $parentSpan = null;

        foreach ($references as $ref){
            if($ref->isType(Reference::CHILD_OF)){
                $hasParent = true;
                $parentSpan = $ref->getContext();
            }
        }

        if(!$hasParent || !$parentSpan->traceIdLow){
            $low = $this->generateId();
            $spanId = $low;
            $flags = $this->sampler->IsSampled();
            $newSpan = new \Jaeger\SpanContext($spanId, 0, $flags, null, 0);
            $newSpan->traceIdLow = $low;
            if($this->gen128bit == true){
                $newSpan->traceIdHigh = $this->generateId();
            }
        }else{
            $newSpan = new \Jaeger\SpanContext($this->generateId(),
                $parentSpan->spanId, $parentSpan->flags, null, 0);
            $newSpan->traceIdLow = $parentSpan->traceIdLow;
            if($parentSpan->traceIdHigh){
                $newSpan->traceIdHigh = $parentSpan->traceIdHigh;
            }
        }

        $span = new Span($operationName, $newSpan, $references);
        $span->setTags($options->getTags());

        if($newSpan->isSampled() == 1) {
            $this->spans[] = $span;
        }

        return $span;
    }
public function startSpan ( $ operationName , $ options = [ ] ) { if ( is_array ( $ options ) ) { $ options = SpanOptions :: create ( $ options ) ; } else { throw new \ Exception ( "options is not array" ) ; } $ references = $ options -> getReferences ( ) ; $ hasParent = false ; $ parentSpan = null ; foreach ( $ references as $ ref ) { if ( $ ref -> isType ( Reference :: CHILD_OF ) ) { $ hasParent = true ; $ parentSpan = $ ref -> getContext ( ) ; } } if ( ! $ hasParent || ! $ parentSpan -> traceIdLow ) { $ low = $ this -> generateId ( ) ; $ spanId = $ low ; $ flags = $ this -> sampler -> IsSampled ( ) ; $ newSpan = new \ Jaeger \ SpanContext ( $ spanId , 0 , $ flags , null , 0 ) ; $ newSpan -> traceIdLow = $ low ; if ( $ this -> gen128bit == true ) { $ newSpan -> traceIdHigh = $ this -> generateId ( ) ; } } else { $ newSpan = new \ Jaeger \ SpanContext ( $ this -> generateId ( ) , $ parentSpan -> spanId , $ parentSpan -> flags , null , 0 ) ; $ newSpan -> traceIdLow = $ parentSpan -> traceIdLow ; if ( $ parentSpan -> traceIdHigh ) { $ newSpan -> traceIdHigh = $ parentSpan -> traceIdHigh ; } } $ span = new Span ( $ operationName , $ newSpan , $ references ) ; $ span -> setTags ( $ options -> getTags ( ) ) ; if ( $ newSpan -> isSampled ( ) == 1 ) { $ this -> spans [ ] = $ span ; } return $ span ; }
init span info
@param string $operationName
@param array $options
@return Span
init span info