Skip to content

Commit d9dc287

Browse files
committed
re-apply black after rebase
Signed-off-by: Benjamin Wohlwend <[email protected]>
1 parent 2c4f772 commit d9dc287

File tree

6 files changed

+27
-36
lines changed

6 files changed

+27
-36
lines changed

elasticapm/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ def __init__(self, config=None, **inline):
138138
skip_modules = ("elasticapm.",)
139139

140140
self.transaction_store = TransactionsStore(
141-
frames_collector_func=lambda: list(stacks.iter_stack_frames(
142-
start_frame=inspect.currentframe(),
143-
skip_top_modules=skip_modules,
144-
)),
141+
frames_collector_func=lambda: list(
142+
stacks.iter_stack_frames(start_frame=inspect.currentframe(), skip_top_modules=skip_modules)
143+
),
145144
frames_processing_func=lambda frames: self._get_stack_info_for_trace(
146145
frames,
147146
library_frame_context_lines=self.config.source_lines_span_library_frames,

elasticapm/context/contextvars.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import contextvars
44

5-
elasticapm_transaction_var = contextvars.ContextVar('elasticapm_transaction_var')
6-
elasticapm_span_var = contextvars.ContextVar('elasticapm_span_var')
5+
elasticapm_transaction_var = contextvars.ContextVar("elasticapm_transaction_var")
6+
elasticapm_span_var = contextvars.ContextVar("elasticapm_span_var")
77

88

99
def get_transaction(clear=False):

elasticapm/contrib/asyncio/traces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
2626
try:
2727
transaction.end_span(self.skip_frames)
2828
except LookupError:
29-
error_logger.info('ended non-existing span %s of type %s', self.name, self.type)
29+
error_logger.info("ended non-existing span %s of type %s", self.name, self.type)
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from elasticapm import async_capture_span
2-
from elasticapm.instrumentation.packages.asyncio_base import \
3-
AsyncAbstractInstrumentedModule
2+
from elasticapm.instrumentation.packages.asyncio_base import AsyncAbstractInstrumentedModule
43
from elasticapm.utils import default_ports
54
from elasticapm.utils.compat import urlparse
65

@@ -9,27 +8,22 @@ def get_host_from_url(url):
98
parsed_url = urlparse.urlparse(url)
109
host = parsed_url.hostname or " "
1110

12-
if (
13-
parsed_url.port and
14-
default_ports.get(parsed_url.scheme) != parsed_url.port
15-
):
11+
if parsed_url.port and default_ports.get(parsed_url.scheme) != parsed_url.port:
1612
host += ":" + str(parsed_url.port)
1713

1814
return host
1915

2016

2117
class AioHttpClientInstrumentation(AsyncAbstractInstrumentedModule):
22-
name = 'aiohttp_client'
18+
name = "aiohttp_client"
2319

24-
instrument_list = [
25-
("aiohttp.client", "ClientSession._request"),
26-
]
20+
instrument_list = [("aiohttp.client", "ClientSession._request")]
2721

2822
async def call(self, module, method, wrapped, instance, args, kwargs):
29-
method = kwargs['method'] if 'method' in kwargs else args[0]
30-
url = kwargs['method'] if 'method' in kwargs else args[1]
23+
method = kwargs["method"] if "method" in kwargs else args[0]
24+
url = kwargs["method"] if "method" in kwargs else args[1]
3125

3226
signature = " ".join([method.upper(), get_host_from_url(url)])
3327

34-
async with async_capture_span(signature, "ext.http.aiohttp", {'url': url}, leaf=True):
28+
async with async_capture_span(signature, "ext.http.aiohttp", {"url": url}, leaf=True):
3529
return await wrapped(*args, **kwargs)

elasticapm/instrumentation/register.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
}
2929

3030
if sys.version_info >= (3, 5):
31-
_cls_register.update([
32-
'elasticapm.instrumentation.packages.aiohttp.AioHttpClientInstrumentation',
33-
])
31+
_cls_register.update(["elasticapm.instrumentation.packages.aiohttp.AioHttpClientInstrumentation"])
3432

3533

3634
def register(cls):

elasticapm/traces.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@
2727

2828

2929
class Transaction(object):
30-
def __init__(
31-
self,
32-
store,
33-
transaction_type="custom",
34-
is_sampled=True,
35-
):
30+
def __init__(self, store, transaction_type="custom", is_sampled=True):
3631
self.id = str(uuid.uuid4())
3732
self.timestamp = datetime.datetime.utcnow()
3833
self.start_time = _time_func()
@@ -149,16 +144,24 @@ def to_dict(self):
149144

150145

151146
class DroppedSpan(object):
152-
__slots__ = ('leaf', 'parent')
147+
__slots__ = ("leaf", "parent")
153148

154149
def __init__(self, parent, leaf=False):
155150
self.parent = parent
156151
self.leaf = leaf
157152

158153

159154
class TransactionsStore(object):
160-
def __init__(self, frames_collector_func, frames_processing_func, collect_frequency, sample_rate=1.0, max_spans=0,
161-
max_queue_size=None, span_frames_min_duration=None, ignore_patterns=None,
155+
def __init__(
156+
self,
157+
frames_collector_func,
158+
frames_processing_func,
159+
collect_frequency,
160+
sample_rate=1.0,
161+
max_spans=0,
162+
max_queue_size=None,
163+
span_frames_min_duration=None,
164+
ignore_patterns=None,
162165
):
163166
self.cond = threading.Condition()
164167
self.collect_frequency = collect_frequency
@@ -206,10 +209,7 @@ def begin_transaction(self, transaction_type):
206209
:returns the Transaction object
207210
"""
208211
is_sampled = self._sample_rate == 1.0 or self._sample_rate > random.random()
209-
transaction = Transaction(
210-
self, transaction_type,
211-
is_sampled=is_sampled,
212-
)
212+
transaction = Transaction(self, transaction_type, is_sampled=is_sampled)
213213
set_transaction(transaction)
214214
return transaction
215215

0 commit comments

Comments
 (0)