FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Bundle decorator.py and fix decorators by hynek · Pull Request #91 · prometheus/client_python · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) No extension  (1) dotfile  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 3 additions & 1 deletion .coveragerc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[run]
branch = True
source = prometheus_client
omit =
prometheus_client/decorator.py

[paths]
source =
Expand All @@ -9,4 +11,4 @@ source =
.tox/pypy/site-packages/prometheus_client

[report]
show_missing = True
show_missing = True
3 changes: 3 additions & 0 deletions NOTICE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Prometheus instrumentation library for Python applications
Copyright 2015 The Prometheus Authors

This product bundles decorator 4.0.10 which is available under a "2-clause BSD"
license. For details, see prometheus_client/decorator.py.
38 changes: 17 additions & 21 deletions prometheus_client/core.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# Python 3
unicode = str

from functools import wraps
from threading import Lock

from .decorator import decorate

_METRIC_NAME_RE = re.compile(r'^[a-zA-Z_:][a-zA-Z0-9_:]*$')
_METRIC_LABEL_NAME_RE = re.compile(r'^[a-zA-Z_:][a-zA-Z0-9_:]*$')
_RESERVED_METRIC_LABEL_NAME_RE = re.compile(r'^__.*$')
Expand Down Expand Up @@ -657,11 +658,10 @@ def __exit__(self, typ, value, traceback):
self._histogram.observe(max(time.time() - self._start, 0))

def __call__(self, f):
@wraps(f)
def wrapped(*args, **kwargs):
def wrapped(func, *args, **kwargs):
with self:
return f(*args, **kwargs)
return wrapped
return func(*args, **kwargs)
return decorate(f, wrapped)


class _ExceptionCounter(object):
Expand All @@ -677,11 +677,10 @@ def __exit__(self, typ, value, traceback):
self._counter.inc()

def __call__(self, f):
@wraps(f)
def wrapped(*args, **kwargs):
def wrapped(func, *args, **kwargs):
with self:
return f(*args, **kwargs)
return wrapped
return func(*args, **kwargs)
return decorate(f, wrapped)


class _InprogressTracker(object):
Expand All @@ -695,11 +694,10 @@ def __exit__(self, typ, value, traceback):
self._gauge.dec()

def __call__(self, f):
@wraps(f)
def wrapped(*args, **kwargs):
def wrapped(func, *args, **kwargs):
with self:
return f(*args, **kwargs)
return wrapped
return func(*args, **kwargs)
return decorate(f, wrapped)


class _SummaryTimer(object):
Expand All @@ -714,11 +712,10 @@ def __exit__(self, typ, value, traceback):
self._summary.observe(max(time.time() - self._start, 0))

def __call__(self, f):
@wraps(f)
def wrapped(*args, **kwargs):
def wrapped(func, *args, **kwargs):
with self:
return f(*args, **kwargs)
return wrapped
return func(*args, **kwargs)
return decorate(f, wrapped)


class _GaugeTimer(object):
Expand All @@ -733,8 +730,7 @@ def __exit__(self, typ, value, traceback):
self._gauge.set(max(time.time() - self._start, 0))

def __call__(self, f):
@wraps(f)
def wrapped(*args, **kwargs):
def wrapped(func, *args, **kwargs):
with self:
return f(*args, **kwargs)
return wrapped
return func(*args, **kwargs)
return decorate(f, wrapped)
Loading

Back | FazBrowse Home | New Git URL