Skip to content

Commit

Permalink
wire results up
Browse files Browse the repository at this point in the history
  • Loading branch information
sxlijin committed Jul 2, 2024
1 parent 4a8ff0e commit fec7343
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions engine/baml-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl BamlRuntime {
.collect();
Ok(BamlRuntime {
inner: InternalBamlRuntime::from_directory(path)?,
tracer: BamlTracer::new(None, env_vars.into_iter()).into(),
tracer: BamlTracer::new(None, env_vars.into_iter())?.into(),
env_vars: copy,
})
}
Expand All @@ -97,7 +97,7 @@ impl BamlRuntime {
.collect();
Ok(BamlRuntime {
inner: InternalBamlRuntime::from_file_content(root_path, files)?,
tracer: BamlTracer::new(None, env_vars.into_iter()).into(),
tracer: BamlTracer::new(None, env_vars.into_iter())?.into(),
env_vars: copy,
})
}
Expand Down
8 changes: 4 additions & 4 deletions engine/baml-runtime/src/tracing/api_wrapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@ impl BoundaryTestAPI for APIWrapper {
}

impl APIWrapper {
pub fn from_env_vars<T: AsRef<str>>(value: impl Iterator<Item = (T, T)>) -> Self {
pub fn from_env_vars<T: AsRef<str>>(value: impl Iterator<Item = (T, T)>) -> Result<Self> {
let config = env_setup::Config::from_env_vars(value).unwrap();
if config.log_redaction_enabled {
log::info!("Redaction enabled: {}", config.log_redaction_enabled);
}
match (&config.secret, &config.project_id) {
Ok(match (&config.secret, &config.project_id) {
(Some(api_key), Some(project_id)) => Self {
config: APIConfig::Web(CompleteAPIConfig {
base_url: config.base_url,
Expand All @@ -362,7 +362,7 @@ impl APIWrapper {
stage: config.stage,
sessions_id: config.sessions_id,
host_name: config.host_name,
client: create_tracing_client().unwrap(),
client: create_tracing_client()?,
log_redaction_enabled: config.log_redaction_enabled,
log_redaction_placeholder: config.log_redaction_placeholder,
}),
Expand All @@ -379,7 +379,7 @@ impl APIWrapper {
log_redaction_placeholder: config.log_redaction_placeholder,
}),
},
}
})
}

pub fn enabled(&self) -> bool {
Expand Down
9 changes: 6 additions & 3 deletions engine/baml-runtime/src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ impl BamlTracer {
pub fn new<T: AsRef<str>>(
options: Option<APIWrapper>,
env_vars: impl Iterator<Item = (T, T)>,
) -> Self {
let options = options.unwrap_or_else(|| APIWrapper::from_env_vars(env_vars));
) -> Result<Self> {
let options = match options {
Some(wrapper) => wrapper,
None => APIWrapper::from_env_vars(env_vars)?,
};

let tracer = BamlTracer {
tracer: if options.enabled() {
Expand All @@ -83,7 +86,7 @@ impl BamlTracer {
n_spans_failed_before_submit: 0,
})),
};
tracer
Ok(tracer)
}

#[cfg(not(target_arch = "wasm32"))]
Expand Down

0 comments on commit fec7343

Please sign in to comment.