-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add counter telemetry #2741
base: main
Are you sure you want to change the base?
Add counter telemetry #2741
Conversation
Captured the LLM model and prompt information and kv stores get and set key information Not sure if the key is accessible when querying on Prometheus/Grafana cc: @calebschoepp |
crates/key-value/src/lib.rs
Outdated
@@ -92,6 +92,9 @@ impl key_value::HostStore for KeyValueDispatch { | |||
store: Resource<key_value::Store>, | |||
key: String, | |||
) -> Result<Result<Option<Vec<u8>>, Error>> { | |||
// Log key value host component get feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the intention behind these comments, but I think they're needlessly verbose. Directly reading spin_telemetry::counter
is pretty intuitive as to what it's doing.
crates/key-value/src/lib.rs
Outdated
@@ -92,6 +92,9 @@ impl key_value::HostStore for KeyValueDispatch { | |||
store: Resource<key_value::Store>, | |||
key: String, | |||
) -> Result<Result<Option<Vec<u8>>, Error>> { | |||
// Log key value host component get feature | |||
spin_telemetry::counter!(spin.key_value_get = 1, key = key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should all probably be monotonic_counter
's b/c they're monotonically increasing.
crates/key-value/src/lib.rs
Outdated
@@ -102,6 +105,9 @@ impl key_value::HostStore for KeyValueDispatch { | |||
key: String, | |||
value: Vec<u8>, | |||
) -> Result<Result<(), Error>> { | |||
// Log key value host component set feature | |||
spin_telemetry::counter!(spin.key_value_set = 1, key = key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It occurs to me that you're adding all this to the host components which we're going to be deleting very soon. This should all probably be added to the factors which mean this would have to be a PR against the factors branch.
crates/llm-remote-http/src/lib.rs
Outdated
spin_telemetry::counter!( | ||
spin.llm_infer = 1, | ||
model_name = model, | ||
prompt_given = prompt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want this as an attribute. The prompt could be very large and it is also likely to be high cardinality which is not a good fit for a metric attribute.
cd4491a
to
ea08fb6
Compare
@me-diru is this intended to land in the factors branch, or should it be rebased off main? Currently, merging this would merge a whole bunch of unrelated factors stuff too. |
This should land on factors (or main once factors merges in there). |
I changed the base to factors, and it should only reflect my code changes. Thanks for checking in @itowlson ! |
@calebschoepp
it gives me an error of
I tried to run the factor_test.rs for the
Which I think satisfies On the other hand, for Would be great to have your input |
@me-diru I still see 3 commits that aren't yours that you'll want to take out of this diff. |
You might need to enable the (This is a common pattern in Rust utility crates, where it's useful for people to be able to serialise the types, but they don't want to force a heavyweight |
That did the trick, tests passed :D I am just curious how the tests passed before, though 😅 In the current case of factor-llm, we don't have to deserialize the Url? |
@me-diru It will work if any crate in the build turns the feature on. This can be cause surprises when you use your crate in a slightly different build context and the other crate that happened to make things work is no longer there and boom your code stops compiling. This is a significant pain point for features but I gather there is not much that can be done. |
Are you still having errors running it @me-diru? I would need to see the runtime config you're using to help more. |
Yes, it's still happening. When I run the same command with the latest spin cli release(2.7), it works fine. anonymized runtime-config file [llm_compute]
type = "remote_http"
url = "<URL>"
auth_token = "<AUTH-TOKEN>"
I checked with Maybe @lann could give more insight |
☝️ This hopefully fixed it. |
@calebschoepp I think it's now capturing the metrics in the new factors code! |
Sweet, @me-diru is this ready for a final review? |
88dd34f
to
185cc10
Compare
@calebschoepp Yes! Please review :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. LGTM!
Could someone from @fermyon/spin-core-maintainers enable CI and merge this?
crates/key-value/src/lib.rs
Outdated
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be emitting them in traces already but I'm not sure its a good idea to be sending KV store keys by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Danielle opened a somewhat related issue for being more careful with what we're emitting in telemetry. https://github.com/orgs/fermyon/projects/62/views/1?pane=issue&itemId=79180245
If we wanted to get fancy we could only emit these potentially sensitive values when some sort of local debug flag is set. But, for simplicities sake we're probably best of just not emitting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah if we don't have a specific need for it lets omit until we can come up with a better approach.
CI didn't run as the base branch is still |
Good catch, @me-diru you'll have to point this onto |
The plan was to merge it to I see all commits from |
88bc510
to
8b03d12
Compare
I have excluded capturing key details in the metrics. However, I was still getting some weird linting issues. It would be great to get more context on them! |
Seems like there aren't any linting errors in CI. Are you just experiencing those linting errors locally? What are they? |
@me-diru CI is currently locked to Rust 1.79. Is it possible you are on a more recent version of Rust with shiny new lints? |
FWIW the lint warnings there have been fixed in #2866 so a rebase will get rid of those. |
Interesting to see most of my merge conflicts were version downgrades |
examples/spin-timer/Cargo.lock
Outdated
[[package]] | ||
name = "wit-parser" | ||
version = "0.217.0" | ||
source = "registry+https://github.com/rust-lang/crates.io-index" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you need to fix this lockfile for linting to pass.
Signed-off-by: Rohit Dandamudi <[email protected]>
There was a timeout error in
|
Fixes #2564
I think this captures the metrics of LLM and Key-Value store