{
  "repo": "tidbcloud/escalation-base",
  "binary": "prometheus-aggregation",
  "binary_path": "prometheus_aggregation/main.go",
  "surface_kind": "worker_service",
  "type": "worker_service",
  "extensions": {
    "notes": [
      "Fresh codex rescan restored prometheus_aggregation as a long-running worker binary. It continuously discovers clinic clusters, queries per-cluster metrics, and remote-writes time series to a Prometheus endpoint.",
      "This binary has no inbound API; the runtime surface is its loop, persistence files, and external HTTP dependencies."
    ]
  },
  "services": [
    {
      "name": "PromAggregationLifecycle",
      "package": "prometheus_aggregation/main.go",
      "methods": [
        {
          "name": "LoadConfig",
          "name_key": "PromAggregationLifecycle.LoadConfig",
          "input": "./config/conf.yaml",
          "output": "Viper config loaded",
          "type": "local"
        },
        {
          "name": "InitLog",
          "name_key": "PromAggregationLifecycle.InitLog",
          "input": "log file name",
          "output": "file-backed logger initialized",
          "type": "local"
        },
        {
          "name": "StartLoop",
          "name_key": "PromAggregationLifecycle.StartLoop",
          "input": "none",
          "output": "infinite metrics aggregation loop running",
          "type": "local"
        }
      ]
    },
    {
      "name": "PromAggregationPipeline",
      "package": "prometheus_aggregation/main.go",
      "methods": [
        {
          "name": "GetToken",
          "name_key": "PromAggregationPipeline.GetToken",
          "input": "hard-coded Auth0 client credentials",
          "output": "Auth0 bearer token",
          "type": "local"
        },
        {
          "name": "DiscoverClusters",
          "name_key": "PromAggregationPipeline.DiscoverClusters",
          "input": "Auth0 token and persisted cluster cache",
          "output": "target clinic clusters with Prometheus URLs",
          "type": "local"
        },
        {
          "name": "FetchAndWriteMetrics",
          "name_key": "PromAggregationPipeline.FetchAndWriteMetrics",
          "input": "metrics list, time window, discovered clusters",
          "output": "remote-write requests sent to Prometheus",
          "type": "local"
        },
        {
          "name": "PersistProgress",
          "name_key": "PromAggregationPipeline.PersistProgress",
          "input": "cluster cache and next start timestamp",
          "output": "persisted JSON state files updated",
          "type": "local"
        }
      ]
    }
  ]
}
