2017 © Pedro Peláez
 

library cloud-trace

Stackdriver Trace Client for PHP

image

google/cloud-trace

Stackdriver Trace Client for PHP

  • Thursday, July 19, 2018
  • by bshaffer
  • Repository
  • 46 Watchers
  • 10 Stars
  • 17,609 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 24 Versions
  • 38 % Grown

The README.md

Stackdriver Trace for PHP

Idiomatic PHP client for Stackdriver Trace., (*1)

Latest Stable Version Packagist, (*2)

NOTE: This repository is part of Google Cloud PHP. Any support requests, bug reports, or development contributions should be directed to that project., (*3)

A distributed tracing system for Google Cloud Platform that collects latency data from App Engine applications and displays it in near real time in the Google Cloud Platform Console., (*4)

Installation

To begin, install the preferred dependency manager for PHP, Composer., (*5)

Now install this component:, (*6)

$ composer require google/cloud-trace

This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods) please see our gRPC installation guide., (*7)

Authentication

Please see our Authentication guide for more information on authenticating your client. Once authenticated, you'll be ready to start making requests., (*8)

Sample

require 'vendor/autoload.php';

use Google\Cloud\Trace\TraceClient;

$traceClient = new TraceClient();

// Create a Trace
$trace = $traceClient->trace();
$span = $trace->span([
    'name' => 'main'
]);
$span->setStartTime();
// some expensive operation
$span->setEndTime();

$trace->setSpans([$span]);
$traceClient->insert($trace);

// List recent Traces
foreach($traceClient->traces() as $trace) {
    var_dump($trace->traceId());
}

Creating a Trace

use Google\Cloud\Trace\TraceClient;

$client = new TraceClient();
$trace = $client->trace();
$span = $trace->span(['name' => 'main']);
$trace->setSpans([$span]);

$client->insert($trace);

Using OpenCensus

We highly recommend using the OpenCensus project to instrument your application. OpenCensus is an open source, distributed tracing framework that maintains integrations with popular frameworks and tools. OpenCensus provides a data exporter for Stackdriver Trace which uses this library. If you were using google/cloud-trace <= v0.3.3 or google/cloud <= 0.46.0, then check out the migration guide to OpenCensus., (*9)

Install with composer or add to your composer.json., (*10)

$ composer require opencensus/opencensus opencensus/opencensus-exporter-stackdriver

opencensus/opencensus provides a service-agnostic implementation. Be sure to also require opencensus/opencensus-exporter-stackdriver to enable exporting of traces to Stackdriver Trace., (*11)

use OpenCensus\Trace\Exporter\StackdriverExporter;
use OpenCensus\Trace\Tracer;

Tracer::start(new StackdriverExporter());

See the OpenCensus documentation for more configuration options and features., (*12)

Version

This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in any minor or patch releases. We will address issues and requests with the highest priority., (*13)

Next Steps

  1. Understand the official documentation.
  2. Take a look at in-depth usage samples.

The Versions

16/03 2018

v0.6.3

0.6.3.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

26/02 2018

v0.6.2

0.6.2.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

01/02 2018

v0.6.1

0.6.1.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

23/01 2018

v0.6.0

0.6.0.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

29/12 2017

v0.5.1

0.5.1.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

22/12 2017

v0.5.0

0.5.0.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

16/12 2017

v0.4.0

0.4.0.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

11/11 2017

v0.3.3

0.3.3.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

25/08 2017

v0.3.2

0.3.2.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

18/07 2017

v0.3.1

0.3.1.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

12/07 2017

v0.3.0

0.3.0.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

01/07 2017

v0.2.0

0.2.0.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires

 

25/05 2017

v0.1.0

0.1.0.0

Stackdriver Trace Client for PHP

  Sources   Download

Apache-2.0

The Requires