Skip to content

Commit

Permalink
Add counter telemetry(WIP)
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Dandamudi <rohitdandamudi.1100@gmail.com>
  • Loading branch information
me-diru committed Aug 22, 2024
1 parent afbcfa6 commit b8e58e8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/factor-llm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ spin-llm-remote-http = { path = "../llm-remote-http" }
spin-locked-app = { path = "../locked-app" }
spin-world = { path = "../world" }
tracing = { workspace = true }
spin-telemetry = { path = "../telemetry" }
tokio = { version = "1", features = ["sync"] }
toml = "0.8"
url = "2"
Expand Down
2 changes: 2 additions & 0 deletions crates/factor-llm/src/spin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ impl LlmEngine for RemoteHttpLlmEngine {
prompt: String,
params: v2::InferencingParams,
) -> Result<v2::InferencingResult, v2::Error> {
spin_telemetry::monotonic_counter!(spin.llm_infer = 1, model_name = model);
println!("This is LLM inference for remotehhtpengine");
self.infer(model, prompt, params).await
}

Expand Down
1 change: 1 addition & 0 deletions crates/key-value/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ tokio = { version = "1", features = ["macros", "sync", "rt"] }
spin-app = { path = "../app" }
spin-core = { path = "../core" }
spin-world = { path = "../world" }
spin-telemetry = { path = "../telemetry" }
table = { path = "../table" }
tracing = { workspace = true }
lru = "0.9.0"
4 changes: 4 additions & 0 deletions crates/key-value/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ impl key_value::HostStore for KeyValueDispatch {
store: Resource<key_value::Store>,
key: String,
) -> Result<Result<Option<Vec<u8>>, Error>> {
spin_telemetry::monotonic_counter!(spin.key_value_get = 1, key = key);

let store = self.get_store(store)?;
Ok(store.get(&key).await)
}
Expand All @@ -108,6 +110,8 @@ impl key_value::HostStore for KeyValueDispatch {
key: String,
value: Vec<u8>,
) -> Result<Result<(), Error>> {
spin_telemetry::monotonic_counter!(spin.key_value_set = 1, key = key);

let store = self.get_store(store)?;
Ok(store.set(&key, &value).await)
}
Expand Down
1 change: 1 addition & 0 deletions examples/spin-timer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b8e58e8

Please sign in to comment.