mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-23 00:27:26 +00:00
# What does this PR do? query_metrics currently has no implementation, meaning once a metric is emitted there is no way in llama stack to query it from the store. implement query_metrics for the meta_reference provider which follows a similar style to `query_traces`, using the trace_store to format an SQL query and execute it in this case the parameters for the query are `metric.METRIC_NAME, start_time, and end_time` and any other matchers if they are provided. this required client side changes since the client had no `query_metrics` or any associated resources, so any tests here will fail but I will provide manual execution logs for the new tests I am adding order the metrics by timestamp. Additionally add `unit` to the `MetricDataPoint` class since this adds much more context to the metric being queried. depends on https://github.com/llamastack/llama-stack-client-python/pull/260 ## Test Plan ``` import time import uuid def create_http_client(): from llama_stack_client import LlamaStackClient return LlamaStackClient(base_url="http://localhost:8321") client = create_http_client() response = client.telemetry.query_metrics(metric_name="total_tokens", start_time=0) print(response) ``` ``` ╰─ python3.12 ~/telemetry.py INFO:httpx:HTTP Request: POST http://localhost:8322/v1/telemetry/metrics/total_tokens "HTTP/1.1 200 OK" [TelemetryQueryMetricsResponse(data=None, metric='total_tokens', labels=[], values=[{'timestamp': 1753999514, 'value': 34.0, 'unit': 'tokens'}, {'timestamp': 1753999816, 'value': 34.0, 'unit': 'tokens'}, {'timestamp': 1753999881, 'value': 34.0, 'unit': 'tokens'}, {'timestamp': 1753999956, 'value': 34.0, 'unit': 'tokens'}, {'timestamp': 1754000200, 'value': 34.0, 'unit': 'tokens'}, {'timestamp': 1754000419, 'value': 36.0, 'unit': 'tokens'}, {'timestamp': 1754000714, 'value': 36.0, 'unit': 'tokens'}, {'timestamp': 1754000876, 'value': 36.0, 'unit': 'tokens'}, {'timestamp': 1754000908, 'value': 34.0, 'unit': 'tokens'}, {'timestamp': 1754001309, 'value': 584.0, 'unit': 'tokens'}, {'timestamp': 1754001311, 'value': 138.0, 'unit': 'tokens'}, {'timestamp': 1754001316, 'value': 349.0, 'unit': 'tokens'}, {'timestamp': 1754001318, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001320, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001341, 'value': 923.0, 'unit': 'tokens'}, {'timestamp': 1754001350, 'value': 354.0, 'unit': 'tokens'}, {'timestamp': 1754001462, 'value': 417.0, 'unit': 'tokens'}, {'timestamp': 1754001464, 'value': 158.0, 'unit': 'tokens'}, {'timestamp': 1754001475, 'value': 697.0, 'unit': 'tokens'}, {'timestamp': 1754001477, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001479, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001489, 'value': 298.0, 'unit': 'tokens'}, {'timestamp': 1754001541, 'value': 615.0, 'unit': 'tokens'}, {'timestamp': 1754001543, 'value': 119.0, 'unit': 'tokens'}, {'timestamp': 1754001548, 'value': 310.0, 'unit': 'tokens'}, {'timestamp': 1754001549, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001551, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001568, 'value': 714.0, 'unit': 'tokens'}, {'timestamp': 1754001800, 'value': 437.0, 'unit': 'tokens'}, {'timestamp': 1754001802, 'value': 200.0, 'unit': 'tokens'}, {'timestamp': 1754001806, 'value': 262.0, 'unit': 'tokens'}, {'timestamp': 1754001808, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001810, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001816, 'value': 82.0, 'unit': 'tokens'}, {'timestamp': 1754001923, 'value': 61.0, 'unit': 'tokens'}, {'timestamp': 1754001929, 'value': 391.0, 'unit': 'tokens'}, {'timestamp': 1754001939, 'value': 598.0, 'unit': 'tokens'}, {'timestamp': 1754001941, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001942, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754001952, 'value': 252.0, 'unit': 'tokens'}, {'timestamp': 1754002053, 'value': 251.0, 'unit': 'tokens'}, {'timestamp': 1754002059, 'value': 375.0, 'unit': 'tokens'}, {'timestamp': 1754002062, 'value': 244.0, 'unit': 'tokens'}, {'timestamp': 1754002064, 'value': 111.0, 'unit': 'tokens'}, {'timestamp': 1754002065, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754002083, 'value': 719.0, 'unit': 'tokens'}, {'timestamp': 1754002302, 'value': 279.0, 'unit': 'tokens'}, {'timestamp': 1754002306, 'value': 218.0, 'unit': 'tokens'}, {'timestamp': 1754002308, 'value': 198.0, 'unit': 'tokens'}, {'timestamp': 1754002309, 'value': 69.0, 'unit': 'tokens'}, {'timestamp': 1754002311, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754002324, 'value': 481.0, 'unit': 'tokens'}, {'timestamp': 1754003161, 'value': 579.0, 'unit': 'tokens'}, {'timestamp': 1754003161, 'value': 69.0, 'unit': 'tokens'}, {'timestamp': 1754003169, 'value': 499.0, 'unit': 'tokens'}, {'timestamp': 1754003171, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754003173, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754003185, 'value': 422.0, 'unit': 'tokens'}, {'timestamp': 1754003448, 'value': 579.0, 'unit': 'tokens'}, {'timestamp': 1754003453, 'value': 422.0, 'unit': 'tokens'}, {'timestamp': 1754003589, 'value': 579.0, 'unit': 'tokens'}, {'timestamp': 1754003609, 'value': 279.0, 'unit': 'tokens'}, {'timestamp': 1754003614, 'value': 481.0, 'unit': 'tokens'}, {'timestamp': 1754003706, 'value': 303.0, 'unit': 'tokens'}, {'timestamp': 1754003706, 'value': 51.0, 'unit': 'tokens'}, {'timestamp': 1754003713, 'value': 426.0, 'unit': 'tokens'}, {'timestamp': 1754003714, 'value': 70.0, 'unit': 'tokens'}, {'timestamp': 1754003715, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754003724, 'value': 225.0, 'unit': 'tokens'}, {'timestamp': 1754004226, 'value': 516.0, 'unit': 'tokens'}, {'timestamp': 1754004228, 'value': 127.0, 'unit': 'tokens'}, {'timestamp': 1754004232, 'value': 281.0, 'unit': 'tokens'}, {'timestamp': 1754004234, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754004236, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754004244, 'value': 206.0, 'unit': 'tokens'}, {'timestamp': 1754004683, 'value': 338.0, 'unit': 'tokens'}, {'timestamp': 1754004690, 'value': 481.0, 'unit': 'tokens'}, {'timestamp': 1754004692, 'value': 124.0, 'unit': 'tokens'}, {'timestamp': 1754004692, 'value': 65.0, 'unit': 'tokens'}, {'timestamp': 1754004694, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754004703, 'value': 211.0, 'unit': 'tokens'}, {'timestamp': 1754004743, 'value': 338.0, 'unit': 'tokens'}, {'timestamp': 1754004749, 'value': 211.0, 'unit': 'tokens'}, {'timestamp': 1754005566, 'value': 481.0, 'unit': 'tokens'}, {'timestamp': 1754006101, 'value': 159.0, 'unit': 'tokens'}, {'timestamp': 1754006105, 'value': 272.0, 'unit': 'tokens'}, {'timestamp': 1754006109, 'value': 308.0, 'unit': 'tokens'}, {'timestamp': 1754006110, 'value': 61.0, 'unit': 'tokens'}, {'timestamp': 1754006112, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754006130, 'value': 705.0, 'unit': 'tokens'}, {'timestamp': 1754051825, 'value': 454.0, 'unit': 'tokens'}, {'timestamp': 1754051827, 'value': 152.0, 'unit': 'tokens'}, {'timestamp': 1754051834, 'value': 481.0, 'unit': 'tokens'}, {'timestamp': 1754051835, 'value': 55.0, 'unit': 'tokens'}, {'timestamp': 1754051837, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754051845, 'value': 102.0, 'unit': 'tokens'}, {'timestamp': 1754099929, 'value': 36.0, 'unit': 'tokens'}, {'timestamp': 1754510050, 'value': 598.0, 'unit': 'tokens'}, {'timestamp': 1754510052, 'value': 160.0, 'unit': 'tokens'}, {'timestamp': 1754510064, 'value': 725.0, 'unit': 'tokens'}, {'timestamp': 1754510065, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754510067, 'value': 133.0, 'unit': 'tokens'}, {'timestamp': 1754510083, 'value': 535.0, 'unit': 'tokens'}, {'timestamp': 1754596582, 'value': 36.0, 'unit': 'tokens'}])] ``` adding tests for each currently documented metric in llama stack using this new function. attached is also some manual testing integrations tests passing locally with replay mode and the linked client changes: <img width="1907" height="529" alt="Screenshot 2025-08-08 at 2 49 14 PM" src="https://github.com/user-attachments/assets/d482ab06-dcff-4f0c-a1f1-f870670ee9bc" /> --------- Signed-off-by: Charlie Doern <cdoern@redhat.com> |
||
|---|---|---|
| .. | ||
| 0b3f2e4754ff.json | ||
| 0b27fd737699.json | ||
| 00ba04f74a96.json | ||
| 0e8f2b001dd9.json | ||
| 0ff78129bb3a.json | ||
| 1adfaa0e062e.json | ||
| 1b92be674e2a.json | ||
| 1b8394f90636.json | ||
| 1b45391880c6.json | ||
| 1f48f4b2ae33.json | ||
| 2afe3b38ca01.json | ||
| 2d187a11704c.json | ||
| 3c0bf9ba81b2.json | ||
| 3c3f13cb7794.json | ||
| 3ca695048bee.json | ||
| 4a3a4447b16b.json | ||
| 4de6877d86fa.json | ||
| 5db0c44c83a4.json | ||
| 5f5d16afadb4.json | ||
| 6cb0285a7638.json | ||
| 6cc063bbd7d3.json | ||
| 6d35c91287e2.json | ||
| 6f96090aa955.json | ||
| 6fbea1abca7c.json | ||
| 6fe1d4fedf12.json | ||
| 7b4815aba6c5.json | ||
| 7bcb0f86c91b.json | ||
| 7e6806cba34a.json | ||
| 8bba71367e87.json | ||
| 9b812cbcb88d.json | ||
| 9c4bc9c3e7ac.json | ||
| 9c007f300365.json | ||
| 9c28ec9ac338.json | ||
| 9c140a29ae09.json | ||
| 9e7a83d3d596.json | ||
| 9fadf5a3d68f.json | ||
| 10eea8c15ddc.json | ||
| 011f70e24ce4.json | ||
| 35db283fef1d.json | ||
| 40f524d1934a.json | ||
| 43e106de6736.json | ||
| 44a1d9de0602.json | ||
| 44fb9cf5875f.json | ||
| 48d2fb183a2a.json | ||
| 56ac6a7c6df0.json | ||
| 61be36ad8ccd.json | ||
| 70adef2c30c4.json | ||
| 75d0dd9d0fa3.json | ||
| 76b89a84cd6f.json | ||
| 80e4404d8987.json | ||
| 80f09f27dd61.json | ||
| 81a91f79c51d.json | ||
| 83c2ffb72daa.json | ||
| 84cab42e1f5c.json | ||
| 90fec951fdb9.json | ||
| 97d3812bfccb.json | ||
| 97e259c0d3e5.json | ||
| 173ecb3aab28.json | ||
| 177ba8517262.json | ||
| 198ef7208389.json | ||
| 211b1562d4e6.json | ||
| 325a72db5755.json | ||
| 382c2f22274c.json | ||
| 390f0c7dac96.json | ||
| 477f8946bf7d.json | ||
| 545d86510a80.json | ||
| 554de3cd986f.json | ||
| 563b994bb7d1.json | ||
| 830a1fe14938.json | ||
| 836f51dfb3c5.json | ||
| 840fbb380b73.json | ||
| 3877ecf1bc62.json | ||
| 4014dd44c15f.json | ||
| 6906a6e71988.json | ||
| 7354ec181984.json | ||
| 12913f20f6ac.json | ||
| 17253d7cc667.json | ||
| 31407e035752.json | ||
| 50340cd4d253.json | ||
| 67198cbad48f.json | ||
| 85594a69d74a.json | ||
| 140187e305dc.json | ||
| 174458ad71b2.json | ||
| 178016edef0e.json | ||
| 197228e26971.json | ||
| 561746e1c8de.json | ||
| 731824c54461.json | ||
| 4096743baf8e.json | ||
| 04172112ffbb.json | ||
| 4597743bcd2a.json | ||
| 8295382a8e7c.json | ||
| a0c4df33879f.json | ||
| a4c8d19bb1eb.json | ||
| a59d0d7c1485.json | ||
| a410d4840402.json | ||
| a5187d9d5057.json | ||
| a6810c23eda8.json | ||
| a97477559b10.json | ||
| ae1c22f18ecc.json | ||
| ae6835cfe70e.json | ||
| afb33182f365.json | ||
| b4cda53cd04f.json | ||
| b14ff438ca99.json | ||
| b44cc7a7afc8.json | ||
| b91f1fb4aedb.json | ||
| b24590574a85.json | ||
| bbd0637dce16.json | ||
| bd356b27a085.json | ||
| bf79a89cc37f.json | ||
| c9cba6f3ee38.json | ||
| c31a86ea6c58.json | ||
| c7582fa7c2c4.json | ||
| c9667519ad7c.json | ||
| cb3df2a1dc22.json | ||
| cd094caaf1c0.json | ||
| d0ac68cbde69.json | ||
| d4c86ac355fb.json | ||
| d4f56d7d1996.json | ||
| da531c71e64f.json | ||
| dac7a32e5db9.json | ||
| dbc41d2417e1.json | ||
| dc8120cf0774.json | ||
| dd9e7d5913e9.json | ||
| dd226d71f844.json | ||
| decfd950646c.json | ||
| e2c9b07709fe.json | ||
| e9c8a0e4f0e0.json | ||
| e08848bfcd28.json | ||
| e29300494763.json | ||
| e96152610712.json | ||
| ed9e9b34008d.json | ||
| eee6a163b837.json | ||
| eee47930e3ae.json | ||
| ef59cbff54d0.json | ||
| ef757a75ed08.json | ||
| f1ea938b0b0d.json | ||
| f3c3afbd9b7e.json | ||
| f70f30f54211.json | ||
| f80b99430f7e.json | ||
| f477c2fe1332.json | ||
| f6857bcea729.json | ||
| fcdef245da95.json | ||
| fe140befeba4.json | ||