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
Container Registry
Model registry
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
Maunium
synapse
Commits
5d281c10
Unverified
Commit
5d281c10
authored
3 years ago
by
Richard van der Hoff
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Stop BackgroundProcessLoggingContext making new prometheus timeseries (#9854)
This undoes part of
b076bc27
.
parent
05fa0683
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/9854.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/9854.bugfix
synapse/metrics/background_process_metrics.py
+16
-4
16 additions, 4 deletions
synapse/metrics/background_process_metrics.py
synapse/replication/tcp/protocol.py
+1
-1
1 addition, 1 deletion
synapse/replication/tcp/protocol.py
with
18 additions
and
5 deletions
changelog.d/9854.bugfix
0 → 100644
+
1
−
0
View file @
5d281c10
Fix a regression in Synapse 1.32.0 which caused Synapse to report large numbers of Prometheus time series, potentially overwhelming Prometheus instances.
This diff is collapsed.
Click to expand it.
synapse/metrics/background_process_metrics.py
+
16
−
4
View file @
5d281c10
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
import
logging
import
logging
import
threading
import
threading
from
functools
import
wraps
from
functools
import
wraps
from
typing
import
TYPE_CHECKING
,
Dict
,
Optional
,
Set
from
typing
import
TYPE_CHECKING
,
Dict
,
Optional
,
Set
,
Union
from
prometheus_client.core
import
REGISTRY
,
Counter
,
Gauge
from
prometheus_client.core
import
REGISTRY
,
Counter
,
Gauge
...
@@ -199,7 +199,7 @@ def run_as_background_process(desc: str, func, *args, bg_start_span=True, **kwar
...
@@ -199,7 +199,7 @@ def run_as_background_process(desc: str, func, *args, bg_start_span=True, **kwar
_background_process_start_count
.
labels
(
desc
).
inc
()
_background_process_start_count
.
labels
(
desc
).
inc
()
_background_process_in_flight_count
.
labels
(
desc
).
inc
()
_background_process_in_flight_count
.
labels
(
desc
).
inc
()
with
BackgroundProcessLoggingContext
(
"
%s-%s
"
%
(
desc
,
count
)
)
as
context
:
with
BackgroundProcessLoggingContext
(
desc
,
count
)
as
context
:
try
:
try
:
ctx
=
noop_context_manager
()
ctx
=
noop_context_manager
()
if
bg_start_span
:
if
bg_start_span
:
...
@@ -244,8 +244,20 @@ class BackgroundProcessLoggingContext(LoggingContext):
...
@@ -244,8 +244,20 @@ class BackgroundProcessLoggingContext(LoggingContext):
__slots__
=
[
"
_proc
"
]
__slots__
=
[
"
_proc
"
]
def
__init__
(
self
,
name
:
str
):
def
__init__
(
self
,
name
:
str
,
instance_id
:
Optional
[
Union
[
int
,
str
]]
=
None
):
super
().
__init__
(
name
)
"""
Args:
name: The name of the background process. Each distinct `name` gets a
separate prometheus time series.
instance_id: an identifer to add to `name` to distinguish this instance of
the named background process in the logs. If this is `None`, one is
made up based on id(self).
"""
if
instance_id
is
None
:
instance_id
=
id
(
self
)
super
().
__init__
(
"
%s-%s
"
%
(
name
,
instance_id
))
self
.
_proc
=
_BackgroundProcess
(
name
,
self
)
self
.
_proc
=
_BackgroundProcess
(
name
,
self
)
def
start
(
self
,
rusage
:
"
Optional[resource._RUsage]
"
):
def
start
(
self
,
rusage
:
"
Optional[resource._RUsage]
"
):
...
...
This diff is collapsed.
Click to expand it.
synapse/replication/tcp/protocol.py
+
1
−
1
View file @
5d281c10
...
@@ -185,7 +185,7 @@ class BaseReplicationStreamProtocol(LineOnlyReceiver):
...
@@ -185,7 +185,7 @@ class BaseReplicationStreamProtocol(LineOnlyReceiver):
# a logcontext which we use for processing incoming commands. We declare it as a
# a logcontext which we use for processing incoming commands. We declare it as a
# background process so that the CPU stats get reported to prometheus.
# background process so that the CPU stats get reported to prometheus.
self
.
_logging_context
=
BackgroundProcessLoggingContext
(
self
.
_logging_context
=
BackgroundProcessLoggingContext
(
"
replication-conn
-%s
"
%
(
self
.
conn_id
,)
"
replication-conn
"
,
self
.
conn_id
)
)
def
connectionMade
(
self
):
def
connectionMade
(
self
):
...
...
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