├── lib
├── Client
│ ├── Version.php
│ ├── SystemLogger.php
│ ├── NoOpSpan.php
│ ├── Auth.php
│ ├── KeyValue.php
│ ├── Runtime.php
│ ├── LogRecord.php
│ ├── Transports
│ │ ├── TransportUDP.php
│ │ ├── TransportHTTPJSON.php
│ │ └── TransportHTTPPROTO.php
│ ├── ReportRequest.php
│ ├── Util.php
│ └── ClientSpan.php
├── vendor
│ └── Thrift
│ │ ├── README-LightStep.md
│ │ ├── StringFunc
│ │ ├── TStringFunc.php
│ │ ├── Core.php
│ │ └── Mbstring.php
│ │ ├── Type
│ │ ├── TMessageType.php
│ │ ├── TType.php
│ │ └── TConstant.php
│ │ ├── Protocol
│ │ ├── JSON
│ │ │ ├── BaseContext.php
│ │ │ ├── ListContext.php
│ │ │ ├── LookaheadReader.php
│ │ │ └── PairContext.php
│ │ ├── TBinaryProtocolAccelerated.php
│ │ ├── TMultiplexedProtocol.php
│ │ ├── TProtocolDecorator.php
│ │ ├── TProtocol.php
│ │ └── TBinaryProtocol.php
│ │ ├── Exception
│ │ ├── TTransportException.php
│ │ ├── TProtocolException.php
│ │ ├── TApplicationException.php
│ │ └── TException.php
│ │ ├── ClassLoader
│ │ └── ThriftClassLoader.php
│ │ └── Base
│ │ └── TBase.php
├── generated
│ ├── Lightstep
│ │ └── Collector
│ │ │ ├── Reference_Relationship.php
│ │ │ ├── Reference
│ │ │ └── Relationship.php
│ │ │ ├── Command.php
│ │ │ ├── Auth.php
│ │ │ ├── Reporter.php
│ │ │ ├── Reference.php
│ │ │ ├── Log.php
│ │ │ ├── MetricsSample.php
│ │ │ ├── SpanContext.php
│ │ │ ├── ReportRequest.php
│ │ │ ├── KeyValue.php
│ │ │ ├── InternalMetrics.php
│ │ │ ├── ReportResponse.php
│ │ │ └── Span.php
│ ├── GPBMetadata
│ │ ├── Google
│ │ │ └── Api
│ │ │ │ ├── Annotations.php
│ │ │ │ └── Http.php
│ │ └── Collector.php
│ └── Google
│ │ └── Api
│ │ ├── CustomHttpPattern.php
│ │ └── Http.php
├── LightStep.php
└── api.php
├── composer.json
└── thrift
└── CroutonThrift
└── ReportingService.php
/lib/Client/Version.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.Reference.Relationship
9 | */
10 | class Relationship
11 | {
12 | /**
13 | * Generated from protobuf enum CHILD_OF = 0;
14 | */
15 | const CHILD_OF = 0;
16 | /**
17 | * Generated from protobuf enum FOLLOWS_FROM = 1;
18 | */
19 | const FOLLOWS_FROM = 1;
20 | }
21 |
22 | // Adding a class alias for backwards compatibility with the previous class name.
23 | class_alias(Relationship::class, \Lightstep\Collector\Reference_Relationship::class);
24 |
25 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "lightstep/tracer",
3 | "description": "LightStep instrumentation API",
4 | "license": "MIT",
5 | "require": {
6 | "ruafozy/mersenne-twister": "^1.3 || ^2.0",
7 | "google/protobuf": ">=3.6.1",
8 | "ext-bcmath": "*",
9 | "psr/log": "^1.0"
10 | },
11 | "require-dev": {
12 | "phpdocumentor/phpdocumentor": "^2.8.5",
13 | "phpunit/phpunit": "~4.8.20"
14 | },
15 | "autoload": {
16 | "psr-4": {
17 | "LightStepBase\\": "lib"
18 | },
19 | "files": [
20 | "lib/LightStep.php"
21 | ]
22 | },
23 | "version": "1.1.2",
24 | "abandoned": "open-telemetry/opentelemetry",
25 | "config": {
26 | "sort-packages": true
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/StringFunc/TStringFunc.php:
--------------------------------------------------------------------------------
1 | internalAddGeneratedFile(hex2bin(
19 | "0ac4010a1c676f6f676c652f6170692f616e6e6f746174696f6e732e7072" .
20 | "6f746f120a676f6f676c652e6170691a20676f6f676c652f70726f746f62" .
21 | "75662f64657363726970746f722e70726f746f426e0a0e636f6d2e676f6f" .
22 | "676c652e6170694210416e6e6f746174696f6e7350726f746f50015a4167" .
23 | "6f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f676f6f67" .
24 | "6c65617069732f6170692f616e6e6f746174696f6e733b616e6e6f746174" .
25 | "696f6e73a2020447415049620670726f746f33"
26 | ));
27 |
28 | static::$is_initialized = true;
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/lib/Client/NoOpSpan.php:
--------------------------------------------------------------------------------
1 | _accessToken = $accessToken;
23 | }
24 |
25 | /**
26 | * @return string The access token.
27 | */
28 | public function getAccessToken() {
29 | return $this->_accessToken;
30 | }
31 |
32 | /**
33 | * @return \CroutonThrift\Auth A Thrift representation of this object.
34 | */
35 | public function toThrift() {
36 | return new \CroutonThrift\Auth([
37 | 'access_token' => strval($this->_accessToken),
38 | ]);
39 | }
40 |
41 | /**
42 | * @return ProtoAuth A Proto representation of this object.
43 | */
44 | public function toProto() {
45 | return new ProtoAuth([
46 | 'access_token' => $this->_accessToken
47 | ]);
48 | }
49 | }
--------------------------------------------------------------------------------
/lib/Client/KeyValue.php:
--------------------------------------------------------------------------------
1 | _key = $key;
22 | $this->_value = $value;
23 | }
24 |
25 | /**
26 | * @return string The key.
27 | */
28 | public function getKey() {
29 | return $this->_key;
30 | }
31 |
32 | /**
33 | * @return string The value.
34 | */
35 | public function getValue() {
36 | return $this->_value;
37 | }
38 |
39 | /**
40 | * @return \CroutonThrift\KeyValue A Thrift representation of this object.
41 | */
42 | public function toThrift()
43 | {
44 | return new \CroutonThrift\KeyValue([
45 | 'Key' => $this->_key,
46 | 'Value' => $this->_value,
47 | ]);
48 | }
49 |
50 | /**
51 | * @return \Lightstep\Collector\KeyValue A Proto representation of this object.
52 | */
53 | public function toProto() {
54 | return new \Lightstep\Collector\KeyValue([
55 | 'key' => $this->_key,
56 | 'string_value' => $this->_value,
57 | ]);
58 | }
59 | }
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Type/TType.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.Command
13 | */
14 | class Command extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field bool disable = 1;
18 | */
19 | private $disable = false;
20 |
21 | /**
22 | * Constructor.
23 | *
24 | * @param array $data {
25 | * Optional. Data for populating the Message object.
26 | *
27 | * @type bool $disable
28 | * }
29 | */
30 | public function __construct($data = NULL) {
31 | \GPBMetadata\Collector::initOnce();
32 | parent::__construct($data);
33 | }
34 |
35 | /**
36 | * Generated from protobuf field bool disable = 1;
37 | * @return bool
38 | */
39 | public function getDisable()
40 | {
41 | return $this->disable;
42 | }
43 |
44 | /**
45 | * Generated from protobuf field bool disable = 1;
46 | * @param bool $var
47 | * @return $this
48 | */
49 | public function setDisable($var)
50 | {
51 | GPBUtil::checkBool($var);
52 | $this->disable = $var;
53 |
54 | return $this;
55 | }
56 |
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/Auth.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.Auth
13 | */
14 | class Auth extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string access_token = 1;
18 | */
19 | private $access_token = '';
20 |
21 | /**
22 | * Constructor.
23 | *
24 | * @param array $data {
25 | * Optional. Data for populating the Message object.
26 | *
27 | * @type string $access_token
28 | * }
29 | */
30 | public function __construct($data = NULL) {
31 | \GPBMetadata\Collector::initOnce();
32 | parent::__construct($data);
33 | }
34 |
35 | /**
36 | * Generated from protobuf field string access_token = 1;
37 | * @return string
38 | */
39 | public function getAccessToken()
40 | {
41 | return $this->access_token;
42 | }
43 |
44 | /**
45 | * Generated from protobuf field string access_token = 1;
46 | * @param string $var
47 | * @return $this
48 | */
49 | public function setAccessToken($var)
50 | {
51 | GPBUtil::checkString($var, True);
52 | $this->access_token = $var;
53 |
54 | return $this;
55 | }
56 |
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Type/TConstant.php:
--------------------------------------------------------------------------------
1 | p_ = $p;
35 | }
36 |
37 | public function write() {
38 | if ($this->first_) {
39 | $this->first_ = false;
40 | } else {
41 | $this->p_->getTransport()->write(TJSONProtocol::COMMA);
42 | }
43 | }
44 |
45 | public function read() {
46 | if ($this->first_) {
47 | $this->first_ = false;
48 | } else {
49 | $this->p_->readJSONSyntaxChar(TJSONProtocol::COMMA);
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/lib/vendor/Thrift/StringFunc/Mbstring.php:
--------------------------------------------------------------------------------
1 | strlen($str) - $start;
37 | }
38 |
39 | return mb_substr($str, $start, $length, '8bit');
40 | }
41 |
42 | public function strlen($str) {
43 | return mb_strlen($str, '8bit');
44 | }
45 | }
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Protocol/JSON/LookaheadReader.php:
--------------------------------------------------------------------------------
1 | p_ = $p;
34 | }
35 |
36 | public function read() {
37 | if ($this->hasData_) {
38 | $this->hasData_ = false;
39 | } else {
40 | $this->data_ = $this->p_->getTransport()->readAll(1);
41 | }
42 |
43 | return substr($this->data_, 0, 1);
44 | }
45 |
46 | public function peek() {
47 | if (!$this->hasData_) {
48 | $this->data_ = $this->p_->getTransport()->readAll(1);
49 | }
50 |
51 | $this->hasData_ = true;
52 | return substr($this->data_, 0, 1);
53 | }
54 | }
--------------------------------------------------------------------------------
/lib/generated/GPBMetadata/Google/Api/Http.php:
--------------------------------------------------------------------------------
1 | internalAddGeneratedFile(hex2bin(
18 | "0aa2040a15676f6f676c652f6170692f687474702e70726f746f120a676f" .
19 | "6f676c652e61706922540a044874747012230a0572756c65731801200328" .
20 | "0b32142e676f6f676c652e6170692e4874747052756c6512270a1f66756c" .
21 | "6c795f6465636f64655f72657365727665645f657870616e73696f6e1802" .
22 | "200128082281020a084874747052756c6512100a0873656c6563746f7218" .
23 | "0120012809120d0a036765741802200128094800120d0a03707574180320" .
24 | "0128094800120e0a04706f7374180420012809480012100a0664656c6574" .
25 | "651805200128094800120f0a0570617463681806200128094800122f0a06" .
26 | "637573746f6d18082001280b321d2e676f6f676c652e6170692e43757374" .
27 | "6f6d487474705061747465726e4800120c0a04626f647918072001280912" .
28 | "150a0d726573706f6e73655f626f6479180c2001280912310a1361646469" .
29 | "74696f6e616c5f62696e64696e6773180b2003280b32142e676f6f676c65" .
30 | "2e6170692e4874747052756c6542090a077061747465726e222f0a114375" .
31 | "73746f6d487474705061747465726e120c0a046b696e6418012001280912" .
32 | "0c0a0470617468180220012809426a0a0e636f6d2e676f6f676c652e6170" .
33 | "6942094874747050726f746f50015a41676f6f676c652e676f6c616e672e" .
34 | "6f72672f67656e70726f746f2f676f6f676c65617069732f6170692f616e" .
35 | "6e6f746174696f6e733b616e6e6f746174696f6e73f80101a20204474150" .
36 | "49620670726f746f33"
37 | ));
38 |
39 | static::$is_initialized = true;
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Protocol/JSON/PairContext.php:
--------------------------------------------------------------------------------
1 | p_ = $p;
35 | }
36 |
37 | public function write() {
38 | if ($this->first_) {
39 | $this->first_ = false;
40 | $this->colon_ = true;
41 | } else {
42 | $this->p_->getTransport()->write($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA);
43 | $this->colon_ = !$this->colon_;
44 | }
45 | }
46 |
47 | public function read() {
48 | if ($this->first_) {
49 | $this->first_ = false;
50 | $this->colon_ = true;
51 | } else {
52 | $this->p_->readJSONSyntaxChar($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA);
53 | $this->colon_ = !$this->colon_;
54 | }
55 | }
56 |
57 | public function escapeNum() {
58 | return $this->colon_;
59 | }
60 | }
--------------------------------------------------------------------------------
/lib/Client/Runtime.php:
--------------------------------------------------------------------------------
1 | _guid = $guid;
31 | $this->_start_micros = $start_micros;
32 | $this->_group_name = $group_name;
33 | $this->_attrs = $attrs;
34 | }
35 |
36 | public function getGroupName() {
37 | return $this->_group_name;
38 | }
39 |
40 | /**
41 | * @return \CroutonThrift\Runtime A Thrift representation of this object.
42 | */
43 | public function toThrift()
44 | {
45 | $thriftAttrs = [];
46 | foreach ($this->_attrs as $attr) {
47 | $thriftAttrs[] = $attr->toThrift();
48 | }
49 | return new \CroutonThrift\Runtime([
50 | 'guid' => $this->_guid,
51 | 'start_micros' => $this->_start_micros,
52 | 'group_name' => $this->_group_name,
53 | 'attrs' => $thriftAttrs,
54 | ]);
55 | }
56 |
57 | /**
58 | * @return Reporter A Proto representation of this object.
59 | */
60 | public function toProto() {
61 | $tags = [];
62 | foreach ($this->_attrs as $attr) {
63 | $tags[] = $attr->toProto();
64 | }
65 | $tags[] = new KeyValue([
66 | 'key' => 'lightstep.component_name',
67 | 'string_value' => $this->_group_name,
68 | ]);
69 |
70 | return new Reporter([
71 | 'tags' => $tags,
72 | 'reporter_id' => Util::hexdec($this->_guid),
73 | ]);
74 | }
75 | }
--------------------------------------------------------------------------------
/lib/Client/LogRecord.php:
--------------------------------------------------------------------------------
1 | _fields = $fields;
24 | $this->_util = new Util();
25 | }
26 |
27 | /**
28 | * @return \CroutonThrift\LogRecord A Thrift representation of this object.
29 | */
30 | public function toThrift() {
31 | $ts = 0;
32 | $fields = [];
33 | foreach ($this->_fields as $key => $value) {
34 | if ($key == 'timestamp_micros') {
35 | $ts = $value;
36 | continue;
37 | }
38 | $fields[] = new \CroutonThrift\KeyValue([
39 | 'Key' => $key,
40 | 'Value' => $value,
41 | ]);
42 | }
43 |
44 | return new \CroutonThrift\LogRecord([
45 | 'fields' => $fields,
46 | 'timestamp_micros' => $ts
47 | ]);
48 | }
49 |
50 | /**
51 | * @return Log A Proto representation of this object.
52 | */
53 | public function toProto() {
54 | $keyValues = [];
55 | foreach ($this->_fields as $key => $value) {
56 | if (!$key || !$value) {
57 | continue;
58 | }
59 | if ($key == 'timestamp_micros') {
60 | continue;
61 | }
62 | $keyValues[] = new \Lightstep\Collector\KeyValue([
63 | 'key' => $key,
64 | 'string_value' => $value,
65 | ]);
66 | };
67 |
68 | $logTime = NULL;
69 | if (array_key_exists('timestamp_micros', $this->_fields)) {
70 | $logTime = $this->_fields['timestamp_micros'];
71 | } else {
72 | $logTime = intval($this->_util->nowMicros());
73 | }
74 |
75 | return new Log([
76 | 'timestamp' => new Timestamp([
77 | 'seconds' => floor($logTime / 1000000),
78 | 'nanos' => $logTime % 1000000,
79 | ]),
80 | 'fields' => $keyValues,
81 | ]);
82 | }
83 | }
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Exception/TApplicationException.php:
--------------------------------------------------------------------------------
1 | array('var' => 'message',
31 | 'type' => TType::STRING),
32 | 2 => array('var' => 'code',
33 | 'type' => TType::I32));
34 |
35 | const UNKNOWN = 0;
36 | const UNKNOWN_METHOD = 1;
37 | const INVALID_MESSAGE_TYPE = 2;
38 | const WRONG_METHOD_NAME = 3;
39 | const BAD_SEQUENCE_ID = 4;
40 | const MISSING_RESULT = 5;
41 | const INTERNAL_ERROR = 6;
42 | const PROTOCOL_ERROR = 7;
43 | const INVALID_TRANSFORM = 8;
44 | const INVALID_PROTOCOL = 9;
45 | const UNSUPPORTED_CLIENT_TYPE = 10;
46 |
47 | function __construct($message=null, $code=0) {
48 | parent::__construct($message, $code);
49 | }
50 |
51 | public function read($output) {
52 | return $this->_read('TApplicationException', self::$_TSPEC, $output);
53 | }
54 |
55 | public function write($output) {
56 | $xfer = 0;
57 | $xfer += $output->writeStructBegin('TApplicationException');
58 | if ($message = $this->getMessage()) {
59 | $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
60 | $xfer += $output->writeString($message);
61 | $xfer += $output->writeFieldEnd();
62 | }
63 | if ($code = $this->getCode()) {
64 | $xfer += $output->writeFieldBegin('type', TType::I32, 2);
65 | $xfer += $output->writeI32($code);
66 | $xfer += $output->writeFieldEnd();
67 | }
68 | $xfer += $output->writeFieldStop();
69 | $xfer += $output->writeStructEnd();
70 | return $xfer;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/Reporter.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.Reporter
13 | */
14 | class Reporter extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field uint64 reporter_id = 1;
18 | */
19 | private $reporter_id = 0;
20 | /**
21 | * Generated from protobuf field repeated .lightstep.collector.KeyValue tags = 4;
22 | */
23 | private $tags;
24 |
25 | /**
26 | * Constructor.
27 | *
28 | * @param array $data {
29 | * Optional. Data for populating the Message object.
30 | *
31 | * @type int|string $reporter_id
32 | * @type \Lightstep\Collector\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $tags
33 | * }
34 | */
35 | public function __construct($data = NULL) {
36 | \GPBMetadata\Collector::initOnce();
37 | parent::__construct($data);
38 | }
39 |
40 | /**
41 | * Generated from protobuf field uint64 reporter_id = 1;
42 | * @return int|string
43 | */
44 | public function getReporterId()
45 | {
46 | return $this->reporter_id;
47 | }
48 |
49 | /**
50 | * Generated from protobuf field uint64 reporter_id = 1;
51 | * @param int|string $var
52 | * @return $this
53 | */
54 | public function setReporterId($var)
55 | {
56 | GPBUtil::checkUint64($var);
57 | $this->reporter_id = $var;
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * Generated from protobuf field repeated .lightstep.collector.KeyValue tags = 4;
64 | * @return \Google\Protobuf\Internal\RepeatedField
65 | */
66 | public function getTags()
67 | {
68 | return $this->tags;
69 | }
70 |
71 | /**
72 | * Generated from protobuf field repeated .lightstep.collector.KeyValue tags = 4;
73 | * @param \Lightstep\Collector\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var
74 | * @return $this
75 | */
76 | public function setTags($var)
77 | {
78 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\KeyValue::class);
79 | $this->tags = $arr;
80 |
81 | return $this;
82 | }
83 |
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/Reference.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.Reference
13 | */
14 | class Reference extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field .lightstep.collector.Reference.Relationship relationship = 1;
18 | */
19 | private $relationship = 0;
20 | /**
21 | * Generated from protobuf field .lightstep.collector.SpanContext span_context = 2;
22 | */
23 | private $span_context = null;
24 |
25 | /**
26 | * Constructor.
27 | *
28 | * @param array $data {
29 | * Optional. Data for populating the Message object.
30 | *
31 | * @type int $relationship
32 | * @type \Lightstep\Collector\SpanContext $span_context
33 | * }
34 | */
35 | public function __construct($data = NULL) {
36 | \GPBMetadata\Collector::initOnce();
37 | parent::__construct($data);
38 | }
39 |
40 | /**
41 | * Generated from protobuf field .lightstep.collector.Reference.Relationship relationship = 1;
42 | * @return int
43 | */
44 | public function getRelationship()
45 | {
46 | return $this->relationship;
47 | }
48 |
49 | /**
50 | * Generated from protobuf field .lightstep.collector.Reference.Relationship relationship = 1;
51 | * @param int $var
52 | * @return $this
53 | */
54 | public function setRelationship($var)
55 | {
56 | GPBUtil::checkEnum($var, \Lightstep\Collector\Reference_Relationship::class);
57 | $this->relationship = $var;
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * Generated from protobuf field .lightstep.collector.SpanContext span_context = 2;
64 | * @return \Lightstep\Collector\SpanContext
65 | */
66 | public function getSpanContext()
67 | {
68 | return $this->span_context;
69 | }
70 |
71 | /**
72 | * Generated from protobuf field .lightstep.collector.SpanContext span_context = 2;
73 | * @param \Lightstep\Collector\SpanContext $var
74 | * @return $this
75 | */
76 | public function setSpanContext($var)
77 | {
78 | GPBUtil::checkMessage($var, \Lightstep\Collector\SpanContext::class);
79 | $this->span_context = $var;
80 |
81 | return $this;
82 | }
83 |
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/Log.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.Log
13 | */
14 | class Log extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field .google.protobuf.Timestamp timestamp = 1;
18 | */
19 | private $timestamp = null;
20 | /**
21 | * Generated from protobuf field repeated .lightstep.collector.KeyValue fields = 2;
22 | */
23 | private $fields;
24 |
25 | /**
26 | * Constructor.
27 | *
28 | * @param array $data {
29 | * Optional. Data for populating the Message object.
30 | *
31 | * @type \Google\Protobuf\Timestamp $timestamp
32 | * @type \Lightstep\Collector\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $fields
33 | * }
34 | */
35 | public function __construct($data = NULL) {
36 | \GPBMetadata\Collector::initOnce();
37 | parent::__construct($data);
38 | }
39 |
40 | /**
41 | * Generated from protobuf field .google.protobuf.Timestamp timestamp = 1;
42 | * @return \Google\Protobuf\Timestamp
43 | */
44 | public function getTimestamp()
45 | {
46 | return $this->timestamp;
47 | }
48 |
49 | /**
50 | * Generated from protobuf field .google.protobuf.Timestamp timestamp = 1;
51 | * @param \Google\Protobuf\Timestamp $var
52 | * @return $this
53 | */
54 | public function setTimestamp($var)
55 | {
56 | GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
57 | $this->timestamp = $var;
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * Generated from protobuf field repeated .lightstep.collector.KeyValue fields = 2;
64 | * @return \Google\Protobuf\Internal\RepeatedField
65 | */
66 | public function getFields()
67 | {
68 | return $this->fields;
69 | }
70 |
71 | /**
72 | * Generated from protobuf field repeated .lightstep.collector.KeyValue fields = 2;
73 | * @param \Lightstep\Collector\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var
74 | * @return $this
75 | */
76 | public function setFields($var)
77 | {
78 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\KeyValue::class);
79 | $this->fields = $arr;
80 |
81 | return $this;
82 | }
83 |
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Protocol/TBinaryProtocolAccelerated.php:
--------------------------------------------------------------------------------
1 | strictRead_;
58 | }
59 | public function isStrictWrite() {
60 | return $this->strictWrite_;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/lib/Client/Transports/TransportUDP.php:
--------------------------------------------------------------------------------
1 | logger = $logger ?: new SystemLogger;
22 | }
23 |
24 | public function ensureConnection($options) {
25 | $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
26 | if (!$sock) {
27 | return;
28 | }
29 |
30 | $this->_sock = $sock;
31 | $this->_host = $options['collector_host'];
32 | $this->_port = $options['collector_port'];
33 | }
34 |
35 | public function flushReport($auth, $report) {
36 | if (!$this->_sock) {
37 | return;
38 | }
39 | if (is_null($auth) || is_null($report)) {
40 | return;
41 | }
42 |
43 | // The UDP payload is encoded in a function call like container that
44 | // maps to the Thrift named arguments.
45 | //
46 | // Note: a trade-off is being made here to reduce code path divergence
47 | // from the "standard" RPC mechanism at the expense of some overhead in
48 | // creating intermediate Thrift data structures and JSON encoding.
49 | $data = array(
50 | 'auth' => $auth->toThrift(),
51 | 'report' => $report->toThrift(),
52 | );
53 |
54 | // Prefix with a header for versioning and routing purposes to future
55 | // proof for other RPC calls.
56 | // The format is ///?
57 | $msg = "/v1/crouton/report?" . json_encode($data);
58 | if (!is_string($msg)) {
59 | throw new \Exception('Could not encode report');
60 | }
61 | $msg = gzencode($msg);
62 | $len = strlen($msg);
63 |
64 | // Drop messages that are going to fail due to UDP size constraints
65 | if ($len > self::MAX_MESSAGE_BYTES) {
66 | return;
67 | }
68 | $bytesSent = @socket_sendto($this->_sock, $msg, strlen($msg), 0, $this->_host, $this->_port);
69 |
70 | // Reset the connection if something went amiss
71 | if ($bytesSent === FALSE) {
72 | $this->logger->error('Socket returned error code: ' . socket_last_error($this->_sock));
73 | socket_close($this->_sock);
74 | $this->_sock = NULL;
75 | }
76 |
77 | // By design, the UDP transport never returns a valid Thrift response
78 | // object
79 | return NULL;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/lib/generated/Google/Api/CustomHttpPattern.php:
--------------------------------------------------------------------------------
1 | google.api.CustomHttpPattern
15 | */
16 | class CustomHttpPattern extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * The name of this custom HTTP verb.
20 | *
21 | * Generated from protobuf field string kind = 1;
22 | */
23 | private $kind = '';
24 | /**
25 | * The path matched by this custom verb.
26 | *
27 | * Generated from protobuf field string path = 2;
28 | */
29 | private $path = '';
30 |
31 | /**
32 | * Constructor.
33 | *
34 | * @param array $data {
35 | * Optional. Data for populating the Message object.
36 | *
37 | * @type string $kind
38 | * The name of this custom HTTP verb.
39 | * @type string $path
40 | * The path matched by this custom verb.
41 | * }
42 | */
43 | public function __construct($data = NULL) {
44 | \GPBMetadata\Google\Api\Http::initOnce();
45 | parent::__construct($data);
46 | }
47 |
48 | /**
49 | * The name of this custom HTTP verb.
50 | *
51 | * Generated from protobuf field string kind = 1;
52 | * @return string
53 | */
54 | public function getKind()
55 | {
56 | return $this->kind;
57 | }
58 |
59 | /**
60 | * The name of this custom HTTP verb.
61 | *
62 | * Generated from protobuf field string kind = 1;
63 | * @param string $var
64 | * @return $this
65 | */
66 | public function setKind($var)
67 | {
68 | GPBUtil::checkString($var, True);
69 | $this->kind = $var;
70 |
71 | return $this;
72 | }
73 |
74 | /**
75 | * The path matched by this custom verb.
76 | *
77 | * Generated from protobuf field string path = 2;
78 | * @return string
79 | */
80 | public function getPath()
81 | {
82 | return $this->path;
83 | }
84 |
85 | /**
86 | * The path matched by this custom verb.
87 | *
88 | * Generated from protobuf field string path = 2;
89 | * @param string $var
90 | * @return $this
91 | */
92 | public function setPath($var)
93 | {
94 | GPBUtil::checkString($var, True);
95 | $this->path = $var;
96 |
97 | return $this;
98 | }
99 |
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/MetricsSample.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.MetricsSample
13 | */
14 | class MetricsSample extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string name = 1;
18 | */
19 | private $name = '';
20 | protected $value;
21 |
22 | /**
23 | * Constructor.
24 | *
25 | * @param array $data {
26 | * Optional. Data for populating the Message object.
27 | *
28 | * @type string $name
29 | * @type int|string $int_value
30 | * @type float $double_value
31 | * }
32 | */
33 | public function __construct($data = NULL) {
34 | \GPBMetadata\Collector::initOnce();
35 | parent::__construct($data);
36 | }
37 |
38 | /**
39 | * Generated from protobuf field string name = 1;
40 | * @return string
41 | */
42 | public function getName()
43 | {
44 | return $this->name;
45 | }
46 |
47 | /**
48 | * Generated from protobuf field string name = 1;
49 | * @param string $var
50 | * @return $this
51 | */
52 | public function setName($var)
53 | {
54 | GPBUtil::checkString($var, True);
55 | $this->name = $var;
56 |
57 | return $this;
58 | }
59 |
60 | /**
61 | * Generated from protobuf field int64 int_value = 2;
62 | * @return int|string
63 | */
64 | public function getIntValue()
65 | {
66 | return $this->readOneof(2);
67 | }
68 |
69 | /**
70 | * Generated from protobuf field int64 int_value = 2;
71 | * @param int|string $var
72 | * @return $this
73 | */
74 | public function setIntValue($var)
75 | {
76 | GPBUtil::checkInt64($var);
77 | $this->writeOneof(2, $var);
78 |
79 | return $this;
80 | }
81 |
82 | /**
83 | * Generated from protobuf field double double_value = 3;
84 | * @return float
85 | */
86 | public function getDoubleValue()
87 | {
88 | return $this->readOneof(3);
89 | }
90 |
91 | /**
92 | * Generated from protobuf field double double_value = 3;
93 | * @param float $var
94 | * @return $this
95 | */
96 | public function setDoubleValue($var)
97 | {
98 | GPBUtil::checkDouble($var);
99 | $this->writeOneof(3, $var);
100 |
101 | return $this;
102 | }
103 |
104 | /**
105 | * @return string
106 | */
107 | public function getValue()
108 | {
109 | return $this->whichOneof("value");
110 | }
111 |
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/lib/Client/ReportRequest.php:
--------------------------------------------------------------------------------
1 | _runtime = $runtime;
31 | $this->_reportStartTime = $reportStartTime;
32 | $this->_now = $now;
33 | $this->_spanRecords = $spanRecords;
34 | $this->_counters = $counters;
35 | }
36 |
37 | /**
38 | * @return \CroutonThrift\ReportRequest A Thrift representation of this object.
39 | */
40 | public function toThrift() {
41 | // Convert the counters to thrift form
42 | $thriftCounters = [];
43 | foreach ($this->_counters as $key => $value) {
44 | $thriftCounters[] = new \CroutonThrift\NamedCounter([
45 | 'Name' => strval($key),
46 | 'Value' => intval($value),
47 | ]);
48 | }
49 |
50 | // Convert the spans to thrift form
51 | $thriftSpans = [];
52 | foreach ($this->_spanRecords as $sr) {
53 | $thriftSpans[] = $sr->toThrift();
54 | }
55 |
56 | return new \CroutonThrift\ReportRequest([
57 | 'runtime' => $this->_runtime->toThrift(),
58 | 'oldest_micros' => $this->_reportStartTime,
59 | 'youngest_micros' => $this->_now,
60 | 'span_records' => $thriftSpans,
61 | 'counters' => $thriftCounters,
62 | ]);
63 | }
64 |
65 | /**
66 | * @param Auth $auth
67 | * @return ProtoReportRequest A Proto representation of this object.
68 | */
69 | public function toProto($auth) {
70 | $counts = [];
71 | foreach ($this->_counters as $key => $value) {
72 | $counts[] = new MetricsSample([
73 | 'name' => strval($key),
74 | 'int_value' => intval($value),
75 | ]);
76 | }
77 | $internalMetrics = new InternalMetrics([
78 | 'counts' => $counts
79 | ]);
80 |
81 | $spans = [];
82 | foreach ($this->_spanRecords as $sr) {
83 | $spans[] = $sr->toProto();
84 | }
85 | return new ProtoReportRequest([
86 | 'auth' => $auth->toProto(),
87 | 'internal_metrics' => $internalMetrics,
88 | 'reporter' => $this->_runtime->toProto(),
89 | 'spans' => $spans,
90 | ]);
91 | }
92 | }
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Protocol/TMultiplexedProtocol.php:
--------------------------------------------------------------------------------
1 | TMultiplexedProtocol is a protocol-independent concrete decorator
29 | * that allows a Thrift client to communicate with a multiplexing Thrift server,
30 | * by prepending the service name to the function name during function calls.
31 | *
32 | * @package Thrift\Protocol
33 | */
34 | class TMultiplexedProtocol extends TProtocolDecorator
35 | {
36 | /**
37 | * Separator between service name and function name.
38 | * Should be the same as used at multiplexed Thrift server.
39 | *
40 | * @var string
41 | */
42 | const SEPARATOR = ":";
43 |
44 | /**
45 | * The name of service.
46 | *
47 | * @var string
48 | */
49 | private $serviceName_;
50 |
51 | /**
52 | * Constructor of TMultiplexedProtocol class.
53 | *
54 | * Wrap the specified protocol, allowing it to be used to communicate with a
55 | * multiplexing server. The $serviceName is required as it is
56 | * prepended to the message header so that the multiplexing server can broker
57 | * the function call to the proper service.
58 | *
59 | * @param TProtocol $protocol
60 | * @param string $serviceName The name of service.
61 | */
62 | public function __construct(TProtocol $protocol, $serviceName)
63 | {
64 | parent::__construct($protocol);
65 | $this->serviceName_ = $serviceName;
66 | }
67 |
68 | /**
69 | * Writes the message header.
70 | * Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR.
71 | *
72 | * @param string $name Function name.
73 | * @param int $type Message type.
74 | * @param int $seqid The sequence id of this message.
75 | */
76 | public function writeMessageBegin($name, $type, $seqid)
77 | {
78 | if ($type == TMessageType::CALL || $type == TMessageType::ONEWAY) {
79 | $nameWithService = $this->serviceName_ . self::SEPARATOR . $name;
80 | parent::writeMessageBegin($nameWithService, $type, $seqid);
81 | } else {
82 | parent::writeMessageBegin($name, $type, $seqid);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/lib/Client/Transports/TransportHTTPJSON.php:
--------------------------------------------------------------------------------
1 | logger = $logger ?: new SystemLogger;
25 | $this->_timeout = ini_get("default_socket_timeout");
26 | }
27 |
28 | public function ensureConnection($options) {
29 | $this->_verbose = $options['verbose'];
30 |
31 | $this->_host = $options['collector_host'];
32 | $this->_port = $options['collector_port'];
33 |
34 | // The prefixed protocol is only needed for secure connections
35 | if ($options['collector_secure'] == true) {
36 | if (isset($options['collector_scheme'])) {
37 | $this->_scheme = $options['collector_scheme'];
38 | } else {
39 | $this->_scheme = self::DEFAULT_SCHEME;
40 | }
41 | }
42 |
43 | if (isset($options['http_connection_timeout'])) {
44 | $this->_timeout = $options['http_connection_timeout'];
45 | }
46 | }
47 |
48 | public function flushReport($auth, $report) {
49 | if (is_null($auth) || is_null($report)) {
50 | if ($this->_verbose > 0) {
51 | $this->logger->error("Auth or report not set.");
52 | }
53 | return NULL;
54 | }
55 |
56 | $thriftReport = $report->toThrift();
57 |
58 | if ($this->_verbose >= 3) {
59 | $this->logger->debug('report contents:', $thriftReport);
60 | }
61 |
62 | $content = json_encode($thriftReport);
63 | $content = gzencode($content);
64 |
65 | $header = "Host: " . $this->_host . "\r\n";
66 | $header .= "User-Agent: LightStep-PHP\r\n";
67 | $header .= "LightStep-Access-Token: " . $auth->getAccessToken() . "\r\n";
68 | $header .= "Content-Type: application/json\r\n";
69 | $header .= "Content-Length: " . strlen($content) . "\r\n";
70 | $header .= "Content-Encoding: gzip\r\n";
71 | $header .= "Connection: keep-alive\r\n\r\n";
72 |
73 | // Use a persistent connection when possible
74 | $fp = @pfsockopen($this->_scheme . $this->_host, $this->_port, $errno, $errstr, $this->_timeout);
75 | if (!$fp) {
76 | if ($this->_verbose > 0) {
77 | $this->logger->error($errstr);
78 | }
79 | return NULL;
80 | }
81 | @fwrite($fp, "POST /api/v0/reports HTTP/1.1\r\n");
82 | @fwrite($fp, $header . $content);
83 | @fflush($fp);
84 | // Wait and read first line of the response e.g. (HTTP/1.1 2xx OK)
85 | // otherwise the connection will close before the request is complete,
86 | // leading to a context cancellation down stream.
87 | fgets($fp);
88 | @fclose($fp);
89 |
90 | return NULL;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/SpanContext.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.SpanContext
13 | */
14 | class SpanContext extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field uint64 trace_id = 1;
18 | */
19 | private $trace_id = 0;
20 | /**
21 | * Generated from protobuf field uint64 span_id = 2;
22 | */
23 | private $span_id = 0;
24 | /**
25 | * Generated from protobuf field map baggage = 3;
26 | */
27 | private $baggage;
28 |
29 | /**
30 | * Constructor.
31 | *
32 | * @param array $data {
33 | * Optional. Data for populating the Message object.
34 | *
35 | * @type int|string $trace_id
36 | * @type int|string $span_id
37 | * @type array|\Google\Protobuf\Internal\MapField $baggage
38 | * }
39 | */
40 | public function __construct($data = NULL) {
41 | \GPBMetadata\Collector::initOnce();
42 | parent::__construct($data);
43 | }
44 |
45 | /**
46 | * Generated from protobuf field uint64 trace_id = 1;
47 | * @return int|string
48 | */
49 | public function getTraceId()
50 | {
51 | return $this->trace_id;
52 | }
53 |
54 | /**
55 | * Generated from protobuf field uint64 trace_id = 1;
56 | * @param int|string $var
57 | * @return $this
58 | */
59 | public function setTraceId($var)
60 | {
61 | GPBUtil::checkUint64($var);
62 | $this->trace_id = $var;
63 |
64 | return $this;
65 | }
66 |
67 | /**
68 | * Generated from protobuf field uint64 span_id = 2;
69 | * @return int|string
70 | */
71 | public function getSpanId()
72 | {
73 | return $this->span_id;
74 | }
75 |
76 | /**
77 | * Generated from protobuf field uint64 span_id = 2;
78 | * @param int|string $var
79 | * @return $this
80 | */
81 | public function setSpanId($var)
82 | {
83 | GPBUtil::checkUint64($var);
84 | $this->span_id = $var;
85 |
86 | return $this;
87 | }
88 |
89 | /**
90 | * Generated from protobuf field map baggage = 3;
91 | * @return \Google\Protobuf\Internal\MapField
92 | */
93 | public function getBaggage()
94 | {
95 | return $this->baggage;
96 | }
97 |
98 | /**
99 | * Generated from protobuf field map baggage = 3;
100 | * @param array|\Google\Protobuf\Internal\MapField $var
101 | * @return $this
102 | */
103 | public function setBaggage($var)
104 | {
105 | $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING);
106 | $this->baggage = $arr;
107 |
108 | return $this;
109 | }
110 |
111 | }
112 |
113 |
--------------------------------------------------------------------------------
/lib/Client/Transports/TransportHTTPPROTO.php:
--------------------------------------------------------------------------------
1 | logger = $logger ?: new SystemLogger;
25 | $this->_timeout = ini_get("default_socket_timeout");
26 | }
27 |
28 | /**
29 | * Assigns the variables that are required for connectivity.
30 | *
31 | * @param array $options Options for how to configure the transport. Expected keys are:
32 | * 'verbose' - if true, payloads and errors will be logged
33 | * 'collector_host' - hostname of the collector for the url
34 | * 'collector_port' - port of the collector for the url
35 | * 'collector_secure' - if true, will use SSL
36 | */
37 | public function ensureConnection($options) {
38 | $this->_verbose = $options['verbose'];
39 |
40 | $this->_host = $options['collector_host'];
41 | $this->_port = $options['collector_port'];
42 |
43 | // The prefixed protocol is only needed for secure connections
44 | if ($options['collector_secure'] == true) {
45 | if (isset($options['collector_scheme'])) {
46 | $this->_scheme = $options['collector_scheme'];
47 | } else {
48 | $this->_scheme = self::DEFAULT_SCHEME;
49 | }
50 | }
51 |
52 | if (isset($options['http_connection_timeout'])) {
53 | $this->_timeout = $options['http_connection_timeout'];
54 | }
55 | }
56 |
57 | public function flushReport($auth, $report) {
58 | if (is_null($auth) || is_null($report)) {
59 | if ($this->_verbose > 0) {
60 | $this->logger->error("Auth or report not set.");
61 | }
62 | return NULL;
63 | }
64 |
65 | $content = $report->toProto($auth)->serializeToString();
66 |
67 | if ($this->_verbose >= 3) {
68 | $this->logger->debug('Report to be flushed', ['content' => $content]);
69 | }
70 |
71 | $header = "Host: " . $this->_host . "\r\n";
72 | $header .= "User-Agent: LightStep-PHP\r\n";
73 | $header .= "Accept: application/octet-stream\r\n";
74 | $header .= "Content-Type: application/octet-stream\r\n";
75 | $header .= "Content-Length: " . strlen($content) . "\r\n";
76 | $header .= "Connection: keep-alive\r\n\r\n";
77 |
78 | // Use a persistent connection when possible
79 | $fp = @pfsockopen($this->_scheme . $this->_host, $this->_port, $errno, $errstr, $this->_timeout);
80 | if (!$fp) {
81 | if ($this->_verbose > 0) {
82 | $this->logger->error($errstr);
83 | }
84 | return NULL;
85 | }
86 |
87 | @fwrite($fp, "POST /api/v2/reports HTTP/1.1\r\n");
88 | @fwrite($fp, $header . $content);
89 | @fflush($fp);
90 | // Wait and read first line of the response e.g. (HTTP/1.1 2xx OK)
91 | // otherwise the connection will close before the request is complete,
92 | // leading to a context cancellation down stream.
93 | fgets($fp);
94 | @fclose($fp);
95 |
96 | return NULL;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/lib/Client/Util.php:
--------------------------------------------------------------------------------
1 | _rng = new \mersenne_twister\twister($seed);
11 | }
12 |
13 | /**
14 | * Returns an integer in the following closed range (i.e. inclusive,
15 | * $lower <= $x <= $upper).
16 | */
17 | public function randIntRange($lower, $upper) {
18 | return $this->_rng->rangeint($lower, $upper);
19 | }
20 |
21 | /**
22 | * Returns a positive or *negative* 32-bit integer.
23 | * http://kingfisher.nfshost.com/sw/twister/
24 | */
25 | public function randInt32() {
26 | return $this->_rng->int32();
27 | }
28 |
29 | /**
30 | * Generates a random ID (not a RFC-4122 UUID).
31 | */
32 | public function _generateUUIDString() {
33 | // must return less than 7fffffffffffffff
34 |
35 | return sprintf("%08x%08x",
36 | $this->randInt32(),
37 | $this->randInt32()
38 | );
39 | }
40 |
41 | public static function nowMicros() {
42 | // Note: microtime returns the current time *in seconds* but with
43 | // microsecond accuracy (not the current time in microseconds!).
44 | return floor(microtime(TRUE) * 1000.0 * 1000.0);
45 | }
46 |
47 | /**
48 | * Add an item to the array, ensuring that the size of the array never exceed the max. If adding the item would
49 | * cause the array count to exceed max, then the item is not added.
50 | *
51 | * @param array $arr Array to add item to
52 | * @param object $item Item to be added
53 | * @param int $max Max number of items allowed in array, if provided max is <= 0, 1 will be used as the max
54 | * @return bool True if the item was successfully added to the array
55 | */
56 | public static function pushIfSpaceAllows(&$arr, $item, $max) {
57 | if ($max <= 0) {
58 | $max = 1;
59 | }
60 |
61 | if (count($arr) >= $max) {
62 | return false;
63 | }
64 |
65 | $arr[] = $item;
66 | return true;
67 | }
68 |
69 | /**
70 | * A php friendly solution for creating uint64 (as string) from hex.
71 | * See: https://stackoverflow.com/questions/11867928/convert-64-bit-integer-hex-string-to-64-bit-decimal-string-on-32-bit-system/11919219
72 | *
73 | * @param string $input A hexadecimal string
74 | * @return string A string containing the decimal value equivalent to the input.
75 | */
76 | public static function hexdec($input) {
77 | $str_high = substr($input, 0, 8);
78 | $str_low = substr($input, 8, 8);
79 |
80 | $dec_high = hexdec($str_high);
81 | $dec_low = hexdec($str_low);
82 |
83 | //workaround for argument 0x100000000
84 | $temp = bcmul($dec_high, 0xffffffff);
85 | $temp2 = bcadd($temp, $dec_high);
86 |
87 | $result = bcadd($temp2, $dec_low);
88 |
89 | return $result;
90 | }
91 |
92 | /**
93 | * @param string $input A string containing a decimal value.
94 | * @return string The hexadecimal string equivalent to the provided input.
95 | */
96 | public static function dechex($input) {
97 | $hex = '';
98 | do {
99 | $last = bcmod($input, 16);
100 | $hex = dechex($last).$hex;
101 | $input = bcdiv(bcsub($input, $last), 16);
102 | } while($input>0);
103 | return str_pad($hex, 16, "0", STR_PAD_LEFT);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/lib/generated/Google/Api/Http.php:
--------------------------------------------------------------------------------
1 | google.api.Http
17 | */
18 | class Http extends \Google\Protobuf\Internal\Message
19 | {
20 | /**
21 | * A list of HTTP configuration rules that apply to individual API methods.
22 | * **NOTE:** All service configuration rules follow "last one wins" order.
23 | *
24 | * Generated from protobuf field repeated .google.api.HttpRule rules = 1;
25 | */
26 | private $rules;
27 | /**
28 | * When set to true, URL path parmeters will be fully URI-decoded except in
29 | * cases of single segment matches in reserved expansion, where "%2F" will be
30 | * left encoded.
31 | * The default behavior is to not decode RFC 6570 reserved characters in multi
32 | * segment matches.
33 | *
34 | * Generated from protobuf field bool fully_decode_reserved_expansion = 2;
35 | */
36 | private $fully_decode_reserved_expansion = false;
37 |
38 | /**
39 | * Constructor.
40 | *
41 | * @param array $data {
42 | * Optional. Data for populating the Message object.
43 | *
44 | * @type \Google\Api\HttpRule[]|\Google\Protobuf\Internal\RepeatedField $rules
45 | * A list of HTTP configuration rules that apply to individual API methods.
46 | * **NOTE:** All service configuration rules follow "last one wins" order.
47 | * @type bool $fully_decode_reserved_expansion
48 | * When set to true, URL path parmeters will be fully URI-decoded except in
49 | * cases of single segment matches in reserved expansion, where "%2F" will be
50 | * left encoded.
51 | * The default behavior is to not decode RFC 6570 reserved characters in multi
52 | * segment matches.
53 | * }
54 | */
55 | public function __construct($data = NULL) {
56 | \GPBMetadata\Google\Api\Http::initOnce();
57 | parent::__construct($data);
58 | }
59 |
60 | /**
61 | * A list of HTTP configuration rules that apply to individual API methods.
62 | * **NOTE:** All service configuration rules follow "last one wins" order.
63 | *
64 | * Generated from protobuf field repeated .google.api.HttpRule rules = 1;
65 | * @return \Google\Protobuf\Internal\RepeatedField
66 | */
67 | public function getRules()
68 | {
69 | return $this->rules;
70 | }
71 |
72 | /**
73 | * A list of HTTP configuration rules that apply to individual API methods.
74 | * **NOTE:** All service configuration rules follow "last one wins" order.
75 | *
76 | * Generated from protobuf field repeated .google.api.HttpRule rules = 1;
77 | * @param \Google\Api\HttpRule[]|\Google\Protobuf\Internal\RepeatedField $var
78 | * @return $this
79 | */
80 | public function setRules($var)
81 | {
82 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\HttpRule::class);
83 | $this->rules = $arr;
84 |
85 | return $this;
86 | }
87 |
88 | /**
89 | * When set to true, URL path parmeters will be fully URI-decoded except in
90 | * cases of single segment matches in reserved expansion, where "%2F" will be
91 | * left encoded.
92 | * The default behavior is to not decode RFC 6570 reserved characters in multi
93 | * segment matches.
94 | *
95 | * Generated from protobuf field bool fully_decode_reserved_expansion = 2;
96 | * @return bool
97 | */
98 | public function getFullyDecodeReservedExpansion()
99 | {
100 | return $this->fully_decode_reserved_expansion;
101 | }
102 |
103 | /**
104 | * When set to true, URL path parmeters will be fully URI-decoded except in
105 | * cases of single segment matches in reserved expansion, where "%2F" will be
106 | * left encoded.
107 | * The default behavior is to not decode RFC 6570 reserved characters in multi
108 | * segment matches.
109 | *
110 | * Generated from protobuf field bool fully_decode_reserved_expansion = 2;
111 | * @param bool $var
112 | * @return $this
113 | */
114 | public function setFullyDecodeReservedExpansion($var)
115 | {
116 | GPBUtil::checkBool($var);
117 | $this->fully_decode_reserved_expansion = $var;
118 |
119 | return $this;
120 | }
121 |
122 | }
123 |
124 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/ReportRequest.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.ReportRequest
13 | */
14 | class ReportRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field .lightstep.collector.Reporter reporter = 1;
18 | */
19 | private $reporter = null;
20 | /**
21 | * Generated from protobuf field .lightstep.collector.Auth auth = 2;
22 | */
23 | private $auth = null;
24 | /**
25 | * Generated from protobuf field repeated .lightstep.collector.Span spans = 3;
26 | */
27 | private $spans;
28 | /**
29 | * Generated from protobuf field int64 timestamp_offset_micros = 5;
30 | */
31 | private $timestamp_offset_micros = 0;
32 | /**
33 | * Generated from protobuf field .lightstep.collector.InternalMetrics internal_metrics = 6;
34 | */
35 | private $internal_metrics = null;
36 |
37 | /**
38 | * Constructor.
39 | *
40 | * @param array $data {
41 | * Optional. Data for populating the Message object.
42 | *
43 | * @type \Lightstep\Collector\Reporter $reporter
44 | * @type \Lightstep\Collector\Auth $auth
45 | * @type \Lightstep\Collector\Span[]|\Google\Protobuf\Internal\RepeatedField $spans
46 | * @type int|string $timestamp_offset_micros
47 | * @type \Lightstep\Collector\InternalMetrics $internal_metrics
48 | * }
49 | */
50 | public function __construct($data = NULL) {
51 | \GPBMetadata\Collector::initOnce();
52 | parent::__construct($data);
53 | }
54 |
55 | /**
56 | * Generated from protobuf field .lightstep.collector.Reporter reporter = 1;
57 | * @return \Lightstep\Collector\Reporter
58 | */
59 | public function getReporter()
60 | {
61 | return $this->reporter;
62 | }
63 |
64 | /**
65 | * Generated from protobuf field .lightstep.collector.Reporter reporter = 1;
66 | * @param \Lightstep\Collector\Reporter $var
67 | * @return $this
68 | */
69 | public function setReporter($var)
70 | {
71 | GPBUtil::checkMessage($var, \Lightstep\Collector\Reporter::class);
72 | $this->reporter = $var;
73 |
74 | return $this;
75 | }
76 |
77 | /**
78 | * Generated from protobuf field .lightstep.collector.Auth auth = 2;
79 | * @return \Lightstep\Collector\Auth
80 | */
81 | public function getAuth()
82 | {
83 | return $this->auth;
84 | }
85 |
86 | /**
87 | * Generated from protobuf field .lightstep.collector.Auth auth = 2;
88 | * @param \Lightstep\Collector\Auth $var
89 | * @return $this
90 | */
91 | public function setAuth($var)
92 | {
93 | GPBUtil::checkMessage($var, \Lightstep\Collector\Auth::class);
94 | $this->auth = $var;
95 |
96 | return $this;
97 | }
98 |
99 | /**
100 | * Generated from protobuf field repeated .lightstep.collector.Span spans = 3;
101 | * @return \Google\Protobuf\Internal\RepeatedField
102 | */
103 | public function getSpans()
104 | {
105 | return $this->spans;
106 | }
107 |
108 | /**
109 | * Generated from protobuf field repeated .lightstep.collector.Span spans = 3;
110 | * @param \Lightstep\Collector\Span[]|\Google\Protobuf\Internal\RepeatedField $var
111 | * @return $this
112 | */
113 | public function setSpans($var)
114 | {
115 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\Span::class);
116 | $this->spans = $arr;
117 |
118 | return $this;
119 | }
120 |
121 | /**
122 | * Generated from protobuf field int64 timestamp_offset_micros = 5;
123 | * @return int|string
124 | */
125 | public function getTimestampOffsetMicros()
126 | {
127 | return $this->timestamp_offset_micros;
128 | }
129 |
130 | /**
131 | * Generated from protobuf field int64 timestamp_offset_micros = 5;
132 | * @param int|string $var
133 | * @return $this
134 | */
135 | public function setTimestampOffsetMicros($var)
136 | {
137 | GPBUtil::checkInt64($var);
138 | $this->timestamp_offset_micros = $var;
139 |
140 | return $this;
141 | }
142 |
143 | /**
144 | * Generated from protobuf field .lightstep.collector.InternalMetrics internal_metrics = 6;
145 | * @return \Lightstep\Collector\InternalMetrics
146 | */
147 | public function getInternalMetrics()
148 | {
149 | return $this->internal_metrics;
150 | }
151 |
152 | /**
153 | * Generated from protobuf field .lightstep.collector.InternalMetrics internal_metrics = 6;
154 | * @param \Lightstep\Collector\InternalMetrics $var
155 | * @return $this
156 | */
157 | public function setInternalMetrics($var)
158 | {
159 | GPBUtil::checkMessage($var, \Lightstep\Collector\InternalMetrics::class);
160 | $this->internal_metrics = $var;
161 |
162 | return $this;
163 | }
164 |
165 | }
166 |
167 |
--------------------------------------------------------------------------------
/lib/LightStep.php:
--------------------------------------------------------------------------------
1 | options(array_merge($opts, [
59 | 'component_name' => $component_name,
60 | 'access_token' => $access_token,
61 | ]));
62 | } else {
63 | self::$_singleton = self::newTracer($component_name, $access_token, $opts);
64 | }
65 | return self::$_singleton;
66 | }
67 |
68 | /**
69 | * Returns the singleton instance of the Tracer.
70 | *
71 | * For convenience, this function can be passed the $component_name and
72 | * $access_token parameters to also initialize the tracer singleton. These
73 | * values will be ignored on any calls after the first to getInstance().
74 | *
75 | * @param $component_name Component name to use for the tracer
76 | * @param $access_token The project access token
77 | * @return \LightStepBase\Tracer
78 | * @throws Exception if the group name or access token is not a valid string
79 | */
80 | public static function getInstance($component_name = NULL, $access_token = NULL, $opts = NULL) {
81 | if (!isset(self::$_singleton)) {
82 | self::$_singleton = self::newTracer($component_name, $access_token, $opts);
83 | }
84 | return self::$_singleton;
85 | }
86 |
87 |
88 | /**
89 | * Creates a new tracer instance.
90 | *
91 | * @param $component_name Component name to use for the tracer
92 | * @param $access_token The project access token
93 | * @return \LightStepBase\Tracer
94 | * @throws Exception if the group name or access token is not a valid string.
95 | */
96 | public static function newTracer ($component_name, $access_token, $opts = NULL) {
97 | if (is_null($opts)) {
98 | $opts = [];
99 | }
100 |
101 | // It is valid to create and use the tracer before it is fully configured.
102 | // The only constraint is that it will not be able to flush data until the
103 | // configuration is complete.
104 | if ($component_name != NULL) {
105 | $opts['component_name'] = $component_name;
106 | }
107 | if ($access_token != NULL) {
108 | $opts['access_token'] = $access_token;
109 | }
110 | return new LightStepBase\Client\ClientTracer($opts);
111 | }
112 |
113 | /*
114 | * Tracer API
115 | */
116 |
117 | /**
118 | * @return \LightStepBase\Span
119 | */
120 | public static function startSpan($operationName, $fields = NULL) {
121 | return self::getInstance()->startSpan($operationName, $fields);
122 | }
123 |
124 | public static function flush() {
125 | self::getInstance()->flush();
126 | }
127 |
128 | public static function disable() {
129 | self::getInstance()->disable();
130 | }
131 | };
132 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/KeyValue.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.KeyValue
15 | */
16 | class KeyValue extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Generated from protobuf field string key = 1;
20 | */
21 | private $key = '';
22 | protected $value;
23 |
24 | /**
25 | * Constructor.
26 | *
27 | * @param array $data {
28 | * Optional. Data for populating the Message object.
29 | *
30 | * @type string $key
31 | * @type string $string_value
32 | * Holds arbitrary string data; well-formed JSON strings should go in
33 | * json_value.
34 | * @type int|string $int_value
35 | * @type float $double_value
36 | * @type bool $bool_value
37 | * @type string $json_value
38 | * Must be a well-formed JSON value. Truncated JSON should go in
39 | * string_value. Should not be used for tags.
40 | * }
41 | */
42 | public function __construct($data = NULL) {
43 | \GPBMetadata\Collector::initOnce();
44 | parent::__construct($data);
45 | }
46 |
47 | /**
48 | * Generated from protobuf field string key = 1;
49 | * @return string
50 | */
51 | public function getKey()
52 | {
53 | return $this->key;
54 | }
55 |
56 | /**
57 | * Generated from protobuf field string key = 1;
58 | * @param string $var
59 | * @return $this
60 | */
61 | public function setKey($var)
62 | {
63 | GPBUtil::checkString($var, True);
64 | $this->key = $var;
65 |
66 | return $this;
67 | }
68 |
69 | /**
70 | * Holds arbitrary string data; well-formed JSON strings should go in
71 | * json_value.
72 | *
73 | * Generated from protobuf field string string_value = 2;
74 | * @return string
75 | */
76 | public function getStringValue()
77 | {
78 | return $this->readOneof(2);
79 | }
80 |
81 | /**
82 | * Holds arbitrary string data; well-formed JSON strings should go in
83 | * json_value.
84 | *
85 | * Generated from protobuf field string string_value = 2;
86 | * @param string $var
87 | * @return $this
88 | */
89 | public function setStringValue($var)
90 | {
91 | GPBUtil::checkString($var, True);
92 | $this->writeOneof(2, $var);
93 |
94 | return $this;
95 | }
96 |
97 | /**
98 | * Generated from protobuf field int64 int_value = 3;
99 | * @return int|string
100 | */
101 | public function getIntValue()
102 | {
103 | return $this->readOneof(3);
104 | }
105 |
106 | /**
107 | * Generated from protobuf field int64 int_value = 3;
108 | * @param int|string $var
109 | * @return $this
110 | */
111 | public function setIntValue($var)
112 | {
113 | GPBUtil::checkInt64($var);
114 | $this->writeOneof(3, $var);
115 |
116 | return $this;
117 | }
118 |
119 | /**
120 | * Generated from protobuf field double double_value = 4;
121 | * @return float
122 | */
123 | public function getDoubleValue()
124 | {
125 | return $this->readOneof(4);
126 | }
127 |
128 | /**
129 | * Generated from protobuf field double double_value = 4;
130 | * @param float $var
131 | * @return $this
132 | */
133 | public function setDoubleValue($var)
134 | {
135 | GPBUtil::checkDouble($var);
136 | $this->writeOneof(4, $var);
137 |
138 | return $this;
139 | }
140 |
141 | /**
142 | * Generated from protobuf field bool bool_value = 5;
143 | * @return bool
144 | */
145 | public function getBoolValue()
146 | {
147 | return $this->readOneof(5);
148 | }
149 |
150 | /**
151 | * Generated from protobuf field bool bool_value = 5;
152 | * @param bool $var
153 | * @return $this
154 | */
155 | public function setBoolValue($var)
156 | {
157 | GPBUtil::checkBool($var);
158 | $this->writeOneof(5, $var);
159 |
160 | return $this;
161 | }
162 |
163 | /**
164 | * Must be a well-formed JSON value. Truncated JSON should go in
165 | * string_value. Should not be used for tags.
166 | *
167 | * Generated from protobuf field string json_value = 6;
168 | * @return string
169 | */
170 | public function getJsonValue()
171 | {
172 | return $this->readOneof(6);
173 | }
174 |
175 | /**
176 | * Must be a well-formed JSON value. Truncated JSON should go in
177 | * string_value. Should not be used for tags.
178 | *
179 | * Generated from protobuf field string json_value = 6;
180 | * @param string $var
181 | * @return $this
182 | */
183 | public function setJsonValue($var)
184 | {
185 | GPBUtil::checkString($var, True);
186 | $this->writeOneof(6, $var);
187 |
188 | return $this;
189 | }
190 |
191 | /**
192 | * @return string
193 | */
194 | public function getValue()
195 | {
196 | return $this->whichOneof("value");
197 | }
198 |
199 | }
200 |
201 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/InternalMetrics.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.InternalMetrics
13 | */
14 | class InternalMetrics extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field .google.protobuf.Timestamp start_timestamp = 1;
18 | */
19 | private $start_timestamp = null;
20 | /**
21 | * Generated from protobuf field uint64 duration_micros = 2;
22 | */
23 | private $duration_micros = 0;
24 | /**
25 | * Generated from protobuf field repeated .lightstep.collector.Log logs = 3;
26 | */
27 | private $logs;
28 | /**
29 | * Generated from protobuf field repeated .lightstep.collector.MetricsSample counts = 4;
30 | */
31 | private $counts;
32 | /**
33 | * Generated from protobuf field repeated .lightstep.collector.MetricsSample gauges = 5;
34 | */
35 | private $gauges;
36 |
37 | /**
38 | * Constructor.
39 | *
40 | * @param array $data {
41 | * Optional. Data for populating the Message object.
42 | *
43 | * @type \Google\Protobuf\Timestamp $start_timestamp
44 | * @type int|string $duration_micros
45 | * @type \Lightstep\Collector\Log[]|\Google\Protobuf\Internal\RepeatedField $logs
46 | * @type \Lightstep\Collector\MetricsSample[]|\Google\Protobuf\Internal\RepeatedField $counts
47 | * @type \Lightstep\Collector\MetricsSample[]|\Google\Protobuf\Internal\RepeatedField $gauges
48 | * }
49 | */
50 | public function __construct($data = NULL) {
51 | \GPBMetadata\Collector::initOnce();
52 | parent::__construct($data);
53 | }
54 |
55 | /**
56 | * Generated from protobuf field .google.protobuf.Timestamp start_timestamp = 1;
57 | * @return \Google\Protobuf\Timestamp
58 | */
59 | public function getStartTimestamp()
60 | {
61 | return $this->start_timestamp;
62 | }
63 |
64 | /**
65 | * Generated from protobuf field .google.protobuf.Timestamp start_timestamp = 1;
66 | * @param \Google\Protobuf\Timestamp $var
67 | * @return $this
68 | */
69 | public function setStartTimestamp($var)
70 | {
71 | GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
72 | $this->start_timestamp = $var;
73 |
74 | return $this;
75 | }
76 |
77 | /**
78 | * Generated from protobuf field uint64 duration_micros = 2;
79 | * @return int|string
80 | */
81 | public function getDurationMicros()
82 | {
83 | return $this->duration_micros;
84 | }
85 |
86 | /**
87 | * Generated from protobuf field uint64 duration_micros = 2;
88 | * @param int|string $var
89 | * @return $this
90 | */
91 | public function setDurationMicros($var)
92 | {
93 | GPBUtil::checkUint64($var);
94 | $this->duration_micros = $var;
95 |
96 | return $this;
97 | }
98 |
99 | /**
100 | * Generated from protobuf field repeated .lightstep.collector.Log logs = 3;
101 | * @return \Google\Protobuf\Internal\RepeatedField
102 | */
103 | public function getLogs()
104 | {
105 | return $this->logs;
106 | }
107 |
108 | /**
109 | * Generated from protobuf field repeated .lightstep.collector.Log logs = 3;
110 | * @param \Lightstep\Collector\Log[]|\Google\Protobuf\Internal\RepeatedField $var
111 | * @return $this
112 | */
113 | public function setLogs($var)
114 | {
115 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\Log::class);
116 | $this->logs = $arr;
117 |
118 | return $this;
119 | }
120 |
121 | /**
122 | * Generated from protobuf field repeated .lightstep.collector.MetricsSample counts = 4;
123 | * @return \Google\Protobuf\Internal\RepeatedField
124 | */
125 | public function getCounts()
126 | {
127 | return $this->counts;
128 | }
129 |
130 | /**
131 | * Generated from protobuf field repeated .lightstep.collector.MetricsSample counts = 4;
132 | * @param \Lightstep\Collector\MetricsSample[]|\Google\Protobuf\Internal\RepeatedField $var
133 | * @return $this
134 | */
135 | public function setCounts($var)
136 | {
137 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\MetricsSample::class);
138 | $this->counts = $arr;
139 |
140 | return $this;
141 | }
142 |
143 | /**
144 | * Generated from protobuf field repeated .lightstep.collector.MetricsSample gauges = 5;
145 | * @return \Google\Protobuf\Internal\RepeatedField
146 | */
147 | public function getGauges()
148 | {
149 | return $this->gauges;
150 | }
151 |
152 | /**
153 | * Generated from protobuf field repeated .lightstep.collector.MetricsSample gauges = 5;
154 | * @param \Lightstep\Collector\MetricsSample[]|\Google\Protobuf\Internal\RepeatedField $var
155 | * @return $this
156 | */
157 | public function setGauges($var)
158 | {
159 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\MetricsSample::class);
160 | $this->gauges = $arr;
161 |
162 | return $this;
163 | }
164 |
165 | }
166 |
167 |
--------------------------------------------------------------------------------
/lib/generated/GPBMetadata/Collector.php:
--------------------------------------------------------------------------------
1 | internalAddGeneratedFile(hex2bin(
20 | "0ac5100a0f636f6c6c6563746f722e70726f746f12136c69676874737465" .
21 | "702e636f6c6c6563746f721a1c676f6f676c652f6170692f616e6e6f7461" .
22 | "74696f6e732e70726f746f22a0010a0b5370616e436f6e7465787412100a" .
23 | "0874726163655f6964180120012804120f0a077370616e5f696418022001" .
24 | "2804123e0a076261676761676518032003280b322d2e6c69676874737465" .
25 | "702e636f6c6c6563746f722e5370616e436f6e746578742e426167676167" .
26 | "65456e7472791a2e0a0c42616767616765456e747279120b0a036b657918" .
27 | "0120012809120d0a0576616c75651802200128093a0238012291010a084b" .
28 | "657956616c7565120b0a036b657918012001280912160a0c737472696e67" .
29 | "5f76616c7565180220012809480012130a09696e745f76616c7565180320" .
30 | "012803480012160a0c646f75626c655f76616c7565180420012801480012" .
31 | "140a0a626f6f6c5f76616c7565180520012808480012140a0a6a736f6e5f" .
32 | "76616c7565180620012809480042070a0576616c756522630a034c6f6712" .
33 | "2d0a0974696d657374616d7018012001280b321a2e676f6f676c652e7072" .
34 | "6f746f6275662e54696d657374616d70122d0a066669656c647318022003" .
35 | "280b321d2e6c69676874737465702e636f6c6c6563746f722e4b65795661" .
36 | "6c756522b6010a095265666572656e636512410a0c72656c6174696f6e73" .
37 | "68697018012001280e322b2e6c69676874737465702e636f6c6c6563746f" .
38 | "722e5265666572656e63652e52656c6174696f6e7368697012360a0c7370" .
39 | "616e5f636f6e7465787418022001280b32202e6c69676874737465702e63" .
40 | "6f6c6c6563746f722e5370616e436f6e74657874222e0a0c52656c617469" .
41 | "6f6e73686970120c0a084348494c445f4f46100012100a0c464f4c4c4f57" .
42 | "535f46524f4d100122ad020a045370616e12360a0c7370616e5f636f6e74" .
43 | "65787418012001280b32202e6c69676874737465702e636f6c6c6563746f" .
44 | "722e5370616e436f6e7465787412160a0e6f7065726174696f6e5f6e616d" .
45 | "6518022001280912320a0a7265666572656e63657318032003280b321e2e" .
46 | "6c69676874737465702e636f6c6c6563746f722e5265666572656e636512" .
47 | "330a0f73746172745f74696d657374616d7018042001280b321a2e676f6f" .
48 | "676c652e70726f746f6275662e54696d657374616d7012170a0f64757261" .
49 | "74696f6e5f6d6963726f73180520012804122b0a04746167731806200328" .
50 | "0b321d2e6c69676874737465702e636f6c6c6563746f722e4b657956616c" .
51 | "756512260a046c6f677318072003280b32182e6c69676874737465702e63" .
52 | "6f6c6c6563746f722e4c6f67224c0a085265706f7274657212130a0b7265" .
53 | "706f727465725f6964180120012804122b0a047461677318042003280b32" .
54 | "1d2e6c69676874737465702e636f6c6c6563746f722e4b657956616c7565" .
55 | "22530a0d4d65747269637353616d706c65120c0a046e616d651801200128" .
56 | "0912130a09696e745f76616c7565180220012803480012160a0c646f7562" .
57 | "6c655f76616c7565180320012801480042070a0576616c756522ef010a0f" .
58 | "496e7465726e616c4d65747269637312330a0f73746172745f74696d6573" .
59 | "74616d7018012001280b321a2e676f6f676c652e70726f746f6275662e54" .
60 | "696d657374616d7012170a0f6475726174696f6e5f6d6963726f73180220" .
61 | "01280412260a046c6f677318032003280b32182e6c69676874737465702e" .
62 | "636f6c6c6563746f722e4c6f6712320a06636f756e747318042003280b32" .
63 | "222e6c69676874737465702e636f6c6c6563746f722e4d65747269637353" .
64 | "616d706c6512320a0667617567657318052003280b32222e6c6967687473" .
65 | "7465702e636f6c6c6563746f722e4d65747269637353616d706c65221c0a" .
66 | "044175746812140a0c6163636573735f746f6b656e18012001280922f401" .
67 | "0a0d5265706f727452657175657374122f0a087265706f72746572180120" .
68 | "01280b321d2e6c69676874737465702e636f6c6c6563746f722e5265706f" .
69 | "7274657212270a046175746818022001280b32192e6c6967687473746570" .
70 | "2e636f6c6c6563746f722e4175746812280a057370616e7318032003280b" .
71 | "32192e6c69676874737465702e636f6c6c6563746f722e5370616e121f0a" .
72 | "1774696d657374616d705f6f66667365745f6d6963726f73180520012803" .
73 | "123e0a10696e7465726e616c5f6d65747269637318062001280b32242e6c" .
74 | "69676874737465702e636f6c6c6563746f722e496e7465726e616c4d6574" .
75 | "72696373221a0a07436f6d6d616e64120f0a0764697361626c6518012001" .
76 | "280822e0010a0e5265706f7274526573706f6e7365122e0a08636f6d6d61" .
77 | "6e647318012003280b321c2e6c69676874737465702e636f6c6c6563746f" .
78 | "722e436f6d6d616e6412350a11726563656976655f74696d657374616d70" .
79 | "18022001280b321a2e676f6f676c652e70726f746f6275662e54696d6573" .
80 | "74616d7012360a127472616e736d69745f74696d657374616d7018032001" .
81 | "280b321a2e676f6f676c652e70726f746f6275662e54696d657374616d70" .
82 | "120e0a066572726f727318042003280912100a087761726e696e67731805" .
83 | "20032809120d0a05696e666f731806200328093295010a10436f6c6c6563" .
84 | "746f72536572766963651280010a065265706f727412222e6c6967687473" .
85 | "7465702e636f6c6c6563746f722e5265706f7274526571756573741a232e" .
86 | "6c69676874737465702e636f6c6c6563746f722e5265706f727452657370" .
87 | "6f6e7365222d82d3e4930227220f2f6170692f76322f7265706f7274733a" .
88 | "012a5a11120f2f6170692f76322f7265706f72747342310a19636f6d2e6c" .
89 | "69676874737465702e7472616365722e6772706350015a0b636f6c6c6563" .
90 | "746f727062a202044c535042620670726f746f33"
91 | ));
92 |
93 | static::$is_initialized = true;
94 | }
95 | }
96 |
97 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/ReportResponse.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.ReportResponse
13 | */
14 | class ReportResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field repeated .lightstep.collector.Command commands = 1;
18 | */
19 | private $commands;
20 | /**
21 | * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 2;
22 | */
23 | private $receive_timestamp = null;
24 | /**
25 | * Generated from protobuf field .google.protobuf.Timestamp transmit_timestamp = 3;
26 | */
27 | private $transmit_timestamp = null;
28 | /**
29 | * Generated from protobuf field repeated string errors = 4;
30 | */
31 | private $errors;
32 | /**
33 | * Generated from protobuf field repeated string warnings = 5;
34 | */
35 | private $warnings;
36 | /**
37 | * Generated from protobuf field repeated string infos = 6;
38 | */
39 | private $infos;
40 |
41 | /**
42 | * Constructor.
43 | *
44 | * @param array $data {
45 | * Optional. Data for populating the Message object.
46 | *
47 | * @type \Lightstep\Collector\Command[]|\Google\Protobuf\Internal\RepeatedField $commands
48 | * @type \Google\Protobuf\Timestamp $receive_timestamp
49 | * @type \Google\Protobuf\Timestamp $transmit_timestamp
50 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $errors
51 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $warnings
52 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $infos
53 | * }
54 | */
55 | public function __construct($data = NULL) {
56 | \GPBMetadata\Collector::initOnce();
57 | parent::__construct($data);
58 | }
59 |
60 | /**
61 | * Generated from protobuf field repeated .lightstep.collector.Command commands = 1;
62 | * @return \Google\Protobuf\Internal\RepeatedField
63 | */
64 | public function getCommands()
65 | {
66 | return $this->commands;
67 | }
68 |
69 | /**
70 | * Generated from protobuf field repeated .lightstep.collector.Command commands = 1;
71 | * @param \Lightstep\Collector\Command[]|\Google\Protobuf\Internal\RepeatedField $var
72 | * @return $this
73 | */
74 | public function setCommands($var)
75 | {
76 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\Command::class);
77 | $this->commands = $arr;
78 |
79 | return $this;
80 | }
81 |
82 | /**
83 | * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 2;
84 | * @return \Google\Protobuf\Timestamp
85 | */
86 | public function getReceiveTimestamp()
87 | {
88 | return $this->receive_timestamp;
89 | }
90 |
91 | /**
92 | * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 2;
93 | * @param \Google\Protobuf\Timestamp $var
94 | * @return $this
95 | */
96 | public function setReceiveTimestamp($var)
97 | {
98 | GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
99 | $this->receive_timestamp = $var;
100 |
101 | return $this;
102 | }
103 |
104 | /**
105 | * Generated from protobuf field .google.protobuf.Timestamp transmit_timestamp = 3;
106 | * @return \Google\Protobuf\Timestamp
107 | */
108 | public function getTransmitTimestamp()
109 | {
110 | return $this->transmit_timestamp;
111 | }
112 |
113 | /**
114 | * Generated from protobuf field .google.protobuf.Timestamp transmit_timestamp = 3;
115 | * @param \Google\Protobuf\Timestamp $var
116 | * @return $this
117 | */
118 | public function setTransmitTimestamp($var)
119 | {
120 | GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
121 | $this->transmit_timestamp = $var;
122 |
123 | return $this;
124 | }
125 |
126 | /**
127 | * Generated from protobuf field repeated string errors = 4;
128 | * @return \Google\Protobuf\Internal\RepeatedField
129 | */
130 | public function getErrors()
131 | {
132 | return $this->errors;
133 | }
134 |
135 | /**
136 | * Generated from protobuf field repeated string errors = 4;
137 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
138 | * @return $this
139 | */
140 | public function setErrors($var)
141 | {
142 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
143 | $this->errors = $arr;
144 |
145 | return $this;
146 | }
147 |
148 | /**
149 | * Generated from protobuf field repeated string warnings = 5;
150 | * @return \Google\Protobuf\Internal\RepeatedField
151 | */
152 | public function getWarnings()
153 | {
154 | return $this->warnings;
155 | }
156 |
157 | /**
158 | * Generated from protobuf field repeated string warnings = 5;
159 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
160 | * @return $this
161 | */
162 | public function setWarnings($var)
163 | {
164 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
165 | $this->warnings = $arr;
166 |
167 | return $this;
168 | }
169 |
170 | /**
171 | * Generated from protobuf field repeated string infos = 6;
172 | * @return \Google\Protobuf\Internal\RepeatedField
173 | */
174 | public function getInfos()
175 | {
176 | return $this->infos;
177 | }
178 |
179 | /**
180 | * Generated from protobuf field repeated string infos = 6;
181 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
182 | * @return $this
183 | */
184 | public function setInfos($var)
185 | {
186 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
187 | $this->infos = $arr;
188 |
189 | return $this;
190 | }
191 |
192 | }
193 |
194 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/ClassLoader/ThriftClassLoader.php:
--------------------------------------------------------------------------------
1 | apc = $apc;
62 | $this->apc_prefix = $apc_prefix;
63 | }
64 |
65 | /**
66 | * Registers a namespace.
67 | *
68 | * @param string $namespace The namespace
69 | * @param array|string $paths The location(s) of the namespace
70 | */
71 | public function registerNamespace($namespace, $paths)
72 | {
73 | $this->namespaces[$namespace] = (array) $paths;
74 | }
75 |
76 | /**
77 | * Registers a Thrift definition namespace.
78 | *
79 | * @param string $namespace The definition namespace
80 | * @param array|string $paths The location(s) of the definition namespace
81 | */
82 | public function registerDefinition($namespace, $paths)
83 | {
84 | $this->definitions[$namespace] = (array) $paths;
85 | }
86 |
87 | /**
88 | * Registers this instance as an autoloader.
89 | *
90 | * @param Boolean $prepend Whether to prepend the autoloader or not
91 | */
92 | public function register($prepend = false)
93 | {
94 | spl_autoload_register(array($this, 'loadClass'), true, $prepend);
95 | }
96 |
97 | /**
98 | * Loads the given class, definition or interface.
99 | *
100 | * @param string $class The name of the class
101 | */
102 | public function loadClass($class)
103 | {
104 | if (
105 | (true === $this->apc && ($file = $this->findFileInApc($class))) or
106 | ($file = $this->findFile($class))
107 | )
108 | {
109 | require_once $file;
110 | }
111 | }
112 |
113 | /**
114 | * Loads the given class or interface in APC.
115 | * @param string $class The name of the class
116 | * @return string
117 | */
118 | protected function findFileInApc($class)
119 | {
120 | if (false === $file = apc_fetch($this->apc_prefix.$class)) {
121 | apc_store($this->apc_prefix.$class, $file = $this->findFile($class));
122 | }
123 |
124 | return $file;
125 | }
126 |
127 | /**
128 | * Find class in namespaces or definitions directories
129 | * @param string $class
130 | * @return string
131 | */
132 | public function findFile($class)
133 | {
134 | // Remove first backslash
135 | if ('\\' == $class[0])
136 | {
137 | $class = substr($class, 1);
138 | }
139 |
140 | if (false !== $pos = strrpos($class, '\\'))
141 | {
142 | // Namespaced class name
143 | $namespace = substr($class, 0, $pos);
144 |
145 | // Iterate in normal namespaces
146 | foreach ($this->namespaces as $ns => $dirs)
147 | {
148 | //Don't interfere with other autoloaders
149 | if (0 !== strpos($namespace, $ns))
150 | {
151 | continue;
152 | }
153 |
154 | foreach ($dirs as $dir)
155 | {
156 | $className = substr($class, $pos + 1);
157 |
158 | $file = $dir.DIRECTORY_SEPARATOR.
159 | str_replace('\\', DIRECTORY_SEPARATOR, $namespace).
160 | DIRECTORY_SEPARATOR.
161 | $className.'.php';
162 |
163 | if (file_exists($file))
164 | {
165 | return $file;
166 | }
167 | }
168 | }
169 |
170 | // Iterate in Thrift namespaces
171 |
172 | // Remove first part of namespace
173 | $m = explode('\\', $class);
174 |
175 | // Ignore wrong call
176 | if(count($m) <= 1)
177 | {
178 | return;
179 | }
180 |
181 | $class = array_pop($m);
182 | $namespace = implode('\\', $m);
183 |
184 | foreach ($this->definitions as $ns => $dirs)
185 | {
186 | //Don't interfere with other autoloaders
187 | if (0 !== strpos($namespace, $ns))
188 | {
189 | continue;
190 | }
191 |
192 | foreach ($dirs as $dir)
193 | {
194 | /**
195 | * Available in service: Interface, Client, Processor, Rest
196 | * And every service methods (_.+)
197 | */
198 | if(
199 | 0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) and
200 | 0 === preg_match('#(.+)_[a-z0-9]+_(args|result)$#i', $class, $n)
201 | )
202 | {
203 | $className = 'Types';
204 | }
205 | else
206 | {
207 | $className = $n[1];
208 | }
209 |
210 | $file = $dir.DIRECTORY_SEPARATOR .
211 | str_replace('\\', DIRECTORY_SEPARATOR, $namespace) .
212 | DIRECTORY_SEPARATOR .
213 | $className . '.php';
214 |
215 | if (file_exists($file))
216 | {
217 | return $file;
218 | }
219 | }
220 | }
221 | }
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/lib/generated/Lightstep/Collector/Span.php:
--------------------------------------------------------------------------------
1 | lightstep.collector.Span
13 | */
14 | class Span extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field .lightstep.collector.SpanContext span_context = 1;
18 | */
19 | private $span_context = null;
20 | /**
21 | * Generated from protobuf field string operation_name = 2;
22 | */
23 | private $operation_name = '';
24 | /**
25 | * Generated from protobuf field repeated .lightstep.collector.Reference references = 3;
26 | */
27 | private $references;
28 | /**
29 | * Generated from protobuf field .google.protobuf.Timestamp start_timestamp = 4;
30 | */
31 | private $start_timestamp = null;
32 | /**
33 | * Generated from protobuf field uint64 duration_micros = 5;
34 | */
35 | private $duration_micros = 0;
36 | /**
37 | * Generated from protobuf field repeated .lightstep.collector.KeyValue tags = 6;
38 | */
39 | private $tags;
40 | /**
41 | * Generated from protobuf field repeated .lightstep.collector.Log logs = 7;
42 | */
43 | private $logs;
44 |
45 | /**
46 | * Constructor.
47 | *
48 | * @param array $data {
49 | * Optional. Data for populating the Message object.
50 | *
51 | * @type \Lightstep\Collector\SpanContext $span_context
52 | * @type string $operation_name
53 | * @type \Lightstep\Collector\Reference[]|\Google\Protobuf\Internal\RepeatedField $references
54 | * @type \Google\Protobuf\Timestamp $start_timestamp
55 | * @type int|string $duration_micros
56 | * @type \Lightstep\Collector\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $tags
57 | * @type \Lightstep\Collector\Log[]|\Google\Protobuf\Internal\RepeatedField $logs
58 | * }
59 | */
60 | public function __construct($data = NULL) {
61 | \GPBMetadata\Collector::initOnce();
62 | parent::__construct($data);
63 | }
64 |
65 | /**
66 | * Generated from protobuf field .lightstep.collector.SpanContext span_context = 1;
67 | * @return \Lightstep\Collector\SpanContext
68 | */
69 | public function getSpanContext()
70 | {
71 | return $this->span_context;
72 | }
73 |
74 | /**
75 | * Generated from protobuf field .lightstep.collector.SpanContext span_context = 1;
76 | * @param \Lightstep\Collector\SpanContext $var
77 | * @return $this
78 | */
79 | public function setSpanContext($var)
80 | {
81 | GPBUtil::checkMessage($var, \Lightstep\Collector\SpanContext::class);
82 | $this->span_context = $var;
83 |
84 | return $this;
85 | }
86 |
87 | /**
88 | * Generated from protobuf field string operation_name = 2;
89 | * @return string
90 | */
91 | public function getOperationName()
92 | {
93 | return $this->operation_name;
94 | }
95 |
96 | /**
97 | * Generated from protobuf field string operation_name = 2;
98 | * @param string $var
99 | * @return $this
100 | */
101 | public function setOperationName($var)
102 | {
103 | GPBUtil::checkString($var, True);
104 | $this->operation_name = $var;
105 |
106 | return $this;
107 | }
108 |
109 | /**
110 | * Generated from protobuf field repeated .lightstep.collector.Reference references = 3;
111 | * @return \Google\Protobuf\Internal\RepeatedField
112 | */
113 | public function getReferences()
114 | {
115 | return $this->references;
116 | }
117 |
118 | /**
119 | * Generated from protobuf field repeated .lightstep.collector.Reference references = 3;
120 | * @param \Lightstep\Collector\Reference[]|\Google\Protobuf\Internal\RepeatedField $var
121 | * @return $this
122 | */
123 | public function setReferences($var)
124 | {
125 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\Reference::class);
126 | $this->references = $arr;
127 |
128 | return $this;
129 | }
130 |
131 | /**
132 | * Generated from protobuf field .google.protobuf.Timestamp start_timestamp = 4;
133 | * @return \Google\Protobuf\Timestamp
134 | */
135 | public function getStartTimestamp()
136 | {
137 | return $this->start_timestamp;
138 | }
139 |
140 | /**
141 | * Generated from protobuf field .google.protobuf.Timestamp start_timestamp = 4;
142 | * @param \Google\Protobuf\Timestamp $var
143 | * @return $this
144 | */
145 | public function setStartTimestamp($var)
146 | {
147 | GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
148 | $this->start_timestamp = $var;
149 |
150 | return $this;
151 | }
152 |
153 | /**
154 | * Generated from protobuf field uint64 duration_micros = 5;
155 | * @return int|string
156 | */
157 | public function getDurationMicros()
158 | {
159 | return $this->duration_micros;
160 | }
161 |
162 | /**
163 | * Generated from protobuf field uint64 duration_micros = 5;
164 | * @param int|string $var
165 | * @return $this
166 | */
167 | public function setDurationMicros($var)
168 | {
169 | GPBUtil::checkUint64($var);
170 | $this->duration_micros = $var;
171 |
172 | return $this;
173 | }
174 |
175 | /**
176 | * Generated from protobuf field repeated .lightstep.collector.KeyValue tags = 6;
177 | * @return \Google\Protobuf\Internal\RepeatedField
178 | */
179 | public function getTags()
180 | {
181 | return $this->tags;
182 | }
183 |
184 | /**
185 | * Generated from protobuf field repeated .lightstep.collector.KeyValue tags = 6;
186 | * @param \Lightstep\Collector\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var
187 | * @return $this
188 | */
189 | public function setTags($var)
190 | {
191 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\KeyValue::class);
192 | $this->tags = $arr;
193 |
194 | return $this;
195 | }
196 |
197 | /**
198 | * Generated from protobuf field repeated .lightstep.collector.Log logs = 7;
199 | * @return \Google\Protobuf\Internal\RepeatedField
200 | */
201 | public function getLogs()
202 | {
203 | return $this->logs;
204 | }
205 |
206 | /**
207 | * Generated from protobuf field repeated .lightstep.collector.Log logs = 7;
208 | * @param \Lightstep\Collector\Log[]|\Google\Protobuf\Internal\RepeatedField $var
209 | * @return $this
210 | */
211 | public function setLogs($var)
212 | {
213 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Lightstep\Collector\Log::class);
214 | $this->logs = $arr;
215 |
216 | return $this;
217 | }
218 |
219 | }
220 |
221 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Protocol/TProtocolDecorator.php:
--------------------------------------------------------------------------------
1 | TProtocolDecorator forwards all requests to an enclosed
28 | * TProtocol instance, providing a way to author concise
29 | * concrete decorator subclasses. While it has no abstract methods, it
30 | * is marked abstract as a reminder that by itself, it does not modify
31 | * the behaviour of the enclosed TProtocol.
32 | *
33 | * @package Thrift\Protocol
34 | */
35 | abstract class TProtocolDecorator extends TProtocol
36 | {
37 | /**
38 | * Instance of protocol, to which all operations will be forwarded.
39 | *
40 | * @var TProtocol
41 | */
42 | private $concreteProtocol_;
43 |
44 | /**
45 | * Constructor of TProtocolDecorator class.
46 | * Encloses the specified protocol.
47 | *
48 | * @param TProtocol $protocol All operations will be forward to this instance. Must be non-null.
49 | */
50 | protected function __construct(TProtocol $protocol)
51 | {
52 | parent::__construct($protocol->getTransport());
53 | $this->concreteProtocol_ = $protocol;
54 | }
55 |
56 | /**
57 | * Writes the message header.
58 | *
59 | * @param string $name Function name
60 | * @param int $type message type TMessageType::CALL or TMessageType::REPLY
61 | * @param int $seqid The sequence id of this message
62 | */
63 | public function writeMessageBegin($name, $type, $seqid)
64 | {
65 | return $this->concreteProtocol_->writeMessageBegin($name, $type, $seqid);
66 | }
67 |
68 | /**
69 | * Closes the message.
70 | */
71 | public function writeMessageEnd()
72 | {
73 | return $this->concreteProtocol_->writeMessageEnd();
74 | }
75 |
76 | /**
77 | * Writes a struct header.
78 | *
79 | * @param string $name Struct name
80 | *
81 | * @throws TException on write error
82 | * @return int How many bytes written
83 | */
84 | public function writeStructBegin($name)
85 | {
86 | return $this->concreteProtocol_->writeStructBegin($name);
87 | }
88 |
89 | /**
90 | * Close a struct.
91 | *
92 | * @throws TException on write error
93 | * @return int How many bytes written
94 | */
95 | public function writeStructEnd()
96 | {
97 | return $this->concreteProtocol_->writeStructEnd();
98 | }
99 |
100 | public function writeFieldBegin($fieldName, $fieldType, $fieldId)
101 | {
102 | return $this->concreteProtocol_->writeFieldBegin($fieldName, $fieldType, $fieldId);
103 | }
104 |
105 | public function writeFieldEnd()
106 | {
107 | return $this->concreteProtocol_->writeFieldEnd();
108 | }
109 |
110 | public function writeFieldStop()
111 | {
112 | return $this->concreteProtocol_->writeFieldStop();
113 | }
114 |
115 | public function writeMapBegin($keyType, $valType, $size)
116 | {
117 | return $this->concreteProtocol_->writeMapBegin($keyType, $valType, $size);
118 | }
119 |
120 | public function writeMapEnd()
121 | {
122 | return $this->concreteProtocol_->writeMapEnd();
123 | }
124 |
125 | public function writeListBegin($elemType, $size)
126 | {
127 | return $this->concreteProtocol_->writeListBegin($elemType, $size);
128 | }
129 |
130 | public function writeListEnd()
131 | {
132 | return $this->concreteProtocol_->writeListEnd();
133 | }
134 |
135 | public function writeSetBegin($elemType, $size)
136 | {
137 | return $this->concreteProtocol_->writeSetBegin($elemType, $size);
138 | }
139 |
140 | public function writeSetEnd()
141 | {
142 | return $this->concreteProtocol_->writeSetEnd();
143 | }
144 |
145 | public function writeBool($bool)
146 | {
147 | return $this->concreteProtocol_->writeBool($bool);
148 | }
149 |
150 | public function writeByte($byte)
151 | {
152 | return $this->concreteProtocol_->writeByte($byte);
153 | }
154 |
155 | public function writeI16($i16)
156 | {
157 | return $this->concreteProtocol_->writeI16($i16);
158 | }
159 |
160 | public function writeI32($i32)
161 | {
162 | return $this->concreteProtocol_->writeI32($i32);
163 | }
164 |
165 | public function writeI64($i64)
166 | {
167 | return $this->concreteProtocol_->writeI64($i64);
168 | }
169 |
170 | public function writeDouble($dub)
171 | {
172 | return $this->concreteProtocol_->writeDouble($dub);
173 | }
174 |
175 | public function writeString($str)
176 | {
177 | return $this->concreteProtocol_->writeString($str);
178 | }
179 |
180 | /**
181 | * Reads the message header
182 | *
183 | * @param string $name Function name
184 | * @param int $type message type TMessageType::CALL or TMessageType::REPLY
185 | * @param int $seqid The sequence id of this message
186 | */
187 | public function readMessageBegin(&$name, &$type, &$seqid)
188 | {
189 | return $this->concreteProtocol_->readMessageBegin($name, $type, $seqid);
190 | }
191 |
192 | /**
193 | * Read the close of message
194 | */
195 | public function readMessageEnd()
196 | {
197 | return $this->concreteProtocol_->readMessageEnd();
198 | }
199 |
200 | public function readStructBegin(&$name)
201 | {
202 | return $this->concreteProtocol_->readStructBegin($name);
203 | }
204 |
205 | public function readStructEnd()
206 | {
207 | return $this->concreteProtocol_->readStructEnd();
208 | }
209 |
210 | public function readFieldBegin(&$name, &$fieldType, &$fieldId)
211 | {
212 | return $this->concreteProtocol_->readFieldBegin($name, $fieldType, $fieldId);
213 | }
214 |
215 | public function readFieldEnd()
216 | {
217 | return $this->concreteProtocol_->readFieldEnd();
218 | }
219 |
220 | public function readMapBegin(&$keyType, &$valType, &$size)
221 | {
222 | $this->concreteProtocol_->readMapBegin($keyType, $valType, $size);
223 | }
224 |
225 | public function readMapEnd()
226 | {
227 | return $this->concreteProtocol_->readMapEnd();
228 | }
229 |
230 | public function readListBegin(&$elemType, &$size)
231 | {
232 | $this->concreteProtocol_->readListBegin($elemType, $size);
233 | }
234 |
235 | public function readListEnd()
236 | {
237 | return $this->concreteProtocol_->readListEnd();
238 | }
239 |
240 | public function readSetBegin(&$elemType, &$size)
241 | {
242 | return $this->concreteProtocol_->readSetBegin($elemType, $size);
243 | }
244 |
245 | public function readSetEnd()
246 | {
247 | return $this->concreteProtocol_->readSetEnd();
248 | }
249 |
250 | public function readBool(&$bool)
251 | {
252 | return $this->concreteProtocol_->readBool($bool);
253 | }
254 |
255 | public function readByte(&$byte)
256 | {
257 | return $this->concreteProtocol_->readByte($byte);
258 | }
259 |
260 | public function readI16(&$i16)
261 | {
262 | return $this->concreteProtocol_->readI16($i16);
263 | }
264 |
265 | public function readI32(&$i32)
266 | {
267 | return $this->concreteProtocol_->readI32($i32);
268 | }
269 |
270 | public function readI64(&$i64)
271 | {
272 | return $this->concreteProtocol_->readI64($i64);
273 | }
274 |
275 | public function readDouble(&$dub)
276 | {
277 | return $this->concreteProtocol_->readDouble($dub);
278 | }
279 |
280 | public function readString(&$str)
281 | {
282 | return $this->concreteProtocol_->readString($str);
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/thrift/CroutonThrift/ReportingService.php:
--------------------------------------------------------------------------------
1 | input_ = $input;
36 | $this->output_ = $output ? $output : $input;
37 | }
38 |
39 | public function Report(\CroutonThrift\Auth $auth, \CroutonThrift\ReportRequest $request)
40 | {
41 | $this->send_Report($auth, $request);
42 | return $this->recv_Report();
43 | }
44 |
45 | public function send_Report(\CroutonThrift\Auth $auth, \CroutonThrift\ReportRequest $request)
46 | {
47 | $args = new \CroutonThrift\ReportingService_Report_args();
48 | $args->auth = $auth;
49 | $args->request = $request;
50 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
51 | if ($bin_accel)
52 | {
53 | thrift_protocol_write_binary($this->output_, 'Report', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
54 | }
55 | else
56 | {
57 | $this->output_->writeMessageBegin('Report', TMessageType::CALL, $this->seqid_);
58 | $args->write($this->output_);
59 | $this->output_->writeMessageEnd();
60 | $this->output_->getTransport()->flush();
61 | }
62 | }
63 |
64 | public function recv_Report()
65 | {
66 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
67 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\CroutonThrift\ReportingService_Report_result', $this->input_->isStrictRead());
68 | else
69 | {
70 | $rseqid = 0;
71 | $fname = null;
72 | $mtype = 0;
73 |
74 | $this->input_->readMessageBegin($fname, $mtype, $rseqid);
75 | if ($mtype == TMessageType::EXCEPTION) {
76 | $x = new TApplicationException();
77 | $x->read($this->input_);
78 | $this->input_->readMessageEnd();
79 | throw $x;
80 | }
81 | $result = new \CroutonThrift\ReportingService_Report_result();
82 | $result->read($this->input_);
83 | $this->input_->readMessageEnd();
84 | }
85 | if ($result->success !== null) {
86 | return $result->success;
87 | }
88 | throw new \Exception("Report failed: unknown result");
89 | }
90 |
91 | }
92 |
93 | // HELPER FUNCTIONS AND STRUCTURES
94 |
95 | class ReportingService_Report_args {
96 | static $_TSPEC;
97 |
98 | /**
99 | * @var \CroutonThrift\Auth
100 | */
101 | public $auth = null;
102 | /**
103 | * @var \CroutonThrift\ReportRequest
104 | */
105 | public $request = null;
106 |
107 | public function __construct($vals=null) {
108 | if (!isset(self::$_TSPEC)) {
109 | self::$_TSPEC = array(
110 | 1 => array(
111 | 'var' => 'auth',
112 | 'type' => TType::STRUCT,
113 | 'class' => '\CroutonThrift\Auth',
114 | ),
115 | 2 => array(
116 | 'var' => 'request',
117 | 'type' => TType::STRUCT,
118 | 'class' => '\CroutonThrift\ReportRequest',
119 | ),
120 | );
121 | }
122 | if (is_array($vals)) {
123 | if (isset($vals['auth'])) {
124 | $this->auth = $vals['auth'];
125 | }
126 | if (isset($vals['request'])) {
127 | $this->request = $vals['request'];
128 | }
129 | }
130 | }
131 |
132 | public function getName() {
133 | return 'ReportingService_Report_args';
134 | }
135 |
136 | public function read($input)
137 | {
138 | $xfer = 0;
139 | $fname = null;
140 | $ftype = 0;
141 | $fid = 0;
142 | $xfer += $input->readStructBegin($fname);
143 | while (true)
144 | {
145 | $xfer += $input->readFieldBegin($fname, $ftype, $fid);
146 | if ($ftype == TType::STOP) {
147 | break;
148 | }
149 | switch ($fid)
150 | {
151 | case 1:
152 | if ($ftype == TType::STRUCT) {
153 | $this->auth = new \CroutonThrift\Auth();
154 | $xfer += $this->auth->read($input);
155 | } else {
156 | $xfer += $input->skip($ftype);
157 | }
158 | break;
159 | case 2:
160 | if ($ftype == TType::STRUCT) {
161 | $this->request = new \CroutonThrift\ReportRequest();
162 | $xfer += $this->request->read($input);
163 | } else {
164 | $xfer += $input->skip($ftype);
165 | }
166 | break;
167 | default:
168 | $xfer += $input->skip($ftype);
169 | break;
170 | }
171 | $xfer += $input->readFieldEnd();
172 | }
173 | $xfer += $input->readStructEnd();
174 | return $xfer;
175 | }
176 |
177 | public function write($output) {
178 | $xfer = 0;
179 | $xfer += $output->writeStructBegin('ReportingService_Report_args');
180 | if ($this->auth !== null) {
181 | if (!is_object($this->auth)) {
182 | throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
183 | }
184 | $xfer += $output->writeFieldBegin('auth', TType::STRUCT, 1);
185 | $xfer += $this->auth->write($output);
186 | $xfer += $output->writeFieldEnd();
187 | }
188 | if ($this->request !== null) {
189 | if (!is_object($this->request)) {
190 | throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
191 | }
192 | $xfer += $output->writeFieldBegin('request', TType::STRUCT, 2);
193 | $xfer += $this->request->write($output);
194 | $xfer += $output->writeFieldEnd();
195 | }
196 | $xfer += $output->writeFieldStop();
197 | $xfer += $output->writeStructEnd();
198 | return $xfer;
199 | }
200 |
201 | }
202 |
203 | class ReportingService_Report_result {
204 | static $_TSPEC;
205 |
206 | /**
207 | * @var \CroutonThrift\ReportResponse
208 | */
209 | public $success = null;
210 |
211 | public function __construct($vals=null) {
212 | if (!isset(self::$_TSPEC)) {
213 | self::$_TSPEC = array(
214 | 0 => array(
215 | 'var' => 'success',
216 | 'type' => TType::STRUCT,
217 | 'class' => '\CroutonThrift\ReportResponse',
218 | ),
219 | );
220 | }
221 | if (is_array($vals)) {
222 | if (isset($vals['success'])) {
223 | $this->success = $vals['success'];
224 | }
225 | }
226 | }
227 |
228 | public function getName() {
229 | return 'ReportingService_Report_result';
230 | }
231 |
232 | public function read($input)
233 | {
234 | $xfer = 0;
235 | $fname = null;
236 | $ftype = 0;
237 | $fid = 0;
238 | $xfer += $input->readStructBegin($fname);
239 | while (true)
240 | {
241 | $xfer += $input->readFieldBegin($fname, $ftype, $fid);
242 | if ($ftype == TType::STOP) {
243 | break;
244 | }
245 | switch ($fid)
246 | {
247 | case 0:
248 | if ($ftype == TType::STRUCT) {
249 | $this->success = new \CroutonThrift\ReportResponse();
250 | $xfer += $this->success->read($input);
251 | } else {
252 | $xfer += $input->skip($ftype);
253 | }
254 | break;
255 | default:
256 | $xfer += $input->skip($ftype);
257 | break;
258 | }
259 | $xfer += $input->readFieldEnd();
260 | }
261 | $xfer += $input->readStructEnd();
262 | return $xfer;
263 | }
264 |
265 | public function write($output) {
266 | $xfer = 0;
267 | $xfer += $output->writeStructBegin('ReportingService_Report_result');
268 | if ($this->success !== null) {
269 | if (!is_object($this->success)) {
270 | throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
271 | }
272 | $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
273 | $xfer += $this->success->write($output);
274 | $xfer += $output->writeFieldEnd();
275 | }
276 | $xfer += $output->writeFieldStop();
277 | $xfer += $output->writeStructEnd();
278 | return $xfer;
279 | }
280 |
281 | }
282 |
283 |
284 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Protocol/TProtocol.php:
--------------------------------------------------------------------------------
1 | trans_ = $trans;
45 | }
46 |
47 | /**
48 | * Accessor for transport
49 | *
50 | * @return TTransport
51 | */
52 | public function getTransport() {
53 | return $this->trans_;
54 | }
55 |
56 | /**
57 | * Writes the message header
58 | *
59 | * @param string $name Function name
60 | * @param int $type message type TMessageType::CALL or TMessageType::REPLY
61 | * @param int $seqid The sequence id of this message
62 | */
63 | public abstract function writeMessageBegin($name, $type, $seqid);
64 |
65 | /**
66 | * Close the message
67 | */
68 | public abstract function writeMessageEnd();
69 |
70 | /**
71 | * Writes a struct header.
72 | *
73 | * @param string $name Struct name
74 | * @throws TException on write error
75 | * @return int How many bytes written
76 | */
77 | public abstract function writeStructBegin($name);
78 |
79 | /**
80 | * Close a struct.
81 | *
82 | * @throws TException on write error
83 | * @return int How many bytes written
84 | */
85 | public abstract function writeStructEnd();
86 |
87 | /*
88 | * Starts a field.
89 | *
90 | * @param string $name Field name
91 | * @param int $type Field type
92 | * @param int $fid Field id
93 | * @throws TException on write error
94 | * @return int How many bytes written
95 | */
96 | public abstract function writeFieldBegin($fieldName, $fieldType, $fieldId);
97 |
98 | public abstract function writeFieldEnd();
99 |
100 | public abstract function writeFieldStop();
101 |
102 | public abstract function writeMapBegin($keyType, $valType, $size);
103 |
104 | public abstract function writeMapEnd();
105 |
106 | public abstract function writeListBegin($elemType, $size);
107 |
108 | public abstract function writeListEnd();
109 |
110 | public abstract function writeSetBegin($elemType, $size);
111 |
112 | public abstract function writeSetEnd();
113 |
114 | public abstract function writeBool($bool);
115 |
116 | public abstract function writeByte($byte);
117 |
118 | public abstract function writeI16($i16);
119 |
120 | public abstract function writeI32($i32);
121 |
122 | public abstract function writeI64($i64);
123 |
124 | public abstract function writeDouble($dub);
125 |
126 | public abstract function writeString($str);
127 |
128 | /**
129 | * Reads the message header
130 | *
131 | * @param string $name Function name
132 | * @param int $type message type TMessageType::CALL or TMessageType::REPLY
133 | * @parem int $seqid The sequence id of this message
134 | */
135 | public abstract function readMessageBegin(&$name, &$type, &$seqid);
136 |
137 | /**
138 | * Read the close of message
139 | */
140 | public abstract function readMessageEnd();
141 |
142 | public abstract function readStructBegin(&$name);
143 |
144 | public abstract function readStructEnd();
145 |
146 | public abstract function readFieldBegin(&$name, &$fieldType, &$fieldId);
147 |
148 | public abstract function readFieldEnd();
149 |
150 | public abstract function readMapBegin(&$keyType, &$valType, &$size);
151 |
152 | public abstract function readMapEnd();
153 |
154 | public abstract function readListBegin(&$elemType, &$size);
155 |
156 | public abstract function readListEnd();
157 |
158 | public abstract function readSetBegin(&$elemType, &$size);
159 |
160 | public abstract function readSetEnd();
161 |
162 | public abstract function readBool(&$bool);
163 |
164 | public abstract function readByte(&$byte);
165 |
166 | public abstract function readI16(&$i16);
167 |
168 | public abstract function readI32(&$i32);
169 |
170 | public abstract function readI64(&$i64);
171 |
172 | public abstract function readDouble(&$dub);
173 |
174 | public abstract function readString(&$str);
175 |
176 | /**
177 | * The skip function is a utility to parse over unrecognized date without
178 | * causing corruption.
179 | *
180 | * @param TType $type What type is it
181 | */
182 | public function skip($type) {
183 | switch ($type) {
184 | case TType::BOOL:
185 | return $this->readBool($bool);
186 | case TType::BYTE:
187 | return $this->readByte($byte);
188 | case TType::I16:
189 | return $this->readI16($i16);
190 | case TType::I32:
191 | return $this->readI32($i32);
192 | case TType::I64:
193 | return $this->readI64($i64);
194 | case TType::DOUBLE:
195 | return $this->readDouble($dub);
196 | case TType::STRING:
197 | return $this->readString($str);
198 | case TType::STRUCT:
199 | {
200 | $result = $this->readStructBegin($name);
201 | while (true) {
202 | $result += $this->readFieldBegin($name, $ftype, $fid);
203 | if ($ftype == TType::STOP) {
204 | break;
205 | }
206 | $result += $this->skip($ftype);
207 | $result += $this->readFieldEnd();
208 | }
209 | $result += $this->readStructEnd();
210 | return $result;
211 | }
212 | case TType::MAP:
213 | {
214 | $result = $this->readMapBegin($keyType, $valType, $size);
215 | for ($i = 0; $i < $size; $i++) {
216 | $result += $this->skip($keyType);
217 | $result += $this->skip($valType);
218 | }
219 | $result += $this->readMapEnd();
220 | return $result;
221 | }
222 | case TType::SET:
223 | {
224 | $result = $this->readSetBegin($elemType, $size);
225 | for ($i = 0; $i < $size; $i++) {
226 | $result += $this->skip($elemType);
227 | }
228 | $result += $this->readSetEnd();
229 | return $result;
230 | }
231 | case TType::LST:
232 | {
233 | $result = $this->readListBegin($elemType, $size);
234 | for ($i = 0; $i < $size; $i++) {
235 | $result += $this->skip($elemType);
236 | }
237 | $result += $this->readListEnd();
238 | return $result;
239 | }
240 | default:
241 | throw new TProtocolException('Unknown field type: '.$type,
242 | TProtocolException::INVALID_DATA);
243 | }
244 | }
245 |
246 | /**
247 | * Utility for skipping binary data
248 | *
249 | * @param TTransport $itrans TTransport object
250 | * @param int $type Field type
251 | */
252 | public static function skipBinary($itrans, $type) {
253 | switch ($type) {
254 | case TType::BOOL:
255 | return $itrans->readAll(1);
256 | case TType::BYTE:
257 | return $itrans->readAll(1);
258 | case TType::I16:
259 | return $itrans->readAll(2);
260 | case TType::I32:
261 | return $itrans->readAll(4);
262 | case TType::I64:
263 | return $itrans->readAll(8);
264 | case TType::DOUBLE:
265 | return $itrans->readAll(8);
266 | case TType::STRING:
267 | $len = unpack('N', $itrans->readAll(4));
268 | $len = $len[1];
269 | if ($len > 0x7fffffff) {
270 | $len = 0 - (($len - 1) ^ 0xffffffff);
271 | }
272 | return 4 + $itrans->readAll($len);
273 | case TType::STRUCT:
274 | {
275 | $result = 0;
276 | while (true) {
277 | $ftype = 0;
278 | $fid = 0;
279 | $data = $itrans->readAll(1);
280 | $arr = unpack('c', $data);
281 | $ftype = $arr[1];
282 | if ($ftype == TType::STOP) {
283 | break;
284 | }
285 | // I16 field id
286 | $result += $itrans->readAll(2);
287 | $result += self::skipBinary($itrans, $ftype);
288 | }
289 | return $result;
290 | }
291 | case TType::MAP:
292 | {
293 | // Ktype
294 | $data = $itrans->readAll(1);
295 | $arr = unpack('c', $data);
296 | $ktype = $arr[1];
297 | // Vtype
298 | $data = $itrans->readAll(1);
299 | $arr = unpack('c', $data);
300 | $vtype = $arr[1];
301 | // Size
302 | $data = $itrans->readAll(4);
303 | $arr = unpack('N', $data);
304 | $size = $arr[1];
305 | if ($size > 0x7fffffff) {
306 | $size = 0 - (($size - 1) ^ 0xffffffff);
307 | }
308 | $result = 6;
309 | for ($i = 0; $i < $size; $i++) {
310 | $result += self::skipBinary($itrans, $ktype);
311 | $result += self::skipBinary($itrans, $vtype);
312 | }
313 | return $result;
314 | }
315 | case TType::SET:
316 | case TType::LST:
317 | {
318 | // Vtype
319 | $data = $itrans->readAll(1);
320 | $arr = unpack('c', $data);
321 | $vtype = $arr[1];
322 | // Size
323 | $data = $itrans->readAll(4);
324 | $arr = unpack('N', $data);
325 | $size = $arr[1];
326 | if ($size > 0x7fffffff) {
327 | $size = 0 - (($size - 1) ^ 0xffffffff);
328 | }
329 | $result = 5;
330 | for ($i = 0; $i < $size; $i++) {
331 | $result += self::skipBinary($itrans, $vtype);
332 | }
333 | return $result;
334 | }
335 | default:
336 | throw new TProtocolException('Unknown field type: '.$type,
337 | TProtocolException::INVALID_DATA);
338 | }
339 | }
340 | }
341 |
--------------------------------------------------------------------------------
/lib/api.php:
--------------------------------------------------------------------------------
1 | strictRead_ = $strictRead;
45 | $this->strictWrite_ = $strictWrite;
46 | }
47 |
48 | public function writeMessageBegin($name, $type, $seqid) {
49 | if ($this->strictWrite_) {
50 | $version = self::VERSION_1 | $type;
51 | return
52 | $this->writeI32($version) +
53 | $this->writeString($name) +
54 | $this->writeI32($seqid);
55 | } else {
56 | return
57 | $this->writeString($name) +
58 | $this->writeByte($type) +
59 | $this->writeI32($seqid);
60 | }
61 | }
62 |
63 | public function writeMessageEnd() {
64 | return 0;
65 | }
66 |
67 | public function writeStructBegin($name) {
68 | return 0;
69 | }
70 |
71 | public function writeStructEnd() {
72 | return 0;
73 | }
74 |
75 | public function writeFieldBegin($fieldName, $fieldType, $fieldId) {
76 | return
77 | $this->writeByte($fieldType) +
78 | $this->writeI16($fieldId);
79 | }
80 |
81 | public function writeFieldEnd() {
82 | return 0;
83 | }
84 |
85 | public function writeFieldStop() {
86 | return
87 | $this->writeByte(TType::STOP);
88 | }
89 |
90 | public function writeMapBegin($keyType, $valType, $size) {
91 | return
92 | $this->writeByte($keyType) +
93 | $this->writeByte($valType) +
94 | $this->writeI32($size);
95 | }
96 |
97 | public function writeMapEnd() {
98 | return 0;
99 | }
100 |
101 | public function writeListBegin($elemType, $size) {
102 | return
103 | $this->writeByte($elemType) +
104 | $this->writeI32($size);
105 | }
106 |
107 | public function writeListEnd() {
108 | return 0;
109 | }
110 |
111 | public function writeSetBegin($elemType, $size) {
112 | return
113 | $this->writeByte($elemType) +
114 | $this->writeI32($size);
115 | }
116 |
117 | public function writeSetEnd() {
118 | return 0;
119 | }
120 |
121 | public function writeBool($value) {
122 | $data = pack('c', $value ? 1 : 0);
123 | $this->trans_->write($data, 1);
124 | return 1;
125 | }
126 |
127 | public function writeByte($value) {
128 | $data = pack('c', $value);
129 | $this->trans_->write($data, 1);
130 | return 1;
131 | }
132 |
133 | public function writeI16($value) {
134 | $data = pack('n', $value);
135 | $this->trans_->write($data, 2);
136 | return 2;
137 | }
138 |
139 | public function writeI32($value) {
140 | $data = pack('N', $value);
141 | $this->trans_->write($data, 4);
142 | return 4;
143 | }
144 |
145 | public function writeI64($value) {
146 | // If we are on a 32bit architecture we have to explicitly deal with
147 | // 64-bit twos-complement arithmetic since PHP wants to treat all ints
148 | // as signed and any int over 2^31 - 1 as a float
149 | if (PHP_INT_SIZE == 4) {
150 | $neg = $value < 0;
151 |
152 | if ($neg) {
153 | $value *= -1;
154 | }
155 |
156 | $hi = (int)($value / 4294967296);
157 | $lo = (int)$value;
158 |
159 | if ($neg) {
160 | $hi = ~$hi;
161 | $lo = ~$lo;
162 | if (($lo & (int)0xffffffff) == (int)0xffffffff) {
163 | $lo = 0;
164 | $hi++;
165 | } else {
166 | $lo++;
167 | }
168 | }
169 | $data = pack('N2', $hi, $lo);
170 |
171 | } else {
172 | $hi = $value >> 32;
173 | $lo = $value & 0xFFFFFFFF;
174 | $data = pack('N2', $hi, $lo);
175 | }
176 |
177 | $this->trans_->write($data, 8);
178 | return 8;
179 | }
180 |
181 | public function writeDouble($value) {
182 | $data = pack('d', $value);
183 | $this->trans_->write(strrev($data), 8);
184 | return 8;
185 | }
186 |
187 | public function writeString($value) {
188 | $len = TStringFuncFactory::create()->strlen($value);
189 | $result = $this->writeI32($len);
190 | if ($len) {
191 | $this->trans_->write($value, $len);
192 | }
193 | return $result + $len;
194 | }
195 |
196 | public function readMessageBegin(&$name, &$type, &$seqid) {
197 | $result = $this->readI32($sz);
198 | if ($sz < 0) {
199 | $version = (int) ($sz & self::VERSION_MASK);
200 | if ($version != (int) self::VERSION_1) {
201 | throw new TProtocolException('Bad version identifier: '.$sz, TProtocolException::BAD_VERSION);
202 | }
203 | $type = $sz & 0x000000ff;
204 | $result +=
205 | $this->readString($name) +
206 | $this->readI32($seqid);
207 | } else {
208 | if ($this->strictRead_) {
209 | throw new TProtocolException('No version identifier, old protocol client?', TProtocolException::BAD_VERSION);
210 | } else {
211 | // Handle pre-versioned input
212 | $name = $this->trans_->readAll($sz);
213 | $result +=
214 | $sz +
215 | $this->readByte($type) +
216 | $this->readI32($seqid);
217 | }
218 | }
219 | return $result;
220 | }
221 |
222 | public function readMessageEnd() {
223 | return 0;
224 | }
225 |
226 | public function readStructBegin(&$name) {
227 | $name = '';
228 | return 0;
229 | }
230 |
231 | public function readStructEnd() {
232 | return 0;
233 | }
234 |
235 | public function readFieldBegin(&$name, &$fieldType, &$fieldId) {
236 | $result = $this->readByte($fieldType);
237 | if ($fieldType == TType::STOP) {
238 | $fieldId = 0;
239 | return $result;
240 | }
241 | $result += $this->readI16($fieldId);
242 | return $result;
243 | }
244 |
245 | public function readFieldEnd() {
246 | return 0;
247 | }
248 |
249 | public function readMapBegin(&$keyType, &$valType, &$size) {
250 | return
251 | $this->readByte($keyType) +
252 | $this->readByte($valType) +
253 | $this->readI32($size);
254 | }
255 |
256 | public function readMapEnd() {
257 | return 0;
258 | }
259 |
260 | public function readListBegin(&$elemType, &$size) {
261 | return
262 | $this->readByte($elemType) +
263 | $this->readI32($size);
264 | }
265 |
266 | public function readListEnd() {
267 | return 0;
268 | }
269 |
270 | public function readSetBegin(&$elemType, &$size) {
271 | return
272 | $this->readByte($elemType) +
273 | $this->readI32($size);
274 | }
275 |
276 | public function readSetEnd() {
277 | return 0;
278 | }
279 |
280 | public function readBool(&$value) {
281 | $data = $this->trans_->readAll(1);
282 | $arr = unpack('c', $data);
283 | $value = $arr[1] == 1;
284 | return 1;
285 | }
286 |
287 | public function readByte(&$value) {
288 | $data = $this->trans_->readAll(1);
289 | $arr = unpack('c', $data);
290 | $value = $arr[1];
291 | return 1;
292 | }
293 |
294 | public function readI16(&$value) {
295 | $data = $this->trans_->readAll(2);
296 | $arr = unpack('n', $data);
297 | $value = $arr[1];
298 | if ($value > 0x7fff) {
299 | $value = 0 - (($value - 1) ^ 0xffff);
300 | }
301 | return 2;
302 | }
303 |
304 | public function readI32(&$value) {
305 | $data = $this->trans_->readAll(4);
306 | $arr = unpack('N', $data);
307 | $value = $arr[1];
308 | if ($value > 0x7fffffff) {
309 | $value = 0 - (($value - 1) ^ 0xffffffff);
310 | }
311 | return 4;
312 | }
313 |
314 | public function readI64(&$value) {
315 | $data = $this->trans_->readAll(8);
316 |
317 | $arr = unpack('N2', $data);
318 |
319 | // If we are on a 32bit architecture we have to explicitly deal with
320 | // 64-bit twos-complement arithmetic since PHP wants to treat all ints
321 | // as signed and any int over 2^31 - 1 as a float
322 | if (PHP_INT_SIZE == 4) {
323 |
324 | $hi = $arr[1];
325 | $lo = $arr[2];
326 | $isNeg = $hi < 0;
327 |
328 | // Check for a negative
329 | if ($isNeg) {
330 | $hi = ~$hi & (int)0xffffffff;
331 | $lo = ~$lo & (int)0xffffffff;
332 |
333 | if ($lo == (int)0xffffffff) {
334 | $hi++;
335 | $lo = 0;
336 | } else {
337 | $lo++;
338 | }
339 | }
340 |
341 | // Force 32bit words in excess of 2G to pe positive - we deal wigh sign
342 | // explicitly below
343 |
344 | if ($hi & (int)0x80000000) {
345 | $hi &= (int)0x7fffffff;
346 | $hi += 0x80000000;
347 | }
348 |
349 | if ($lo & (int)0x80000000) {
350 | $lo &= (int)0x7fffffff;
351 | $lo += 0x80000000;
352 | }
353 |
354 | $value = $hi * 4294967296 + $lo;
355 |
356 | if ($isNeg) {
357 | $value = 0 - $value;
358 | }
359 | } else {
360 |
361 | // Upcast negatives in LSB bit
362 | if ($arr[2] & 0x80000000) {
363 | $arr[2] = $arr[2] & 0xffffffff;
364 | }
365 |
366 | // Check for a negative
367 | if ($arr[1] & 0x80000000) {
368 | $arr[1] = $arr[1] & 0xffffffff;
369 | $arr[1] = $arr[1] ^ 0xffffffff;
370 | $arr[2] = $arr[2] ^ 0xffffffff;
371 | $value = 0 - $arr[1]*4294967296 - $arr[2] - 1;
372 | } else {
373 | $value = $arr[1]*4294967296 + $arr[2];
374 | }
375 | }
376 |
377 | return 8;
378 | }
379 |
380 | public function readDouble(&$value) {
381 | $data = strrev($this->trans_->readAll(8));
382 | $arr = unpack('d', $data);
383 | $value = $arr[1];
384 | return 8;
385 | }
386 |
387 | public function readString(&$value) {
388 | $result = $this->readI32($len);
389 | if ($len) {
390 | $value = $this->trans_->readAll($len);
391 | } else {
392 | $value = '';
393 | }
394 | return $result + $len;
395 | }
396 | }
397 |
--------------------------------------------------------------------------------
/lib/Client/ClientSpan.php:
--------------------------------------------------------------------------------
1 | _tracer = $tracer;
36 | $this->_traceGUID = $tracer->_generateUUIDString();
37 | $this->_guid = $tracer->_generateUUIDString();
38 | $this->maxPayloadDepth = $maxPayloadDepth;
39 | }
40 |
41 | public function __destruct() {
42 | // Use $_endMicros as a indicator this span has not been finished
43 | if ($this->_endMicros == 0) {
44 | $this->warnf("finish() never closed on span (operaton='%s')", $this->_operation, $this->_joinIds);
45 | $this->finish();
46 | }
47 | }
48 |
49 | public function tracer() {
50 | return $this->_tracer;
51 | }
52 |
53 | public function guid() {
54 | return $this->_guid;
55 | }
56 |
57 | public function setRuntimeGUID($guid) {
58 | $this->_runtimeGUID = $guid;
59 | }
60 |
61 | public function traceGUID() {
62 | return $this->_traceGUID;
63 | }
64 |
65 | public function setTraceGUID($guid) {
66 | $this->_traceGUID = $guid;
67 | return $this;
68 | }
69 |
70 | public function setStartMicros($start) {
71 | $this->_startMicros = $start;
72 | return $this;
73 | }
74 |
75 | public function setEndMicros($start) {
76 | $this->_endMicros = $start;
77 | return $this;
78 | }
79 |
80 | public function finish() {
81 | $this->_tracer->_finishSpan($this);
82 | }
83 |
84 | public function setOperationName($name) {
85 | $this->_operation = $name;
86 | return $this;
87 | }
88 |
89 | public function addTraceJoinId($key, $value) {
90 | $this->_joinIds[$key] = $value;
91 | return $this;
92 | }
93 |
94 | public function setEndUserId($id) {
95 | $this->addTraceJoinId(LIGHTSTEP_JOIN_KEY_END_USER_ID, $id);
96 | return $this;
97 | }
98 |
99 | public function setTags($fields) {
100 | foreach ($fields as $key => $value) {
101 | $this->setTag($key, $value);
102 | }
103 | return $this;
104 | }
105 |
106 | public function setTag($key, $value) {
107 | $this->_tags[$key] = $value;
108 | return $this;
109 | }
110 |
111 | public function setBaggageItem($key, $value) {
112 | $this->_baggage[$key] = $value;
113 | return $this;
114 | }
115 |
116 | public function getBaggageItem($key) {
117 | return $this->_baggage[$key];
118 | }
119 |
120 | public function getBaggage() {
121 | return $this->_baggage;
122 | }
123 |
124 | public function setParent($span) {
125 | // Inherit any join IDs from the parent that have not been explicitly
126 | // set on the child
127 | foreach ($span->_joinIds as $key => $value) {
128 | if (!array_key_exists($key, $this->_joinIds)) {
129 | $this->_joinIds[$key] = $value;
130 | }
131 | }
132 |
133 | $this->_traceGUID = $span->_traceGUID;
134 | $this->setTag("parent_span_guid", $span->guid());
135 | return $this;
136 | }
137 |
138 | public function setParentGUID($guid) {
139 | $this->setTag("parent_span_guid", $guid);
140 | return $this;
141 | }
142 |
143 | public function getParentGUID() {
144 | if (array_key_exists('parent_span_guid', $this->_tags)) {
145 | return $this->_tags['parent_span_guid'];
146 | }
147 | return NULL;
148 | }
149 |
150 | public function logEvent($event, $payload = NULL) {
151 | $this->log([
152 | 'event' => strval($event),
153 | 'payload' => $payload,
154 | ]);
155 | }
156 |
157 | public function log($fields) {
158 | $record = [
159 | 'span_guid' => strval($this->_guid),
160 | ];
161 | $payload = NULL;
162 |
163 | if (!empty($fields['event'])) {
164 | $record['event'] = strval($fields['event']);
165 | }
166 |
167 | if (!empty($fields['timestamp'])) {
168 | $record['timestamp_micros'] = intval(1000 * $fields['timestamp']);
169 | }
170 | // no need to verify value of fields['payload'] as it will be checked by _rawLogRecord
171 | $this->_rawLogRecord($record, $fields['payload']);
172 | }
173 |
174 | public function infof($fmt) {
175 | $this->_log('I', false, $fmt, func_get_args());
176 | return $this;
177 | }
178 |
179 | public function warnf($fmt) {
180 | $this->_log('W', false, $fmt, func_get_args());
181 | return $this;
182 | }
183 |
184 | public function errorf($fmt) {
185 | $this->_errorFlag = true;
186 | $this->_log('E', true, $fmt, func_get_args());
187 | return $this;
188 | }
189 |
190 | public function fatalf($fmt) {
191 | $this->_errorFlag = true;
192 | $text = $this->_log('F', true, $fmt, func_get_args());
193 | if ($this->_dieOnFatal) {
194 | die($text);
195 | }
196 | return $this;
197 | }
198 |
199 | public function setDieOnFatal($dieOnFatal) {
200 | $this->_dieOnFatal = $dieOnFatal;
201 | }
202 |
203 | protected function _log($level, $errorFlag, $fmt, $allArgs) {
204 | // The $allArgs variable contains the $fmt string
205 | array_shift($allArgs);
206 | $text = vsprintf($fmt, $allArgs);
207 |
208 | $this->_rawLogRecord([
209 | 'span_guid' => strval($this->_guid),
210 | 'level' => $level,
211 | 'error_flag' => $errorFlag ? 'true' : 'false',
212 | 'message' => $text,
213 | ], $allArgs);
214 | return $text;
215 | }
216 |
217 | /**
218 | * Internal use only.
219 | */
220 | public function _rawLogRecord($fields, $payloadArray) {
221 | $fields['runtime_guid'] = strval($this->_guid);
222 |
223 | if (empty($fields['timestamp_micros'])) {
224 | $fields['timestamp_micros'] = intval(Util::nowMicros());
225 | }
226 |
227 | // TODO: data scrubbing and size limiting
228 | if (!empty($payloadArray)) {
229 | // $json == FALSE on failure
230 | //
231 | // Examples that will cause failure:
232 | // - "Resources" (e.g. file handles)
233 | // - Circular references
234 | // - Exceeding the max depth (i.e. it *does not* trim, it rejects)
235 | //
236 | $json = json_encode($payloadArray, 0, $this->maxPayloadDepth);
237 | if (is_string($json)) {
238 | $fields["payload_json"] = $json;
239 | }
240 | }
241 |
242 | $rec = new LogRecord($fields);
243 | $this->_logRecords[] = $rec;
244 | }
245 |
246 | public function toThrift() {
247 | // Coerce all the types to strings to ensure there are no encoding/decoding
248 | // issues
249 | $joinIds = [];
250 | foreach ($this->_joinIds as $key => $value) {
251 | $pair = new \CroutonThrift\TraceJoinId([
252 | "TraceKey" => strval($key),
253 | "Value" => strval($value),
254 | ]);
255 | $joinIds[] = $pair;
256 | }
257 |
258 | $tags = [];
259 | foreach ($this->_tags as $key => $value) {
260 | $pair = new \CroutonThrift\KeyValue([
261 | "Key" => strval($key),
262 | "Value" => strval($value),
263 | ]);
264 | $tags[] = $pair;
265 | }
266 |
267 | // Convert the logs to thrift form
268 | $thriftLogs = [];
269 | foreach ($this->_logRecords as $lr) {
270 | $lr->runtime_guid = $this->_runtimeGUID;
271 | $thriftLogs[] = $lr->toThrift();
272 | }
273 |
274 | $rec = new \CroutonThrift\SpanRecord([
275 | "runtime_guid" => strval($this->_runtimeGUID),
276 | "span_guid" => strval($this->_guid),
277 | "trace_guid" => strval($this->_traceGUID),
278 | "span_name" => strval($this->_operation),
279 | "oldest_micros" => intval($this->_startMicros),
280 | "youngest_micros" => intval($this->_endMicros),
281 | "join_ids" => $joinIds,
282 | "error_flag" => $this->_errorFlag,
283 | "attributes" => $tags,
284 | "log_records" => $thriftLogs,
285 | ]);
286 | return $rec;
287 | }
288 |
289 | /**
290 | * @return Span A Proto representation of this object.
291 | */
292 | public function toProto() {
293 | $spanContext = new SpanContext([
294 | 'trace_id' => Util::hexdec($this->traceGUID()),
295 | 'span_id' => Util::hexdec($this->guid()),
296 | ]);
297 |
298 | $ts = new Timestamp([
299 | 'seconds' => floor($this->_startMicros / 1000000),
300 | 'nanos' => ($this->_startMicros % 1000000) * 100,
301 | ]);
302 |
303 | $tags = [];
304 | foreach ($this->_tags as $key => $value) {
305 | if ($key == 'parent_span_guid') {
306 | continue;
307 | }
308 | $protoTag = new \Lightstep\Collector\KeyValue([
309 | 'key' => $key,
310 | 'string_value' => $value,
311 | ]);
312 | $tags[] = $protoTag;
313 | }
314 |
315 | $logs = [];
316 | foreach ($this->_logRecords as $log) {
317 | $logs[] = $log->toProto();
318 | }
319 |
320 | $references = [];
321 | if ($this->getParentGUID() != NULL) {
322 | $parentSpanContext = new SpanContext([
323 | 'trace_id' => Util::hexdec($this->traceGUID()),
324 | 'span_id' => Util::hexdec($this->getParentGUID())
325 | ]);
326 |
327 | $ref = new Reference([
328 | 'span_context' => $parentSpanContext,
329 | 'relationship' => Relationship::CHILD_OF
330 | ]);
331 | $references[] = $ref;
332 | }
333 |
334 | return new Span([
335 | 'span_context' => $spanContext,
336 | 'operation_name' => strval($this->_operation),
337 | 'start_timestamp' => $ts,
338 | 'duration_micros' => $this->_endMicros-$this->_startMicros,
339 | 'tags' => $tags,
340 | 'logs' => $logs,
341 | 'references' => $references,
342 | ]);
343 | }
344 | }
345 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Base/TBase.php:
--------------------------------------------------------------------------------
1 | 'Bool',
37 | TType::BYTE => 'Byte',
38 | TType::I16 => 'I16',
39 | TType::I32 => 'I32',
40 | TType::I64 => 'I64',
41 | TType::DOUBLE => 'Double',
42 | TType::STRING => 'String');
43 |
44 | abstract function read($input);
45 |
46 | abstract function write($output);
47 |
48 | public function __construct($spec=null, $vals=null) {
49 | if (is_array($spec) && is_array($vals)) {
50 | foreach ($spec as $fid => $fspec) {
51 | $var = $fspec['var'];
52 | if (isset($vals[$var])) {
53 | $this->$var = $vals[$var];
54 | }
55 | }
56 | }
57 | }
58 |
59 | public function __wakeup()
60 | {
61 | $this->__construct(get_object_vars($this));
62 | }
63 |
64 | private function _readMap(&$var, $spec, $input) {
65 | $xfer = 0;
66 | $ktype = $spec['ktype'];
67 | $vtype = $spec['vtype'];
68 | $kread = $vread = null;
69 | if (isset(TBase::$tmethod[$ktype])) {
70 | $kread = 'read'.TBase::$tmethod[$ktype];
71 | } else {
72 | $kspec = $spec['key'];
73 | }
74 | if (isset(TBase::$tmethod[$vtype])) {
75 | $vread = 'read'.TBase::$tmethod[$vtype];
76 | } else {
77 | $vspec = $spec['val'];
78 | }
79 | $var = array();
80 | $_ktype = $_vtype = $size = 0;
81 | $xfer += $input->readMapBegin($_ktype, $_vtype, $size);
82 | for ($i = 0; $i < $size; ++$i) {
83 | $key = $val = null;
84 | if ($kread !== null) {
85 | $xfer += $input->$kread($key);
86 | } else {
87 | switch ($ktype) {
88 | case TType::STRUCT:
89 | $class = $kspec['class'];
90 | $key = new $class();
91 | $xfer += $key->read($input);
92 | break;
93 | case TType::MAP:
94 | $xfer += $this->_readMap($key, $kspec, $input);
95 | break;
96 | case TType::LST:
97 | $xfer += $this->_readList($key, $kspec, $input, false);
98 | break;
99 | case TType::SET:
100 | $xfer += $this->_readList($key, $kspec, $input, true);
101 | break;
102 | }
103 | }
104 | if ($vread !== null) {
105 | $xfer += $input->$vread($val);
106 | } else {
107 | switch ($vtype) {
108 | case TType::STRUCT:
109 | $class = $vspec['class'];
110 | $val = new $class();
111 | $xfer += $val->read($input);
112 | break;
113 | case TType::MAP:
114 | $xfer += $this->_readMap($val, $vspec, $input);
115 | break;
116 | case TType::LST:
117 | $xfer += $this->_readList($val, $vspec, $input, false);
118 | break;
119 | case TType::SET:
120 | $xfer += $this->_readList($val, $vspec, $input, true);
121 | break;
122 | }
123 | }
124 | $var[$key] = $val;
125 | }
126 | $xfer += $input->readMapEnd();
127 | return $xfer;
128 | }
129 |
130 | private function _readList(&$var, $spec, $input, $set=false) {
131 | $xfer = 0;
132 | $etype = $spec['etype'];
133 | $eread = $vread = null;
134 | if (isset(TBase::$tmethod[$etype])) {
135 | $eread = 'read'.TBase::$tmethod[$etype];
136 | } else {
137 | $espec = $spec['elem'];
138 | }
139 | $var = array();
140 | $_etype = $size = 0;
141 | if ($set) {
142 | $xfer += $input->readSetBegin($_etype, $size);
143 | } else {
144 | $xfer += $input->readListBegin($_etype, $size);
145 | }
146 | for ($i = 0; $i < $size; ++$i) {
147 | $elem = null;
148 | if ($eread !== null) {
149 | $xfer += $input->$eread($elem);
150 | } else {
151 | $espec = $spec['elem'];
152 | switch ($etype) {
153 | case TType::STRUCT:
154 | $class = $espec['class'];
155 | $elem = new $class();
156 | $xfer += $elem->read($input);
157 | break;
158 | case TType::MAP:
159 | $xfer += $this->_readMap($elem, $espec, $input);
160 | break;
161 | case TType::LST:
162 | $xfer += $this->_readList($elem, $espec, $input, false);
163 | break;
164 | case TType::SET:
165 | $xfer += $this->_readList($elem, $espec, $input, true);
166 | break;
167 | }
168 | }
169 | if ($set) {
170 | $var[$elem] = true;
171 | } else {
172 | $var []= $elem;
173 | }
174 | }
175 | if ($set) {
176 | $xfer += $input->readSetEnd();
177 | } else {
178 | $xfer += $input->readListEnd();
179 | }
180 | return $xfer;
181 | }
182 |
183 | protected function _read($class, $spec, $input) {
184 | $xfer = 0;
185 | $fname = null;
186 | $ftype = 0;
187 | $fid = 0;
188 | $xfer += $input->readStructBegin($fname);
189 | while (true) {
190 | $xfer += $input->readFieldBegin($fname, $ftype, $fid);
191 | if ($ftype == TType::STOP) {
192 | break;
193 | }
194 | if (isset($spec[$fid])) {
195 | $fspec = $spec[$fid];
196 | $var = $fspec['var'];
197 | if ($ftype == $fspec['type']) {
198 | $xfer = 0;
199 | if (isset(TBase::$tmethod[$ftype])) {
200 | $func = 'read'.TBase::$tmethod[$ftype];
201 | $xfer += $input->$func($this->$var);
202 | } else {
203 | switch ($ftype) {
204 | case TType::STRUCT:
205 | $class = $fspec['class'];
206 | $this->$var = new $class();
207 | $xfer += $this->$var->read($input);
208 | break;
209 | case TType::MAP:
210 | $xfer += $this->_readMap($this->$var, $fspec, $input);
211 | break;
212 | case TType::LST:
213 | $xfer += $this->_readList($this->$var, $fspec, $input, false);
214 | break;
215 | case TType::SET:
216 | $xfer += $this->_readList($this->$var, $fspec, $input, true);
217 | break;
218 | }
219 | }
220 | } else {
221 | $xfer += $input->skip($ftype);
222 | }
223 | } else {
224 | $xfer += $input->skip($ftype);
225 | }
226 | $xfer += $input->readFieldEnd();
227 | }
228 | $xfer += $input->readStructEnd();
229 | return $xfer;
230 | }
231 |
232 | private function _writeMap($var, $spec, $output) {
233 | $xfer = 0;
234 | $ktype = $spec['ktype'];
235 | $vtype = $spec['vtype'];
236 | $kwrite = $vwrite = null;
237 | if (isset(TBase::$tmethod[$ktype])) {
238 | $kwrite = 'write'.TBase::$tmethod[$ktype];
239 | } else {
240 | $kspec = $spec['key'];
241 | }
242 | if (isset(TBase::$tmethod[$vtype])) {
243 | $vwrite = 'write'.TBase::$tmethod[$vtype];
244 | } else {
245 | $vspec = $spec['val'];
246 | }
247 | $xfer += $output->writeMapBegin($ktype, $vtype, count($var));
248 | foreach ($var as $key => $val) {
249 | if (isset($kwrite)) {
250 | $xfer += $output->$kwrite($key);
251 | } else {
252 | switch ($ktype) {
253 | case TType::STRUCT:
254 | $xfer += $key->write($output);
255 | break;
256 | case TType::MAP:
257 | $xfer += $this->_writeMap($key, $kspec, $output);
258 | break;
259 | case TType::LST:
260 | $xfer += $this->_writeList($key, $kspec, $output, false);
261 | break;
262 | case TType::SET:
263 | $xfer += $this->_writeList($key, $kspec, $output, true);
264 | break;
265 | }
266 | }
267 | if (isset($vwrite)) {
268 | $xfer += $output->$vwrite($val);
269 | } else {
270 | switch ($vtype) {
271 | case TType::STRUCT:
272 | $xfer += $val->write($output);
273 | break;
274 | case TType::MAP:
275 | $xfer += $this->_writeMap($val, $vspec, $output);
276 | break;
277 | case TType::LST:
278 | $xfer += $this->_writeList($val, $vspec, $output, false);
279 | break;
280 | case TType::SET:
281 | $xfer += $this->_writeList($val, $vspec, $output, true);
282 | break;
283 | }
284 | }
285 | }
286 | $xfer += $output->writeMapEnd();
287 | return $xfer;
288 | }
289 |
290 | private function _writeList($var, $spec, $output, $set=false) {
291 | $xfer = 0;
292 | $etype = $spec['etype'];
293 | $ewrite = null;
294 | if (isset(TBase::$tmethod[$etype])) {
295 | $ewrite = 'write'.TBase::$tmethod[$etype];
296 | } else {
297 | $espec = $spec['elem'];
298 | }
299 | if ($set) {
300 | $xfer += $output->writeSetBegin($etype, count($var));
301 | } else {
302 | $xfer += $output->writeListBegin($etype, count($var));
303 | }
304 | foreach ($var as $key => $val) {
305 | $elem = $set ? $key : $val;
306 | if (isset($ewrite)) {
307 | $xfer += $output->$ewrite($elem);
308 | } else {
309 | switch ($etype) {
310 | case TType::STRUCT:
311 | $xfer += $elem->write($output);
312 | break;
313 | case TType::MAP:
314 | $xfer += $this->_writeMap($elem, $espec, $output);
315 | break;
316 | case TType::LST:
317 | $xfer += $this->_writeList($elem, $espec, $output, false);
318 | break;
319 | case TType::SET:
320 | $xfer += $this->_writeList($elem, $espec, $output, true);
321 | break;
322 | }
323 | }
324 | }
325 | if ($set) {
326 | $xfer += $output->writeSetEnd();
327 | } else {
328 | $xfer += $output->writeListEnd();
329 | }
330 | return $xfer;
331 | }
332 |
333 | protected function _write($class, $spec, $output) {
334 | $xfer = 0;
335 | $xfer += $output->writeStructBegin($class);
336 | foreach ($spec as $fid => $fspec) {
337 | $var = $fspec['var'];
338 | if ($this->$var !== null) {
339 | $ftype = $fspec['type'];
340 | $xfer += $output->writeFieldBegin($var, $ftype, $fid);
341 | if (isset(TBase::$tmethod[$ftype])) {
342 | $func = 'write'.TBase::$tmethod[$ftype];
343 | $xfer += $output->$func($this->$var);
344 | } else {
345 | switch ($ftype) {
346 | case TType::STRUCT:
347 | $xfer += $this->$var->write($output);
348 | break;
349 | case TType::MAP:
350 | $xfer += $this->_writeMap($this->$var, $fspec, $output);
351 | break;
352 | case TType::LST:
353 | $xfer += $this->_writeList($this->$var, $fspec, $output, false);
354 | break;
355 | case TType::SET:
356 | $xfer += $this->_writeList($this->$var, $fspec, $output, true);
357 | break;
358 | }
359 | }
360 | $xfer += $output->writeFieldEnd();
361 | }
362 | }
363 | $xfer += $output->writeFieldStop();
364 | $xfer += $output->writeStructEnd();
365 | return $xfer;
366 | }
367 | }
368 |
--------------------------------------------------------------------------------
/lib/vendor/Thrift/Exception/TException.php:
--------------------------------------------------------------------------------
1 | $fspec) {
47 | $var = $fspec['var'];
48 | if (isset($vals[$var])) {
49 | $this->$var = $vals[$var];
50 | }
51 | }
52 | } else {
53 | parent::__construct($p1, $p2);
54 | }
55 | }
56 |
57 | static $tmethod = array(TType::BOOL => 'Bool',
58 | TType::BYTE => 'Byte',
59 | TType::I16 => 'I16',
60 | TType::I32 => 'I32',
61 | TType::I64 => 'I64',
62 | TType::DOUBLE => 'Double',
63 | TType::STRING => 'String');
64 |
65 | private function _readMap(&$var, $spec, $input) {
66 | $xfer = 0;
67 | $ktype = $spec['ktype'];
68 | $vtype = $spec['vtype'];
69 | $kread = $vread = null;
70 | if (isset(TBase::$tmethod[$ktype])) {
71 | $kread = 'read'.TBase::$tmethod[$ktype];
72 | } else {
73 | $kspec = $spec['key'];
74 | }
75 | if (isset(TBase::$tmethod[$vtype])) {
76 | $vread = 'read'.TBase::$tmethod[$vtype];
77 | } else {
78 | $vspec = $spec['val'];
79 | }
80 | $var = array();
81 | $_ktype = $_vtype = $size = 0;
82 | $xfer += $input->readMapBegin($_ktype, $_vtype, $size);
83 | for ($i = 0; $i < $size; ++$i) {
84 | $key = $val = null;
85 | if ($kread !== null) {
86 | $xfer += $input->$kread($key);
87 | } else {
88 | switch ($ktype) {
89 | case TType::STRUCT:
90 | $class = $kspec['class'];
91 | $key = new $class();
92 | $xfer += $key->read($input);
93 | break;
94 | case TType::MAP:
95 | $xfer += $this->_readMap($key, $kspec, $input);
96 | break;
97 | case TType::LST:
98 | $xfer += $this->_readList($key, $kspec, $input, false);
99 | break;
100 | case TType::SET:
101 | $xfer += $this->_readList($key, $kspec, $input, true);
102 | break;
103 | }
104 | }
105 | if ($vread !== null) {
106 | $xfer += $input->$vread($val);
107 | } else {
108 | switch ($vtype) {
109 | case TType::STRUCT:
110 | $class = $vspec['class'];
111 | $val = new $class();
112 | $xfer += $val->read($input);
113 | break;
114 | case TType::MAP:
115 | $xfer += $this->_readMap($val, $vspec, $input);
116 | break;
117 | case TType::LST:
118 | $xfer += $this->_readList($val, $vspec, $input, false);
119 | break;
120 | case TType::SET:
121 | $xfer += $this->_readList($val, $vspec, $input, true);
122 | break;
123 | }
124 | }
125 | $var[$key] = $val;
126 | }
127 | $xfer += $input->readMapEnd();
128 | return $xfer;
129 | }
130 |
131 | private function _readList(&$var, $spec, $input, $set=false) {
132 | $xfer = 0;
133 | $etype = $spec['etype'];
134 | $eread = $vread = null;
135 | if (isset(TBase::$tmethod[$etype])) {
136 | $eread = 'read'.TBase::$tmethod[$etype];
137 | } else {
138 | $espec = $spec['elem'];
139 | }
140 | $var = array();
141 | $_etype = $size = 0;
142 | if ($set) {
143 | $xfer += $input->readSetBegin($_etype, $size);
144 | } else {
145 | $xfer += $input->readListBegin($_etype, $size);
146 | }
147 | for ($i = 0; $i < $size; ++$i) {
148 | $elem = null;
149 | if ($eread !== null) {
150 | $xfer += $input->$eread($elem);
151 | } else {
152 | $espec = $spec['elem'];
153 | switch ($etype) {
154 | case TType::STRUCT:
155 | $class = $espec['class'];
156 | $elem = new $class();
157 | $xfer += $elem->read($input);
158 | break;
159 | case TType::MAP:
160 | $xfer += $this->_readMap($elem, $espec, $input);
161 | break;
162 | case TType::LST:
163 | $xfer += $this->_readList($elem, $espec, $input, false);
164 | break;
165 | case TType::SET:
166 | $xfer += $this->_readList($elem, $espec, $input, true);
167 | break;
168 | }
169 | }
170 | if ($set) {
171 | $var[$elem] = true;
172 | } else {
173 | $var []= $elem;
174 | }
175 | }
176 | if ($set) {
177 | $xfer += $input->readSetEnd();
178 | } else {
179 | $xfer += $input->readListEnd();
180 | }
181 | return $xfer;
182 | }
183 |
184 | protected function _read($class, $spec, $input) {
185 | $xfer = 0;
186 | $fname = null;
187 | $ftype = 0;
188 | $fid = 0;
189 | $xfer += $input->readStructBegin($fname);
190 | while (true) {
191 | $xfer += $input->readFieldBegin($fname, $ftype, $fid);
192 | if ($ftype == TType::STOP) {
193 | break;
194 | }
195 | if (isset($spec[$fid])) {
196 | $fspec = $spec[$fid];
197 | $var = $fspec['var'];
198 | if ($ftype == $fspec['type']) {
199 | $xfer = 0;
200 | if (isset(TBase::$tmethod[$ftype])) {
201 | $func = 'read'.TBase::$tmethod[$ftype];
202 | $xfer += $input->$func($this->$var);
203 | } else {
204 | switch ($ftype) {
205 | case TType::STRUCT:
206 | $class = $fspec['class'];
207 | $this->$var = new $class();
208 | $xfer += $this->$var->read($input);
209 | break;
210 | case TType::MAP:
211 | $xfer += $this->_readMap($this->$var, $fspec, $input);
212 | break;
213 | case TType::LST:
214 | $xfer += $this->_readList($this->$var, $fspec, $input, false);
215 | break;
216 | case TType::SET:
217 | $xfer += $this->_readList($this->$var, $fspec, $input, true);
218 | break;
219 | }
220 | }
221 | } else {
222 | $xfer += $input->skip($ftype);
223 | }
224 | } else {
225 | $xfer += $input->skip($ftype);
226 | }
227 | $xfer += $input->readFieldEnd();
228 | }
229 | $xfer += $input->readStructEnd();
230 | return $xfer;
231 | }
232 |
233 | private function _writeMap($var, $spec, $output) {
234 | $xfer = 0;
235 | $ktype = $spec['ktype'];
236 | $vtype = $spec['vtype'];
237 | $kwrite = $vwrite = null;
238 | if (isset(TBase::$tmethod[$ktype])) {
239 | $kwrite = 'write'.TBase::$tmethod[$ktype];
240 | } else {
241 | $kspec = $spec['key'];
242 | }
243 | if (isset(TBase::$tmethod[$vtype])) {
244 | $vwrite = 'write'.TBase::$tmethod[$vtype];
245 | } else {
246 | $vspec = $spec['val'];
247 | }
248 | $xfer += $output->writeMapBegin($ktype, $vtype, count($var));
249 | foreach ($var as $key => $val) {
250 | if (isset($kwrite)) {
251 | $xfer += $output->$kwrite($key);
252 | } else {
253 | switch ($ktype) {
254 | case TType::STRUCT:
255 | $xfer += $key->write($output);
256 | break;
257 | case TType::MAP:
258 | $xfer += $this->_writeMap($key, $kspec, $output);
259 | break;
260 | case TType::LST:
261 | $xfer += $this->_writeList($key, $kspec, $output, false);
262 | break;
263 | case TType::SET:
264 | $xfer += $this->_writeList($key, $kspec, $output, true);
265 | break;
266 | }
267 | }
268 | if (isset($vwrite)) {
269 | $xfer += $output->$vwrite($val);
270 | } else {
271 | switch ($vtype) {
272 | case TType::STRUCT:
273 | $xfer += $val->write($output);
274 | break;
275 | case TType::MAP:
276 | $xfer += $this->_writeMap($val, $vspec, $output);
277 | break;
278 | case TType::LST:
279 | $xfer += $this->_writeList($val, $vspec, $output, false);
280 | break;
281 | case TType::SET:
282 | $xfer += $this->_writeList($val, $vspec, $output, true);
283 | break;
284 | }
285 | }
286 | }
287 | $xfer += $output->writeMapEnd();
288 | return $xfer;
289 | }
290 |
291 | private function _writeList($var, $spec, $output, $set=false) {
292 | $xfer = 0;
293 | $etype = $spec['etype'];
294 | $ewrite = null;
295 | if (isset(TBase::$tmethod[$etype])) {
296 | $ewrite = 'write'.TBase::$tmethod[$etype];
297 | } else {
298 | $espec = $spec['elem'];
299 | }
300 | if ($set) {
301 | $xfer += $output->writeSetBegin($etype, count($var));
302 | } else {
303 | $xfer += $output->writeListBegin($etype, count($var));
304 | }
305 | foreach ($var as $key => $val) {
306 | $elem = $set ? $key : $val;
307 | if (isset($ewrite)) {
308 | $xfer += $output->$ewrite($elem);
309 | } else {
310 | switch ($etype) {
311 | case TType::STRUCT:
312 | $xfer += $elem->write($output);
313 | break;
314 | case TType::MAP:
315 | $xfer += $this->_writeMap($elem, $espec, $output);
316 | break;
317 | case TType::LST:
318 | $xfer += $this->_writeList($elem, $espec, $output, false);
319 | break;
320 | case TType::SET:
321 | $xfer += $this->_writeList($elem, $espec, $output, true);
322 | break;
323 | }
324 | }
325 | }
326 | if ($set) {
327 | $xfer += $output->writeSetEnd();
328 | } else {
329 | $xfer += $output->writeListEnd();
330 | }
331 | return $xfer;
332 | }
333 |
334 | protected function _write($class, $spec, $output) {
335 | $xfer = 0;
336 | $xfer += $output->writeStructBegin($class);
337 | foreach ($spec as $fid => $fspec) {
338 | $var = $fspec['var'];
339 | if ($this->$var !== null) {
340 | $ftype = $fspec['type'];
341 | $xfer += $output->writeFieldBegin($var, $ftype, $fid);
342 | if (isset(TBase::$tmethod[$ftype])) {
343 | $func = 'write'.TBase::$tmethod[$ftype];
344 | $xfer += $output->$func($this->$var);
345 | } else {
346 | switch ($ftype) {
347 | case TType::STRUCT:
348 | $xfer += $this->$var->write($output);
349 | break;
350 | case TType::MAP:
351 | $xfer += $this->_writeMap($this->$var, $fspec, $output);
352 | break;
353 | case TType::LST:
354 | $xfer += $this->_writeList($this->$var, $fspec, $output, false);
355 | break;
356 | case TType::SET:
357 | $xfer += $this->_writeList($this->$var, $fspec, $output, true);
358 | break;
359 | }
360 | }
361 | $xfer += $output->writeFieldEnd();
362 | }
363 | }
364 | $xfer += $output->writeFieldStop();
365 | $xfer += $output->writeStructEnd();
366 | return $xfer;
367 | }
368 |
369 | }
370 |
--------------------------------------------------------------------------------