MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _trace_payload

Function _trace_payload

uncommon_route/traces.py:578–674  ·  view source on GitHub ↗
(trace: RequestTrace)

Source from the content-addressed store, hash-verified

576
577
578def _trace_payload(trace: RequestTrace) -> dict[str, Any]:
579 return {
580 "timestamp": trace.timestamp,
581 "request_id": trace.request_id,
582 "requested_model": trace.requested_model,
583 "model": trace.model,
584 "status_code": trace.status_code,
585 "mode": trace.mode,
586 "tier": _normalize_tier_label(trace.tier),
587 "decision_tier": _normalize_tier_label(trace.decision_tier) if trace.decision_tier else "",
588 "served_quality": _normalize_served_quality(trace.served_quality),
589 "served_quality_target": _normalize_served_quality(trace.served_quality_target),
590 "served_quality_floor": _normalize_served_quality(trace.served_quality_floor),
591 "capability_lane": str(trace.capability_lane or "").strip().lower(),
592 "method": trace.method,
593 "api_format": trace.api_format,
594 "endpoint": trace.endpoint,
595 "is_virtual": trace.is_virtual,
596 "session_id": trace.session_id,
597 "streaming": trace.streaming,
598 "prompt_preview": trace.prompt_preview,
599 "prompt_hash": trace.prompt_hash,
600 "step_type": trace.step_type,
601 "route_reasoning": trace.route_reasoning,
602 "confidence": trace.confidence,
603 "raw_confidence": trace.raw_confidence,
604 "confidence_source": trace.confidence_source,
605 "calibration_version": trace.calibration_version,
606 "calibration_sample_count": trace.calibration_sample_count,
607 "calibration_temperature": trace.calibration_temperature,
608 "calibration_applied_tags": list(trace.calibration_applied_tags or []),
609 "complexity": trace.complexity,
610 "estimated_cost": trace.estimated_cost,
611 "baseline_cost": trace.baseline_cost,
612 "actual_cost": trace.actual_cost,
613 "savings": trace.savings,
614 "latency_us": trace.latency_us,
615 "usage_input_tokens": trace.usage_input_tokens,
616 "usage_output_tokens": trace.usage_output_tokens,
617 "cache_read_input_tokens": trace.cache_read_input_tokens,
618 "cache_write_input_tokens": trace.cache_write_input_tokens,
619 "cache_hit_ratio": trace.cache_hit_ratio,
620 "transport": trace.transport,
621 "requested_transport": trace.requested_transport,
622 "transport_reason": trace.transport_reason,
623 "transport_preference_source": trace.transport_preference_source,
624 "cache_mode": trace.cache_mode,
625 "cache_family": trace.cache_family,
626 "cache_breakpoints": trace.cache_breakpoints,
627 "input_tokens_before": trace.input_tokens_before,
628 "input_tokens_after": trace.input_tokens_after,
629 "artifacts_created": trace.artifacts_created,
630 "compacted_messages": trace.compacted_messages,
631 "semantic_summaries": trace.semantic_summaries,
632 "semantic_calls": trace.semantic_calls,
633 "semantic_failures": trace.semantic_failures,
634 "semantic_quality_fallbacks": trace.semantic_quality_fallbacks,
635 "checkpoint_created": trace.checkpoint_created,

Callers 4

recordMethod · 0.85
export_recordsMethod · 0.85
recentMethod · 0.85
findMethod · 0.85

Calls 2

_normalize_tier_labelFunction · 0.70

Tested by

no test coverage detected