Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
3bc9629b
Commit
3bc9629b
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Measure federation send transaction resources
parent
d4548947
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/federation/transaction_queue.py
+7
-5
7 additions, 5 deletions
synapse/federation/transaction_queue.py
synapse/util/metrics.py
+14
-0
14 additions, 0 deletions
synapse/util/metrics.py
with
21 additions
and
5 deletions
synapse/federation/transaction_queue.py
+
7
−
5
View file @
3bc9629b
...
...
@@ -26,6 +26,7 @@ from synapse.util.logcontext import PreserveLoggingContext
from
synapse.util.retryutils
import
(
get_retry_limiter
,
NotRetryingDestination
,
)
from
synapse.util.metrics
import
measure_func
import
synapse.metrics
import
logging
...
...
@@ -51,7 +52,7 @@ class TransactionQueue(object):
self
.
transport_layer
=
transport_layer
self
.
_
clock
=
hs
.
get_clock
()
self
.
clock
=
hs
.
get_clock
()
# Is a mapping from destinations -> deferreds. Used to keep track
# of which destinations have transactions in flight and when they are
...
...
@@ -82,7 +83,7 @@ class TransactionQueue(object):
self
.
pending_failures_by_dest
=
{}
# HACK to get unique tx id
self
.
_next_txn_id
=
int
(
self
.
_
clock
.
time_msec
())
self
.
_next_txn_id
=
int
(
self
.
clock
.
time_msec
())
def
can_send_to
(
self
,
destination
):
"""
Can we send messages to the given server?
...
...
@@ -197,6 +198,7 @@ class TransactionQueue(object):
yield
deferred
@measure_func
(
"
attempt_new_transaction
"
)
@defer.inlineCallbacks
@log_function
def
_attempt_new_transaction
(
self
,
destination
):
...
...
@@ -246,7 +248,7 @@ class TransactionQueue(object):
limiter
=
yield
get_retry_limiter
(
destination
,
self
.
_
clock
,
self
.
clock
,
self
.
store
,
)
...
...
@@ -262,7 +264,7 @@ class TransactionQueue(object):
logger
.
debug
(
"
TX [%s] Persisting transaction...
"
,
destination
)
transaction
=
Transaction
.
create_new
(
origin_server_ts
=
int
(
self
.
_
clock
.
time_msec
()),
origin_server_ts
=
int
(
self
.
clock
.
time_msec
()),
transaction_id
=
txn_id
,
origin
=
self
.
server_name
,
destination
=
destination
,
...
...
@@ -293,7 +295,7 @@ class TransactionQueue(object):
# keys work
def
json_data_cb
():
data
=
transaction
.
get_dict
()
now
=
int
(
self
.
_
clock
.
time_msec
())
now
=
int
(
self
.
clock
.
time_msec
())
if
"
pdus
"
in
data
:
for
p
in
data
[
"
pdus
"
]:
if
"
age_ts
"
in
p
:
...
...
This diff is collapsed.
Click to expand it.
synapse/util/metrics.py
+
14
−
0
View file @
3bc9629b
...
...
@@ -13,10 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
twisted.internet
import
defer
from
synapse.util.logcontext
import
LoggingContext
import
synapse.metrics
from
functools
import
wraps
import
logging
...
...
@@ -47,6 +49,18 @@ block_db_txn_duration = metrics.register_distribution(
)
def
measure_func
(
name
):
def
wrapper
(
func
):
@wraps
(
func
)
@defer.inlineCallbacks
def
measured_func
(
self
,
*
args
,
**
kwargs
):
with
Measure
(
self
.
clock
,
name
):
r
=
yield
func
(
self
,
*
args
,
**
kwargs
)
defer
.
returnValue
(
r
)
return
measured_func
return
wrapper
class
Measure
(
object
):
__slots__
=
[
"
clock
"
,
"
name
"
,
"
start_context
"
,
"
start
"
,
"
new_context
"
,
"
ru_utime
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment