Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 6 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ machineid-rs = "1.2.4"
mockito = "1.7.2"
nom = "8.0.0"
nu-ansi-term = "0.50.1"
posthog-rs = "0.13.0"
pretty_assertions = "1.4.1"
posthog-rs = { version = "0.13.1", default-features = false, features = ["async-client"] }
proc-macro2 = "1.0"
quote = "1.0"
rustyline = "18.0.0"
Expand Down
14 changes: 14 additions & 0 deletions crates/forge_main/src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@

use crate::TRACKER;

/// Helper functions to eliminate duplication of tokio::spawn + TRACKER patterns

Check failure on line 5 in crates/forge_main/src/tracker.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

empty line after doc comment

Check warning on line 5 in crates/forge_main/src/tracker.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

empty line after doc comment

/// Begin a new trace. All subsequent [`dispatch`] calls within this
/// conversation turn will share the same `$trace_id` in PostHog, grouping
/// prompt, tool-call, and error events into a single AI observability trace.
pub async fn begin_trace(session_id: Option<String>) {
TRACKER.begin_trace(session_id).await;
}

/// End the current trace so that the next conversation turn starts a fresh
/// trace and session.
pub async fn end_trace() {
TRACKER.end_trace().await;
}

/// Generic dispatcher for any event
fn dispatch(event: EventKind) {
tokio::spawn(TRACKER.dispatch(event));
Expand Down
5 changes: 4 additions & 1 deletion crates/forge_main/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3958,6 +3958,7 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI

async fn on_message(&mut self, content: Option<String>) -> Result<()> {
let conversation_id = self.init_conversation().await?;
tracker::begin_trace(Some(conversation_id.into_string())).await;

if self.config.auto_install_vscode_extension {
self.install_vscode_extension();
Expand Down Expand Up @@ -3996,7 +3997,9 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI
// Create the chat request with the event
let chat = ChatRequest::new(event, conversation_id);

self.on_chat(chat).await
let result = self.on_chat(chat).await;
tracker::end_trace().await;
result
}

async fn on_chat(&mut self, chat: ChatRequest) -> Result<()> {
Expand Down
6 changes: 2 additions & 4 deletions crates/forge_tracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
reqwest.workspace = true
derive_more.workspace = true
url.workspace = true
posthog-rs.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
tracing.workspace = true
uuid.workspace = true
sysinfo.workspace = true
posthog-rs = "0.13.0"
async-trait.workspace = true
chrono.workspace = true
whoami.workspace = true
convert_case.workspace = true
http.workspace = true
regex.workspace = true
tracing-appender.workspace = true
tracing-subscriber.workspace = true
Expand Down
Loading
Loading