Skip to content

[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
added type info to profiles
  • Loading branch information
yjv committed Nov 6, 2016
commit b616f96c7e551128fb2ce109dacbeca1d81fde0d
19 changes: 9 additions & 10 deletions src/Symfony/Component/Profiler/Context/ConsoleCommandContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,26 @@ public function __construct(Command $command, $exitCode, $exception = null)
$this->command = $command;
}

/**
* @return \Exception|\Throwable|null
*/
public function getException()
{
return $this->exception;
}

/**
* @return null|string
*/
public function getName()
{
return sprintf('command=>%s', $this->command->getName());
return sprintf('command => %s', $this->command->getName());
}

/**
* @return null|string
*/
public function getStatusCode()
{
return $this->exitCode;
}

/**
* @return string
*/
public function getType()
{
return Types::COMMAND;
}
}
9 changes: 7 additions & 2 deletions src/Symfony/Component/Profiler/Context/ContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ interface ContextInterface
public function getException();

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

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

/**
* @return null|int
*/
public function getStatusCode();
}
8 changes: 8 additions & 0 deletions src/Symfony/Component/Profiler/Context/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ public function getResponse()
{
return $this->response;
}

/**
* @return string
*/
public function getType()
{
return Types::REQUEST;
}
}
16 changes: 16 additions & 0 deletions src/Symfony/Component/Profiler/Context/Types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Created by PhpStorm.
* User: yosefderay
* Date: 11/5/16
* Time: 9:21 PM
*/

namespace Symfony\Component\Profiler\Context;


final class Types
{
const REQUEST = 'request';
const COMMAND = 'command';
}
17 changes: 17 additions & 0 deletions src/Symfony/Component/Profiler/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Profile
private $name;
private $time;
private $statusCode;
private $type;

/**
* @var Profile
Expand Down Expand Up @@ -198,6 +199,22 @@ public function getChildren()
return $this->children;
}

/**
* @return mixed
*/
public function getType()
{
return $this->type;
}

/**
* @param mixed $type
*/
public function setType($type)
{
$this->type = $type;
}

/**
* Sets children profiler.
*
Expand Down
11 changes: 6 additions & 5 deletions src/Symfony/Component/Profiler/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,23 @@ public function find($ip, $url, $limit, $method, $statusCode, $start, $end)
/**
* Collects data for the given response.
*
* @param ContextInterface $data
* @param ContextInterface $context
* @return null|Profile A Profile instance or null if the profiler is disabled
*/
public function collectData(ContextInterface $data)
public function collectData(ContextInterface $context)
{
if (false === $this->enabled) {
return null;
}

$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
$profile->setTime(time());
$profile->setName($data->getName());
$profile->setStatusCode($data->getStatusCode());
$profile->setName($context->getName());
$profile->setStatusCode($context->getStatusCode());
$profile->setType($context->getType());

foreach ($this->collectors as $collector) {
if ($collector->collectData($data, $profile)) {
if ($collector->collectData($context, $profile)) {
// we need to clone for sub-requests
$profile->addCollector(clone $collector);
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy