/**
  * Profile before and after product load, using Blackfire
  *
  * @param \Magento\Catalog\Model\Product $subject
  * @param callable $proceed
  * @param int $modelId
  * @param null $field
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundLoad(\Magento\Catalog\Model\Product $subject, \Closure $proceed, $modelId, $field = null)
 {
     // obtain a Blackfire client
     $blackfire = new Client(new \Blackfire\ClientConfiguration($this->blackFireClientId, $this->blackFireClientToken));
     // start Backfire probing
     $probe = $blackfire->createProbe();
     // perform the actual product load
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $proceed($modelId, $field);
     // end Blackfire probing
     $blackfire->endProbe($probe);
     return $product;
 }
 /**
  * @param Client $client
  * @param \closure $callback
  * @param Configuration $config
  *
  * @return $this
  */
 public function setWith($client, $callback = null, $config = null)
 {
     if (!$client instanceof Client) {
         $this->fail($this->_('%s is not a blackfire client', $this));
     }
     if (!$callback instanceof \closure) {
         $this->fail($this->_('%s is not a closure', $this));
     }
     if (!$config instanceof Configuration) {
         $this->fail($this->_('%s is not a profile configuration', $this));
     }
     try {
         $probe = $client->createProbe($config);
         $callback();
         $profile = $client->endProbe($probe);
     } catch (ExceptionInterface $e) {
         $this->fail($e->getMessage());
     }
     parent::setWith($profile);
     return $this;
 }