core: type observability timestamps

This commit is contained in:
a.tolmachev
2026-04-19 07:53:15 +00:00
parent 153f9cb108
commit 899440fd8a
6 changed files with 61 additions and 11 deletions
+2 -1
View File
@@ -130,7 +130,8 @@ pub struct UsageRollupRecord {
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UsageTimelinePoint {
pub bucket_start: String,
#[serde(with = "time::serde::rfc3339")]
pub bucket_start: OffsetDateTime,
pub calls_ok: u64,
pub calls_error: u64,
}
+1 -1
View File
@@ -2496,7 +2496,7 @@ mod tests {
error_kind: None,
request_preview: json!({"input":"value"}),
response_preview: json!({"ok":true}),
created_at: created_at.to_owned(),
created_at: timestamp(created_at),
}
}
@@ -47,7 +47,7 @@ impl PostgresRegistry {
.bind(&request.log.error_kind)
.bind(Json(request.log.request_preview.clone()))
.bind(Json(request.log.response_preview.clone()))
.bind(&request.log.created_at)
.bind(request.log.created_at)
.execute(&self.pool)
.await?;
@@ -75,7 +75,7 @@ impl PostgresRegistry {
l.error_kind,
l.request_preview_json,
l.response_preview_json,
to_char(l.created_at at time zone 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"') as created_at,
l.created_at as created_at,
o.name as operation_name,
o.display_name as operation_display_name,
a.slug as agent_slug,
@@ -147,7 +147,7 @@ impl PostgresRegistry {
l.error_kind,
l.request_preview_json,
l.response_preview_json,
to_char(l.created_at at time zone 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"') as created_at,
l.created_at as created_at,
o.name as operation_name,
o.display_name as operation_display_name,
a.slug as agent_slug,
@@ -229,7 +229,7 @@ impl PostgresRegistry {
let bucket = usage_bucket_sql(query.bucket);
let sql = format!(
"select
to_char(date_trunc('{bucket}', created_at at time zone 'UTC'), 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') as bucket_start,
(date_trunc('{bucket}', created_at at time zone 'UTC') at time zone 'UTC') as bucket_start,
count(*) filter (where status = 'ok')::bigint as calls_ok,
count(*) filter (where status = 'error')::bigint as calls_error
from invocation_logs