Docs » Instrument applications for SignalFx µAPM » Send traces from a PHP application to SignalFx µAPM

Send traces from a PHP application to SignalFx µAPM 🔗

Important

The original µAPM product, released in 2019, is now called µAPM Previous Generation (µAPM PG). In the documentation, µAPM now refers to the product released on March 31, 2020.

If you are using µAPM Previous Generation (µAPM PG), see µAPM PG Instrumentation Guide.

Automatically instrument a PHP application to capture and send traces to SignalFx with the SignalFx PHP Tracing Library. The SignalFx PHP Tracing Library uses OpenTracing API 2.0 to instrument a PHP application. To set up instrumentation, see the SignalFx PHP Tracing Library on GitHub. You can also manually instrument a PHP application by building on the OpenTracing-compatible tracer the SignalFx PHP Tracing Library provides with the OpenTracing API for PHP on GitHub.

Configure the SignalFx PHP Tracing Library to send traces to a Smart Agent. The Smart Agent forwards data to a µAPM ingest endpoint in SignalFx. Configure the Smart Agent to add tags to identify spans that belong to specific hosts or microservices. If you want to configure instrumentation for a PHP application and can’t deploy a Smart Agent, you can configure the SignalFx PHP Tracing Library to send traces directly to an OpenTelemetry Collector or µAPM ingest endpoint in SignalFx instead. For more information about deploying a Smart Agent, see Deploy a SignalFx Smart Agent for µAPM.

Optionally, deploy an OpenTelemetry Collector between a Smart Agent or instrumented code and the µAPM ingest endpoint. The OpenTelemetry Collector supports protocols the Smart Agent doesn’t support and allows for larger retry buffers to prevent packet loss. For more information about deploying an OpenTelemetry Collector for µAPM, see Deploy an OpenTelemetry Collector for SignalFx µAPM.

Requirements and supported software 🔗

To view a full list of the requirements and supported libraries and frameworks, see Supported Libraries and Frameworks on GitHub.

Add custom instrumentation to a PHP application 🔗

To trace code the SignalFx PHP Tracing Library doesn’t instrument by default, use the OpenTracing API for PHP on GitHub salong with the SignalFx PHP Tracing Library.

Here’s an example illustrating how you can use the OpenTracing API for PHP and the SignalFx PHP Tracing Library together:

use SignalFx\GlobalTracer;
use OpenTracing\Tags;

function myApplicationLogic($indicator) {
  $tracer = GlobalTracer::get(); //  Provides the tracer used by signalfx_tracing instrumentations
  $span = $tracer->startActiveSpan('myApplicationLogic')->getSpan();
  $span->setTag('indicator', $indicator);

  try {
    $widget = myAdditionalApplicationLogic($indicator);
    $span->setTag('widget', $widget);
    return $widget;
  } catch (Exception $e) {
    $span->setTag(Tags\ERROR, true)
    throw $e;
  } finally {
    $span->finish();
  }
}