Skip to content
This repository was 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 1 commit
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
Prev Previous commit
Next Next commit
Remove max-version pin.
  • Loading branch information
clokep committed Sep 13, 2021
commit 7b377f09c05a82f0b4de952266c1bb680593c0a0
11 changes: 10 additions & 1 deletion synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,16 @@ 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 +390,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
2 changes: 1 addition & 1 deletion synapse/python_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"systemd": ["systemd-python>=231"],
"url_preview": ["lxml>=3.5.0"],
"sentry": ["sentry-sdk>=0.7.2"],
"opentracing": ["jaeger-client>=4.0.0,<4.7.0", "opentracing>=2.2.0"],
"opentracing": ["jaeger-client>=4.0.0", "opentracing>=2.2.0"],
"jwt": ["pyjwt>=1.6.4"],
# hiredis is not a *strict* dependency, but it makes things much faster.
# (if it is not installed, we fall back to slow code.)
Expand Down