Reference documentation and code samples for the Stackdriver Trace Client class TraceClient.
Google Stackdriver Trace allows you to collect latency data from your applications and display it in the Google Cloud Platform Console.
Find more information at Stackdriver Trace API docs.
Example:
use Google\Cloud\Trace\TraceClient;
$trace = new TraceClient();
Methods
__construct
Create a Trace client.
Parameters | |
---|---|
Name | Description |
config |
array
Configuration options. |
↳ apiEndpoint |
string
A hostname with optional port to use in place of the service's default endpoint. |
↳ projectId |
string
The project ID from the Google Developer's Console. |
↳ authCache |
CacheItemPoolInterface
A cache used storing access tokens. Defaults to a simple in memory implementation. |
↳ authCacheOptions |
array
Cache configuration options. |
↳ authHttpHandler |
callable
A handler used to deliver Psr7 requests specifically for authentication. |
↳ credentialsFetcher |
FetchAuthTokenInterface
A credentials fetcher instance. |
↳ httpHandler |
callable
A handler used to deliver Psr7 requests. Only valid for requests sent over REST. |
↳ keyFile |
array
The contents of the service account credentials .json file retrieved from the Google Developer's Console. Ex: |
↳ keyFilePath |
string
The full path to your service account credentials .json file retrieved from the Google Developers Console. |
↳ requestTimeout |
float
Seconds to wait before timing out the request. Defaults to |
↳ retries |
int
Number of retries for a failed request. Defaults to |
↳ scopes |
array
Scopes to be used for the request. |
↳ quotaProject |
string
Specifies a user project to bill for access charges associated with the request. |
insert
Sends a Trace log in a simple fashion.
Example:
$trace = $traceClient->trace();
$result = $traceClient->insert($trace);
Parameters | |
---|---|
Name | Description |
trace |
Google\Cloud\Trace\Trace
The trace log to send. |
options |
array
[optional] Configuration Options |
Returns | |
---|---|
Type | Description |
bool |
insertBatch
Sends multiple Trace logs in a simple fashion.
Example:
$trace = $traceClient->trace();
$result = $traceClient->insertBatch([$trace]);
Parameters | |
---|---|
Name | Description |
traces |
array<Google\Cloud\Trace\Trace>
The trace logs to send. |
options |
array
[optional] Configuration Options |
Returns | |
---|---|
Type | Description |
bool |
trace
Lazily find or instantiates a trace. There are no network requests made at this point. To see the operations that can be performed on a trace please see Google\Cloud\Trace\Trace. If no traceId is provided, one will be generated for you.
Example:
// Create a trace with a generated traceId
$trace = $traceClient->trace();
// Create a trace with a specific traceId
$trace = $traceClient->trace('1234abcd');
Parameter | |
---|---|
Name | Description |
traceId |
string
[optional] The trace id of the trace to reference. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Trace\Trace |
Constants
VERSION
Value: '1.5.3'
FULL_CONTROL_SCOPE
Value: 'https://www.googleapis.com/auth/cloud-platform'