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

Add opentracing spans to calls to external cache #12380

Merged
merged 6 commits into from
Apr 7, 2022
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
3 changes: 3 additions & 0 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ class SynapseTags:
# Uniqueish ID of a database transaction
DB_TXN_ID = "db.txn_id"

# The name of the external cache
CACHE_NAME = "cache.name"


class SynapseBaggage:
FORCE_TRACING = "synapse-force-tracing"
Expand Down
10 changes: 8 additions & 2 deletions synapse/replication/tcp/external_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ async def set(self, cache_name: str, key: str, value: Any, expiry_ms: int) -> No

logger.debug("Caching %s %s: %r", cache_name, key, encoded_value)

with opentracing.start_active_span("ExternalCache.set"):
with opentracing.start_active_span(
"ExternalCache.set",
tags={opentracing.SynapseTags: cache_name},
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
):
with response_timer.labels("set").time():
return await make_deferred_yieldable(
self._redis_connection.set(
Expand All @@ -110,7 +113,10 @@ async def get(self, cache_name: str, key: str) -> Optional[Any]:
if self._redis_connection is None:
return None

with opentracing.start_active_span("ExternalCache.get"):
with opentracing.start_active_span(
"ExternalCache.get",
tags={opentracing.SynapseTags: cache_name},
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
):
with response_timer.labels("get").time():
result = await make_deferred_yieldable(
self._redis_connection.get(self._get_redis_key(cache_name, key))
Expand Down