Create Zend Server Monitor Event #2343

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@ruslan-g

Create Zend Server Monitor Event when exception thrown

@b-durand

I don't "understand" the strategy here 😉

It's a bad idea IMHO:

  1. All people don't run with a Zend Server as PHP stack (apache, nginx, ...)
  2. We have already Zend\Log\Writer\ZendMonitor, so you catch the exception and log the event with the needed backend. Where is the benefit here?

I would dismiss this PR.

@weierophinney weierophinney commented on the diff Sep 13, 2012
library/Zend/Mvc/View/Http/ViewManager.php
$this->registerMvcRenderingStrategies($events);
$this->registerViewStrategies();
$events->attach($routeNotFoundStrategy);
+ $events->attach($zendMonitorExceptionStrategy);
@weierophinney
weierophinney Sep 13, 2012

This is the wrong place to wire it. Since it has to do with dispatch logic, it should not be in the ViewManager.

I'd recommend creating a Logger service factory. Users could then call on that to attach additional writers, or to simply get the logger instance. We could then by default add a ZendMonitor log writer, and have filters attached to it that only log in certain situations. This could then be attached to specific events.

@b-durand
b-durand Sep 14, 2012

Why add a ZendMonitor LogWriter by default? I don't understand...

@weierophinney weierophinney commented on the diff Sep 13, 2012
...y/Zend/Mvc/View/Http/ZendMonitorExceptionStrategy.php
@@ -0,0 +1,118 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
+
+namespace Zend\Mvc\View\Http;
@weierophinney
weierophinney Sep 13, 2012

Again, this is not view related. I'd actually put it at the top-level of the Mvc hierarchy instead.

@weierophinney weierophinney commented on the diff Sep 13, 2012
...y/Zend/Mvc/View/Http/ZendMonitorExceptionStrategy.php
+ }
+
+ switch ($error) {
+ case Application::ERROR_CONTROLLER_NOT_FOUND:
+ case Application::ERROR_CONTROLLER_INVALID:
+ case Application::ERROR_ROUTER_NO_MATCH:
+ // Specifically not handling these
+ return;
+
+ case Application::ERROR_EXCEPTION:
+ default:
+ if (!empty($e)) {
+ $exception = $e->getParam('exception'); /* @var $exception \Exception */
+ $message = 'An error occurred during execution: ' . $exception->getMessage();
+ if ($this->isCustomEventByRuleIsEnabled()) {
+ zend_monitor_custom_event_ex('Zend Framework Exception', $message, 'Zend Framework Exception Rule');
@weierophinney
weierophinney Sep 13, 2012

Why isn't the ZendMonitor log writer being used here?

@weierophinney
Zend Framework member

Ruslan -- we may want to chat a bit about this over email or skype. I think a different direction is likely necessary, and want to go over ideas with you.

@b-durand

We don't have a "global" exception handler (aka try/catch) in MVC dispatch or you want to use Error in event without exception?

@weierophinney weierophinney reopened this Sep 14, 2012
@weierophinney
Zend Framework member

Closing, following a discussion with Yonni Mendes (from the Server UI team); he will likely submit a new PR based on the feedback I gave to him verbally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment