Decorators

base

This module contains a Metlog decorator base class and some additional helper code. The primary reason for these abstractions is ‘deferred configuration’. Decorators are evaluated by Python at import time, but often the configuration needed for a Metlog client, which might negate (or change) the behavior of a Metlog decorator, isn’t available until later, after some config parsing code has executed. This code provides a mechanism to have a function get wrapped in one way (or not at all) when the decorator is originally evaluated, but then to be wrapped differently once the config has loaded and the desired final behavior has been established.

metlog.decorators.base.MetlogDecorator[source]

This is a base class for Metlog decorators, designed to support ‘rebinding’ of the actual decorator method once Metlog configuration has actually been loaded. The first time the decorated function is invoked, the predicate method will be called. If the result is True, then metlog_call (intended to be implemented by subclasses) will be used as the decorator. If the predicate returns False, then _invoke (which by default does nothing but call the wrapped function) will be used as the decorator.

util

metlog.decorators.util.return_fq_name(func, klass=None)[source]

Resolve a fully qualified name for a function or method

stats

metlog.decorators.stats.incr_count[source]

Lazily decorate any callable w/ a wrapper that will increment a metlog counter whenever the callable is invoked.

metlog.decorators.stats.timeit[source]

Lazily decorate any callable with a metlog timer.

Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.