LightStep

LightStep Documentation

Welcome to the LightStep developer hub. You'll find comprehensive guides and documentation to help you start working with LightStep as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

PHP Quick Start

This Quick Start will have you configure your tracer to communicate with the LightStep Satellites and create a single span - span - Represents a logical unit of work in the system that has a start time and a duration. Spans can be nested. on your service. You install the LightStep tracer and then use the LightStep API to instrument your code.

You need to know OpenTracing before proceeding

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.

  1. Find your access token in LightStep. You'll need this to configure your LightStep tracer.
    a. Click the Project Settings button.
    b. In the Access Tokens table, click the Copy icon to copy your access token to the clipboard.

  2. Install the LightStep tracer.

composer require lightstep/tracer

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

  1. 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.
<?php

require __DIR__ . '/vendor/autoload.php';

LightStep::initGlobalTracer('YOUR_SERVICE_NAME', 'YOUR_ACCESS_TOKEN');
  1. 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.
$span = LightStep::startSpan("trivial/loop");
for ($i = 0; $i < 10; $i++) {
    $span->logEvent("loop_iteration", $i);
    echo "The current unix time is " . time() . "\n";
    usleep(1e5);
    $span->setTag("KEY", "VALUE");
}
$span->finish();
  
  1. Run your app.

  2. Open LightStep. You should see your service in the Service directory list.

If you want to continue adding instrumentation by creating more spans and connecting them into traces, continue on with PHP: Add Spans.

Updated 4 months ago


PHP Quick Start


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.