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

Use the BaseReporter super-class for _WrappedRustReporter #105

Merged
merged 2 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/105.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure the Rust reporter passes type checking with jaeger-client 4.7's type annotations.
babolivier marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 11 additions & 1 deletion synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,17 @@ class _DummyTagNames:
try:
from rust_python_jaeger_reporter import Reporter

# jaeger-client 4.7.0 requires that reporters inherit from BaseReporter, which
# didn't exist before that version.
try:
from jaeger_client.reporter import BaseReporter
except ImportError:

class BaseReporter: # type: ignore[no-redef]
pass

@attr.s(slots=True, frozen=True)
class _WrappedRustReporter:
class _WrappedRustReporter(BaseReporter):
"""Wrap the reporter to ensure `report_span` never throws."""

_reporter = attr.ib(type=Reporter, default=attr.Factory(Reporter))
Expand Down Expand Up @@ -382,6 +391,7 @@ def init_tracer(hs: "HomeServer"):
# If we have the rust jaeger reporter available let's use that.
if RustReporter:
logger.info("Using rust_python_jaeger_reporter library")
assert config.sampler is not None
tracer = config.create_tracer(RustReporter(), config.sampler)
opentracing.set_global_tracer(tracer)
else:
Expand Down