mirror of https://github.com/buster-so/buster.git
ok integration tests are working. About to implement with actual agent.
This commit is contained in:
parent
0a9f17fa42
commit
9324307302
|
@ -113,9 +113,9 @@ impl Span {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alias for add_metadata
|
/// Alias for add_metadata that converts any displayable value to a string
|
||||||
pub fn with_metadata(self, key: &str, value: &str) -> Self {
|
pub fn with_metadata<T: std::fmt::Display>(self, key: &str, value: T) -> Self {
|
||||||
self.add_metadata(key, value)
|
self.add_metadata(key, &value.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the span ID
|
/// Get the span ID
|
||||||
|
|
|
@ -96,7 +96,7 @@ async fn test_real_trace_with_spans() -> Result<()> {
|
||||||
|
|
||||||
// Add a root span
|
// Add a root span
|
||||||
let root_span = trace.add_span("Root Operation", "function").await?;
|
let root_span = trace.add_span("Root Operation", "function").await?;
|
||||||
let root_span = root_span
|
let mut root_span = root_span
|
||||||
.with_input(json!({
|
.with_input(json!({
|
||||||
"operation": "root",
|
"operation": "root",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
@ -107,11 +107,24 @@ async fn test_real_trace_with_spans() -> Result<()> {
|
||||||
.with_metadata("test_id", trace_id.clone());
|
.with_metadata("test_id", trace_id.clone());
|
||||||
|
|
||||||
// Log the root span
|
// Log the root span
|
||||||
|
client.log_span(root_span.clone()).await?;
|
||||||
|
|
||||||
|
sleep(Duration::from_secs(10)).await;
|
||||||
|
|
||||||
|
root_span = root_span
|
||||||
|
.with_output(json!({
|
||||||
|
"result": "success",
|
||||||
|
"parameters": {
|
||||||
|
"test": true,
|
||||||
|
"timestamp": chrono::Utc::now().to_rfc3339()
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
client.log_span(root_span).await?;
|
client.log_span(root_span).await?;
|
||||||
|
|
||||||
// Add an LLM span
|
// Add an LLM span
|
||||||
let llm_span = trace.add_span("LLM Call", "llm").await?;
|
let llm_span = trace.add_span("LLM Call", "llm").await?;
|
||||||
let llm_span = llm_span
|
let mut llm_span = llm_span
|
||||||
.with_input(json!({
|
.with_input(json!({
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
|
@ -120,6 +133,14 @@ async fn test_real_trace_with_spans() -> Result<()> {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}))
|
}))
|
||||||
|
.with_metadata("model", "test-model");
|
||||||
|
|
||||||
|
// Log the LLM span
|
||||||
|
client.log_span(llm_span.clone()).await?;
|
||||||
|
|
||||||
|
sleep(Duration::from_secs(15)).await;
|
||||||
|
|
||||||
|
llm_span = llm_span
|
||||||
.with_output(json!({
|
.with_output(json!({
|
||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
|
@ -129,11 +150,8 @@ async fn test_real_trace_with_spans() -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}))
|
}));
|
||||||
.with_tokens(15, 12)
|
|
||||||
.with_metadata("model", "test-model");
|
|
||||||
|
|
||||||
// Log the LLM span
|
|
||||||
client.log_span(llm_span).await?;
|
client.log_span(llm_span).await?;
|
||||||
|
|
||||||
// Add a tool span
|
// Add a tool span
|
||||||
|
@ -164,7 +182,7 @@ async fn test_real_trace_with_spans() -> Result<()> {
|
||||||
trace.finish().await?;
|
trace.finish().await?;
|
||||||
|
|
||||||
// Allow some time for async processing
|
// Allow some time for async processing
|
||||||
sleep(Duration::from_millis(200)).await;
|
sleep(Duration::from_secs(30)).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue