Skip to content

Commit d6122fe

Browse files
committed
TASK: Cleanup logging to use LOGFMT and add performance data logging
1 parent 0195768 commit d6122fe

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/Command/NodeIndexQueueCommandController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class NodeIndexQueueCommandController extends CommandController {
4040
* @Flow\Inject
4141
*/
4242
protected $persistenceManager;
43-
43+
4444
/**
4545
* @Flow\Inject
4646
* @var NodeTypeMappingBuilder
@@ -104,7 +104,7 @@ public function buildCommand($workspace = NULL) {
104104
*/
105105
protected function indexWorkspace($workspaceName, $indexPostfix) {
106106
$offset = 0;
107-
$batchSize = 100;
107+
$batchSize = 250;
108108
while (TRUE) {
109109
$iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $offset, $batchSize);
110110

@@ -136,7 +136,7 @@ protected function indexWorkspace($workspaceName, $indexPostfix) {
136136
protected function createNextIndex($indexPostfix) {
137137
$this->nodeIndexer->setIndexNamePostfix($indexPostfix);
138138
$this->nodeIndexer->getIndex()->create();
139-
$this->logger->log('Created index ' . $this->nodeIndexer->getIndexName(), LOG_INFO);
139+
$this->logger->log(sprintf('action=indexing step=index-created index=%s', $this->nodeIndexer->getIndexName()), LOG_INFO);
140140
}
141141

142142
/**
@@ -148,7 +148,7 @@ protected function updateMapping() {
148148
/** @var \Flowpack\ElasticSearch\Domain\Model\Mapping $mapping */
149149
$mapping->apply();
150150
}
151-
$this->logger->log('Updated Mapping.', LOG_INFO);
151+
$this->logger->log(sprintf('action=indexing step=mapping-updated index=%s', $this->nodeIndexer->getIndexName()), LOG_INFO);
152152
}
153153

154154

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/IndexingJob.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public function __construct($indexPostfix, $workspaceName, array $nodes)
9494
public function execute(QueueInterface $queue, Message $message)
9595
{
9696
$this->nodeIndexer->withBulkProcessing(function () {
97+
$numberOfNodes = count($this->nodes);
98+
$startTime = microtime(true);
9799
foreach ($this->nodes as $node) {
98100
/** @var NodeData $nodeData */
99101
$nodeData = $this->nodeDataRepository->findByIdentifier($node['nodeIdentifier']);
@@ -107,18 +109,21 @@ public function execute(QueueInterface $queue, Message $message)
107109

108110
// Skip this iteration if the node can not be fetched from the current context
109111
if (!$currentNode instanceof NodeInterface) {
110-
$this->logger->log(sprintf('Node with identifier %s could not be processed', $node['nodeIdentifier']));
112+
$this->logger->log(sprintf('action=indexing step=failed node=%s message="Node could not be processed"', $node['nodeIdentifier']));
111113
continue;
112114
}
113115

114116
$this->nodeIndexer->setIndexNamePostfix($this->indexPostfix);
115-
$this->logger->log(sprintf('Process indexing job for %s', $currentNode));
117+
$this->logger->log(sprintf('action=indexing step=started node=%s', $currentNode->getIdentifier()));
116118

117119
$this->nodeIndexer->indexNode($currentNode);
118120

119121
}
120122

121123
$this->nodeIndexer->flush();
124+
$duration = microtime(true) - $startTime;
125+
$rate = $numberOfNodes / $duration;
126+
$this->logger->log(sprintf('action=indexing step=finished number_of_nodes=%d duration=%f nodes_per_second=%f', $numberOfNodes, $duration, $rate));
122127
});
123128

124129
return true;

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/UpdateAliasJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct($indexPostfix) {
6262
public function execute(QueueInterface $queue, Message $message) {
6363
$this->nodeIndexer->setIndexNamePostfix($this->indexPostfix);
6464
$this->nodeIndexer->updateIndexAlias();
65-
$this->logger->log(sprintf('Update Index Alias (%s)', $this->indexPostfix), LOG_NOTICE);
65+
$this->logger->log(sprintf('action=indexing step=index-switched alias=%s', $this->indexPostfix), LOG_NOTICE);
6666

6767
return TRUE;
6868
}

0 commit comments

Comments
 (0)