google / cloud-trace
Stackdriver Trace Client for PHP
Requires
- php: ^8.0
- google/cloud-core: ^1.57
- google/gax: ^1.36.0
- ramsey/uuid: ^3.0|^4.0
Requires (Dev)
- erusev/parsedown: ^1.6
- phpdocumentor/reflection: ^5.3.3||^6.0
- phpdocumentor/reflection-docblock: ^5.3
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: 2.*
Suggests
- ext-grpc: The gRPC extension enables use of the performant gRPC transport
- ext-protobuf: Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions.
- opencensus/opencensus: Provides application tracing integrations.
- dev-main
- v1.8.8
- v1.8.7
- v1.8.6
- v1.8.5
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.0
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.11
- v1.4.10
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- v0.18.0
- v0.17.1
- v0.17.0
- v0.16.0
- v0.15.0
- v0.14.4
- v0.14.3
- v0.14.2
- v0.14.1
- v0.14.0
- v0.13.0
- v0.12.5
- v0.12.4
- v0.12.3
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.0
- v0.10.6
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.0
- v0.8.0
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.1
- v0.5.0
- v0.4.0
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.0
- v0.1.0
This package is auto-updated.
Last update: 2024-12-12 23:19:04 UTC
README
Idiomatic PHP client for Stackdriver Trace.
NOTE: This repository is part of Google Cloud PHP. Any support requests, bug reports, or development contributions should be directed to that project.
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.
Installation
To begin, install the preferred dependency manager for PHP, Composer.
Now install this component:
$ 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.
Authentication
Please see our Authentication guide for more information on authenticating your client. Once authenticated, you'll be ready to start making requests.
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.
Install with composer
or add to your composer.json
.
$ 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.
use OpenCensus\Trace\Exporter\StackdriverExporter; use OpenCensus\Trace\Tracer; Tracer::start(new StackdriverExporter());
See the OpenCensus documentation for more configuration options and features.
Debugging
Please see our Debugging guide for more information about the debugging tools.
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.
Next Steps
- Understand the official documentation.
- Take a look at in-depth usage samples.