Skip to content

Commit

Permalink
Reduce cardinality of http_server_active_requests (#745)
Browse files Browse the repository at this point in the history
Set the multiprocess mode on http_server_active_requests to "livesum" to reduce the cardinality to one metric per server.
  • Loading branch information
SuperQ committed Oct 19, 2022
1 parent 0ae7c2f commit 30a3457
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions baseplate/clients/cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CassandraPrometheusLabels(NamedTuple):
"cassandra_client_active_requests",
"Current number of active cassandra queries",
CassandraPrometheusLabels._fields,
multiprocess_mode="livesum",
)
REQUEST_TOTAL = Counter(
"cassandra_client_requests_total",
Expand Down
1 change: 1 addition & 0 deletions baseplate/clients/memcache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def make_object_for_context(self, name: str, span: Span) -> "MonitoredMemcacheCo
f"{PROM_NAMESPACE}_client_active_requests",
"Number of active requests",
LABELS_COMMON,
multiprocess_mode="livesum",
)


Expand Down
4 changes: 4 additions & 0 deletions baseplate/clients/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
f"{PROM_PREFIX}_active_requests",
"Number of active requests for a given client",
PROM_SHARED_LABELS,
multiprocess_mode="livesum",
)

PROM_POOL_PREFIX = f"{PROM_PREFIX}_pool"
Expand All @@ -59,16 +60,19 @@
f"{PROM_POOL_PREFIX}_max_size",
"Maximum number of connections allowed in this redis client connection pool",
PROM_LABELS,
multiprocess_mode="livesum",
)
IDLE_CONNECTIONS = Gauge(
f"{PROM_POOL_PREFIX}_idle_connections",
"Number of idle connections in this redis client connection pool",
PROM_LABELS,
multiprocess_mode="livesum",
)
OPEN_CONNECTIONS = Gauge(
f"{PROM_POOL_PREFIX}_active_connections",
"Number of open connections in this redis client connection pool",
PROM_LABELS,
multiprocess_mode="livesum",
)


Expand Down
1 change: 1 addition & 0 deletions baseplate/clients/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def http_adapter_from_config(
f"{PROM_NAMESPACE}_active_requests",
"Number of active requests for a given client",
HTTP_LABELS_COMMON,
multiprocess_mode="livesum",
)


Expand Down
4 changes: 4 additions & 0 deletions baseplate/clients/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,20 @@ class SQLAlchemyEngineContextFactory(ContextFactory):
f"{PROM_POOL_PREFIX}_max_size",
"Maximum number of connections allowed in this pool",
PROM_POOL_LABELS,
multiprocess_mode="livesum",
)

checked_out_connections_gauge = Gauge(
f"{PROM_POOL_PREFIX}_active_connections",
"Number of connections in use by this pool (checked out + overflow)",
PROM_POOL_LABELS,
multiprocess_mode="livesum",
)
checked_in_connections_gauge = Gauge(
f"{PROM_POOL_PREFIX}_idle_connections",
"Number of connections not in use by this pool (unused pool connections)",
PROM_POOL_LABELS,
multiprocess_mode="livesum",
)

PROM_LABELS = [
Expand All @@ -198,6 +201,7 @@ class SQLAlchemyEngineContextFactory(ContextFactory):
f"{PROM_PREFIX}_active_requests",
"total requests that are in-flight",
PROM_LABELS,
multiprocess_mode="livesum",
)

requests_total = Counter(
Expand Down
1 change: 1 addition & 0 deletions baseplate/clients/thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
f"{PROM_NAMESPACE}_active_requests",
"number of in-flight requests",
PROM_COMMON_LABELS,
multiprocess_mode="livesum",
)


Expand Down
1 change: 1 addition & 0 deletions baseplate/frameworks/pyramid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def close(self) -> None:
"http_method",
"http_endpoint",
],
multiprocess_mode="livesum",
)


Expand Down
1 change: 1 addition & 0 deletions baseplate/frameworks/queue_consumer/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class KafkaConsumerPrometheusLabels(NamedTuple):
"kafka_consumer_active_messages",
"gauge that reflects the number of messages currently being processed",
KafkaConsumerPrometheusLabels._fields,
multiprocess_mode="livesum",
)


Expand Down
1 change: 1 addition & 0 deletions baseplate/frameworks/queue_consumer/kombu.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AmqpConsumerPrometheusLabels(NamedTuple):
"amqp_consumer_active_messages",
"gauge that reflects the number of messages currently being processed",
AmqpConsumerPrometheusLabels._fields,
multiprocess_mode="livesum",
)


Expand Down
1 change: 1 addition & 0 deletions baseplate/frameworks/thrift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
f"{PROM_NAMESPACE}_active_requests",
"The number of in-flight requests being handled by the service",
["thrift_method"],
multiprocess_mode="livesum",
)


Expand Down

0 comments on commit 30a3457

Please sign in to comment.