Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 8 additions & 4 deletions api/app/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,6 @@
# Redis Cluster URL used to communicate with the event ingestion server.
INGESTION_REDIS_URL = env.str("INGESTION_REDIS_URL", default="")

# DSN for the ClickHouse instance holding ingested experimentation events.
EXPERIMENTATION_CLICKHOUSE_URL = env.str("EXPERIMENTATION_CLICKHOUSE_URL", default=None)

CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
Expand Down Expand Up @@ -1501,6 +1498,13 @@

CLICKHOUSE_ENABLED = bool(CLICKHOUSE_URL or CLICKHOUSE_HOST)

CLICKHOUSE_CONNECTION_CLIENT_NAME = "flagsmith-core-api"

# DSN for the ClickHouse instance holding ingested experimentation events.
# TODO: consolidate connection management across the two CH use cases
# https://github.com/Flagsmith/flagsmith/issues/8033
EXPERIMENTATION_CLICKHOUSE_URL = env.str("EXPERIMENTATION_CLICKHOUSE_URL", default=None)

SEGMENT_MEMBERSHIP_REFRESH_INTERVAL_HOURS = env.int(
"SEGMENT_MEMBERSHIP_REFRESH_INTERVAL_HOURS", default=6
)
Expand Down Expand Up @@ -1543,7 +1547,7 @@
# from breaking migrations with Error 517.
"alter_sync": 2,
},
"client_name": "flagsmith-core-api",
"client_name": CLICKHOUSE_CONNECTION_CLIENT_NAME,
},
}
DATABASES["clickhouse"] = _clickhouse_db # type: ignore[assignment]
Expand Down
1 change: 1 addition & 0 deletions api/experimentation/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def _get_clickhouse_client() -> Client:
host, kwargs = parse_url(settings.EXPERIMENTATION_CLICKHOUSE_URL)
kwargs.setdefault("connect_timeout", CLICKHOUSE_CONNECT_TIMEOUT_SECONDS)
kwargs.setdefault("send_receive_timeout", CLICKHOUSE_QUERY_TIMEOUT_SECONDS)
kwargs.setdefault("client_name", settings.CLICKHOUSE_CONNECTION_CLIENT_NAME)
Comment thread
matthewelwell marked this conversation as resolved.
return Client(host, **kwargs)


Expand Down
2 changes: 2 additions & 0 deletions api/tests/unit/experimentation/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_get_clickhouse_client__configured_url__builds_client_with_timeouts(
secure=True,
connect_timeout=services.CLICKHOUSE_CONNECT_TIMEOUT_SECONDS,
send_receive_timeout=services.CLICKHOUSE_QUERY_TIMEOUT_SECONDS,
client_name=settings.CLICKHOUSE_CONNECTION_CLIENT_NAME,
)
assert client is mock_client_cls.return_value
services._get_clickhouse_client.cache_clear()
Expand All @@ -97,6 +98,7 @@ def test_get_clickhouse_client__dsn_timeouts__are_preserved(
database="db",
connect_timeout=1,
send_receive_timeout=2,
client_name=settings.CLICKHOUSE_CONNECTION_CLIENT_NAME,
)
services._get_clickhouse_client.cache_clear()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ Attributes:
### `warehouse.connection.connected`

Logged at `info` from:
- `api/experimentation/services.py:802`
- `api/experimentation/services.py:803`

Attributes:
- `environment.id`
Expand All @@ -541,7 +541,7 @@ Attributes:
### `warehouse.connection.test_event_sent`

Logged at `info` from:
- `api/experimentation/services.py:782`
- `api/experimentation/services.py:783`

Attributes:
- `environment.id`
Expand All @@ -550,7 +550,7 @@ Attributes:
### `warehouse.srm.overallocated`

Logged at `error` from:
- `api/experimentation/services.py:404`
- `api/experimentation/services.py:405`

Attributes:
- `environment.id`
Expand All @@ -560,7 +560,7 @@ Attributes:
### `warehouse.srm.unkeyed_variant`

Logged at `error` from:
- `api/experimentation/services.py:390`
- `api/experimentation/services.py:391`

Attributes:
- `environment.id`
Expand Down
Loading