-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set up tracing types & upload fake trace data (#1425)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Introduces a new tracing system for the BAML toolchain, adding modules for handling trace events, updating dependencies, and including tests for the new functionality. > > - **Behavior**: > - Introduces tracing functionality with `TraceEvent`, `TraceSpanStart`, `TraceSpanEnd`, and `TraceLog` in `baml-types/src/tracing.rs`. > - Adds `TraceEventUploadRequest` and `TraceEventUploadResponse` in `baml-types/src/rpc/mod.rs` for handling trace event uploads. > - Implements `TracerThread` in `btrace/src/tracer_thread.rs` to handle trace event batching and uploading. > - **Modules**: > - Adds `tracing` and `rpc` modules to `baml-types`. > - Adds `btrace` module with `TraceContext` and `InstrumentationScope` in `btrace/src/lib.rs`. > - **Dependencies**: > - Adds `tracing-core`, `time`, and `web-time` dependencies to `baml-types` and `btrace`. > - Updates `Cargo.toml` files to include new modules and dependencies. > - **Testing**: > - Adds tests for tracing functionality in `btrace/tests.rs` using `wasm-bindgen-test`. > - **Misc**: > - Adds `sandbox` module with example usage of tracing in `sandbox/src/main.rs` and `sandbox/src/upload-traces-main.rs`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 1b80ae0. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
- Loading branch information
Showing
15 changed files
with
1,063 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use indexmap::IndexMap; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::tracing::TraceEventBatch; | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
|
||
// TODO: version handling should be non-exhaustive for all of these | ||
// clients need to say "i can only handle v1 responses" | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub enum BamlSrcUploadStatus { | ||
Pending, | ||
Completed, | ||
Failed, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "version")] | ||
pub enum GetBamlSrcUploadStatusRequest { | ||
V1 { | ||
project_id: String, | ||
fingerprint: String, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "version")] | ||
pub enum GetBamlSrcUploadStatusResponse { | ||
V1 { | ||
project_id: String, | ||
fingerprint: String, | ||
status: BamlSrcUploadStatus, | ||
}, | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "version")] | ||
pub enum BamlSrcCreateUploadUrlRequest { | ||
V1 { | ||
project_id: String, | ||
fingerprint: String, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "version")] | ||
pub enum BamlSrcCreateUploadUrlResponse { | ||
V1 { | ||
project_id: String, | ||
fingerprint: String, | ||
upload_url: String, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "version")] | ||
pub enum BamlSrcBlob { | ||
V1 { | ||
project_id: String, | ||
fingerprint: String, | ||
baml_src: IndexMap<String, String>, | ||
}, | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "version")] | ||
pub enum TraceEventUploadRequest { | ||
V1 { | ||
project_id: String, | ||
trace_event_batch: TraceEventBatch, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "version")] | ||
pub enum TraceEventUploadResponse { | ||
V1 { project_id: String }, | ||
} |
Oops, something went wrong.