use Google\Cloud\Trace\TraceClient;
$trace = new TraceClient();
Namespace
Google \ Cloud \ Trace
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 toa 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:json_decode(file_get_contents($path), true).
↳ 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 to0with REST and60with gRPC.
↳ retries
int
Number of retries for a failed request.Defaults to3.
↳ scopes
array
Scopes to be used for the request.
↳ quotaProject
string
Specifies a user project to bill for access charges associated with the request.
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
seeTrace. 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Stackdriver Trace Client - Class TraceClient (1.8.10)\n\nVersion latestkeyboard_arrow_down\n\n- [1.8.10 (latest)](/php/docs/reference/cloud-trace/latest/TraceClient)\n- [1.8.9](/php/docs/reference/cloud-trace/1.8.9/TraceClient)\n- [1.7.0](/php/docs/reference/cloud-trace/1.7.0/TraceClient)\n- [1.6.5](/php/docs/reference/cloud-trace/1.6.5/TraceClient)\n- [1.5.3](/php/docs/reference/cloud-trace/1.5.3/TraceClient)\n- [1.4.11](/php/docs/reference/cloud-trace/1.4.11/TraceClient) \nReference documentation and code samples for the Stackdriver Trace Client class TraceClient.\n\nGoogle Stackdriver Trace allows you to collect latency data from\nyour applications and display it in the Google Cloud Platform Console.\n\nFind more information at [Stackdriver Trace API docs](https://cloud.google.com/trace/docs/).\n\nExample: \n\n use Google\\Cloud\\Trace\\TraceClient;\n\n $trace = new TraceClient();\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Trace\n\nMethods\n-------\n\n### __construct\n\nCreate a Trace client.\n\n### insert\n\nSee also:\n\n- [Project patchTraces API documentation.](https://cloud.google.com/trace/docs/reference/v1/rest/v1/projects/patchTraces)\n\n### insertBatch\n\nSee also:\n\n- [Project patchTraces API documentation.](https://cloud.google.com/trace/docs/reference/v1/rest/v1/projects/patchTraces)\n\n### trace\n\nLazily find or instantiates a trace. There are no network requests made at this\npoint. To see the operations that can be performed on a trace please\nsee [Trace](/php/docs/reference/cloud-trace/latest/Trace). If no traceId is provided, one will be\ngenerated for you.\n\nExample: \n\n // Create a trace with a generated traceId\n $trace = $traceClient-\u003etrace();\n\n // Create a trace with a specific traceId\n $trace = $traceClient-\u003etrace('1234abcd');\n\nConstants\n---------\n\n### VERSION\n\n Value: '1.8.10'\n\n### FULL_CONTROL_SCOPE\n\n Value: 'https://www.googleapis.com/auth/cloud-platform'"]]