"""Prometheus指标定义"""
from prometheus_client import Counter, Histogram, Gauge, Info

# API层指标
API_REQUESTS_TOTAL = Counter(
    "geo_api_requests_total",
    "Total API requests",
    ["method", "endpoint", "status"]
)

API_REQUEST_DURATION_SECONDS = Histogram(
    "geo_api_request_duration_seconds",
    "API request duration in seconds",
    ["method", "endpoint"],
    buckets=(0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0)
)

API_REQUESTS_IN_PROGRESS = Gauge(
    "geo_api_requests_in_progress",
    "Number of requests currently being processed",
    ["method", "endpoint"]
)

# Agent层指标
AGENT_EXECUTIONS_TOTAL = Counter(
    "geo_agent_executions_total",
    "Total agent executions",
    ["agent_name", "status"]
)

AGENT_EXECUTION_DURATION_SECONDS = Histogram(
    "geo_agent_execution_duration_seconds",
    "Agent execution duration in seconds",
    ["agent_name"],
    buckets=(0.1, 0.5, 1.0, 5.0, 10.0, 30.0, 60.0, 120.0)
)

AGENT_RUNNING_TASKS = Gauge(
    "geo_agent_running_tasks",
    "Number of tasks currently running",
    ["agent_name"]
)

# LLM层指标
LLM_REQUESTS_TOTAL = Counter(
    "geo_llm_requests_total",
    "Total LLM requests",
    ["provider", "model", "status"]
)

LLM_REQUEST_DURATION_SECONDS = Histogram(
    "geo_llm_request_duration_seconds",
    "LLM request duration in seconds",
    ["provider", "model"],
    buckets=(0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 30.0, 60.0)
)

LLM_TOKENS_TOTAL = Counter(
    "geo_llm_tokens_total",
    "Total LLM tokens used",
    ["provider", "model", "token_type"]
)

LLM_COST_ESTIMATED = Gauge(
    "geo_llm_cost_estimated",
    "Estimated LLM cost in USD",
    ["provider", "model"]
)

# 业务层指标
BRAND_COUNT = Gauge(
    "geo_brands_total",
    "Total number of brands"
)

QUERY_COUNT_TOTAL = Counter(
    "geo_queries_total",
    "Total number of queries executed",
    ["platform", "status"]
)

CONTENT_GENERATED_TOTAL = Counter(
    "geo_content_generated_total",
    "Total content generated"
)

CITATION_DETECTED_TOTAL = Counter(
    "geo_citations_detected_total",
    "Total citations detected",
    ["platform"]
)

# 系统信息
SERVICE_INFO = Info(
    "geo_service",
    "GEO service information"
)
