-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add metrics for recipe metadata in scheduler, UI, and CLI #4399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,6 +231,53 @@ async fn run_now_handler( | |
| .await | ||
| .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; | ||
|
|
||
| let recipe_display_name = match scheduler.list_scheduled_jobs().await { | ||
| Ok(jobs) => jobs | ||
| .into_iter() | ||
| .find(|job| job.id == id) | ||
| .and_then(|job| { | ||
| std::path::Path::new(&job.source) | ||
| .file_name() | ||
| .and_then(|name| name.to_str()) | ||
| .map(|s| s.to_string()) | ||
| }) | ||
| .unwrap_or_else(|| id.clone()), | ||
| Err(_) => id.clone(), | ||
| }; | ||
|
|
||
| let recipe_version = match scheduler.list_scheduled_jobs().await { | ||
| Ok(jobs) => jobs | ||
| .into_iter() | ||
| .find(|job| job.id == id) | ||
| .and_then(|job| { | ||
| std::fs::read_to_string(&job.source) | ||
| .ok() | ||
| .and_then(|content| { | ||
| goose::recipe::template_recipe::parse_recipe_content( | ||
| &content, | ||
| std::path::Path::new(&job.source) | ||
| .parent() | ||
| .unwrap_or_else(|| std::path::Path::new("")) | ||
| .to_string_lossy() | ||
| .to_string(), | ||
| ) | ||
| .ok() | ||
| .map(|(r, _)| r.version) | ||
| }) | ||
| }) | ||
| .unwrap_or_else(|| "unknown".to_string()), | ||
| Err(_) => "unknown".to_string(), | ||
| }; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you filtering through the list of jobs twice here, once to find the name, once to find the version? make that into one thing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that's on me. let me fix this quick |
||
|
|
||
| tracing::info!( | ||
| counter.goose.recipe_runs = 1, | ||
| recipe_name = %recipe_display_name, | ||
| recipe_version = %recipe_version, | ||
| session_type = "schedule", | ||
| interface = "server", | ||
| "Recipe execution started" | ||
| ); | ||
|
|
||
| tracing::info!("Server: Calling scheduler.run_now() for job '{}'", id); | ||
|
|
||
| match scheduler.run_now(&id).await { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,16 @@ export const useChatEngine = ({ | |
| api: getApiUrl('/reply'), | ||
| id: chat.id, | ||
| initialMessages: chat.messages, | ||
| body: { session_id: chat.id, session_working_dir: window.appConfig.get('GOOSE_WORKING_DIR') }, | ||
| body: { | ||
| session_id: chat.id, | ||
| session_working_dir: window.appConfig.get('GOOSE_WORKING_DIR'), | ||
| ...(chat.recipeConfig?.title | ||
| ? { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. title is required, so you want to check on recipeConfig here, not title
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's what this is doing
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's checking chat.recipeConfig?.title not hat.recipeConfig |
||
| recipe_name: chat.recipeConfig.title, | ||
| recipe_version: chat.recipeConfig?.version ?? 'unknown', | ||
| } | ||
| : {}), | ||
| }, | ||
| onFinish: async (_message, _reason) => { | ||
| stopPowerSaveBlocker(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to pass this in? do we not have this information in the session meta data, that seems like a better place. same actually for the schedule_job_id I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not have it currently no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we want to move the source of truth for conversations to the server, not add stuff to the reply handler. I also don't think this does record what you want it to record. I think you want to measure how often recipes are used, not how many messages users send to recipes. not that it is doing that, if you resume a conversation, it won't remember it was started by a recipe.
I would suggest to wait with this until the https://github.com/block/goose/pull/4216/files lands and then add the logging to agent/start which should know whether it was done through a recipe (and if not, that would be the right place to add).