Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WIP] Master profiler component #20502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
yjv committed Nov 6, 2016
commit 537b550bd3a2bc72350de655292013ca67439410
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 10:27 PM
*/

namespace Symfony\Component\Profiler;
namespace Symfony\Component\Profiler\Data;

use Symfony\Component\Console\Command\Command;

Expand Down Expand Up @@ -56,20 +56,4 @@ public function getStatusCode()
{
return $this->exitCode;
}

/**
* @return null|string
*/
public function getMethod()
{
return null;
}

/**
* @return null|string
*/
public function getClientIp()
{
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 5:06 PM
*/

namespace Symfony\Component\Profiler;
namespace Symfony\Component\Profiler\Data;

interface DataInterface
{
Expand All @@ -24,14 +24,4 @@ public function getUri();
* @return null|string
*/
public function getStatusCode();

/**
* @return null|string
*/
public function getMethod();

/**
* @return null|string
*/
public function getClientIp();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* Time: 10:18 PM
*/

namespace Symfony\Component\Profiler;
namespace Symfony\Component\Profiler\Data;

use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand All @@ -21,7 +20,7 @@ class RequestData implements DataInterface
public function __construct(Request $request, Response $response, $exception = null)
{
if (!is_null($exception) && !$exception instanceof \Exception && !$exception instanceof \Throwable) {
throw new \InvalidArgumentException('$exception must be either null or an exception');
throw new \InvalidArgumentException('$exception must be either null or an instance of \Exception or \Throwable');
}

$this->exception = $exception;
Expand All @@ -44,20 +43,6 @@ public function getStatusCode()
return $this->response->getStatusCode();
}

public function getMethod()
{
return $this->request->getMethod();
}

public function getClientIp()
{
try {
return $this->request->getClientIp();
} catch (ConflictingHeadersException $e) {
return 'Unknown';
}
}

/**
* @return Request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;
use Symfony\Component\Profiler\RequestData;
use Symfony\Component\Profiler\Data\RequestData;

/**
* AjaxDataCollector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@

use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;
use Symfony\Component\Profiler\RequestData;

/**
* ConfigDataCollector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@

namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Profiler\ConsoleCommandData;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;
use Symfony\Component\Profiler\RequestData;
use Symfony\Component\Profiler\Data\RequestData;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Cloner\VarCloner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@

namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\Debug\Exception\SilencedErrorContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;
use Symfony\Component\Profiler\RequestData;
use Symfony\Component\Profiler\Data\RequestData;
use Symfony\Component\Routing\Route;

/**
Expand Down Expand Up @@ -51,6 +51,12 @@ public function collectData(DataInterface $data, Profile $profile)

$response = $data->getResponse();
$request = $data->getRequest();
$profile->setMethod($request->getMethod());
try {
$profile->setIp($request->getClientIp());
} catch (ConflictingHeadersException $e) {
$profile->setIp('Unknown');
}
$responseHeaders = $response->headers->all();
$cookies = array();
foreach ($response->headers->getCookies() as $cookie) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;
use Symfony\Component\Profiler\RequestData;
use Symfony\Component\Profiler\Data\RequestData;

/**
* RouterDataCollector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
namespace Symfony\Component\Profiler\DataCollector;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Profiler\DataInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\Profile;
use Symfony\Component\Profiler\RequestData;
use Symfony\Component\Profiler\Data\RequestData;
use Symfony\Component\Stopwatch\Stopwatch;

/**
Expand Down
5 changes: 2 additions & 3 deletions 5 src/Symfony/Component/Profiler/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\HttpFoundation\Response;
use Psr\Log\LoggerInterface;
use Symfony\Component\Profiler\Data\DataInterface;
use Symfony\Component\Profiler\DataCollector\DataCollectorInterface;
use Symfony\Component\Profiler\DataCollector\LateDataCollectorInterface;

Expand Down Expand Up @@ -157,12 +158,10 @@ public function collectData(DataInterface $data)
$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
$profile->setTime(time());
$profile->setUrl($data->getUri());
$profile->setMethod($data->getMethod());
$profile->setStatusCode($data->getStatusCode());
$profile->setIp($data->getClientIp());

foreach ($this->collectors as $collector) {
if ($collector->collectData($data,)) {
if ($collector->collectData($data, $profile)) {
// we need to clone for sub-requests
$profile->addCollector(clone $collector);
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.