Skip to content

Add update_span method#25

Merged
Ken Jiang (knjiang) merged 3 commits intomainfrom
ken/add-update-span
Mar 18, 2026
Merged

Add update_span method#25
Ken Jiang (knjiang) merged 3 commits intomainfrom
ken/add-update-span

Conversation

@knjiang
Copy link
Copy Markdown
Collaborator

@knjiang Ken Jiang (knjiang) commented Mar 17, 2026

This PR adds update_span method similar to the typescript/python sdk

Comment thread src/log_queue/queue.rs Outdated
LogDestination::playground_logs(object_id.clone())
}
},
_ => LogDestination::project_logs("unknown".to_string()),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intended behavior?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah no, im gonna drop the update if it's an uknown span object type.

Comment thread src/log_queue/queue.rs Outdated
Some(ParentSpanInfo::Dataset { object_id }) => {
LogDestination::dataset(object_id.clone())
let destination = if let Some(span_components) = span_components.as_ref() {
if let Some(object_id) = span_components.object_id.as_ref() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use a match statement here, so it's clear that the options are exhaustive

Comment thread src/logger.rs
/// Update an existing span using the output of `SpanHandle::export()`.
///
/// Validation happens before queuing. The actual upload remains asynchronous.
pub async fn update_span(&self, exported: &str, event: crate::span::SpanLog) -> Result<()> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe for a separate change (i think Stephen Belanger (@Qard) is thinking about this..) but does this have to be async?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the aim is to work towards limiting async to internal code. We have a background working doing all the async request dispatching and then all user-facing APIs are basically just fire-and-forget style other than an explicit flush_and_wait. We may want some other interfaces exposing asynchronous functions, but the idea is that we should not be forcing end user code to be async by making our API surface only usable in an async runtime.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to defer this to unblock gateway. i think we should probably address background_login since we need to resolve credentials before shipping off to queue.

https://github.com/braintrustdata/braintrust-sdk-rust/blob/main/src/logger.rs#L599

@knjiang Ken Jiang (knjiang) merged commit b5c8aa8 into main Mar 18, 2026
2 checks passed
@Qard Stephen Belanger (Qard) deleted the ken/add-update-span branch March 19, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants