Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit b1e8e90

Browse files
author
David Robertson
committed
Another batch of annotations
1 parent 01be194 commit b1e8e90

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

Diff for: synapse/logging/opentracing.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class _WrappedRustReporter(BaseReporter):
271271
def set_process(self, *args, **kwargs):
272272
return self._reporter.set_process(*args, **kwargs)
273273

274-
def report_span(self, span):
274+
def report_span(self, span: "opentracing.Span") -> None:
275275
try:
276276
return self._reporter.report_span(span)
277277
except Exception:
@@ -537,19 +537,19 @@ def start_active_span_follows_from(
537537

538538

539539
def start_active_span_from_edu(
540-
edu_content,
541-
operation_name,
542-
references: Optional[list] = None,
543-
tags=None,
544-
start_time=None,
545-
ignore_active_span=False,
546-
finish_on_close=True,
547-
):
540+
edu_content: Dict[str, Any],
541+
operation_name: str,
542+
references: Optional[List["opentracing.Reference"]] = None,
543+
tags: Optional[Dict] = None,
544+
start_time: Optional[float] = None,
545+
ignore_active_span: bool = False,
546+
finish_on_close: bool = True,
547+
) -> "opentracing.Scope":
548548
"""
549549
Extracts a span context from an edu and uses it to start a new active span
550550
551551
Args:
552-
edu_content (dict): and edu_content with a `context` field whose value is
552+
edu_content: an edu_content with a `context` field whose value is
553553
canonical json for a dict which contains opentracing information.
554554
555555
For the other args see opentracing.tracer
@@ -603,7 +603,7 @@ def set_tag(key: str, value: Union[str, bool, int, float]) -> None:
603603

604604

605605
@ensure_active_span("log")
606-
def log_kv(key_values: Dict[str, Any], timestamp=None) -> None:
606+
def log_kv(key_values: Dict[str, Any], timestamp: Optional[float] = None) -> None:
607607
"""Log to the active span"""
608608
assert opentracing.tracer.active_span is not None
609609
opentracing.tracer.active_span.log_kv(key_values, timestamp)
@@ -636,7 +636,9 @@ def force_tracing(span=Sentinel) -> None:
636636
span.set_baggage_item(SynapseBaggage.FORCE_TRACING, "1")
637637

638638

639-
def is_context_forced_tracing(span_context) -> bool:
639+
def is_context_forced_tracing(
640+
span_context: Optional["opentracing.SpanContext"],
641+
) -> bool:
640642
"""Check if sampling has been force for the given span context."""
641643
if span_context is None:
642644
return False
@@ -708,13 +710,13 @@ def inject_response_headers(response_headers: Headers) -> None:
708710

709711

710712
@ensure_active_span("get the active span context as a dict", ret={})
711-
def get_active_span_text_map(destination=None):
713+
def get_active_span_text_map(destination: Optional[str] = None) -> Dict[str, str]:
712714
"""
713715
Gets a span context as a dict. This can be used instead of manually
714716
injecting a span into an empty carrier.
715717
716718
Args:
717-
destination (str): the name of the remote server.
719+
destination: the name of the remote server.
718720
719721
Returns:
720722
dict: the active span's context if opentracing is enabled, otherwise empty.
@@ -733,7 +735,7 @@ def get_active_span_text_map(destination=None):
733735

734736

735737
@ensure_active_span("get the span context as a string.", ret={})
736-
def active_span_context_as_string():
738+
def active_span_context_as_string() -> str:
737739
"""
738740
Returns:
739741
The active span context encoded as a string.

0 commit comments

Comments
 (0)