Package: zperfmetrics
Table of ContentsPerfmetrics configuration for Zope and PloneInstallationUsageRequest Lifecycle IntegrationZopePloneStatd, Graphite & Grafana in DockerSource CodeContributorsHistory1.0b5 (2016-08-05)1.0b4 (2016-08-05)1.0b3 (2016-08-05)1.0b2 (2016-08-04)1.0b1 (2016-08-04)1.0a7 (2016-08-03)1.0a6 (2016-07-28)1.0a5 (2016-06-28)1.0a4 (2016-06-10)1.0a3 (2016-06-09)1.0a2 (2016-03-22)1.0a1 (2016-03-22)1.0a0 (2016-03-22)LicensePerfmetrics configuration for Zope and Plonezperfmetrics works like and depends onperfmetrics, additional it:offers a ZConfig configuration for the statsd,uses the current requests path in the statd dotted path prefix,also provides a patch to measure plone.app.theming for diazo compile and diazo transform if Plone is available,InstallationFirst get yourstatsdconfigured properly.
This is out of scope of this module.Depend on this module in your packagessetup.py.Given you usezc.builodutto set up your Zope2 or Plone,
add to your[instance]section or the section withrecipe = plone.recipe.zope2instancethe lines:[instance01]
recipe = plone.recipe.zope2instance
...
zope-conf-imports =
    zperfmetrics
zope-conf-additional =
    <perfmetrics>
        uri statsd://localhost:8125
        before MyFancyProject
        hostname on
        virtualhost on
        after ${:_buildout_section_name_}
    </perfmetrics>
...Given this runs on a host calledw-plone1,
this will result in a prefixMyFancyProject.w-plone1.instance01.uriFull URI of statd.beforePrefix path before the hostname.hostnameGet hostname and insert into prefix.
(Boolean:onoroff)virtualhostGet virtualhost and use in ZPerfmetrics after the static prefix.
(Boolean:onoroff)afterPrefix path after the hostname.UsageYou need to decorate your code or use thewithstatement to measure a code block.Usage:from zperfmetrics import ZMetric
from zperfmetrics import zmetric
from zperfmetrics import zmetricmethod

@zmetric
def some_function():
    # whole functions timing and call counts will be measured
    pass

@ZMetric(stat='a_custom_prefix')
def some_other_function():
    # set a custom prefix instead of module path and fucntion name.
    pass

class Foo(object):

    @zmetricmethod
    def some_method(self):
        # whole methods timing and call counts will be measured
        pass

    @ZMetric(method=True, timing=False):
    def some_counted_method(self):
        # whole methods number of calls will be measured, but no times
        pass

    @ZMetric(method=True, count=False):
    def some_timed_method(self):
        # whole methods timing be measured, but no counts
        pass

    def some_method_partly_measured(self):
        # do something here you dont want to measure
        with ZMetric(stat='part_of_other_method_time'):
            # do something to measure
            # call counts and timing will be measured
            pass
        # do something here you dont want to measure

    @ZMetric(method=True, rate=0.5):
    def some_random_recorded_method(self):
        # randomly record 50% of the calls.
        passRequest Lifecycle IntegrationAll ZPerfmetrics with a request passed in are considered to be under therequest_lifecyclesection.All metrics in here are build like:$PREFIX.request_lifecycle.[$VIRTUAL_HOST].$PATH.*.ZopeThis package provides subscribers to measure the time a request takes,
including some points in time between.These subscribers are loaded via zcml and are logging underpublish.*:publish.traversaltime needed from publication start until traversal is finished.publish.renderingtime needed from traversal end until before commit begin.This value is a bit fuzzy and should be taken with a grain of salt,
because there can be other subscribers to this event which take their time.
Since the order of execution of the subscribers is not defined,
processing may happen after this measurementIf plone tranformchain is active,
the rendering time is before transforms are starting.publish.finalizetime needed from rendering end (or transform end if plone.transformchain is active) until database commit is done.publish_allwhole time needed from publication start until request is completly processed.PloneInstalling this package in Plone by depending onzperfmetrics[plone]forces usage ofplone.transformchainversion 1.2 or newer.First,publish.renderinggets less fuzzy because the expensive transforms (also subscribers to publish.beforecommit) are all done.Then it introduces new measurements related toplone.transformchain:publish.transform_alltime needed for all transforms in theplone.transformchain.
This usually includes Diazo.publish_transform_single.${ORDER}-${TRANSFORMNAME}time needed for a specific single transform.
transforms are ordered and named, both are replaced.This package patches:diazo.setupmetricplone.app.theming.transform.ThemeTransform.setupTransformis patched as a basic (path-less) perfmetricsMetric.
The setup of the transform happens once on startup and is the time needed to create the Diazo xslt from its rules.xml, index.html and related files.Statd, Graphite & Grafana in DockerSetting up Statsd, Graphite and Grafana can be complex.
For local testing - but also for production environments - firing up some docker containers comes in handy.A very minimal version of such aStatd, Graphite & Grafana in Docker setup(original) helps getting things initially up and running.Install Dockerandinstall docker-compose(justpip installdocker-compose),
then just clone the repository and in itsdockerdirectory rundocker-composeup-d.Let Zperfmetrics point touristatsd://localhost:8125and collect some data.
Open Grafana in your browser athttp://localhost:3000.Go first toGrafana Getting Started,
the 10 minute videoreally helpsto find the hidden part of its UI.Source CodeThe sources are in a GIT DVCS with its main branches atgithub.We’d be happy to see many branches, forks and pull-requests to make zperfmetrics even better.ContributorsJens W. Klein <jens@bluedynamics.com>Zalán SomogyváryHistory1.0b5 (2016-08-05)Event better naming in order to be able to group and stack:
Renamedpublish.sumtopublish_allandpublish.transform_singletopublish_transform_single.
[jensens]1.0b4 (2016-08-05)Cleanup names, better grouping in order to make graphing easier.
[jensens]1.0b3 (2016-08-05)Enhancement: Introduce after-prefix a top levelrequest_lifecycleto be consistent with levels.
[jensens]1.0b2 (2016-08-04)Fix: Name of a single transform may contain dots.
They are now replaced by_.
[jensens]Fix: The root element of a path was not shown on the same level as all other paths.
Now it is shown as__root__[jensens]Feature: It was not possible to filter by virtual host in environment with more than one site per Zope.
A new configuration optionvirtualhostwas introduced.
If set to on, the virtualhost name will be inserted beforePATH.
[jensens]Support: In order to make a test installation easier,
an example docker-compose setup was added to the Github repository together with some documentation in the README.rst.
[jensens]1.0b1 (2016-08-04)Added subscribers toplone.transformchainevents.
New setup extra[plone].
Removed one patch for diazo transform.
Madepublish.beforecommitless fuzzy in Plone.
[jensens]1.0a7 (2016-08-03)Fix: virtual path config in ZMetric class.
[syzn]1.0a6 (2016-07-28)Feature: New value publish.commit.
Delta time used from publish.beforecommit to request end.
[jensens]Fix: publish.sum shows now overall time of request processing.
[jensens]Fix: Update README to reflect last changes.
[jensens]Use more beautiful paths if VirtualHostMonster is used.
[syzn]1.0a5 (2016-06-28)Fix: Before/after hooks were not assigned correctly.
[jensens]1.0a4 (2016-06-10)Fixes measurements of zope request, also add more detailed metrics.
[jensens]1.0a3 (2016-06-09)Measure time a zope request needs.
[jensens]1.0a2 (2016-03-22)Refactored: ZConfig best practice
[jensens]Fix: Strip trailing dot from prefix
[jensens]1.0a1 (2016-03-22)Fix: README was wrong.
[jensens]1.0a0 (2016-03-22)made it work [jensens, 2016-03-17]LicenseCopyright (c) 2016, BlueDynamics Alliance, Austria, Germany, Switzerland
All rights reserved.Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.Neither the name of the BlueDynamics Alliance nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY BlueDynamics AllianceAS ISAND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL BlueDynamics Alliance BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.