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

Commit

Permalink
Use the BaseReporter super-class for _WrappedRustReporter. (#10799)
Browse files Browse the repository at this point in the history
This fixes mypy errors with jaeger-client >= 4.7.0 and should be a no-op
for versions before that.
  • Loading branch information
clokep authored Sep 13, 2021
1 parent 524b8ea commit 003846d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/10799.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a max version for the `jaeger-client` dependency for an incompatibility with the rust reporter.
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

0 comments on commit 003846d

Please sign in to comment.