feat: record call observability columns and terminal failure rows
Grow the telemetry contract from 26 to 36 fields and give every logical call a failure terminal row, so SQL can finally answer "how many calls failed" and "why did the whole pool die". Schema and port move together with the emitter writes in one commit: splitting them would ship columns that nothing populates. - schema: append 10 nullable columns (scope, operation, logical_call_id, event_kind, http_status_code, error_type, cause_type, error_body, attempts, total_latency_ms) to all five definition sites in one order - ports: 10 keyword-only parameters without defaults; the protocol signature is now the single source the assembly gate derives from - emitter: take domain exception objects instead of pre-flattened text and pin down the diagnostics in one helper; a relabelled 503 stays 503 and success rows leave all five columns NULL - emitter: reject recorders whose record_llm_call cannot accept the current field shape at assembly time, since _record would otherwise swallow the TypeError and drop every row while calls keep succeeding - clients: write at most one terminal row per logical call through a single shared exit, deduplicated by the call context; TelemetryMW stops writing terminals so the two sites cannot double count - clients: cancellation stays best effort and propagates, non-domain exceptions get no terminal row and keep their classification - transports: give _status_to_error an explicit operation and fix the historically mislabelled embedding HTTP failures - structured: promote the bounded error formatter so the reask feedback and the terminal explanation share one set of limits Terminal rows carry no cost and no tokens, so cost aggregation is unchanged; failure counts must now filter on event_kind.
This commit is contained in:
@@ -124,6 +124,18 @@ class _DummyRecorder:
|
||||
reasoning_tokens,
|
||||
tenant_id,
|
||||
meta,
|
||||
thinking_observation,
|
||||
reasoning_effort,
|
||||
scope,
|
||||
operation,
|
||||
logical_call_id,
|
||||
event_kind,
|
||||
http_status_code,
|
||||
error_type,
|
||||
cause_type,
|
||||
error_body,
|
||||
attempts,
|
||||
total_latency_ms,
|
||||
) -> None: ...
|
||||
|
||||
|
||||
@@ -275,8 +287,47 @@ class TestTelemetryRecorderSignature:
|
||||
params = inspect.signature(TelemetryRecorder.record_llm_call).parameters
|
||||
assert {"tenant_id", "meta"} <= set(params)
|
||||
|
||||
def test_call_observability_fields_are_declared(self):
|
||||
"""1.3.5 十列进协议(issue #19/#23);字段总数以实测为准不凭记忆。
|
||||
|
||||
本签名同时是装配闸的事实源(`_assert_recorder_shape` 按它派生参数名),
|
||||
故它与实现一旦漂移,下游自定义 recorder 会在装配期就被拒。
|
||||
"""
|
||||
import inspect
|
||||
|
||||
params = inspect.signature(TelemetryRecorder.record_llm_call).parameters
|
||||
assert {
|
||||
"scope",
|
||||
"operation",
|
||||
"logical_call_id",
|
||||
"event_kind",
|
||||
"http_status_code",
|
||||
"error_type",
|
||||
"cause_type",
|
||||
"error_body",
|
||||
"attempts",
|
||||
"total_latency_ms",
|
||||
} <= set(params)
|
||||
assert len(params) - 1 == 36 # 减掉 self
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name", ["tenant_id", "meta", "thinking_observation", "reasoning_effort"]
|
||||
"name",
|
||||
[
|
||||
"tenant_id",
|
||||
"meta",
|
||||
"thinking_observation",
|
||||
"reasoning_effort",
|
||||
"scope",
|
||||
"operation",
|
||||
"logical_call_id",
|
||||
"event_kind",
|
||||
"http_status_code",
|
||||
"error_type",
|
||||
"cause_type",
|
||||
"error_body",
|
||||
"attempts",
|
||||
"total_latency_ms",
|
||||
],
|
||||
)
|
||||
def test_caller_dimensions_have_no_default(self, name):
|
||||
import inspect
|
||||
|
||||
Reference in New Issue
Block a user