Page MenuHomePhabricator

D18704.id44901.diff
No OneTemporary

D18704.id44901.diff

diff --git a/src/conduit/ConduitClient.php b/src/conduit/ConduitClient.php
--- a/src/conduit/ConduitClient.php
+++ b/src/conduit/ConduitClient.php
@@ -155,12 +155,8 @@
$this->password);
}
- $conduit_future = new ConduitFuture($core_future);
- $conduit_future->setClient($this, $method);
- $conduit_future->beginProfile($data);
- $conduit_future->isReady();
-
- return $conduit_future;
+ return id(new ConduitFuture($core_future))
+ ->setClient($this, $method);
}
public function setBasicAuthCredentials($username, $password) {
diff --git a/src/conduit/ConduitFuture.php b/src/conduit/ConduitFuture.php
--- a/src/conduit/ConduitFuture.php
+++ b/src/conduit/ConduitFuture.php
@@ -2,8 +2,8 @@
final class ConduitFuture extends FutureProxy {
- protected $client;
- protected $conduitMethod;
+ private $client;
+ private $conduitMethod;
private $profilerCallID;
public function setClient(ConduitClient $client, $method) {
@@ -12,15 +12,19 @@
return $this;
}
- public function beginProfile($data) {
- $profiler = PhutilServiceProfiler::getInstance();
- $this->profilerCallID = $profiler->beginServiceCall(
- array(
- 'type' => 'conduit',
- 'method' => $this->conduitMethod,
- 'size' => strlen(http_build_query($data, '', '&')),
- ));
- return $this;
+ public function isReady() {
+ if ($this->profilerCallID === null) {
+ $profiler = PhutilServiceProfiler::getInstance();
+
+ $this->profilerCallID = $profiler->beginServiceCall(
+ array(
+ 'type' => 'conduit',
+ 'method' => $this->conduitMethod,
+ 'size' => $this->getProxiedFuture()->getHTTPRequestByteLength(),
+ ));
+ }
+
+ return parent::isReady();
}
protected function didReceiveResult($result) {
diff --git a/src/future/http/BaseHTTPFuture.php b/src/future/http/BaseHTTPFuture.php
--- a/src/future/http/BaseHTTPFuture.php
+++ b/src/future/http/BaseHTTPFuture.php
@@ -264,6 +264,18 @@
return $this->addHeader('Authorization', 'Basic '.$credentials);
}
+ public function getHTTPRequestByteLength() {
+ // NOTE: This isn't very accurate, but it's only used by the "--trace"
+ // call profiler to help pick out huge requests.
+ $data = $this->getData();
+
+ if (is_scalar($data)) {
+ return strlen($data);
+ }
+
+ return strlen(http_build_query($data, '', '&'));
+ }
+
/* -( Resolving the Request )---------------------------------------------- */

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 15, 8:04 PM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714216
Default Alt Text
D18704.id44901.diff (2 KB)

Event Timeline