Skip to content

Conversation

@chingor13
Copy link
Contributor

@chingor13 chingor13 commented Apr 18, 2017

Part 2 of the Stackdriver Trace implementation. Adds easy ways to add tracing into your framework.

  • Creates a singleton RequestTracer that is available throughout your application to maintain trace context.
  • Handle expected standard labels for App Engine if they are available.
  • Sampling interface for deciding which requests to trace
  • Reporting interface for deciding how to report trace results.

Change to TraceSpan interface:

  • the start/end times can be specified as the correctly formatted timestamp string, a DateTimeInterface, a microtime float, or a timestamp integer.

Example integration:

$traceClient = new Google\Cloud\Trace\TraceClient();
$reporter = new Google\Cloud\Trace\Reporter\SyncReporter($traceClient);
Google\Cloud\Trace\RequestTracer::start($reporter);

Other notes:

  • The AsyncReporter was removed until the Batch module is merged.
  • The ExtensionTracer won't work for anyone unless they have the stackdriver extension install which is not release. I can tear it out if you want.

* Implement the Trace REST API Client.

Implements basic Trace and TraceSpan resources.

TraceClient tests

Fix tests. Connection needed to be protected

Code style fixes

* Rename some methods, move a required parameter

* remove labels class for now

* Refactor TraceSpan to store attributes directly in the info array

* Fix Trace namespace in ServiceBuilder

* Rename some getter methods. Whitelist attributes in TraceSpan constructor

* Fix aliases for Core classes

* Request tracing prototype

* Create more namespaces

* RequestTracer should return results

* Add labels to the primary span detected from the response.

* Snippet tests and phpcs fixes

* Fix cs

* add Trace test

* Add system tests for using the TraceClient

* list traces test depends on creating the traces

* Copyrights and documentation comments

* remove debug statement

* Fix some typehinting and documentation

* Refactor Trace to lazy load span data if not set.

* Convert listTraces output from a generator to an ItemIterator

* Add @see note for Trace list function

* Fix Trace system tests

* Add TraceSpan factory function on Trace

* Add test for lazy fetching span data from the api

* Fix RequestTracer to work with updated apis

* Make RequestTracer an instance. Static functions are redirected to the singleton instance of RequestTracer

* Add options to trace insert and trace get calls

* Remove REST Connection emulator hooks - there is no Trace emulator.

* Trace#info no longer checks to see if you have already specified spans

* Documentation updates

* Remove projectId getter/setter from Trace.

* cs ignore for long documentation links

* Docs, fixing traces resultLimit, set timezone

* Generate a span name from a cleaned backtrace

* If the trace span is not created within a class, is the file's basename

* Some backtrace entries do not have line numbers

* Revert the change to info() that tried to maintain an info array

* Add SamplerFactory

* Add 3 more example trace reporters

* Add GAE labels to the root span

* fix missing semicolon

* Fix GAE env variable parsing

* Inject the cacheItemClass name into the QpsSampler.

CacheItemPoolInterface implementations often are linked to their
CacheItemInterface implementations in order to communicate expiry (not
part of the PSR-6 spec.

* Add a NullReporter.

* TracerInterface now returns only spans rather than creating a trace record. Add tests

* Add TraceContext class.

* TraceSpan start and end times can accept numerics (timestamps) or strings

* Documentation updates

* close all spans at the end of the request

* Adding version, license, docs for creating new google/cloud-trace package

* Use factories for generating sampler and reporter from the initial RequestTracer::start()

* Rename TraceReporter -> SyncReporter

* Detect PSR-6 apc/apcu cache. Detect default start time from headers.

* can't use pluck staticly

* Docs and examples for RequestTracer

* Remove ReporterFactory. Add documentation

* Adding tests

* SamplerFactory tests

* Add suggested packages for the cache adapters

* Add ExtensionTracer which will not work until the stackdriver extension is available

* JsonSerializable TraceSpan

* Fix serializable

* Return trace context headers if provided to the request

* Prefix service name in front of version if present

* Extension tracer can handle initial trace context

* Put the version header back to just the version

* Add Trace section to main README

* fix default spanId

* finish -> end

* Rename finish -> end for consistency across languages

* Rename instrument -> inSpan to match other languages

* Fix the label name for the module version for GAE

* Update README for google/cloud-trace

* TracerInterface no longer returns the span started or stopped.

The extension tracer cannot return a reference to its internal
representation of a TraceSpan. It would cause strange behavior to be
able to modify the span object returned by reference.

* ensure -> finally

* Remove many unused label constants. Add load balancer labels. Add trace client version to agent

* Test fixes
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 18, 2017
@chingor13 chingor13 changed the title Request Tracing WIP: Request Tracing Apr 18, 2017
@jdpedrie jdpedrie added the api: cloudtrace Issues related to the Cloud Trace API. label Apr 18, 2017
* @param LoggerInterface $logger The logger to write to.
* @param string $level The logger level to write as. **Defaults to** `notice`.
*/
public function __construct(LoggerInterface $logger, $level = null)

This comment was marked as spam.

* @param callable $callable The callable to inSpan.
* @return mixed Returns whatever the callable returns
*/
public function _inSpan(array $spanOptions, callable $callable, array $arguments = [])

This comment was marked as spam.

Copy link
Contributor

@tmatsuo tmatsuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I reverted the batch package PR on the master, and created batch branch for developping/alpha testing purpose.

* @param array $headers The headers array (normally the $_SERVER variable)
* @return TraceContext
*/
public static function fromHeaders($headers)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@chingor13 chingor13 changed the title WIP: Request Tracing Request Tracing May 4, 2017
@chingor13
Copy link
Contributor Author

@dwsupplee @jdpedrie @tmatsuo If you get a chance, this PR is ready for some feedback.

Copy link
Contributor

@tmatsuo tmatsuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked from the top to src/Trace/RequestHandler.php

namespace Google\Cloud\Trace;

/**
* Trait which provides helper methods for customer-supplied encryption.

This comment was marked as spam.

Stackdriver servers at the end of the request. This is not ideal as it will add
latency to requests that are traced. You may instead use the `AsyncReporter` but
you will also require the `AsyncBatchRunner` daemon running on your system. Your
application will also need to set the `IS_BATCH_DAEMON_RUNNING=true` environment variable.

This comment was marked as spam.


### Sampling Rate

By default we attempt to trace all requests. This is not idea as a little bit of

This comment was marked as spam.

of requests, configure a sampler.

The preferred sampler is the `QpsSampler` (Queries Per Second). This sampler implementation
requires a PSR-6 cache implementation to function.

This comment was marked as spam.

This comment was marked as spam.

* This implementation of the ReporterInterface uses `print_r` to output
* the trace's representation to stdout.
*/
class EchoReporter implements ReporterInterface

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

*
* @return CacheItemPoolInterface
*/
private function defaultCache()

This comment was marked as spam.

use Google\Cloud\Trace\TraceSpan;

/**
* This implementation of the TracerInterface is the null object implementation.

This comment was marked as spam.

use ArrayTrait;

/**
* Create a new ContextTracer

This comment was marked as spam.

use Google\Cloud\Trace\TraceSpan;

/**
* This interface allows you to use the null object pattern for your tracer.

This comment was marked as spam.

This comment was marked as spam.

@iamacarpet
Copy link

iamacarpet commented May 11, 2017

Had a quick read through the commits as I'm hoping to include @chingor13 sample Laravel service provider in our library for GAE support.

The QpsSampler using the APCu cache is a great idea, love it.

I can't see it anywhere, but are there plans to respect the o=1 in the X-Cloud-Trace-Context header too, maybe regardless of the Sampler used?

The documentation for your Cloud Trace libraries in other languages reference sending the same trace context via the X-Cloud-Trace-Context HTTP header to any sub-requests when using microservices and including o=1 if the current request is a trace, which the microservices should respect and then trace into the main request.

We were thinking of writing a Guzzle hook to both trace the time taken for each request as a span automatically, plus include this header too.

EDIT: Also forgot to ask, for the Standard environment. Before I spend some time and write a custom AsyncReporter, do you have any plans to support something like this on Standard?

We currently use a microservice written in Go tuned to handle a lot of requests at once, then pass the trace logs via a Push Queue from PHP, as the Push Queue submit latency is <100ms and we saw Trace latency ~700ms+, but I want our devs to be able to use your new interface so it'll be generic between Standard and Flex

@chingor13
Copy link
Contributor Author

chingor13 commented May 11, 2017

@iamacarpet The sampler should not be consulted if the context header has forced the request to be traced. At any point in your code, you should be able to get the current context, a TraceContext object, via RequestTracer::context(). This object's __toString returns the header to pass to downstream services.

@chingor13
Copy link
Contributor Author

chingor13 commented May 11, 2017

@iamacarpet As far as the AsyncBatchDaemon on Standard, it will run (in degraded mode) and batch requests together (not applicable for Trace) and send the data at the end of the request. You'll still see the added latency for the request for reporting traces. For Standard, you probably still want to go the PushQueue route and you could even write your own ReporterInterface implementation for it.

The built-in AsyncReporter (using AsyncBatchDaemon) will return once this branch and the batch branch are both in master.

@iamacarpet
Copy link

Ah yes, just seen that condition here, thanks very much for pointing me in the right direction.

No problem, the Push Queue route is fine with me, good to confirm :).

@chingor13
Copy link
Contributor Author

@dwsupplee @jdpedrie The google-cloud-php-trace repo should be created at any moment. Can you take a look at this PR so we can release an alpha trace library?

$ composer require google/cloud-trace
```

2. Include and start the labrary as the first action in your application:

This comment was marked as spam.

RequestTracer::start($reporter, ['sampler' => $sampler]);
```

The PHP Cache organization provides many

This comment was marked as spam.

class NullReporter implements ReporterInterface
{
/**
* Report the provided Trace to a backend.

This comment was marked as spam.

*/
public static function build($options)
{
if (is_a($options, SamplerInterface::class)) {

This comment was marked as spam.

* Returns a "Zulu" formatted string representing the provided \DateTime.
*
* @param \DateTimeInterface $when [optional] The end time of this span.
* @param \DateTimeInterface|int|float|string $when [optional] The end time of this span.

This comment was marked as spam.

Copy link
Contributor

@dwsupplee dwsupplee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great addition @chingor13. Thanks for the patience on my review.

*/
private function generateTraceId()
{
return sprintf(

This comment was marked as spam.

This comment was marked as spam.


```php
$pi = RequestTracer::inSpan(['name' => 'expensive-operation'], function() {
// some expensive operation

This comment was marked as spam.

*/
public function report(TracerInterface $tracer)
{
$fp = fopen($this->filename, 'a');

This comment was marked as spam.

*/
public function report(TracerInterface $tracer)
{
$this->logger->log($this->level, json_encode($tracer->spans()));

This comment was marked as spam.

This comment was marked as spam.

}

/**
* inSpan a callable by creating a TraceSpan that manages the startTime and endTime.

This comment was marked as spam.

This comment was marked as spam.

*
* @param string $traceId The current traceId. If not set, one will be generated for you.
* @param string $spanId The current spanId
* @param bool $enabled Whether or not tracing is enabled on this request **Defaults to** `null`.

This comment was marked as spam.

use Google\Cloud\Trace\TraceSpan;

/**
* This implementation of the TracerInterface utilizes the stackdriver extension

This comment was marked as spam.

* @param string $value
*/
public function addLabel($label, $value)
{

This comment was marked as spam.

This comment was marked as spam.

"license": "Apache-2.0",
"minimum-stability": "stable",
"require": {
"google/cloud-core": "*"

This comment was marked as spam.

namespace Google\Cloud\Tests\Unit\Trace;

use Google\Cloud\Trace\TraceContext;
/**

This comment was marked as spam.

private $traceId;

/**
* @var string The current spanId. This is the deepest nested span currently open.

This comment was marked as spam.

@dwsupplee
Copy link
Contributor

@chingor13 is there anything else, or ready to merge? :)

@chingor13
Copy link
Contributor Author

Ready!

@dwsupplee dwsupplee merged commit c864895 into googleapis:master May 23, 2017
@jdpedrie jdpedrie mentioned this pull request May 25, 2017
dwsupplee pushed a commit that referenced this pull request Jun 22, 2017
* Add ext-grpc as a dep for services that only provides grpc lib (#475)

* Choose rest over grpc for now. (#477)

* project to projectId (#484)

* RFC: Adds removePolicy to Iam Policy Builder (#480)

* Adds removePolicy to Iam Policy Builder

* adds snippet test

* Introduce support for Cloud Spanner (#333)

* introduce cache based session pool and streaming execute/read

* Implement remaining API, add system tests.

* Buffer result sets and retry only with error code unavailable

* Fix parameterization and value mapping

Add system test coverage.

Add more read system tests and fix KeyRange issues

Spanner transaction system tests

Add remaining p0 spanner system tests

* allow user determined row formatting

doc fix

address code review

move symfony/lock from require to suggest

* Update README and Spanner composer.json

* update verbiage

* small tweaks

* Add resource-prefix header to outgoing spanner requests

* Add Video Intelligence GAPIC client (#492)

* Add GAPIC only video intelligence

* Add docs

* Update namespace capitalization

* Address PR comments

* Fix * escaping

* Update grpc install description

* inverse retry condition

* Prepare v0.29.0 (#493)

* Update docs to include new core types (#494)

* README updates / Add VI to list of includes (#495)

* readme fixes

* Add VI to list of includes

* increase ServiceBuilder version for v0.29.0 release (#496)

* Prepare v0.30.0 (#497)

* Prepare v0.30.0

* Add GAPIC to Spanner docs table of contents

* make param type more specific (#500)

* fixes extraStatements bug for Spanner\Instance::createDatabase (#499)

* fixes extraStatements bug for Spanner\Instance::createDatabase

* fixes tests

* corrects spanner dependency on core and removes symfony/lock requirement (#503)

* corrects spanner dependency on core and removes symfony/lock requirement

* changes core php req to >=5.5

* Cast keySet keys to arrays instead of wrapping them (#505)

* cast keySet keys to arrays instead of wrapping them

* adds tests for keyset formatting

* Prepare v0.30.1 (#501)

* Prepare v0.30.1

* Bump cloud-core version

* Bump proto-client-php version

* Update GAPICs for Spanner (#508)

* Update spanner gapic

* Update video intelligence

* Update Spanner, VideoIntelligence and Speech

* Address PR feedback

* Modify exceptions when a whitelist may be present (#482)

* Modify exceptions when a whitelist may be present

* Add Whitelist system tests

* Code review fixes

* Refactor out additional call_user_func

* Prepare v0.31.0 (#510)

* Prepare v0.31.1 (#511)

* Request Tracing (#456)

* Request tracing (#4)

* Implement the Trace REST API Client.

Implements basic Trace and TraceSpan resources.

TraceClient tests

Fix tests. Connection needed to be protected

Code style fixes

* Rename some methods, move a required parameter

* remove labels class for now

* Refactor TraceSpan to store attributes directly in the info array

* Fix Trace namespace in ServiceBuilder

* Rename some getter methods. Whitelist attributes in TraceSpan constructor

* Fix aliases for Core classes

* Request tracing prototype

* Create more namespaces

* RequestTracer should return results

* Add labels to the primary span detected from the response.

* Snippet tests and phpcs fixes

* Fix cs

* add Trace test

* Add system tests for using the TraceClient

* list traces test depends on creating the traces

* Copyrights and documentation comments

* remove debug statement

* Fix some typehinting and documentation

* Refactor Trace to lazy load span data if not set.

* Convert listTraces output from a generator to an ItemIterator

* Add @see note for Trace list function

* Fix Trace system tests

* Add TraceSpan factory function on Trace

* Add test for lazy fetching span data from the api

* Fix RequestTracer to work with updated apis

* Make RequestTracer an instance. Static functions are redirected to the singleton instance of RequestTracer

* Add options to trace insert and trace get calls

* Remove REST Connection emulator hooks - there is no Trace emulator.

* Trace#info no longer checks to see if you have already specified spans

* Documentation updates

* Remove projectId getter/setter from Trace.

* cs ignore for long documentation links

* Docs, fixing traces resultLimit, set timezone

* Generate a span name from a cleaned backtrace

* If the trace span is not created within a class, is the file's basename

* Some backtrace entries do not have line numbers

* Revert the change to info() that tried to maintain an info array

* Add SamplerFactory

* Add 3 more example trace reporters

* Add GAE labels to the root span

* fix missing semicolon

* Fix GAE env variable parsing

* Inject the cacheItemClass name into the QpsSampler.

CacheItemPoolInterface implementations often are linked to their
CacheItemInterface implementations in order to communicate expiry (not
part of the PSR-6 spec.

* Add a NullReporter.

* TracerInterface now returns only spans rather than creating a trace record. Add tests

* Add TraceContext class.

* TraceSpan start and end times can accept numerics (timestamps) or strings

* Documentation updates

* close all spans at the end of the request

* Adding version, license, docs for creating new google/cloud-trace package

* Use factories for generating sampler and reporter from the initial RequestTracer::start()

* Rename TraceReporter -> SyncReporter

* Detect PSR-6 apc/apcu cache. Detect default start time from headers.

* can't use pluck staticly

* Docs and examples for RequestTracer

* Remove ReporterFactory. Add documentation

* Adding tests

* SamplerFactory tests

* Add suggested packages for the cache adapters

* Add ExtensionTracer which will not work until the stackdriver extension is available

* JsonSerializable TraceSpan

* Fix serializable

* Return trace context headers if provided to the request

* Prefix service name in front of version if present

* Extension tracer can handle initial trace context

* Put the version header back to just the version

* Add Trace section to main README

* fix default spanId

* finish -> end

* Rename finish -> end for consistency across languages

* Rename instrument -> inSpan to match other languages

* Fix the label name for the module version for GAE

* Update README for google/cloud-trace

* TracerInterface no longer returns the span started or stopped.

The extension tracer cannot return a reference to its internal
representation of a TraceSpan. It would cause strange behavior to be
able to modify the span object returned by reference.

* ensure -> finally

* Remove many unused label constants. Add load balancer labels. Add trace client version to agent

* Test fixes

* Separate the RequestTracer static methods from the RequestHandler instance.

* Fix CS

* Move default logger level to constructor

* Cannot typehint floats

* Add snippet tests

* Implement the AsyncReporter that uses the BatchRunner

* Add another search path for the autoloader for the batch daemon

* Only need to use 2 worker threads by default

* Removing AsyncReporter for now, until Batch package is back

* clarify adding root label from adding label to current span

* Add the addRootLabel to extension tracer

* Adding tests for tracers and reporters

* Fix EchoReporter test

* Doc fixes

* Documentation update for suggesting cache implementations

* Documentation updates. is_a -> instanceof

* Fix the snippet test syntax for updated dev tools

* Spacing and doc updates for PR comments.

* Documentation types, pin google/cloud-core version. SamplerFactory only handles arrays.

* Documentation fixes

* Handle failure cases for LoggerReporter and FileReporter

* Add ramsey/uuid dependency for generating trace ids (uuids)

* Remove extension tracer for now

* Fix use statement for SamplerInterface

* Update required symfony/lock dependency version (#515)

* Test component composer integration, bump gax requirement (#507)

* Test component composer integeration, bump gax requirement

* Use dry-run and repository path

* Switch to exec()

* Add to travis build

* Skip if grpc missing

* Prepare v0.32.0 (#516)

* Prepare v0.32.0

* Bump monitoring, error reporting

* Fix TraceClient example on the main README.md (#517)

* Correct the suggested commit for symfony/lock (#518)

* Add Query system tests, fix value mapping bugs (#520)

* Update Translate service definition, add system tests, remove documentation for non-existent option (#522)

* Prepare v0.32.1 (#523)

* Add support for bucket labels (#529)

* Added new option "uploadProgressCallback" to method $bucket->upload(). (#412)

* Added new option "uploadProgressCallback" to method $bucket->upload().
It's a callable parameter which defines a callback function/method to be triggered on each successfully uploaded chunk if resumable upload is used.

* Include forgotten namespace.

* Added description of the new constructor method in class ResumableUploader.

* Added missing namespace dependency.

* Alphabetical order in used namespaces.
Fixed option name in constructor's description.
Syntax changes to follow the project's consistency.
Used cached getSize() value instead of additional calculations on each upload iteration.

* Added test method for showing how to use the 'uploadProgressCallback' option for tracking the upload progress.

* Fix some Travis build requirements to pass the build successfully.

* Fixed some Travis build requirements to pass the build successfully.

* Rollback .gitignore changes

* Move type constants to Database (#532)

* Skip creating the labels info until there are labels. (#542)

Revert extension name change in test

* upgrade to google/auth ^1.0 (#535)

* upgrade to google/auth ^1.0

* Update google/gax dependency

* Fixing a documentation comment in SpannerClient class construct (#543)

* Add support for Storage - Requester Pays (#527)

* Add support for Storage - Requester Pays

* Add system tests for requester pays

* Address code review

* Fix StorageObject::exists()

* Fix system test for storage IAM

* Add whitelist notice
@chingor13 chingor13 deleted the tracing branch June 27, 2017 17:44
dwsupplee pushed a commit to dwsupplee/gcloud-php that referenced this pull request Jun 30, 2017
* Add ext-grpc as a dep for services that only provides grpc lib (googleapis#475)

* Choose rest over grpc for now. (googleapis#477)

* project to projectId (googleapis#484)

* RFC: Adds removePolicy to Iam Policy Builder (googleapis#480)

* Adds removePolicy to Iam Policy Builder

* adds snippet test

* Introduce support for Cloud Spanner (googleapis#333)

* introduce cache based session pool and streaming execute/read

* Implement remaining API, add system tests.

* Buffer result sets and retry only with error code unavailable

* Fix parameterization and value mapping

Add system test coverage.

Add more read system tests and fix KeyRange issues

Spanner transaction system tests

Add remaining p0 spanner system tests

* allow user determined row formatting

doc fix

address code review

move symfony/lock from require to suggest

* Update README and Spanner composer.json

* update verbiage

* small tweaks

* Add resource-prefix header to outgoing spanner requests

* Add Video Intelligence GAPIC client (googleapis#492)

* Add GAPIC only video intelligence

* Add docs

* Update namespace capitalization

* Address PR comments

* Fix * escaping

* Update grpc install description

* inverse retry condition

* Prepare v0.29.0 (googleapis#493)

* Update docs to include new core types (googleapis#494)

* README updates / Add VI to list of includes (googleapis#495)

* readme fixes

* Add VI to list of includes

* increase ServiceBuilder version for v0.29.0 release (googleapis#496)

* Prepare v0.30.0 (googleapis#497)

* Prepare v0.30.0

* Add GAPIC to Spanner docs table of contents

* make param type more specific (googleapis#500)

* fixes extraStatements bug for Spanner\Instance::createDatabase (googleapis#499)

* fixes extraStatements bug for Spanner\Instance::createDatabase

* fixes tests

* corrects spanner dependency on core and removes symfony/lock requirement (googleapis#503)

* corrects spanner dependency on core and removes symfony/lock requirement

* changes core php req to >=5.5

* Cast keySet keys to arrays instead of wrapping them (googleapis#505)

* cast keySet keys to arrays instead of wrapping them

* adds tests for keyset formatting

* Prepare v0.30.1 (googleapis#501)

* Prepare v0.30.1

* Bump cloud-core version

* Bump proto-client-php version

* Update GAPICs for Spanner (googleapis#508)

* Update spanner gapic

* Update video intelligence

* Update Spanner, VideoIntelligence and Speech

* Address PR feedback

* Modify exceptions when a whitelist may be present (googleapis#482)

* Modify exceptions when a whitelist may be present

* Add Whitelist system tests

* Code review fixes

* Refactor out additional call_user_func

* Prepare v0.31.0 (googleapis#510)

* Prepare v0.31.1 (googleapis#511)

* Request Tracing (googleapis#456)

* Request tracing (googleapis#4)

* Implement the Trace REST API Client.

Implements basic Trace and TraceSpan resources.

TraceClient tests

Fix tests. Connection needed to be protected

Code style fixes

* Rename some methods, move a required parameter

* remove labels class for now

* Refactor TraceSpan to store attributes directly in the info array

* Fix Trace namespace in ServiceBuilder

* Rename some getter methods. Whitelist attributes in TraceSpan constructor

* Fix aliases for Core classes

* Request tracing prototype

* Create more namespaces

* RequestTracer should return results

* Add labels to the primary span detected from the response.

* Snippet tests and phpcs fixes

* Fix cs

* add Trace test

* Add system tests for using the TraceClient

* list traces test depends on creating the traces

* Copyrights and documentation comments

* remove debug statement

* Fix some typehinting and documentation

* Refactor Trace to lazy load span data if not set.

* Convert listTraces output from a generator to an ItemIterator

* Add @see note for Trace list function

* Fix Trace system tests

* Add TraceSpan factory function on Trace

* Add test for lazy fetching span data from the api

* Fix RequestTracer to work with updated apis

* Make RequestTracer an instance. Static functions are redirected to the singleton instance of RequestTracer

* Add options to trace insert and trace get calls

* Remove REST Connection emulator hooks - there is no Trace emulator.

* Trace#info no longer checks to see if you have already specified spans

* Documentation updates

* Remove projectId getter/setter from Trace.

* cs ignore for long documentation links

* Docs, fixing traces resultLimit, set timezone

* Generate a span name from a cleaned backtrace

* If the trace span is not created within a class, is the file's basename

* Some backtrace entries do not have line numbers

* Revert the change to info() that tried to maintain an info array

* Add SamplerFactory

* Add 3 more example trace reporters

* Add GAE labels to the root span

* fix missing semicolon

* Fix GAE env variable parsing

* Inject the cacheItemClass name into the QpsSampler.

CacheItemPoolInterface implementations often are linked to their
CacheItemInterface implementations in order to communicate expiry (not
part of the PSR-6 spec.

* Add a NullReporter.

* TracerInterface now returns only spans rather than creating a trace record. Add tests

* Add TraceContext class.

* TraceSpan start and end times can accept numerics (timestamps) or strings

* Documentation updates

* close all spans at the end of the request

* Adding version, license, docs for creating new google/cloud-trace package

* Use factories for generating sampler and reporter from the initial RequestTracer::start()

* Rename TraceReporter -> SyncReporter

* Detect PSR-6 apc/apcu cache. Detect default start time from headers.

* can't use pluck staticly

* Docs and examples for RequestTracer

* Remove ReporterFactory. Add documentation

* Adding tests

* SamplerFactory tests

* Add suggested packages for the cache adapters

* Add ExtensionTracer which will not work until the stackdriver extension is available

* JsonSerializable TraceSpan

* Fix serializable

* Return trace context headers if provided to the request

* Prefix service name in front of version if present

* Extension tracer can handle initial trace context

* Put the version header back to just the version

* Add Trace section to main README

* fix default spanId

* finish -> end

* Rename finish -> end for consistency across languages

* Rename instrument -> inSpan to match other languages

* Fix the label name for the module version for GAE

* Update README for google/cloud-trace

* TracerInterface no longer returns the span started or stopped.

The extension tracer cannot return a reference to its internal
representation of a TraceSpan. It would cause strange behavior to be
able to modify the span object returned by reference.

* ensure -> finally

* Remove many unused label constants. Add load balancer labels. Add trace client version to agent

* Test fixes

* Separate the RequestTracer static methods from the RequestHandler instance.

* Fix CS

* Move default logger level to constructor

* Cannot typehint floats

* Add snippet tests

* Implement the AsyncReporter that uses the BatchRunner

* Add another search path for the autoloader for the batch daemon

* Only need to use 2 worker threads by default

* Removing AsyncReporter for now, until Batch package is back

* clarify adding root label from adding label to current span

* Add the addRootLabel to extension tracer

* Adding tests for tracers and reporters

* Fix EchoReporter test

* Doc fixes

* Documentation update for suggesting cache implementations

* Documentation updates. is_a -> instanceof

* Fix the snippet test syntax for updated dev tools

* Spacing and doc updates for PR comments.

* Documentation types, pin google/cloud-core version. SamplerFactory only handles arrays.

* Documentation fixes

* Handle failure cases for LoggerReporter and FileReporter

* Add ramsey/uuid dependency for generating trace ids (uuids)

* Remove extension tracer for now

* Fix use statement for SamplerInterface

* Update required symfony/lock dependency version (googleapis#515)

* Test component composer integration, bump gax requirement (googleapis#507)

* Test component composer integeration, bump gax requirement

* Use dry-run and repository path

* Switch to exec()

* Add to travis build

* Skip if grpc missing

* Prepare v0.32.0 (googleapis#516)

* Prepare v0.32.0

* Bump monitoring, error reporting

* Fix TraceClient example on the main README.md (googleapis#517)

* Correct the suggested commit for symfony/lock (googleapis#518)

* Add Query system tests, fix value mapping bugs (googleapis#520)

* Update Translate service definition, add system tests, remove documentation for non-existent option (googleapis#522)

* Prepare v0.32.1 (googleapis#523)

* Add support for bucket labels (googleapis#529)

* Added new option "uploadProgressCallback" to method $bucket->upload(). (googleapis#412)

* Added new option "uploadProgressCallback" to method $bucket->upload().
It's a callable parameter which defines a callback function/method to be triggered on each successfully uploaded chunk if resumable upload is used.

* Include forgotten namespace.

* Added description of the new constructor method in class ResumableUploader.

* Added missing namespace dependency.

* Alphabetical order in used namespaces.
Fixed option name in constructor's description.
Syntax changes to follow the project's consistency.
Used cached getSize() value instead of additional calculations on each upload iteration.

* Added test method for showing how to use the 'uploadProgressCallback' option for tracking the upload progress.

* Fix some Travis build requirements to pass the build successfully.

* Fixed some Travis build requirements to pass the build successfully.

* Rollback .gitignore changes

* Move type constants to Database (googleapis#532)

* Skip creating the labels info until there are labels. (googleapis#542)

Revert extension name change in test

* upgrade to google/auth ^1.0 (googleapis#535)

* upgrade to google/auth ^1.0

* Update google/gax dependency

* Fixing a documentation comment in SpannerClient class construct (googleapis#543)

* Add support for Storage - Requester Pays (googleapis#527)

* Add support for Storage - Requester Pays

* Add system tests for requester pays

* Address code review

* Fix StorageObject::exists()

* Fix system test for storage IAM

* Add whitelist notice
dwsupplee pushed a commit to dwsupplee/gcloud-php that referenced this pull request Jun 30, 2017
* Add ext-grpc as a dep for services that only provides grpc lib (googleapis#475)

* Choose rest over grpc for now. (googleapis#477)

* project to projectId (googleapis#484)

* RFC: Adds removePolicy to Iam Policy Builder (googleapis#480)

* Adds removePolicy to Iam Policy Builder

* adds snippet test

* Introduce support for Cloud Spanner (googleapis#333)

* introduce cache based session pool and streaming execute/read

* Implement remaining API, add system tests.

* Buffer result sets and retry only with error code unavailable

* Fix parameterization and value mapping

Add system test coverage.

Add more read system tests and fix KeyRange issues

Spanner transaction system tests

Add remaining p0 spanner system tests

* allow user determined row formatting

doc fix

address code review

move symfony/lock from require to suggest

* Update README and Spanner composer.json

* update verbiage

* small tweaks

* Add resource-prefix header to outgoing spanner requests

* Add Video Intelligence GAPIC client (googleapis#492)

* Add GAPIC only video intelligence

* Add docs

* Update namespace capitalization

* Address PR comments

* Fix * escaping

* Update grpc install description

* inverse retry condition

* Prepare v0.29.0 (googleapis#493)

* Update docs to include new core types (googleapis#494)

* README updates / Add VI to list of includes (googleapis#495)

* readme fixes

* Add VI to list of includes

* increase ServiceBuilder version for v0.29.0 release (googleapis#496)

* Prepare v0.30.0 (googleapis#497)

* Prepare v0.30.0

* Add GAPIC to Spanner docs table of contents

* make param type more specific (googleapis#500)

* fixes extraStatements bug for Spanner\Instance::createDatabase (googleapis#499)

* fixes extraStatements bug for Spanner\Instance::createDatabase

* fixes tests

* corrects spanner dependency on core and removes symfony/lock requirement (googleapis#503)

* corrects spanner dependency on core and removes symfony/lock requirement

* changes core php req to >=5.5

* Cast keySet keys to arrays instead of wrapping them (googleapis#505)

* cast keySet keys to arrays instead of wrapping them

* adds tests for keyset formatting

* Prepare v0.30.1 (googleapis#501)

* Prepare v0.30.1

* Bump cloud-core version

* Bump proto-client-php version

* Update GAPICs for Spanner (googleapis#508)

* Update spanner gapic

* Update video intelligence

* Update Spanner, VideoIntelligence and Speech

* Address PR feedback

* Modify exceptions when a whitelist may be present (googleapis#482)

* Modify exceptions when a whitelist may be present

* Add Whitelist system tests

* Code review fixes

* Refactor out additional call_user_func

* Prepare v0.31.0 (googleapis#510)

* Prepare v0.31.1 (googleapis#511)

* Request Tracing (googleapis#456)

* Request tracing (googleapis#4)

* Implement the Trace REST API Client.

Implements basic Trace and TraceSpan resources.

TraceClient tests

Fix tests. Connection needed to be protected

Code style fixes

* Rename some methods, move a required parameter

* remove labels class for now

* Refactor TraceSpan to store attributes directly in the info array

* Fix Trace namespace in ServiceBuilder

* Rename some getter methods. Whitelist attributes in TraceSpan constructor

* Fix aliases for Core classes

* Request tracing prototype

* Create more namespaces

* RequestTracer should return results

* Add labels to the primary span detected from the response.

* Snippet tests and phpcs fixes

* Fix cs

* add Trace test

* Add system tests for using the TraceClient

* list traces test depends on creating the traces

* Copyrights and documentation comments

* remove debug statement

* Fix some typehinting and documentation

* Refactor Trace to lazy load span data if not set.

* Convert listTraces output from a generator to an ItemIterator

* Add @see note for Trace list function

* Fix Trace system tests

* Add TraceSpan factory function on Trace

* Add test for lazy fetching span data from the api

* Fix RequestTracer to work with updated apis

* Make RequestTracer an instance. Static functions are redirected to the singleton instance of RequestTracer

* Add options to trace insert and trace get calls

* Remove REST Connection emulator hooks - there is no Trace emulator.

* Trace#info no longer checks to see if you have already specified spans

* Documentation updates

* Remove projectId getter/setter from Trace.

* cs ignore for long documentation links

* Docs, fixing traces resultLimit, set timezone

* Generate a span name from a cleaned backtrace

* If the trace span is not created within a class, is the file's basename

* Some backtrace entries do not have line numbers

* Revert the change to info() that tried to maintain an info array

* Add SamplerFactory

* Add 3 more example trace reporters

* Add GAE labels to the root span

* fix missing semicolon

* Fix GAE env variable parsing

* Inject the cacheItemClass name into the QpsSampler.

CacheItemPoolInterface implementations often are linked to their
CacheItemInterface implementations in order to communicate expiry (not
part of the PSR-6 spec.

* Add a NullReporter.

* TracerInterface now returns only spans rather than creating a trace record. Add tests

* Add TraceContext class.

* TraceSpan start and end times can accept numerics (timestamps) or strings

* Documentation updates

* close all spans at the end of the request

* Adding version, license, docs for creating new google/cloud-trace package

* Use factories for generating sampler and reporter from the initial RequestTracer::start()

* Rename TraceReporter -> SyncReporter

* Detect PSR-6 apc/apcu cache. Detect default start time from headers.

* can't use pluck staticly

* Docs and examples for RequestTracer

* Remove ReporterFactory. Add documentation

* Adding tests

* SamplerFactory tests

* Add suggested packages for the cache adapters

* Add ExtensionTracer which will not work until the stackdriver extension is available

* JsonSerializable TraceSpan

* Fix serializable

* Return trace context headers if provided to the request

* Prefix service name in front of version if present

* Extension tracer can handle initial trace context

* Put the version header back to just the version

* Add Trace section to main README

* fix default spanId

* finish -> end

* Rename finish -> end for consistency across languages

* Rename instrument -> inSpan to match other languages

* Fix the label name for the module version for GAE

* Update README for google/cloud-trace

* TracerInterface no longer returns the span started or stopped.

The extension tracer cannot return a reference to its internal
representation of a TraceSpan. It would cause strange behavior to be
able to modify the span object returned by reference.

* ensure -> finally

* Remove many unused label constants. Add load balancer labels. Add trace client version to agent

* Test fixes

* Separate the RequestTracer static methods from the RequestHandler instance.

* Fix CS

* Move default logger level to constructor

* Cannot typehint floats

* Add snippet tests

* Implement the AsyncReporter that uses the BatchRunner

* Add another search path for the autoloader for the batch daemon

* Only need to use 2 worker threads by default

* Removing AsyncReporter for now, until Batch package is back

* clarify adding root label from adding label to current span

* Add the addRootLabel to extension tracer

* Adding tests for tracers and reporters

* Fix EchoReporter test

* Doc fixes

* Documentation update for suggesting cache implementations

* Documentation updates. is_a -> instanceof

* Fix the snippet test syntax for updated dev tools

* Spacing and doc updates for PR comments.

* Documentation types, pin google/cloud-core version. SamplerFactory only handles arrays.

* Documentation fixes

* Handle failure cases for LoggerReporter and FileReporter

* Add ramsey/uuid dependency for generating trace ids (uuids)

* Remove extension tracer for now

* Fix use statement for SamplerInterface

* Update required symfony/lock dependency version (googleapis#515)

* Test component composer integration, bump gax requirement (googleapis#507)

* Test component composer integeration, bump gax requirement

* Use dry-run and repository path

* Switch to exec()

* Add to travis build

* Skip if grpc missing

* Prepare v0.32.0 (googleapis#516)

* Prepare v0.32.0

* Bump monitoring, error reporting

* Fix TraceClient example on the main README.md (googleapis#517)

* Correct the suggested commit for symfony/lock (googleapis#518)

* Add Query system tests, fix value mapping bugs (googleapis#520)

* Update Translate service definition, add system tests, remove documentation for non-existent option (googleapis#522)

* Prepare v0.32.1 (googleapis#523)

* Add support for bucket labels (googleapis#529)

* Added new option "uploadProgressCallback" to method $bucket->upload(). (googleapis#412)

* Added new option "uploadProgressCallback" to method $bucket->upload().
It's a callable parameter which defines a callback function/method to be triggered on each successfully uploaded chunk if resumable upload is used.

* Include forgotten namespace.

* Added description of the new constructor method in class ResumableUploader.

* Added missing namespace dependency.

* Alphabetical order in used namespaces.
Fixed option name in constructor's description.
Syntax changes to follow the project's consistency.
Used cached getSize() value instead of additional calculations on each upload iteration.

* Added test method for showing how to use the 'uploadProgressCallback' option for tracking the upload progress.

* Fix some Travis build requirements to pass the build successfully.

* Fixed some Travis build requirements to pass the build successfully.

* Rollback .gitignore changes

* Move type constants to Database (googleapis#532)

* Skip creating the labels info until there are labels. (googleapis#542)

Revert extension name change in test

* upgrade to google/auth ^1.0 (googleapis#535)

* upgrade to google/auth ^1.0

* Update google/gax dependency

* Fixing a documentation comment in SpannerClient class construct (googleapis#543)

* Add support for Storage - Requester Pays (googleapis#527)

* Add support for Storage - Requester Pays

* Add system tests for requester pays

* Address code review

* Fix StorageObject::exists()

* Fix system test for storage IAM

* Add whitelist notice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: cloudtrace Issues related to the Cloud Trace API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants