Annotate remaining opentracing fields, arguments, and return types (#6476)

This commit is contained in:
kasium
2021-12-03 11:41:49 +01:00
committed by GitHub
parent 1fa1270e00
commit 9dc75772d3
18 changed files with 127 additions and 103 deletions

View File

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

View File

@@ -6,7 +6,7 @@ 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 is_parent(self, parent: Span, span: Span) -> bool: ...
def test_active_span(self) -> None: ...
def test_start_active_span(self) -> None: ...
def test_start_active_span_parent(self) -> None: ...

View File

@@ -1,6 +1,10 @@
from typing import Any, Callable
from ..scope_manager import ScopeManager
class ScopeCompatibilityCheckMixin:
def scope_manager(self) -> None: ...
def run_test(self, test_fn) -> None: ...
def scope_manager(self) -> ScopeManager: ...
def run_test(self, test_fn: Callable[[Any], Any]) -> None: ...
def test_missing_active_external(self) -> None: ...
def test_missing_active(self) -> None: ...
def test_activate(self) -> None: ...

View File

@@ -1,6 +1,8 @@
from typing import Any
from ..span import SpanContext
from .propagator import Propagator
class BinaryPropagator(Propagator):
def inject(self, span_context: SpanContext, carrier) -> None: ...
def extract(self, carrier): ...
def inject(self, span_context: SpanContext, carrier: dict[Any, Any]) -> None: ...
def extract(self, carrier: dict[Any, Any]) -> SpanContext: ...

View File

@@ -1,11 +1,9 @@
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: ...
trace_id: int | None
span_id: int | None
def __init__(self, trace_id: int | None = ..., span_id: int | None = ..., baggage: dict[str, str] | None = ...) -> None: ...
@property
def baggage(self): ...
def with_baggage_item(self, key, value): ...
def baggage(self) -> dict[str, str]: ...
def with_baggage_item(self, key: str, value: str) -> SpanContext: ...

View File

@@ -1,5 +1,7 @@
from typing import Any
from ..span import SpanContext
class Propagator:
def inject(self, span_context: SpanContext, carrier) -> None: ...
def extract(self, carrier) -> None: ...
def inject(self, span_context: SpanContext, carrier: dict[Any, Any]) -> None: ...
def extract(self, carrier: dict[Any, Any]) -> SpanContext: ...

View File

@@ -1,24 +1,33 @@
from typing import Any
from opentracing import Span
from ..span import Span, SpanContext
from ..tracer import Tracer
class MockSpan(Span):
operation_name: str
operation_name: str | None
start_time: Any
parent_id: Any
tags: Any
finish_time: int
parent_id: int | None
tags: dict[str, Any]
finish_time: float
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): ...
logs: list[LogData]
def __init__(
self,
tracer: Tracer,
operation_name: str | None = ...,
context: SpanContext | None = ...,
parent_id: int | None = ...,
tags: dict[str, Any] | None = ...,
start_time: float | None = ...,
) -> None: ...
def set_operation_name(self, operation_name: str) -> Span: ...
def set_tag(self, key: str, value: str | bool | int | float) -> Span: ...
def log_kv(self, key_values: dict[str, Any], timestamp: float | None = ...) -> Span: ...
def finish(self, finish_time: float | None = ...) -> None: ...
def set_baggage_item(self, key: str, value: str) -> Span: ...
def get_baggage_item(self, key: str) -> str | None: ...
class LogData:
key_values: Any
timestamp: Any
def __init__(self, key_values, timestamp=...) -> None: ...
key_values: dict[str, Any]
timestamp: float | None
def __init__(self, key_values: dict[str, Any], timestamp: float | None = ...) -> None: ...

View File

@@ -5,10 +5,10 @@ from .propagator import Propagator
prefix_tracer_state: str
prefix_baggage: str
field_name_trace_id: Any
field_name_span_id: Any
field_name_trace_id: str
field_name_span_id: str
field_count: int
class TextPropagator(Propagator):
def inject(self, span_context: SpanContext, carrier) -> None: ...
def extract(self, carrier): ...
def inject(self, span_context: SpanContext, carrier: dict[Any, Any]) -> None: ...
def extract(self, carrier: dict[Any, Any]) -> SpanContext: ...

View File

@@ -1,25 +1,11 @@
from ..propagation import Format
from ..scope_manager import ScopeManager
from ..span import SpanContext
from ..span import Span
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 register_propagator(self, format: Format, propagator: Propagator) -> None: ...
def finished_spans(self) -> list[Span]: ...
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

@@ -1,11 +1,17 @@
from types import TracebackType
from typing import Type
from .scope_manager import ScopeManager
from .span import Span
class Scope:
def __init__(self, manager, span: Span) -> None: ...
def __init__(self, manager: ScopeManager, span: Span) -> None: ...
@property
def span(self): ...
def span(self) -> Span: ...
@property
def manager(self): ...
def manager(self) -> ScopeManager: ...
def close(self) -> None: ...
def __enter__(self): ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def __enter__(self) -> Scope: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

View File

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

View File

@@ -1,8 +1,9 @@
from ..scope import Scope
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): ...
def activate(self, span: Span, finish_on_close: bool) -> Scope: ...
@property
def active(self): ...
def active(self) -> Scope: ...

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,25 +1,28 @@
from typing import Any
from types import TracebackType
from typing import Any, Type
from .tracer import Tracer
class SpanContext:
EMPTY_BAGGAGE: Any
EMPTY_BAGGAGE: dict[str, str]
@property
def baggage(self): ...
def baggage(self) -> dict[str, str]: ...
class Span:
def __init__(self, tracer: Tracer, context: SpanContext) -> None: ...
@property
def context(self): ...
def context(self) -> SpanContext: ...
@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): ...
def set_operation_name(self, operation_name: str) -> Span: ...
def finish(self, finish_time: float | None = ...) -> None: ...
def set_tag(self, key: str, value: str | bool | int | float) -> Span: ...
def log_kv(self, key_values: dict[str, Any], timestamp: float | None = ...) -> Span: ...
def set_baggage_item(self, key: str, value: str) -> Span: ...
def get_baggage_item(self, key: str) -> str | None: ...
def __enter__(self) -> Span: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def log_event(self, event: Any, payload: Any | None = ...) -> Span: ...
def log(self, **kwargs: Any) -> Span: ...

View File

@@ -1,3 +1,7 @@
from typing import Any, NamedTuple
from .propagation import Format
from .scope import Scope
from .scope_manager import ScopeManager
from .span import Span, SpanContext
@@ -6,35 +10,39 @@ class Tracer:
@property
def scope_manager(self) -> ScopeManager: ...
@property
def active_span(self) -> Span: ...
def active_span(self) -> Span | None: ...
def start_active_span(
self,
operation_name: str,
child_of=...,
references=...,
tags=...,
start_time=...,
child_of: Span | SpanContext | None = ...,
references: list[Reference] | None = ...,
tags: dict[Any, Any] | None = ...,
start_time: float | None = ...,
ignore_active_span: bool = ...,
finish_on_close: bool = ...,
): ...
) -> Scope: ...
def start_span(
self,
operation_name: str | None = ...,
child_of=...,
references=...,
tags=...,
start_time=...,
child_of: Span | SpanContext | None = ...,
references: list[Reference] | None = ...,
tags: dict[Any, Any] | None = ...,
start_time: float | None = ...,
ignore_active_span: bool = ...,
): ...
def inject(self, span_context: SpanContext, format, carrier) -> None: ...
def extract(self, format, carrier): ...
) -> Span: ...
def inject(self, span_context: SpanContext, format: Format, carrier: dict[Any, Any]) -> None: ...
def extract(self, format: Format, carrier: dict[Any, Any]) -> SpanContext: ...
class ReferenceType:
CHILD_OF: str
FOLLOWS_FROM: str
class Reference: ...
class Reference(NamedTuple):
type: str
referenced_context: SpanContext | None
def child_of(referenced_context=...): ...
def follows_from(referenced_context=...): ...
def start_child_span(parent_span: Span, operation_name: str, tags=..., start_time=...): ...
def child_of(referenced_context: SpanContext | None = ...) -> Reference: ...
def follows_from(referenced_context: SpanContext | None = ...) -> Reference: ...
def start_child_span(
parent_span: Span, operation_name: str, tags: dict[Any, Any] | None = ..., start_time: float | None = ...
) -> Span: ...