|
22 | 22 | from epsagon.trace_transports import NoneTransport, HTTPTransport, LogTransport |
23 | 23 | from .constants import ( |
24 | 24 | TIMEOUT_GRACE_TIME_MS, |
25 | | - EPSAGON_MARKER, |
26 | 25 | MAX_LABEL_SIZE, |
27 | 26 | DEFAULT_SAMPLE_RATE, |
28 | 27 | TRACE_URL_PREFIX, |
@@ -96,7 +95,6 @@ def __init__(self): |
96 | 95 | self.keys_to_ignore = None |
97 | 96 | self.keys_to_allow = None |
98 | 97 | self.use_single_trace = True |
99 | | - self.use_async_tracer = False |
100 | 98 | self.singleton_trace = None |
101 | 99 | self.local_thread_to_unique_id = {} |
102 | 100 | self.transport = NoneTransport() |
@@ -209,13 +207,6 @@ def switch_to_multiple_traces(self): |
209 | 207 | """ |
210 | 208 | self.use_single_trace = False |
211 | 209 |
|
212 | | - def switch_to_async_tracer(self): |
213 | | - """ |
214 | | - Set the use_async_tracer flag to True. |
215 | | - :return: None |
216 | | - """ |
217 | | - self.use_async_tracer = True |
218 | | - |
219 | 210 | def _create_new_trace(self, unique_id=None): |
220 | 211 | """ |
221 | 212 | Creating new trace instance |
@@ -264,66 +255,18 @@ def _get_thread_trace(self, should_create=False): |
264 | 255 | self.traces[thread_id] = new_trace |
265 | 256 | return self.traces[thread_id] |
266 | 257 |
|
267 | | - @staticmethod |
268 | | - def _get_current_task(): |
269 | | - """ |
270 | | - Gets the current asyncio task safely |
271 | | - :return: The task. |
272 | | - """ |
273 | | - # Dynamic import since this is only valid in Python3+ |
274 | | - asyncio = __import__('asyncio') |
275 | | - try: |
276 | | - return asyncio.Task.current_task() |
277 | | - except RuntimeError: |
278 | | - return None |
279 | | - |
280 | | - def _get_tracer_async_mode(self, should_create): |
281 | | - """ |
282 | | - Get trace assuming async tracer. |
283 | | - :return: The trace. |
284 | | - """ |
285 | | - task = type(self)._get_current_task() |
286 | | - if not task: |
287 | | - return None |
288 | | - |
289 | | - trace = getattr(task, EPSAGON_MARKER, None) |
290 | | - if not trace and should_create: |
291 | | - trace = self._create_new_trace() |
292 | | - setattr(task, EPSAGON_MARKER, trace) |
293 | | - return trace |
294 | | - |
295 | | - def _pop_trace_async_mode(self): |
296 | | - """ |
297 | | - Pops the trace from the current task, assuming async tracer |
298 | | - :return: The trace. |
299 | | - """ |
300 | | - task = type(self)._get_current_task() |
301 | | - if not task: |
302 | | - return None |
303 | | - |
304 | | - trace = getattr(task, EPSAGON_MARKER, None) |
305 | | - if trace: # can safely remove tracer from async task |
306 | | - delattr(task, EPSAGON_MARKER) |
307 | | - return trace |
308 | | - |
309 | 258 | def _get_trace(self, unique_id=None, should_create=False): |
310 | 259 | """ |
311 | 260 | Get trace based on the tracing mode: |
312 | 261 | single trace (use_single_trace=True) or |
313 | | - multiple threads (use_single_trace=False) or |
314 | | - async tasks (use_async_tracer=True) |
| 262 | + multiple threads (use_single_trace=False) |
315 | 263 |
|
316 | 264 | If should_create then creating a new trace if trace does not exist |
317 | 265 | if use_single_trace is set to False, each thread will have |
318 | 266 | it's own trace.. |
319 | | - if use_async_tracer is set to True, each asyncio.Task will be |
320 | | - assigned with the trace. |
321 | 267 | :return: The trace. |
322 | 268 | """ |
323 | 269 | with TraceFactory.LOCK: |
324 | | - if self.use_async_tracer: |
325 | | - return self._get_tracer_async_mode(should_create=should_create) |
326 | | - |
327 | 270 | unique_id = self.get_thread_local_unique_id(unique_id) |
328 | 271 | if unique_id: |
329 | 272 | trace = ( |
@@ -378,11 +321,6 @@ def pop_trace(self, trace=None): |
378 | 321 | :return: unique id |
379 | 322 | """ |
380 | 323 | with self.LOCK: |
381 | | - if self.use_async_tracer: |
382 | | - trace = self._pop_trace_async_mode() |
383 | | - if trace: |
384 | | - # async tracer found |
385 | | - return trace |
386 | 324 | if self.traces: |
387 | 325 | trace = self.traces.pop(self.get_trace_identifier(trace), None) |
388 | 326 | if not self.traces: |
|
0 commit comments