Skip to content

Commit 938dffd

Browse files
committed
Show what scheme was used
1 parent 11afbff commit 938dffd

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

Collector/QueryLogger.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
namespace Neo4j\Neo4jBundle\Collector;
66

7+
use GraphAware\Bolt\Result\Result;
78
use GraphAware\Common\Cypher\StatementInterface;
89
use GraphAware\Common\Result\StatementResult as StatementResultInterface;
910
use GraphAware\Common\Result\StatementStatisticsInterface;
11+
use GraphAware\Neo4j\Client\Exception\Neo4jExceptionInterface;
1012

1113
/**
1214
* @author Xavier Coureau <[email protected]>
@@ -59,6 +61,11 @@ public function record(StatementInterface $statement)
5961
*/
6062
public function finish(StatementResultInterface $statementResult)
6163
{
64+
$scheme = 'Http';
65+
if ($statementResult instanceof Result) {
66+
$scheme = 'Bolt';
67+
}
68+
6269
$statement = $statementResult->statement();
6370
$statementText = $statement->text();
6471
$statementParams = $statement->parameters();
@@ -77,9 +84,18 @@ public function finish(StatementResultInterface $statementResult)
7784
'end_time' => microtime(true) * 1000,
7885
'nb_results' => $statementResult->size(),
7986
'statistics' => $this->statisticsToArray($statementResult->summarize()->updateStatistics()),
87+
'scheme' => $scheme,
8088
]);
8189
}
8290

91+
/**
92+
* @param Neo4jExceptionInterface $exception
93+
*/
94+
public function logException(Neo4jExceptionInterface $exception)
95+
{
96+
// TODO log exceptions
97+
}
98+
8399
/**
84100
* {@inheritdoc}
85101
*/
@@ -138,7 +154,7 @@ private function statisticsToArray(StatementStatisticsInterface $statementStatis
138154
'constraints_added' => $statementStatistics->constraintsAdded(),
139155
'constraints_removed' => $statementStatistics->constraintsRemoved(),
140156
];
141-
157+
142158
return $data;
143159
}
144160
}

EventSubscriber/LoggerSubscriber.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Neo4j\Neo4jBundle\EventSubscriber;
66

7+
use GraphAware\Neo4j\Client\Event\FailureEvent;
78
use GraphAware\Neo4j\Client\Event\PostRunEvent;
89
use GraphAware\Neo4j\Client\Event\PreRunEvent;
910
use GraphAware\Neo4j\Client\Neo4jClientEvents;
@@ -33,6 +34,7 @@ public static function getSubscribedEvents()
3334
return [
3435
Neo4jClientEvents::NEO4J_PRE_RUN => 'onPreRun',
3536
Neo4jClientEvents::NEO4J_POST_RUN => 'onPostRun',
37+
Neo4jClientEvents::NEO4J_ON_FAILURE => 'onFailure',
3638
];
3739
}
3840

@@ -55,4 +57,12 @@ public function onPostRun(PostRunEvent $event)
5557
$this->queryLogger->finish($result);
5658
}
5759
}
60+
61+
/**
62+
* @param FailureEvent $event
63+
*/
64+
public function onFailure(FailureEvent $event)
65+
{
66+
$this->queryLogger->logException($event->getException());
67+
}
5868
}

Resources/views/webprofiler.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
<div>
7777
<strong class="font-normal text-small">Number of results</strong>: {{ statement.nb_results }}
7878
</div>
79+
<div>
80+
<strong class="font-normal text-small">Scheme</strong>: {{ statement.scheme }}
81+
</div>
7982
<div>
8083
<strong class="font-normal text-small">Statistics</strong>: {{ statement.statistics|yaml_encode }}
8184
</div>

0 commit comments

Comments
 (0)