use serde::Serialize;
use tracing::debug;
use super::config::LangfuseConfig;
use crate::core::exceptions::OperonError;
use crate::core::tracing::models::TraceData;
pub struct LangfuseClient {
pub config: LangfuseConfig,
}
impl std::fmt::Debug for LangfuseClient {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LangfuseClient")
.field("host", &self.config.host)
.field("enabled", &self.config.enabled)
.finish()
}
}
impl LangfuseClient {
pub fn new(config: LangfuseConfig) -> Self {
Self { config }
}
pub fn ingest(&self, trace: &TraceData) -> Result<(), OperonError> {
if !self.config.enabled {
debug!(
"LangfuseClient: tracing disabled; dropping {}",
trace.request_id
);
return Ok(());
}
debug!(
"LangfuseClient: staged ingest for '{}' ({} nodes; Phase 7 stub)",
trace.workflow_name,
trace.nodes.len()
);
Ok(())
}
#[allow(dead_code)]
pub(crate) fn auth_header(&self) -> String {
use base64::{engine::general_purpose::STANDARD, Engine as _};
STANDARD.encode(format!(
"{}:{}",
self.config.public_key, self.config.secret_key
))
}
}
#[derive(Debug, Clone, Serialize)]
#[allow(dead_code)]
struct IngestionBatch<'a> {
batch: &'a [serde_json::Value],
metadata: &'a serde_json::Value,
}