-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add optional dependency tests for poetry
- Loading branch information
1 parent
7ba21cb
commit 7970c8b
Showing
27 changed files
with
4,164 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
61 changes: 61 additions & 0 deletions
61
...rkspaces/pip-app/packages/prometheus_client-0.6.0/build/lib/prometheus_client/__init__.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/python | ||
|
||
from . import core | ||
from . import exposition | ||
from . import gc_collector | ||
from . import platform_collector | ||
from . import process_collector | ||
from . import registry | ||
from . import metrics_core | ||
from . import metrics | ||
|
||
__all__ = ['Counter', 'Gauge', 'Summary', 'Histogram', 'Info', 'Enum'] | ||
|
||
CollectorRegistry = registry.CollectorRegistry | ||
REGISTRY = registry.REGISTRY | ||
Metric = metrics_core.Metric | ||
Counter = metrics.Counter | ||
Gauge = metrics.Gauge | ||
Summary = metrics.Summary | ||
Histogram = metrics.Histogram | ||
Info = metrics.Info | ||
Enum = metrics.Enum | ||
|
||
CONTENT_TYPE_LATEST = exposition.CONTENT_TYPE_LATEST | ||
generate_latest = exposition.generate_latest | ||
MetricsHandler = exposition.MetricsHandler | ||
make_wsgi_app = exposition.make_wsgi_app | ||
start_http_server = exposition.start_http_server | ||
start_wsgi_server = exposition.start_wsgi_server | ||
write_to_textfile = exposition.write_to_textfile | ||
push_to_gateway = exposition.push_to_gateway | ||
pushadd_to_gateway = exposition.pushadd_to_gateway | ||
delete_from_gateway = exposition.delete_from_gateway | ||
instance_ip_grouping_key = exposition.instance_ip_grouping_key | ||
|
||
ProcessCollector = process_collector.ProcessCollector | ||
PROCESS_COLLECTOR = process_collector.PROCESS_COLLECTOR | ||
|
||
PlatformCollector = platform_collector.PlatformCollector | ||
PLATFORM_COLLECTOR = platform_collector.PLATFORM_COLLECTOR | ||
|
||
GCCollector = gc_collector.GCCollector | ||
GC_COLLECTOR = gc_collector.GC_COLLECTOR | ||
|
||
if __name__ == '__main__': | ||
c = Counter('cc', 'A counter') | ||
c.inc() | ||
|
||
g = Gauge('gg', 'A gauge') | ||
g.set(17) | ||
|
||
s = Summary('ss', 'A summary', ['a', 'b']) | ||
s.labels('c', 'd').observe(17) | ||
|
||
h = Histogram('hh', 'A histogram') | ||
h.observe(.6) | ||
|
||
start_http_server(8000) | ||
import time | ||
while True: | ||
time.sleep(1) |
Empty file.
82 changes: 82 additions & 0 deletions
82
...s/pip-app/packages/prometheus_client-0.6.0/build/lib/prometheus_client/bridge/graphite.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/python | ||
from __future__ import unicode_literals | ||
|
||
import logging | ||
import re | ||
import socket | ||
import threading | ||
import time | ||
from timeit import default_timer | ||
|
||
from ..registry import REGISTRY | ||
|
||
# Roughly, have to keep to what works as a file name. | ||
# We also remove periods, so labels can be distinguished. | ||
|
||
_INVALID_GRAPHITE_CHARS = re.compile(r"[^a-zA-Z0-9_-]") | ||
|
||
|
||
def _sanitize(s): | ||
return _INVALID_GRAPHITE_CHARS.sub('_', s) | ||
|
||
|
||
class _RegularPush(threading.Thread): | ||
def __init__(self, pusher, interval, prefix): | ||
super(_RegularPush, self).__init__() | ||
self._pusher = pusher | ||
self._interval = interval | ||
self._prefix = prefix | ||
|
||
def run(self): | ||
wait_until = default_timer() | ||
while True: | ||
while True: | ||
now = default_timer() | ||
if now >= wait_until: | ||
# May need to skip some pushes. | ||
while wait_until < now: | ||
wait_until += self._interval | ||
break | ||
# time.sleep can return early. | ||
time.sleep(wait_until - now) | ||
try: | ||
self._pusher.push(prefix=self._prefix) | ||
except IOError: | ||
logging.exception("Push failed") | ||
|
||
|
||
class GraphiteBridge(object): | ||
def __init__(self, address, registry=REGISTRY, timeout_seconds=30, _timer=time.time): | ||
self._address = address | ||
self._registry = registry | ||
self._timeout = timeout_seconds | ||
self._timer = _timer | ||
|
||
def push(self, prefix=''): | ||
now = int(self._timer()) | ||
output = [] | ||
|
||
prefixstr = '' | ||
if prefix: | ||
prefixstr = prefix + '.' | ||
|
||
for metric in self._registry.collect(): | ||
for s in metric.samples: | ||
if s.labels: | ||
labelstr = '.' + '.'.join( | ||
['{0}.{1}'.format( | ||
_sanitize(k), _sanitize(v)) | ||
for k, v in sorted(s.labels.items())]) | ||
else: | ||
labelstr = '' | ||
output.append('{0}{1}{2} {3} {4}\n'.format( | ||
prefixstr, _sanitize(s.name), labelstr, float(s.value), now)) | ||
|
||
conn = socket.create_connection(self._address, self._timeout) | ||
conn.sendall(''.join(output).encode('ascii')) | ||
conn.close() | ||
|
||
def start(self, interval=60.0, prefix=''): | ||
t = _RegularPush(self, interval, prefix) | ||
t.daemon = True | ||
t.start() |
68 changes: 68 additions & 0 deletions
68
.../pip-app/packages/prometheus_client-0.6.0/build/lib/prometheus_client/context_managers.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from __future__ import unicode_literals | ||
|
||
from timeit import default_timer | ||
|
||
from .decorator import decorate | ||
|
||
|
||
class ExceptionCounter(object): | ||
def __init__(self, counter, exception): | ||
self._counter = counter | ||
self._exception = exception | ||
|
||
def __enter__(self): | ||
pass | ||
|
||
def __exit__(self, typ, value, traceback): | ||
if isinstance(value, self._exception): | ||
self._counter.inc() | ||
|
||
def __call__(self, f): | ||
def wrapped(func, *args, **kwargs): | ||
with self: | ||
return func(*args, **kwargs) | ||
|
||
return decorate(f, wrapped) | ||
|
||
|
||
class InprogressTracker(object): | ||
def __init__(self, gauge): | ||
self._gauge = gauge | ||
|
||
def __enter__(self): | ||
self._gauge.inc() | ||
|
||
def __exit__(self, typ, value, traceback): | ||
self._gauge.dec() | ||
|
||
def __call__(self, f): | ||
def wrapped(func, *args, **kwargs): | ||
with self: | ||
return func(*args, **kwargs) | ||
|
||
return decorate(f, wrapped) | ||
|
||
|
||
class Timer(object): | ||
def __init__(self, callback): | ||
self._callback = callback | ||
|
||
def _new_timer(self): | ||
return self.__class__(self._callback) | ||
|
||
def __enter__(self): | ||
self._start = default_timer() | ||
|
||
def __exit__(self, typ, value, traceback): | ||
# Time can go backwards. | ||
duration = max(default_timer() - self._start, 0) | ||
self._callback(duration) | ||
|
||
def __call__(self, f): | ||
def wrapped(func, *args, **kwargs): | ||
# Obtaining new instance of timer every time | ||
# ensures thread safety and reentrancy. | ||
with self._new_timer(): | ||
return func(*args, **kwargs) | ||
|
||
return decorate(f, wrapped) |
35 changes: 35 additions & 0 deletions
35
test/workspaces/pip-app/packages/prometheus_client-0.6.0/build/lib/prometheus_client/core.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import unicode_literals | ||
|
||
from .metrics import Counter, Enum, Gauge, Histogram, Info, Summary | ||
from .metrics_core import ( | ||
CounterMetricFamily, GaugeHistogramMetricFamily, GaugeMetricFamily, | ||
HistogramMetricFamily, InfoMetricFamily, Metric, Sample, | ||
StateSetMetricFamily, SummaryMetricFamily, UnknownMetricFamily, | ||
UntypedMetricFamily, | ||
) | ||
from .registry import CollectorRegistry, REGISTRY | ||
from .samples import Exemplar, Sample, Timestamp | ||
|
||
__all__ = ( | ||
'CollectorRegistry', | ||
'Counter', | ||
'CounterMetricFamily', | ||
'Enum', | ||
'Exemplar', | ||
'Gauge', | ||
'GaugeHistogramMetricFamily', | ||
'GaugeMetricFamily', | ||
'Histogram', | ||
'HistogramMetricFamily', | ||
'Info', | ||
'InfoMetricFamily', | ||
'Metric', | ||
'REGISTRY', | ||
'Sample', | ||
'StateSetMetricFamily', | ||
'Summary', | ||
'SummaryMetricFamily', | ||
'Timestamp', | ||
'UnknownMetricFamily', | ||
'UntypedMetricFamily', | ||
) |
Oops, something went wrong.