This Quick Start will have you configure your tracer to communicate with the Lightstep Satellites and create a single span on your service. You install the Lightstep tracer and then use the Lightstep API to instrument your code.

While Lightstep offers tracers and APIs specific to its tracing software, you will still use the OpenTracing API to fully instrument your code. Be sure you have read and are familiar with both Lightstep tracers and the OpenTracing specification in your application’s language.

PHP Instrumentation for OpenTracing

  1. Find your access token in Lightstep. You’ll need this to configure your Lightstep tracer.
    • Click the Project Settings button.
    • In the Access Tokens table, click the Copy icon to copy your access token to the clipboard.
  2. Install the Lightstep tracer.
    Using composer:

    1
    
       composer require lightstep/tracer
    

    The lightstep/tracer package is available on packagist.org.

  3. Also using composer, include the Lightstep tracer in composer.json
    1
    2
    3
    4
    5
    
     {
       "require": {
         "lightstep/tracer": "^1.0"
       }
     }
    
  4. In your application, configure the Lightstep tracer and register it as the OpenTracing global tracer. As part of the configuration, you need to add your access token and add your service’s name.

    1
    2
    3
    
    require __DIR__ . '/vendor/autoload.php';
    
    $tracer = LightStep::initGlobalTracer('YOUR_SERVICE_NAME', 'YOUR_ACCESS_TOKEN');
    
  5. Test that everything is connected by sending a test span. Annotate the span by adding a tag (key/value pair) and logs, then flush the tracer.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
     $span = LightStep::startSpan("trivial/loop");
     for ($i = 0; $i < 10; $i++) {
         $span->infof("loop_iteration %d", $i);
         echo "The current unix time is " . time() . "
         ";
           sleep(.1);
     }
     $span->finish();
     exit();
    
  6. Run your app.

  7. Open Lightstep. You should see your service in the Service directory list.

It may take a few moments for your service to display in the Service Directory. To see data immediately, click the Explorer tab to view data in the histogram.

Read the Lightstep PHP API docs to learn more.