Пример #1
0
def get_context() -> SpanContext:
    if not hasattr(_thread_local, 'context'):
        _thread_local.context = None
    _thread_local.context = _thread_local.context or (
        SpanContext() if agent.connected() else NoopContext())

    return _thread_local.context
Пример #2
0
def get_context() -> SpanContext:
    spans = _spans()

    if spans:
        return spans[len(spans) - 1].context

    return SpanContext() if agent.connected() else NoopContext()
Пример #3
0
def get_context() -> SpanContext:
    local = _local()
    context = getattr(local, 'context', False)

    if not context:
        context = local.context = (SpanContext() if agent.connected() else NoopContext())
        _spans_set([])  # XXX would be better in SpanContext.__init__() but for some reason doesn't work there

    return context
Пример #4
0
def get_context() -> SpanContext:
    _thread_local.context = _thread_local.context or (SpanContext() if agent.connected() else NoopContext())

    return _thread_local.context