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

Fix @tag_args being off-by-one (ahead) #13452

Merged
merged 7 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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/13452.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `@tag_args` being off-by-one with the arguments when tagging a span (tracing).
3 changes: 2 additions & 1 deletion synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,9 @@ def tag_args(func: Callable[P, R]) -> Callable[P, R]:
@wraps(func)
def _tag_args_inner(*args: P.args, **kwargs: P.kwargs) -> R:
argspec = inspect.getfullargspec(func)
# We use `[1:]` to skip the `self` object reference
MadLittleMods marked this conversation as resolved.
Show resolved Hide resolved
for i, arg in enumerate(argspec.args[1:]):
MadLittleMods marked this conversation as resolved.
Show resolved Hide resolved
set_tag("ARG_" + arg, str(args[i])) # type: ignore[index]
set_tag("ARG_" + arg, str(args[i + 1])) # type: ignore[index]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests possible if you push 😓

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe more worth doing since it doesn't seem to behave as we assume (#13452 (comment))

set_tag("args", str(args[len(argspec.args) :])) # type: ignore[index]
MadLittleMods marked this conversation as resolved.
Show resolved Hide resolved
set_tag("kwargs", str(kwargs))
return func(*args, **kwargs)
Expand Down