{
  "repo": "tidbcloud/billing",
  "binary": "stress",
  "binary_path": "cmd/stress/main.go",
  "surface_kind": "mixed_service",
  "type": "mixed_service",
  "extensions": {
    "notes": [
      "cmd/stress is a real deployable service binary, not a throwaway test helper: it owns its own Gin listener, metrics, pprof, audit-log setup, and SQS measure sender wiring on a fixed port 16688.",
      "The old KB route `/stress/billing/customers/:customer/units` was wrong. The actual runtime route registered by InitializeMeasureRouter2Stress is `POST /stress/billing/tenants/:tenant_id/measures`.",
      "Unlike cmd/server and cmd/worker, the stress binary deliberately leaves eventbus startup, payment-handler wiring, and marketplace-handler wiring commented out, so those side effects must stay out of the runtime surface."
    ]
  },
  "services": [
    {
      "name": "BillingStressLifecycle",
      "package": "cmd/stress",
      "methods": [
        {
          "name": "LoadConfig",
          "name_key": "BillingStressLifecycle.LoadConfig",
          "input": "process env + config files",
          "output": "global billing config initialized",
          "type": "local"
        },
        {
          "name": "EnableStressMode",
          "name_key": "BillingStressLifecycle.EnableStressMode",
          "input": "BillingStressTest=true",
          "output": "stress-specific config flag set in viper",
          "type": "local"
        },
        {
          "name": "InitializeStressDatabase",
          "name_key": "BillingStressLifecycle.InitializeStressDatabase",
          "input": "stress DB config or fallback default DB config",
          "output": "global primary and read-only GORM handles for stress mode",
          "type": "local"
        },
        {
          "name": "InitializeCache",
          "name_key": "BillingStressLifecycle.InitializeCache",
          "input": "EnableCache + RedisHost + RedisDB",
          "output": "shared cache handler initialized",
          "type": "local"
        },
        {
          "name": "InitializeRateLimiter",
          "name_key": "BillingStressLifecycle.InitializeRateLimiter",
          "input": "ratelimit config",
          "output": "shared rate limiter initialized",
          "type": "local"
        },
        {
          "name": "InitializeWebIdentity",
          "name_key": "BillingStressLifecycle.InitializeWebIdentity",
          "input": "AWS_WEB_IDENTITY_TOKEN_FILE + GCP workload identity env",
          "output": "GCP workload-identity auth preconditions validated",
          "type": "local"
        },
        {
          "name": "InitializeLoggerAndSentry",
          "name_key": "BillingStressLifecycle.InitializeLoggerAndSentry",
          "input": "EnableSentryLog + sentry DSN + log level",
          "output": "logger replaced and sentry hooked when enabled",
          "type": "local"
        },
        {
          "name": "BuildHTTPServer",
          "name_key": "BillingStressLifecycle.BuildHTTPServer",
          "input": "gin.Default()",
          "output": "stress gin engine ready for metrics and business routes",
          "type": "local"
        },
        {
          "name": "RegisterMetrics",
          "name_key": "BillingStressLifecycle.RegisterMetrics",
          "input": "stress gin engine",
          "output": "/metrics route plus Prometheus request instrumentation",
          "type": "local"
        },
        {
          "name": "RegisterStressRoutes",
          "name_key": "BillingStressLifecycle.RegisterStressRoutes",
          "input": "stress group /stress/billing",
          "output": "GET /stress/billing/test and POST /stress/billing/tenants/:tenant_id/measures mounted",
          "type": "local"
        },
        {
          "name": "RegisterPprof",
          "name_key": "BillingStressLifecycle.RegisterPprof",
          "input": "stress gin engine",
          "output": "pprof endpoints mounted on the stress listener",
          "type": "local"
        },
        {
          "name": "InitializeAuditLog",
          "name_key": "BillingStressLifecycle.InitializeAuditLog",
          "input": "background context + 1s timeout",
          "output": "audit log SDK initialized",
          "type": "local"
        },
        {
          "name": "InitializeMeasureSender",
          "name_key": "BillingStressLifecycle.InitializeMeasureSender",
          "input": "ENV + measure SQS config",
          "output": "default SQS measure sender initialized",
          "type": "local"
        },
        {
          "name": "StartHTTPServer",
          "name_key": "BillingStressLifecycle.StartHTTPServer",
          "input": "hard-coded port 16688",
          "output": "stress HTTP server serving metrics, pprof, and stress routes",
          "type": "background_worker"
        }
      ]
    },
    {
      "name": "BillingStressHTTP",
      "package": "api",
      "type": "http",
      "methods": [
        {
          "name": "GET /metrics",
          "name_key": "HTTP GET /metrics",
          "path": "/metrics",
          "http_method": "GET",
          "input": "Prometheus scrape request",
          "output": "billing2 Prometheus metrics",
          "type": "http"
        },
        {
          "name": "GET /stress/billing/test",
          "name_key": "HTTP GET /stress/billing/test",
          "path": "/stress/billing/test",
          "http_method": "GET",
          "input": "none",
          "output": "test success",
          "type": "http"
        },
        {
          "name": "POST /stress/billing/tenants/:tenant_id/measures",
          "name_key": "HTTP POST /stress/billing/tenants/:tenant_id/measures",
          "path": "/stress/billing/tenants/:tenant_id/measures",
          "http_method": "POST",
          "input": "forms.UnitCosts JSON body",
          "output": "queued or directly-costed UnitCosts result depending on HTTPMeasuresToQueue",
          "type": "http"
        }
      ]
    },
    {
      "name": "BillingStressPprofHTTP",
      "package": "pprof",
      "type": "http",
      "methods": [
        {
          "name": "GET /debug/pprof/*",
          "name_key": "HTTP GET /debug/pprof/*",
          "path": "/debug/pprof/*",
          "http_method": "GET",
          "input": "pprof profile path",
          "output": "Go pprof profile or index response",
          "type": "http"
        },
        {
          "name": "POST /debug/pprof/symbol",
          "name_key": "HTTP POST /debug/pprof/symbol",
          "path": "/debug/pprof/symbol",
          "http_method": "POST",
          "input": "pprof symbol body",
          "output": "resolved pprof symbols",
          "type": "http"
        }
      ]
    }
  ]
}
