opentracing / opentracing-php

OpenTracing API for PHP
Apache License 2.0
509 stars 56 forks source link

Unconsistent return types for startActiveSpan and startSpan #92

Closed radiopapus closed 4 years ago

radiopapus commented 5 years ago

Background

I research opentracing-php api and want to implement my client to get better understanding. I started from Tracer. As I understood Scope is just a wrapper for Span.

Problem

There are two methods in Tracer:

  1. startActiveSpan($operationName, $options = []): Scope
  2. startSpan($operationName, $options = []):Span

As you can see methods have a similar name but return different types.

Questions to address

Why methods return different types? What if startActiveSpan will return Span?

Proposal

I can prepare PR for that.

jcchavezs commented 4 years ago

This is actually the way they are meant to be. Starting an active span means that it is inside a scope and we need to be able to access the scope.