Skip to content

Commit 02f94a8

Browse files
aaronvghellovai
andauthored
oct 7 studio (#2591)
# Pull Request Template Thanks for taking the time to fill out this pull request! ## Issue Reference Please link to any related issues - [ ] This PR fixes/closes #[issue number] ## Changes Please describe the changes proposed in this pull request [Describe your changes here...] ## Testing Please describe how you tested these changes - [ ] Unit tests added/updated - [ ] Manual testing performed - [ ] Tested in [environment] ## Screenshots If applicable, add screenshots to help explain your changes [Add screenshots here...] ## PR Checklist Please ensure you've completed these items - [ ] I have read and followed the contributing guidelines - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ## Additional Notes Add any other context about the PR here [Add any additional notes here...] <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds org billing fields/endpoints, hardens runtime tracing completion (incl. cancellations), extends Python tracing/flush behavior, and updates docs/tests for tracing. > > - **Backend/API (baml-rpc)**: > - Add Stripe billing fields to `ui_control_plane_orgs::Organization` (`stripe_entitlements`, `stripe_subscription_data`). > - New endpoints: `DeleteOrganization` (`/v1/delete-organization`) and `SyncStripeSubscription` (`/v1/billing/sync-stripe-subscription`). > - `RelativeTime` adds `"5m"`; `FunctionSummary` includes `language`; default limit for summaries raised to `400`. > - **Runtime/Tracing (baml-runtime)**: > - Introduce `TracingCallGuard` to always emit `TraceEvent::new_function_end` and call `finish_baml_call`, including on errors/cancellation. > - Refactor `call_function_with_expr_events` to use guard; cancellation emits `BamlError::External("Operation cancelled")`. > - Normalize external error message to `ExternalException: …`. > - Pass through `BOUNDARY_API_KEY`/`BOUNDARY_API_URL` to clients for telemetry. > - **Python client**: > - Trace decorators now catch `BaseException` (e.g., `KeyboardInterrupt`, `CancelledError`). > - Add `abort_all_active_operations()` and invoke on `flush()`; brief delay to allow event emission. > - **Docs**: > - Observability guide: add section on tracing with `ThreadPoolExecutor` and tag note tweak. > - **Tests/CI**: > - New comprehensive `test_tracing.py`; augment existing tests for call stack/tag verification; update `.gitignore` for `trace-events-debug.jsonl`; exclude tracing test in CI script. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7eb8672. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: hellovai <[email protected]>
1 parent 716b7b1 commit 02f94a8

File tree

17 files changed

+1694
-78
lines changed

17 files changed

+1694
-78
lines changed

engine/baml-rpc/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ pub use s3::S3UploadMetadata;
2121
pub use ui::{
2222
ui_baml_src::{GetBamlSrcBundle, GetBamlSrcBundleRequest, GetBamlSrcBundleResponse},
2323
ui_control_plane_orgs::{
24-
CreateOrganization, CreateOrganizationRequest, CreateOrganizationResponse, GetOrganization,
25-
GetOrganizationRequest, GetOrganizationResponse, Organization, UpdateOrganization,
24+
CreateOrganization, CreateOrganizationRequest, CreateOrganizationResponse,
25+
DeleteOrganization, DeleteOrganizationRequest, DeleteOrganizationResponse, GetOrganization,
26+
GetOrganizationRequest, GetOrganizationResponse, Organization, SyncStripeSubscription,
27+
SyncStripeSubscriptionRequest, SyncStripeSubscriptionResponse, UpdateOrganization,
2628
UpdateOrganizationRequest, UpdateOrganizationResponse,
2729
},
2830
ui_control_plane_projects::{

engine/baml-rpc/src/ui/ui_control_plane_orgs.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ pub struct Organization {
1515
pub stripe_subscription_id: Option<String>,
1616
#[ts(optional)]
1717
pub stripe_subscription_status: Option<String>,
18+
#[ts(optional)]
19+
pub stripe_entitlements: Option<Vec<String>>,
20+
/// Complete Stripe subscription state (single source of truth)
21+
/// Contains subscription data + entitlements from 2 Stripe API calls
22+
/// stripe_entitlements[] is derived from this JSON for fast indexed queries
23+
#[ts(optional, type = "any")]
24+
pub stripe_subscription_data: Option<serde_json::Value>,
1825
}
1926

2027
#[derive(Debug, Serialize, Deserialize, TS)]
@@ -54,6 +61,10 @@ pub struct UpdateOrganizationRequest {
5461
pub stripe_subscription_id: Option<String>,
5562
#[ts(optional)]
5663
pub stripe_subscription_status: Option<String>,
64+
#[ts(optional)]
65+
pub stripe_entitlements: Option<Vec<String>>,
66+
#[ts(optional, type = "any")]
67+
pub stripe_subscription_data: Option<serde_json::Value>,
5768
}
5869

5970
#[derive(Debug, Serialize, Deserialize, TS)]
@@ -91,3 +102,49 @@ impl ApiEndpoint for GetOrganization {
91102

92103
const PATH: &'static str = "/v1/get-organization";
93104
}
105+
106+
#[derive(Debug, Serialize, Deserialize, TS)]
107+
#[ts(export)]
108+
pub struct DeleteOrganizationRequest {
109+
pub org_id: String,
110+
}
111+
112+
#[derive(Debug, Serialize, Deserialize, TS)]
113+
#[ts(export)]
114+
pub struct DeleteOrganizationResponse {
115+
pub success: bool,
116+
}
117+
118+
pub struct DeleteOrganization;
119+
120+
impl ApiEndpoint for DeleteOrganization {
121+
type Request<'a> = DeleteOrganizationRequest;
122+
type Response<'a> = DeleteOrganizationResponse;
123+
124+
const PATH: &'static str = "/v1/delete-organization";
125+
}
126+
127+
#[derive(Debug, Serialize, Deserialize, TS)]
128+
#[ts(export)]
129+
pub struct SyncStripeSubscriptionRequest {
130+
pub org_id: String,
131+
}
132+
133+
#[derive(Debug, Serialize, Deserialize, TS)]
134+
#[ts(export)]
135+
pub struct SyncStripeSubscriptionResponse {
136+
pub success: bool,
137+
#[ts(optional)]
138+
pub error: Option<String>,
139+
#[ts(optional, type = "any")]
140+
pub data: Option<serde_json::Value>,
141+
}
142+
143+
pub struct SyncStripeSubscription;
144+
145+
impl ApiEndpoint for SyncStripeSubscription {
146+
type Request<'a> = SyncStripeSubscriptionRequest;
147+
type Response<'a> = SyncStripeSubscriptionResponse;
148+
149+
const PATH: &'static str = "/v1/billing/sync-stripe-subscription";
150+
}

engine/baml-rpc/src/ui/ui_function_calls.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ pub struct OrderBy {
241241
#[derive(Debug, Deserialize, Serialize, TS, Clone)]
242242
#[ts(export)]
243243
pub enum RelativeTime {
244+
#[serde(rename = "5m")]
245+
FiveMinutes,
244246
#[serde(rename = "1h")]
245247
OneHour,
246248
#[serde(rename = "6h")]

engine/baml-rpc/src/ui/ui_traces.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl Default for ListTraceFunctionSummariesRequest {
327327
fn default() -> Self {
328328
Self {
329329
project_id: ProjectId::new(),
330-
limit: Some(100),
330+
limit: Some(400),
331331
starting_after: None,
332332
relative_time: None,
333333
start_time: None,
@@ -350,6 +350,7 @@ pub struct FunctionSummary {
350350
pub function_id: Option<ui_types::UiFunctionIdString>,
351351
pub function_name: String,
352352
pub function_type: String, // 'baml_llm' or 'native'
353+
pub language: String,
353354
#[ts(type = "Record<string, unknown>")]
354355
pub tags: serde_json::Map<String, serde_json::Value>,
355356

engine/baml-runtime/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl IntoBamlError for &anyhow::Error {
188188
return baml_error.clone();
189189
}
190190
baml_types::tracing::events::BamlError::External {
191-
message: Cow::Owned(format!("into_baml_error: {self:?}")),
191+
message: Cow::Owned(format!("ExternalException: {self:?}")),
192192
}
193193
}
194194
}

0 commit comments

Comments
 (0)