forked from phoenix-oss/llama-stack-mirror
fix: some telemetry APIs don't currently work (#1188)
Summary: This bug is surfaced by using the http LS client. The issue is that non-scalar values in 'GET' method are `body` params in fastAPI, but our spec generation script doesn't respect that. We fix by just making them POST method instead. Test Plan: Test API call with newly sync'd client (https://github.com/meta-llama/llama-stack-client-python/pull/149) <img width="1114" alt="image" src="https://github.com/user-attachments/assets/7710aca5-d163-4e00-a465-14e6fcaac2b2" />
This commit is contained in:
parent
ea1faae50e
commit
1166afdf76
5 changed files with 179 additions and 158 deletions
170
docs/_static/llama-stack-spec.html
vendored
170
docs/_static/llama-stack-spec.html
vendored
|
@ -1073,7 +1073,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/v1/telemetry/spans/{span_id}/tree": {
|
"/v1/telemetry/spans/{span_id}/tree": {
|
||||||
"get": {
|
"post": {
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
|
@ -1098,28 +1098,19 @@
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
],
|
||||||
"name": "attributes_to_return",
|
"requestBody": {
|
||||||
"in": "query",
|
"content": {
|
||||||
"required": false,
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "array",
|
"$ref": "#/components/schemas/GetSpanTreeRequest"
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": true
|
||||||
"name": "max_depth",
|
|
||||||
"in": "query",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"type": "integer"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"/v1/tools/{tool_name}": {
|
"/v1/tools/{tool_name}": {
|
||||||
"get": {
|
"get": {
|
||||||
|
@ -2263,7 +2254,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/v1/telemetry/spans": {
|
"/v1/telemetry/spans": {
|
||||||
"get": {
|
"post": {
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
|
@ -2280,42 +2271,21 @@
|
||||||
"Telemetry"
|
"Telemetry"
|
||||||
],
|
],
|
||||||
"description": "",
|
"description": "",
|
||||||
"parameters": [
|
"parameters": [],
|
||||||
{
|
"requestBody": {
|
||||||
"name": "attribute_filters",
|
"content": {
|
||||||
"in": "query",
|
"application/json": {
|
||||||
"required": true,
|
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "array",
|
"$ref": "#/components/schemas/QuerySpansRequest"
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/QueryCondition"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": true
|
||||||
"name": "attributes_to_return",
|
|
||||||
"in": "query",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "max_depth",
|
|
||||||
"in": "query",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"type": "integer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/v1/telemetry/traces": {
|
"/v1/telemetry/traces": {
|
||||||
"get": {
|
"post": {
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
|
@ -2332,46 +2302,17 @@
|
||||||
"Telemetry"
|
"Telemetry"
|
||||||
],
|
],
|
||||||
"description": "",
|
"description": "",
|
||||||
"parameters": [
|
"parameters": [],
|
||||||
{
|
"requestBody": {
|
||||||
"name": "attribute_filters",
|
"content": {
|
||||||
"in": "query",
|
"application/json": {
|
||||||
"required": false,
|
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "array",
|
"$ref": "#/components/schemas/QueryTracesRequest"
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/QueryCondition"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": true
|
||||||
"name": "limit",
|
|
||||||
"in": "query",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"type": "integer"
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "offset",
|
|
||||||
"in": "query",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"type": "integer"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "order_by",
|
|
||||||
"in": "query",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/v1/eval/benchmarks/{benchmark_id}/jobs": {
|
"/v1/eval/benchmarks/{benchmark_id}/jobs": {
|
||||||
|
@ -6056,6 +5997,22 @@
|
||||||
],
|
],
|
||||||
"title": "Span"
|
"title": "Span"
|
||||||
},
|
},
|
||||||
|
"GetSpanTreeRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"attributes_to_return": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"max_depth": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"title": "GetSpanTreeRequest"
|
||||||
|
},
|
||||||
"SpanStatus": {
|
"SpanStatus": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
@ -7673,6 +7630,32 @@
|
||||||
],
|
],
|
||||||
"title": "QueryConditionOp"
|
"title": "QueryConditionOp"
|
||||||
},
|
},
|
||||||
|
"QuerySpansRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"attribute_filters": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/QueryCondition"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"attributes_to_return": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"max_depth": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"attribute_filters",
|
||||||
|
"attributes_to_return"
|
||||||
|
],
|
||||||
|
"title": "QuerySpansRequest"
|
||||||
|
},
|
||||||
"QuerySpansResponse": {
|
"QuerySpansResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -7689,6 +7672,31 @@
|
||||||
],
|
],
|
||||||
"title": "QuerySpansResponse"
|
"title": "QuerySpansResponse"
|
||||||
},
|
},
|
||||||
|
"QueryTracesRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"attribute_filters": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/QueryCondition"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"limit": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"offset": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"order_by": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"title": "QueryTracesRequest"
|
||||||
|
},
|
||||||
"QueryTracesResponse": {
|
"QueryTracesResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
123
docs/_static/llama-stack-spec.yaml
vendored
123
docs/_static/llama-stack-spec.yaml
vendored
|
@ -647,7 +647,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
/v1/telemetry/spans/{span_id}/tree:
|
/v1/telemetry/spans/{span_id}/tree:
|
||||||
get:
|
post:
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: OK
|
description: OK
|
||||||
|
@ -664,18 +664,12 @@ paths:
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
- name: attributes_to_return
|
requestBody:
|
||||||
in: query
|
content:
|
||||||
required: false
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
$ref: '#/components/schemas/GetSpanTreeRequest'
|
||||||
items:
|
required: true
|
||||||
type: string
|
|
||||||
- name: max_depth
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
/v1/tools/{tool_name}:
|
/v1/tools/{tool_name}:
|
||||||
get:
|
get:
|
||||||
responses:
|
responses:
|
||||||
|
@ -1370,7 +1364,7 @@ paths:
|
||||||
$ref: '#/components/schemas/QueryChunksRequest'
|
$ref: '#/components/schemas/QueryChunksRequest'
|
||||||
required: true
|
required: true
|
||||||
/v1/telemetry/spans:
|
/v1/telemetry/spans:
|
||||||
get:
|
post:
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: OK
|
description: OK
|
||||||
|
@ -1381,28 +1375,15 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Telemetry
|
- Telemetry
|
||||||
description: ''
|
description: ''
|
||||||
parameters:
|
parameters: []
|
||||||
- name: attribute_filters
|
requestBody:
|
||||||
in: query
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/QuerySpansRequest'
|
||||||
required: true
|
required: true
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/QueryCondition'
|
|
||||||
- name: attributes_to_return
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
- name: max_depth
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
/v1/telemetry/traces:
|
/v1/telemetry/traces:
|
||||||
get:
|
post:
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: OK
|
description: OK
|
||||||
|
@ -1413,31 +1394,13 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Telemetry
|
- Telemetry
|
||||||
description: ''
|
description: ''
|
||||||
parameters:
|
parameters: []
|
||||||
- name: attribute_filters
|
requestBody:
|
||||||
in: query
|
content:
|
||||||
required: false
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
$ref: '#/components/schemas/QueryTracesRequest'
|
||||||
items:
|
required: true
|
||||||
$ref: '#/components/schemas/QueryCondition'
|
|
||||||
- name: limit
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
- name: offset
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
- name: order_by
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
/v1/eval/benchmarks/{benchmark_id}/jobs:
|
/v1/eval/benchmarks/{benchmark_id}/jobs:
|
||||||
post:
|
post:
|
||||||
responses:
|
responses:
|
||||||
|
@ -3933,6 +3896,17 @@ components:
|
||||||
- name
|
- name
|
||||||
- start_time
|
- start_time
|
||||||
title: Span
|
title: Span
|
||||||
|
GetSpanTreeRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
attributes_to_return:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
max_depth:
|
||||||
|
type: integer
|
||||||
|
additionalProperties: false
|
||||||
|
title: GetSpanTreeRequest
|
||||||
SpanStatus:
|
SpanStatus:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
|
@ -4975,6 +4949,24 @@ components:
|
||||||
- gt
|
- gt
|
||||||
- lt
|
- lt
|
||||||
title: QueryConditionOp
|
title: QueryConditionOp
|
||||||
|
QuerySpansRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
attribute_filters:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/QueryCondition'
|
||||||
|
attributes_to_return:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
max_depth:
|
||||||
|
type: integer
|
||||||
|
additionalProperties: false
|
||||||
|
required:
|
||||||
|
- attribute_filters
|
||||||
|
- attributes_to_return
|
||||||
|
title: QuerySpansRequest
|
||||||
QuerySpansResponse:
|
QuerySpansResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -4986,6 +4978,23 @@ components:
|
||||||
required:
|
required:
|
||||||
- data
|
- data
|
||||||
title: QuerySpansResponse
|
title: QuerySpansResponse
|
||||||
|
QueryTracesRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
attribute_filters:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/QueryCondition'
|
||||||
|
limit:
|
||||||
|
type: integer
|
||||||
|
offset:
|
||||||
|
type: integer
|
||||||
|
order_by:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
additionalProperties: false
|
||||||
|
title: QueryTracesRequest
|
||||||
QueryTracesResponse:
|
QueryTracesResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|
|
@ -150,7 +150,14 @@ def _get_endpoint_functions(
|
||||||
|
|
||||||
print(f"Processing {colored(func_name, 'white')}...")
|
print(f"Processing {colored(func_name, 'white')}...")
|
||||||
operation_name = func_name
|
operation_name = func_name
|
||||||
if operation_name.startswith("get_") or operation_name.endswith("/get"):
|
|
||||||
|
if webmethod.method == "GET":
|
||||||
|
prefix = "get"
|
||||||
|
elif webmethod.method == "DELETE":
|
||||||
|
prefix = "delete"
|
||||||
|
elif webmethod.method == "POST":
|
||||||
|
prefix = "post"
|
||||||
|
elif operation_name.startswith("get_") or operation_name.endswith("/get"):
|
||||||
prefix = "get"
|
prefix = "get"
|
||||||
elif (
|
elif (
|
||||||
operation_name.startswith("delete_")
|
operation_name.startswith("delete_")
|
||||||
|
@ -159,11 +166,6 @@ def _get_endpoint_functions(
|
||||||
or operation_name.endswith("/remove")
|
or operation_name.endswith("/remove")
|
||||||
):
|
):
|
||||||
prefix = "delete"
|
prefix = "delete"
|
||||||
else:
|
|
||||||
if webmethod.method == "GET":
|
|
||||||
prefix = "get"
|
|
||||||
elif webmethod.method == "DELETE":
|
|
||||||
prefix = "delete"
|
|
||||||
else:
|
else:
|
||||||
# by default everything else is a POST
|
# by default everything else is a POST
|
||||||
prefix = "post"
|
prefix = "post"
|
||||||
|
|
|
@ -216,7 +216,7 @@ class Telemetry(Protocol):
|
||||||
@webmethod(route="/telemetry/events", method="POST")
|
@webmethod(route="/telemetry/events", method="POST")
|
||||||
async def log_event(self, event: Event, ttl_seconds: int = DEFAULT_TTL_DAYS * 86400) -> None: ...
|
async def log_event(self, event: Event, ttl_seconds: int = DEFAULT_TTL_DAYS * 86400) -> None: ...
|
||||||
|
|
||||||
@webmethod(route="/telemetry/traces", method="GET")
|
@webmethod(route="/telemetry/traces", method="POST")
|
||||||
async def query_traces(
|
async def query_traces(
|
||||||
self,
|
self,
|
||||||
attribute_filters: Optional[List[QueryCondition]] = None,
|
attribute_filters: Optional[List[QueryCondition]] = None,
|
||||||
|
@ -231,7 +231,7 @@ class Telemetry(Protocol):
|
||||||
@webmethod(route="/telemetry/traces/{trace_id:path}/spans/{span_id:path}", method="GET")
|
@webmethod(route="/telemetry/traces/{trace_id:path}/spans/{span_id:path}", method="GET")
|
||||||
async def get_span(self, trace_id: str, span_id: str) -> Span: ...
|
async def get_span(self, trace_id: str, span_id: str) -> Span: ...
|
||||||
|
|
||||||
@webmethod(route="/telemetry/spans/{span_id:path}/tree", method="GET")
|
@webmethod(route="/telemetry/spans/{span_id:path}/tree", method="POST")
|
||||||
async def get_span_tree(
|
async def get_span_tree(
|
||||||
self,
|
self,
|
||||||
span_id: str,
|
span_id: str,
|
||||||
|
@ -239,7 +239,7 @@ class Telemetry(Protocol):
|
||||||
max_depth: Optional[int] = None,
|
max_depth: Optional[int] = None,
|
||||||
) -> QuerySpanTreeResponse: ...
|
) -> QuerySpanTreeResponse: ...
|
||||||
|
|
||||||
@webmethod(route="/telemetry/spans", method="GET")
|
@webmethod(route="/telemetry/spans", method="POST")
|
||||||
async def query_spans(
|
async def query_spans(
|
||||||
self,
|
self,
|
||||||
attribute_filters: List[QueryCondition],
|
attribute_filters: List[QueryCondition],
|
||||||
|
|
|
@ -481,6 +481,8 @@ def main():
|
||||||
def extract_path_params(route: str) -> List[str]:
|
def extract_path_params(route: str) -> List[str]:
|
||||||
segments = route.split("/")
|
segments = route.split("/")
|
||||||
params = [seg[1:-1] for seg in segments if seg.startswith("{") and seg.endswith("}")]
|
params = [seg[1:-1] for seg in segments if seg.startswith("{") and seg.endswith("}")]
|
||||||
|
# to handle path params like {param:path}
|
||||||
|
params = [param.split(":")[0] for param in params]
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue