Skip to content

Commit 6aec0ec

Browse files
Preslav LeConvex, Inc.
authored andcommitted
Move transaction tracing to public methods. (#24740)
GitOrigin-RevId: 558d4614f8ff54cf41336eff9b70c10236931f49
1 parent fa61b8b commit 6aec0ec

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

crates/database/src/bootstrap_model/system_metadata.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl<'a, RT: Runtime> SystemMetadataModel<'a, RT> {
3434

3535
/// Creates a new document with given value in the specified table,
3636
/// enforcing that the transaction's identity is system or admin.
37+
#[minitrace::trace]
3738
#[convex_macro::instrument_future]
3839
pub async fn insert(
3940
&mut self,
@@ -62,6 +63,7 @@ impl<'a, RT: Runtime> SystemMetadataModel<'a, RT> {
6263

6364
/// Creates a new document with given value in the specified table without
6465
/// checking authorization. This also inserts table metadata.
66+
#[minitrace::trace]
6567
#[convex_macro::instrument_future]
6668
pub async fn insert_metadata(
6769
&mut self,
@@ -80,6 +82,7 @@ impl<'a, RT: Runtime> SystemMetadataModel<'a, RT> {
8082

8183
/// Merges the existing document with the given object. Will overwrite any
8284
/// conflicting fields.
85+
#[minitrace::trace]
8386
#[convex_macro::instrument_future]
8487
pub async fn patch(
8588
&mut self,
@@ -91,6 +94,7 @@ impl<'a, RT: Runtime> SystemMetadataModel<'a, RT> {
9194
self.tx.patch_inner(id, value).await
9295
}
9396

97+
#[minitrace::trace]
9498
#[convex_macro::instrument_future]
9599
pub async fn replace(
96100
&mut self,
@@ -102,6 +106,7 @@ impl<'a, RT: Runtime> SystemMetadataModel<'a, RT> {
102106
}
103107

104108
/// Delete the document at the given path.
109+
#[minitrace::trace]
105110
#[convex_macro::instrument_future]
106111
pub async fn delete(&mut self, id: ResolvedDocumentId) -> anyhow::Result<ResolvedDocument> {
107112
anyhow::ensure!(self.tx.table_mapping().is_system(id.table().table_number));

crates/database/src/bootstrap_model/user_facing.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> {
8181
.map(|(document, _)| document))
8282
}
8383

84+
#[minitrace::trace]
8485
#[convex_macro::instrument_future]
8586
pub async fn get_with_ts(
8687
&mut self,
@@ -117,6 +118,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> {
117118
/// of the batch will throw similar errors.
118119
/// TODO(lee) dedupe duplicate fetches within a batch, which requires
119120
/// cloning errors.
121+
#[minitrace::trace]
120122
#[convex_macro::instrument_future]
121123
pub async fn get_batch(
122124
&mut self,
@@ -184,6 +186,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> {
184186
}
185187

186188
/// Creates a new document with given value in the specified table.
189+
#[minitrace::trace]
187190
#[convex_macro::instrument_future]
188191
pub async fn insert(
189192
&mut self,
@@ -238,6 +241,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> {
238241

239242
/// Merges the existing document with the given object. Will overwrite any
240243
/// conflicting fields.
244+
#[minitrace::trace]
241245
#[convex_macro::instrument_future]
242246
pub async fn patch(
243247
&mut self,
@@ -265,6 +269,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> {
265269
}
266270

267271
/// Replace the document with the given value.
272+
#[minitrace::trace]
268273
#[convex_macro::instrument_future]
269274
pub async fn replace(
270275
&mut self,
@@ -289,6 +294,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> {
289294

290295
/// Delete the document at the given path -- called from user facing APIs
291296
/// (e.g. syscalls)
297+
#[minitrace::trace]
292298
#[convex_macro::instrument_future]
293299
pub async fn delete(&mut self, id: DeveloperDocumentId) -> anyhow::Result<DeveloperDocument> {
294300
if self.tx.is_system(*id.table())
@@ -373,6 +379,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> {
373379

374380
/// NOTE: returns a page of results. Callers must call record_read_document
375381
/// for all documents returned from the index stream.
382+
#[minitrace::trace]
376383
#[convex_macro::instrument_future]
377384
pub async fn index_range_batch(
378385
&mut self,

crates/database/src/transaction.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ impl<RT: Runtime> Transaction<RT> {
479479
self.get_inner(id, table_name).await
480480
}
481481

482-
#[minitrace::trace]
483482
#[convex_macro::instrument_future]
484483
pub(crate) async fn patch_inner(
485484
&mut self,
@@ -513,7 +512,6 @@ impl<RT: Runtime> Transaction<RT> {
513512
|| self.virtual_table_mapping().number_exists(&table_number)
514513
}
515514

516-
#[minitrace::trace]
517515
#[convex_macro::instrument_future]
518516
pub(crate) async fn replace_inner(
519517
&mut self,
@@ -542,7 +540,6 @@ impl<RT: Runtime> Transaction<RT> {
542540
Ok(new_document)
543541
}
544542

545-
#[minitrace::trace]
546543
#[convex_macro::instrument_future]
547544
pub async fn delete_inner(
548545
&mut self,
@@ -1007,6 +1004,7 @@ impl<RT: Runtime> Transaction<RT> {
10071004

10081005
/// NOTE: returns a page of results. Callers must call record_read_document
10091006
/// for all documents returned from the index stream.
1007+
#[minitrace::trace]
10101008
#[convex_macro::instrument_future]
10111009
pub async fn index_range_batch(
10121010
&mut self,

crates/database/src/virtual_tables/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl<'a, RT: Runtime> VirtualTable<'a, RT> {
4747
Self { tx }
4848
}
4949

50+
#[minitrace::trace]
5051
pub async fn get_batch(
5152
&mut self,
5253
mut ids: BTreeMap<BatchKey, (DeveloperDocumentId, Option<Version>)>,
@@ -99,6 +100,7 @@ impl<'a, RT: Runtime> VirtualTable<'a, RT> {
99100
results
100101
}
101102

103+
#[minitrace::trace]
102104
pub async fn index_range(
103105
&mut self,
104106
range_request: RangeRequest,

0 commit comments

Comments
 (0)