Use the BaseReporter super-class for _WrappedRustReporter. (#10799)

This fixes mypy errors with jaeger-client >= 4.7.0 and should be a no-op
for versions before that.
This commit is contained in:
Patrick Cloke 2021-09-13 08:54:01 -04:00 committed by GitHub
parent 524b8ead77
commit 003846d68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

1
changelog.d/10799.misc Normal file
View File

@ -0,0 +1 @@
Add a max version for the `jaeger-client` dependency for an incompatibility with the rust reporter.

View File

@ -236,8 +236,17 @@ except ImportError:
try: try:
from rust_python_jaeger_reporter import Reporter 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) @attr.s(slots=True, frozen=True)
class _WrappedRustReporter: class _WrappedRustReporter(BaseReporter):
"""Wrap the reporter to ensure `report_span` never throws.""" """Wrap the reporter to ensure `report_span` never throws."""
_reporter = attr.ib(type=Reporter, default=attr.Factory(Reporter)) _reporter = attr.ib(type=Reporter, default=attr.Factory(Reporter))
@ -382,6 +391,7 @@ def init_tracer(hs: "HomeServer"):
# If we have the rust jaeger reporter available let's use that. # If we have the rust jaeger reporter available let's use that.
if RustReporter: if RustReporter:
logger.info("Using rust_python_jaeger_reporter library") logger.info("Using rust_python_jaeger_reporter library")
assert config.sampler is not None
tracer = config.create_tracer(RustReporter(), config.sampler) tracer = config.create_tracer(RustReporter(), config.sampler)
opentracing.set_global_tracer(tracer) opentracing.set_global_tracer(tracer)
else: else: