Skip to content

Commit 8aac035

Browse files
committed
Add counter telemetry(WIP)
Signed-off-by: Rohit Dandamudi <[email protected]>
1 parent c28929f commit 8aac035

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/factor-llm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ spin-llm-remote-http = { path = "../llm-remote-http" }
1818
spin-locked-app = { path = "../locked-app" }
1919
spin-world = { path = "../world" }
2020
tracing = { workspace = true }
21+
spin-telemetry = { path = "../telemetry" }
2122
tokio = { version = "1", features = ["sync"] }
2223
toml = "0.8"
2324
url = "2"

crates/factor-llm/src/spin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ impl LlmEngine for RemoteHttpLlmEngine {
4040
prompt: String,
4141
params: v2::InferencingParams,
4242
) -> Result<v2::InferencingResult, v2::Error> {
43+
spin_telemetry::monotonic_counter!(spin.llm_infer = 1, model_name = model);
44+
println!("This is LLM inference for remotehhtpengine");
4345
self.infer(model, prompt, params).await
4446
}
4547

crates/key-value/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tokio = { version = "1", features = ["macros", "sync", "rt"] }
1313
spin-app = { path = "../app" }
1414
spin-core = { path = "../core" }
1515
spin-world = { path = "../world" }
16+
spin-telemetry = { path = "../telemetry" }
1617
table = { path = "../table" }
1718
tracing = { workspace = true }
1819
lru = "0.9.0"

crates/key-value/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ impl key_value::HostStore for KeyValueDispatch {
9898
store: Resource<key_value::Store>,
9999
key: String,
100100
) -> Result<Result<Option<Vec<u8>>, Error>> {
101+
spin_telemetry::monotonic_counter!(spin.key_value_get = 1, key = key);
102+
101103
let store = self.get_store(store)?;
102104
Ok(store.get(&key).await)
103105
}
@@ -108,6 +110,8 @@ impl key_value::HostStore for KeyValueDispatch {
108110
key: String,
109111
value: Vec<u8>,
110112
) -> Result<Result<(), Error>> {
113+
spin_telemetry::monotonic_counter!(spin.key_value_set = 1, key = key);
114+
111115
let store = self.get_store(store)?;
112116
Ok(store.set(&key, &value).await)
113117
}

examples/spin-timer/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)