Skip to content

Commit ba9e5db

Browse files
chore: add missing tracing for accounting module (#2039)
1 parent 472449c commit ba9e5db

File tree

11 files changed

+144
-28
lines changed

11 files changed

+144
-28
lines changed

core/accounting/src/balance_sheet/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ mod chart_of_accounts_integration;
22
pub mod error;
33
pub mod ledger;
44

5+
use tracing::instrument;
6+
57
use audit::AuditSvc;
68
use authz::PermissionCheck;
79
use cala_ledger::CalaLedger;
@@ -95,6 +97,7 @@ where
9597
}
9698
}
9799

100+
#[instrument(name = "core_accounting.balance_sheet.create", skip(self), err)]
98101
pub async fn create_balance_sheet(&self, name: String) -> Result<(), BalanceSheetError> {
99102
let mut op = es_entity::DbOp::init(&self.pool).await?;
100103

@@ -114,6 +117,11 @@ where
114117
}
115118
}
116119

120+
#[instrument(
121+
name = "core_accounting.balance_sheet.get_integration_config",
122+
skip(self),
123+
err
124+
)]
117125
pub async fn get_chart_of_accounts_integration_config(
118126
&self,
119127
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -132,6 +140,11 @@ where
132140
.await?)
133141
}
134142

143+
#[instrument(
144+
name = "core_accounting.balance_sheet.set_integration_config",
145+
skip(self, chart),
146+
err
147+
)]
135148
pub async fn set_chart_of_accounts_integration_config(
136149
&self,
137150
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -193,6 +206,7 @@ where
193206
Ok(config)
194207
}
195208

209+
#[instrument(name = "core_accounting.balance_sheet.balance_sheet", skip(self), err)]
196210
pub async fn balance_sheet(
197211
&self,
198212
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,

core/accounting/src/chart_of_accounts/mod.rs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ pub mod error;
44
mod repo;
55
pub mod tree;
66

7-
pub(super) use csv::{CsvParseError, CsvParser};
8-
pub use entity::Chart;
9-
pub(super) use entity::*;
10-
pub(super) use repo::*;
7+
use tracing::instrument;
118

129
use audit::AuditSvc;
1310
use authz::PermissionCheck;
1411

1512
use cala_ledger::{CalaLedger, account_set::NewAccountSet};
16-
use tracing::instrument;
1713

1814
use crate::primitives::{
1915
CalaAccountSetId, CalaJournalId, ChartId, CoreAccountingAction, CoreAccountingObject,
2016
};
17+
18+
pub(super) use csv::{CsvParseError, CsvParser};
19+
pub use entity::Chart;
20+
pub(super) use entity::*;
2121
use error::*;
22+
pub(super) use repo::*;
2223

2324
pub struct ChartOfAccounts<Perms>
2425
where
@@ -65,7 +66,11 @@ where
6566
}
6667
}
6768

68-
#[instrument(name = "chart_of_accounts.create_chart", skip(self))]
69+
#[instrument(
70+
name = "core_accounting.chart_of_accounts.create_chart",
71+
skip(self),
72+
err
73+
)]
6974
pub async fn create_chart(
7075
&self,
7176
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -98,7 +103,11 @@ where
98103
Ok(chart)
99104
}
100105

101-
#[instrument(name = "chart_of_account.import_from_csv", skip(self, data))]
106+
#[instrument(
107+
name = "core_accounting.chart_of_accounts.import_from_csv",
108+
skip(self, data),
109+
err
110+
)]
102111
pub async fn import_from_csv(
103112
&self,
104113
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -168,15 +177,19 @@ where
168177
))
169178
}
170179

171-
#[instrument(name = "chart_of_accounts.find_by_id", skip(self), err)]
180+
#[instrument(name = "core_accounting.chart_of_accounts.find_by_id", skip(self), err)]
172181
pub async fn find_by_id(
173182
&self,
174183
id: impl Into<ChartId> + std::fmt::Debug,
175184
) -> Result<Chart, ChartOfAccountsError> {
176185
self.repo.find_by_id(id.into()).await
177186
}
178187

179-
#[instrument(name = "chart_of_accounts.find_by_reference_with_sub", skip(self))]
188+
#[instrument(
189+
name = "core_accounting.chart_of_accounts.find_by_reference_with_sub",
190+
skip(self),
191+
err
192+
)]
180193
pub async fn find_by_reference_with_sub(
181194
&self,
182195
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -193,7 +206,11 @@ where
193206
self.find_by_reference(reference).await
194207
}
195208

196-
#[instrument(name = "chart_of_accounts.find_by_reference", skip(self))]
209+
#[instrument(
210+
name = "core_accounting.chart_of_accounts.find_by_reference",
211+
skip(self),
212+
err
213+
)]
197214
pub async fn find_by_reference(
198215
&self,
199216
reference: &str,
@@ -208,7 +225,7 @@ where
208225
Ok(chart)
209226
}
210227

211-
#[instrument(name = "chart_of_accounts.find_all", skip(self), err)]
228+
#[instrument(name = "core_accounting.chart_of_accounts.find_all", skip(self), err)]
212229
pub async fn find_all<T: From<Chart>>(
213230
&self,
214231
ids: &[ChartId],

core/accounting/src/csv/mod.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ mod job;
55
mod primitives;
66
mod repo;
77

8-
use crate::Jobs;
9-
use crate::Storage;
8+
use tracing::instrument;
9+
1010
use audit::AuditSvc;
1111
use authz::PermissionCheck;
1212

13+
use crate::Jobs;
14+
use crate::Storage;
15+
1316
use es_entity::ListDirection;
14-
pub use repo::accounting_csv_cursor::AccountingCsvsByCreatedAtCursor;
1517

1618
use super::{
1719
CoreAccountingAction, CoreAccountingObject,
@@ -23,6 +25,7 @@ pub use entity::*;
2325
use error::*;
2426
use job::*;
2527
pub use primitives::*;
28+
pub use repo::accounting_csv_cursor::AccountingCsvsByCreatedAtCursor;
2629
use repo::*;
2730

2831
#[derive(Clone)]
@@ -66,6 +69,7 @@ where
6669
}
6770
}
6871

72+
#[instrument(name = "core_accounting.csv.create", skip(self), err)]
6973
pub async fn create_ledger_account_csv(
7074
&self,
7175
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -108,6 +112,7 @@ where
108112
Ok(csv)
109113
}
110114

115+
#[instrument(name = "core_accounting.csv.generate_download_link", skip(self), err)]
111116
pub async fn generate_download_link(
112117
&self,
113118
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -137,6 +142,11 @@ where
137142
})
138143
}
139144

145+
#[instrument(
146+
name = "core_accounting.csv.list_for_ledger_account_id",
147+
skip(self),
148+
err
149+
)]
140150
pub async fn list_for_ledger_account_id(
141151
&self,
142152
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -169,6 +179,7 @@ where
169179
Ok(csvs)
170180
}
171181

182+
#[instrument(name = "core_accounting.csv.find_all", skip(self), err)]
172183
pub async fn find_all<T: From<AccountingCsv>>(
173184
&self,
174185
ids: &[AccountingCsvId],

core/accounting/src/journal/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ where
3737
}
3838
}
3939

40-
#[instrument(name = "accounting.journal.entries", skip(self))]
40+
#[instrument(name = "core_accounting.journal.entries", skip(self), err)]
4141
pub async fn entries(
4242
&self,
4343
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,

core/accounting/src/ledger_account/mod.rs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ where
4545
}
4646
}
4747

48+
#[instrument(name = "core_accounting.ledger_account.history", skip(self), err)]
4849
pub async fn history(
4950
&self,
5051
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
51-
id: impl Into<LedgerAccountId>,
52+
id: impl Into<LedgerAccountId> + std::fmt::Debug,
5253
args: es_entity::PaginatedQueryArgs<JournalEntryCursor>,
5354
) -> Result<es_entity::PaginatedQueryRet<JournalEntry, JournalEntryCursor>, LedgerAccountError>
5455
{
@@ -64,9 +65,14 @@ where
6465
Ok(self.ledger.ledger_account_history(id, args).await?)
6566
}
6667

68+
#[instrument(
69+
name = "core_accounting.ledger_account.complete_history",
70+
skip(self),
71+
err
72+
)]
6773
pub(crate) async fn complete_history(
6874
&self,
69-
id: impl Into<LedgerAccountId> + Copy,
75+
id: impl Into<LedgerAccountId> + Copy + std::fmt::Debug,
7076
) -> Result<Vec<JournalEntry>, LedgerAccountError> {
7177
let id = id.into();
7278

@@ -93,7 +99,11 @@ where
9399
Ok(all_entries)
94100
}
95101

96-
#[instrument(name = "accounting.ledger_account.find_by_id", skip(self, chart), err)]
102+
#[instrument(
103+
name = "core_accounting.ledger_account.find_by_id",
104+
skip(self, chart),
105+
err
106+
)]
97107
pub async fn find_by_id(
98108
&self,
99109
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -112,7 +122,11 @@ where
112122
Ok(accounts.remove(&id))
113123
}
114124

115-
#[instrument(name = "accounting.ledger_account.find_by_id", skip(self, chart), err)]
125+
#[instrument(
126+
name = "core_accounting.ledger_account.find_by_id",
127+
skip(self, chart),
128+
err
129+
)]
116130
pub async fn find_by_code(
117131
&self,
118132
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -139,6 +153,11 @@ where
139153
}
140154
}
141155

156+
#[instrument(
157+
name = "core_accounting.ledger_account.find_all",
158+
skip(self, chart),
159+
err
160+
)]
142161
pub async fn find_all<T: From<LedgerAccount>>(
143162
&self,
144163
chart: &Chart,
@@ -155,6 +174,11 @@ where
155174
}
156175

157176
#[allow(clippy::too_many_arguments)]
177+
#[instrument(
178+
name = "core_accounting.ledger_account.list_account_children",
179+
skip(self, chart),
180+
err
181+
)]
158182
pub async fn list_account_children(
159183
&self,
160184
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -217,6 +241,11 @@ where
217241
/// Pushes into `account`'s `ancestor_ids` ancestors from the chart of account. The ancestors
218242
/// are pushed in ascending order, the root of the chart of accounts is pushed last. `account`
219243
/// itself is not pushed.
244+
#[instrument(
245+
name = "core_accounting.ledger_account.populate_ancestors",
246+
skip(self, chart, account),
247+
err
248+
)]
220249
async fn populate_ancestors(
221250
&self,
222251
chart: &Chart,
@@ -236,6 +265,11 @@ where
236265
Ok(())
237266
}
238267

268+
#[instrument(
269+
name = "core_accounting.ledger_account.populate_children",
270+
skip(self, chart, account),
271+
err
272+
)]
239273
async fn populate_children(
240274
&self,
241275
chart: &Chart,

core/accounting/src/ledger_transaction/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ mod cursor;
22
pub mod error;
33
mod value;
44

5+
use tracing::instrument;
6+
57
use std::collections::HashMap;
68

79
use audit::AuditSvc;
810
use authz::PermissionCheck;
911
use cala_ledger::{CalaLedger, transaction::TransactionsByCreatedAtCursor};
10-
use tracing::instrument;
1112

1213
use crate::primitives::{CoreAccountingAction, CoreAccountingObject, LedgerTransactionId};
1314

@@ -37,7 +38,11 @@ where
3738
}
3839
}
3940

40-
#[instrument(name = "accounting.ledger_transaction.find_by_id", skip(self), err)]
41+
#[instrument(
42+
name = "core_accounting.ledger_transaction.find_by_id",
43+
skip(self),
44+
err
45+
)]
4146
pub async fn find_by_id(
4247
&self,
4348
sub: &<<Perms as PermissionCheck>::Audit as AuditSvc>::Subject,
@@ -64,6 +69,7 @@ where
6469
Ok(res)
6570
}
6671

72+
#[instrument(name = "core_accounting.ledger_transaction.find_all", skip(self), err)]
6773
pub async fn find_all<T: From<LedgerTransaction>>(
6874
&self,
6975
ids: &[LedgerTransactionId],
@@ -108,7 +114,7 @@ where
108114
}
109115

110116
#[instrument(
111-
name = "accounting.ledger_transaction.list_for_template_code",
117+
name = "core_accounting.ledger_transaction.list_for_template_code",
112118
skip(self),
113119
err
114120
)]

0 commit comments

Comments
 (0)