Add Litestar metrics with OpenTelemetry and Prometheus instrumentation, plugin or middleware wiring, exporter configuration, path grouping, labels, exemplars, and endpoint exclusion strategy. Use when implementing service-level monitoring, scrape endpoints, request metrics, or custom observability dimensions in Litestar. Do not use for log formatting, tracing-only concerns, or exception contract design.
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Add Litestar metrics with OpenTelemetry and Prometheus instrumentation, plugin or middleware wiring, exporter configuration, path grouping, labels, exemplars, and endpoint exclusion strategy. Use when implementing service-level monitoring, scrape endpoints, request metrics, or custom observability dimensions in Litestar. Do not use for log formatting, tracing-only concerns, or exception contract design.
Metrics
Execution Workflow
Choose the metrics backend first: OpenTelemetry for OTel ecosystem integration or Prometheus for scrape-based metrics exposure.
Register instrumentation at app scope with the appropriate plugin or middleware.
Decide which routes, methods, and paths should be excluded from metrics.
Keep labels low-cardinality and group dynamic paths when needed.
Add custom dimensions or exemplars only when they materially improve observability.
Validate exporter or scrape behavior before depending on dashboards and alerts.
Core Rules
Keep instrumentation centralized at app construction.
Prefer backend defaults until concrete monitoring needs justify customization.
Avoid high-cardinality labels such as user IDs, request IDs, or raw path values.
Exclude noisy or irrelevant paths and methods intentionally.
Group dynamic paths to avoid cardinality explosion.
Treat metrics naming, units, and label sets as stable contracts.
Keep metrics concerns separate from logs, traces, and exception-response formatting.
Decision Guide
Use OpenTelemetry when the service already participates in an OTel pipeline or shared collector/exporter setup.
Use Prometheus when the service should expose a scrape endpoint directly.
Use Prometheus group_path=True when route path cardinality could explode.
Use Prometheus labels or OTel resource dimensions only when the values are stable and bounded.
Use exemplars only when the exposition format and monitoring stack actually support them.
Use litestar-logging and tracing separately when the task is not primarily metrics.