Skip to content

Commit ef18791

Browse files
nipunn1313Convex, Inc.
authored and
Convex, Inc.
committed
Add swift and kotlin and python client metrics logging (#30561)
Add logging to set up swift/kotlin GitOrigin-RevId: 6559efa77fac190cbeffa00a2049a9c7cfdd7ff5
1 parent 3970171 commit ef18791

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

python/_convex/_convex.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PyQuerySetSubscription:
3232
def anext(self) -> Awaitable[Dict[Any, Any]]: ...
3333

3434
class PyConvexClient:
35-
def __new__(cls, deployment_url: str) -> "PyConvexClient": ...
35+
def __new__(cls, deployment_url: str, version: str) -> "PyConvexClient": ...
3636
def subscribe(
3737
self, name: str, args: Optional[Dict[str, Any]] = None
3838
) -> PyQuerySubscription: ...

python/convex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ConvexClient:
176176

177177
def __init__(self, deployment_url: str):
178178
"""Construct a WebSocket-based client given the URL of a Convex deployment."""
179-
self.client: PyConvexClient = PyConvexClient(deployment_url)
179+
self.client: PyConvexClient = PyConvexClient(deployment_url, __version__)
180180

181181
def subscribe(self, name: str, args: FunctionArgs = None) -> QuerySubscription:
182182
"""Return a to subscription to the query `name` with optional `args`."""

python/convex/http_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, address: str) -> None:
4141
self.debug: bool = False
4242
# format prerelease with a dash in headers
4343
version = __version__.replace("a", "-a")
44-
self.headers = {"Convex-Client": f"python-convex-{version}"}
44+
self.headers = {"Convex-Client": f"python-{version}"}
4545

4646
def set_auth(self, value: str) -> None:
4747
"""Set auth for use when calling Convex functions."""

src/client/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl PyConvexClient {
126126
/// Note that the WebSocket is not connected yet and therefore the
127127
/// connection url is not validated to be accepting connections.
128128
#[new]
129-
fn py_new(deployment_url: &PyString) -> PyResult<Self> {
129+
fn py_new(deployment_url: &PyString, version: &PyString) -> PyResult<Self> {
130130
let dep = deployment_url.to_str()?;
131131
// The ConvexClient is instantiated in the context of a tokio Runtime, and
132132
// needs to run its worker in the background so that it can constantly
@@ -139,7 +139,8 @@ impl PyConvexClient {
139139
.unwrap();
140140

141141
// Block on the async function using the Tokio runtime.
142-
let instance = rt.block_on(ConvexClient::new(dep));
142+
let client_id = format!("python-{}", version.to_str()?);
143+
let instance = rt.block_on(ConvexClient::new_with_client_id(dep, &client_id));
143144
match instance {
144145
Ok(instance) => Ok(PyConvexClient {
145146
rt,

tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ def test_version() -> None:
1414
# Convex backend expects a dash in 0.1.6-a0, PyPI doesn't.
1515
if "a" in version:
1616
version = version.replace("a", "-a")
17-
assert http_client.headers["Convex-Client"] == f"python-convex-{version}"
17+
assert http_client.headers["Convex-Client"] == f"python-{version}"

0 commit comments

Comments
 (0)