Add opentracing stubs (#6473)

This commit is contained in:
kasium
2021-12-02 20:55:35 +01:00
committed by GitHub
parent 3f281881c2
commit 906d5f1faf
29 changed files with 328 additions and 0 deletions

View File

@@ -35,6 +35,7 @@
"stubs/Markdown",
"stubs/mysqlclient",
"stubs/oauthlib",
"stubs/opentracing",
"stubs/Pillow",
"stubs/paramiko",
"stubs/prettytable",

View File

@@ -0,0 +1,4 @@
opentracing.harness.api_check
opentracing.harness.scope_check
opentracing.scope_managers.gevent
opentracing.scope_managers.tornado

View File

@@ -0,0 +1 @@
version = "2.4.*"

View File

@@ -0,0 +1,24 @@
from .propagation import (
Format as Format,
InvalidCarrierException as InvalidCarrierException,
SpanContextCorruptedException as SpanContextCorruptedException,
UnsupportedFormatException as UnsupportedFormatException,
)
from .scope import Scope as Scope
from .scope_manager import ScopeManager as ScopeManager
from .span import Span as Span, SpanContext as SpanContext
from .tracer import (
Reference as Reference,
ReferenceType as ReferenceType,
Tracer as Tracer,
child_of as child_of,
follows_from as follows_from,
start_child_span as start_child_span,
)
tracer: Tracer
is_tracer_registered: bool
def global_tracer() -> Tracer: ...
def set_global_tracer(value: Tracer) -> None: ...
def is_global_tracer_registered() -> bool: ...

View File

@@ -0,0 +1 @@
from ..tags import *

View File

@@ -0,0 +1,34 @@
from opentracing.span import Span
from ..tracer import Tracer
class APICompatibilityCheckMixin:
def tracer(self) -> Tracer: ...
def check_baggage_values(self) -> bool: ...
def check_scope_manager(self) -> bool: ...
def is_parent(self, parent, span: Span) -> bool: ...
def test_active_span(self) -> None: ...
def test_start_active_span(self) -> None: ...
def test_start_active_span_parent(self) -> None: ...
def test_start_active_span_ignore_active_span(self) -> None: ...
def test_start_active_span_not_finish_on_close(self) -> None: ...
def test_start_active_span_finish_on_close(self) -> None: ...
def test_start_active_span_default_finish_on_close(self) -> None: ...
def test_start_span(self) -> None: ...
def test_start_span_propagation(self) -> None: ...
def test_start_span_propagation_ignore_active_span(self) -> None: ...
def test_start_span_with_parent(self) -> None: ...
def test_start_child_span(self) -> None: ...
def test_set_operation_name(self) -> None: ...
def test_span_as_context_manager(self) -> None: ...
def test_span_tag_value_types(self) -> None: ...
def test_span_tags_with_chaining(self) -> None: ...
def test_span_logs(self) -> None: ...
def test_span_baggage(self) -> None: ...
def test_context_baggage(self) -> None: ...
def test_text_propagation(self) -> None: ...
def test_binary_propagation(self) -> None: ...
def test_mandatory_formats(self) -> None: ...
def test_unknown_format(self) -> None: ...
def test_tracer_start_active_span_scope(self) -> None: ...
def test_tracer_start_span_scope(self) -> None: ...

View File

@@ -0,0 +1,11 @@
class ScopeCompatibilityCheckMixin:
def scope_manager(self) -> None: ...
def run_test(self, test_fn) -> None: ...
def test_missing_active_external(self) -> None: ...
def test_missing_active(self) -> None: ...
def test_activate(self) -> None: ...
def test_activate_external(self) -> None: ...
def test_activate_finish_on_close(self) -> None: ...
def test_activate_nested(self) -> None: ...
def test_activate_finish_on_close_nested(self) -> None: ...
def test_close_wrong_order(self) -> None: ...

View File

@@ -0,0 +1,5 @@
ERROR_KIND: str
ERROR_OBJECT: str
EVENT: str
MESSAGE: str
STACK: str

View File

@@ -0,0 +1,2 @@
from .propagator import Propagator as Propagator
from .tracer import MockTracer as MockTracer

View File

@@ -0,0 +1,6 @@
from ..span import SpanContext
from .propagator import Propagator
class BinaryPropagator(Propagator):
def inject(self, span_context: SpanContext, carrier) -> None: ...
def extract(self, carrier): ...

View File

@@ -0,0 +1,11 @@
from typing import Any
import opentracing
class SpanContext(opentracing.SpanContext):
trace_id: Any
span_id: Any
def __init__(self, trace_id=..., span_id=..., baggage=...) -> None: ...
@property
def baggage(self): ...
def with_baggage_item(self, key, value): ...

View File

@@ -0,0 +1,5 @@
from ..span import SpanContext
class Propagator:
def inject(self, span_context: SpanContext, carrier) -> None: ...
def extract(self, carrier) -> None: ...

View File

@@ -0,0 +1,24 @@
from typing import Any
from opentracing import Span
class MockSpan(Span):
operation_name: str
start_time: Any
parent_id: Any
tags: Any
finish_time: int
finished: bool
logs: Any
def __init__(self, tracer, operation_name=..., context=..., parent_id=..., tags=..., start_time=...) -> None: ...
def set_operation_name(self, operation_name: str): ...
def set_tag(self, key, value): ...
def log_kv(self, key_values, timestamp=...): ...
def finish(self, finish_time=...) -> None: ...
def set_baggage_item(self, key, value): ...
def get_baggage_item(self, key): ...
class LogData:
key_values: Any
timestamp: Any
def __init__(self, key_values, timestamp=...) -> None: ...

View File

@@ -0,0 +1,14 @@
from typing import Any
from ..span import SpanContext
from .propagator import Propagator
prefix_tracer_state: str
prefix_baggage: str
field_name_trace_id: Any
field_name_span_id: Any
field_count: int
class TextPropagator(Propagator):
def inject(self, span_context: SpanContext, carrier) -> None: ...
def extract(self, carrier): ...

View File

@@ -0,0 +1,25 @@
from ..scope_manager import ScopeManager
from ..span import SpanContext
from ..tracer import Tracer
from .propagator import Propagator
class MockTracer(Tracer):
def __init__(self, scope_manager: ScopeManager | None = ...) -> None: ...
def register_propagator(self, format, propagator: Propagator) -> None: ...
def finished_spans(self): ...
def reset(self) -> None: ...
def start_active_span(
self,
operation_name,
child_of=...,
references=...,
tags=...,
start_time=...,
ignore_active_span: bool = ...,
finish_on_close: bool = ...,
): ...
def start_span(
self, operation_name=..., child_of=..., references=..., tags=..., start_time=..., ignore_active_span: bool = ...
): ...
def inject(self, span_context: SpanContext, format, carrier) -> None: ...
def extract(self, format, carrier): ...

View File

@@ -0,0 +1,8 @@
class UnsupportedFormatException(Exception): ...
class InvalidCarrierException(Exception): ...
class SpanContextCorruptedException(Exception): ...
class Format:
BINARY: str
TEXT_MAP: str
HTTP_HEADERS: str

View File

@@ -0,0 +1,11 @@
from .span import Span
class Scope:
def __init__(self, manager, span: Span) -> None: ...
@property
def span(self): ...
@property
def manager(self): ...
def close(self) -> None: ...
def __enter__(self): ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...

View File

@@ -0,0 +1,7 @@
from .span import Span
class ScopeManager:
def __init__(self) -> None: ...
def activate(self, span: Span, finish_on_close: bool): ...
@property
def active(self): ...

View File

@@ -0,0 +1,8 @@
from ..scope_manager import ScopeManager
from ..span import Span
class ThreadLocalScopeManager(ScopeManager):
def __init__(self) -> None: ...
def activate(self, span: Span, finish_on_close: bool): ...
@property
def active(self): ...

View File

@@ -0,0 +1,7 @@
from ..scope_managers import ThreadLocalScopeManager
from ..span import Span
class AsyncioScopeManager(ThreadLocalScopeManager):
def activate(self, span: Span, finish_on_close: bool): ...
@property
def active(self): ...

View File

@@ -0,0 +1 @@
ACTIVE_ATTR: str

View File

@@ -0,0 +1,9 @@
from ..scope_manager import ScopeManager
from ..span import Span
class ContextVarsScopeManager(ScopeManager):
def activate(self, span: Span, finish_on_close: bool): ...
@property
def active(self): ...
def no_parent_scope() -> None: ...

View File

@@ -0,0 +1,6 @@
from ..scope_manager import ScopeManager
class GeventScopeManager(ScopeManager):
def activate(self, span, finish_on_close: bool): ...
@property
def active(self): ...

View File

@@ -0,0 +1,15 @@
from typing import Any
from ..scope_managers import ThreadLocalScopeManager
from ..span import Span
class TornadoScopeManager(ThreadLocalScopeManager):
def activate(self, span: Span, finish_on_close: bool): ...
@property
def active(self): ...
class ThreadSafeStackContext:
contexts: Any
def __init__(self, *args) -> None: ...
def tracer_stack_context(): ...

View File

@@ -0,0 +1,25 @@
from typing import Any
from .tracer import Tracer
class SpanContext:
EMPTY_BAGGAGE: Any
@property
def baggage(self): ...
class Span:
def __init__(self, tracer: Tracer, context: SpanContext) -> None: ...
@property
def context(self): ...
@property
def tracer(self) -> Tracer: ...
def set_operation_name(self, operation_name: str): ...
def finish(self, finish_time=...) -> None: ...
def set_tag(self, key, value): ...
def log_kv(self, key_values, timestamp=...): ...
def set_baggage_item(self, key, value): ...
def get_baggage_item(self, key) -> None: ...
def __enter__(self): ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def log_event(self, event, payload=...): ...
def log(self, **kwargs): ...

View File

@@ -0,0 +1,23 @@
SPAN_KIND: str
SPAN_KIND_RPC_CLIENT: str
SPAN_KIND_RPC_SERVER: str
SPAN_KIND_CONSUMER: str
SPAN_KIND_PRODUCER: str
SERVICE: str
ERROR: str
COMPONENT: str
SAMPLING_PRIORITY: str
PEER_SERVICE: str
PEER_HOSTNAME: str
PEER_ADDRESS: str
PEER_HOST_IPV4: str
PEER_HOST_IPV6: str
PEER_PORT: str
HTTP_URL: str
HTTP_METHOD: str
HTTP_STATUS_CODE: str
DATABASE_INSTANCE: str
DATABASE_STATEMENT: str
DATABASE_TYPE: str
DATABASE_USER: str
MESSAGE_BUS_DESTINATION: str

View File

@@ -0,0 +1,40 @@
from .scope_manager import ScopeManager
from .span import Span, SpanContext
class Tracer:
def __init__(self, scope_manager: ScopeManager | None = ...) -> None: ...
@property
def scope_manager(self) -> ScopeManager: ...
@property
def active_span(self) -> Span: ...
def start_active_span(
self,
operation_name: str,
child_of=...,
references=...,
tags=...,
start_time=...,
ignore_active_span: bool = ...,
finish_on_close: bool = ...,
): ...
def start_span(
self,
operation_name: str | None = ...,
child_of=...,
references=...,
tags=...,
start_time=...,
ignore_active_span: bool = ...,
): ...
def inject(self, span_context: SpanContext, format, carrier) -> None: ...
def extract(self, format, carrier): ...
class ReferenceType:
CHILD_OF: str
FOLLOWS_FROM: str
class Reference: ...
def child_of(referenced_context=...): ...
def follows_from(referenced_context=...): ...
def start_child_span(parent_span: Span, operation_name: str, tags=..., start_time=...): ...