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

Use the BaseReporter super-class for _WrappedRustReporter. #10799

Merged
merged 3 commits into from
Sep 13, 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/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.
Comment on lines +239 to +240
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I didn't realise this was new in 4.7.

(Is the inheritance you describe a runtime requirement, or just part of the type annotations added in 4.7?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on jaegertracing/jaeger-client-python#329 I think it is really just there for type-annotations.

It does seem that they consolidated some logic into it. (The close method as you noticed.) But it seems to essentially be a no-op so I don't think this is huge.

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