Cursor rule
.cursor/rules/otel-metrics.mdcGuidelines for creating OpenTelemetry metrics to avoid cardinality issues
Cursor rules
Quality
61/100
Scores the file, not the repository.Length
305 words
8 headings · 1 code blocksRepository
16k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1234567# OpenTelemetry Metrics Guidelines89When creating or editing OTEL metrics (counters, histograms, gauges), always ensure metric attributes have **low cardinality**.1011## What is Cardinality?1213Cardinality refers to the number of unique values an attribute can have. Each unique combination of attribute values creates a new time series, which consumes memory and storage in your metrics backend.1415## Rules1617### DO use low-cardinality attributes:18- **Enums**: `environment_type` (PRODUCTION, STAGING, DEVELOPMENT, PREVIEW)19- **Booleans**: `hasFailures`, `streaming`, `success`20- **Bounded error codes**: A finite, controlled set of error types21- **Shard IDs**: When sharding is bounded (e.g., 0-15)2223### DO NOT use high-cardinality attributes:24- **UUIDs/IDs**: `envId`, `userId`, `runId`, `projectId`, `organizationId`25- **Unbounded integers**: `itemCount`, `batchSize`, `retryCount`26- **Timestamps**: `createdAt`, `startTime`27- **Free-form strings**: `errorMessage`, `taskName`, `queueName`2829## Example3031```typescript32// BAD - High cardinality33this.counter.add(1, {34 envId: options.environmentId, // UUID - unbounded35 itemCount: options.runCount, // Integer - unbounded36});3738// GOOD - Low cardinality39this.counter.add(1, {40 environment_type: options.environmentType, // Enum - 4 values41 streaming: true, // Boolean - 2 values42});43```4445## Prometheus Metric Naming4647When metrics are exported via OTLP to Prometheus, the exporter automatically adds unit suffixes to metric names:4849| OTel Metric Name | Unit | Prometheus Name |50|------------------|------|-----------------|51| `my_duration_ms` | `ms` | `my_duration_ms_milliseconds` |52| `my_counter` | counter | `my_counter_total` |53| `items_inserted` | counter | `items_inserted_inserts_total` |54| `batch_size` | histogram | `batch_size_items_bucket` |5556Keep this in mind when writing Grafana dashboards or Prometheus queries—the metric names in Prometheus will differ from the names defined in code.5758## Reference5960See the schedule engine (`internal-packages/schedule-engine/src/engine/index.ts`) for a good example of low-cardinality metric attributes.6162High cardinality metrics can cause:63- Memory bloat in metrics backends (Axiom, Prometheus, etc.)64- Slow queries and dashboard timeouts65- Increased costs (many backends charge per time series)66- Potential data loss or crashes at scale67
Also in triggerdotdev/trigger.dev
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| triggerdotdev/trigger.dev.cursor/rules/executing-commands.mdc · 16k | Cursor rules | test | 49/100 | 3 days ago | |
| triggerdotdev/trigger.dev.cursor/rules/webapp.mdc · 16k | Cursor rules | setuptestsecurity | 55/100 | 3 days ago | |
| triggerdotdev/trigger.dev.cursor/rules/writing-tasks.mdc · 16k | Cursor rules | setupbuildarchtypes+5 | 64/100 | 3 days ago | |
| triggerdotdev/trigger.dev.github/copilot-instructions.md · 16k | Copilot instructions | teststyletypes | 32/100 | 3 days ago | |
| triggerdotdev/trigger.devAGENTS.md · 16k | AGENTS.md | setupbuildtestlint-format+8 | 88/100 | 3 days ago | |
| triggerdotdev/trigger.devapps/supervisor/CLAUDE.md · 16k | CLAUDE.md | no sections | 25/100 | 3 days ago | |
| triggerdotdev/trigger.devapps/webapp/CLAUDE.md · 16k | CLAUDE.md | setupbuildteststyle+5 | 88/100 | 3 days ago | |
| triggerdotdev/trigger.devinternal-packages/clickhouse/CLAUDE.md · 16k | CLAUDE.md | styletypesdo-not | 61/100 | 3 days ago | |
| triggerdotdev/trigger.devinternal-packages/database/CLAUDE.md · 16k | CLAUDE.md | typesdatabasedo-not | 65/100 | 3 days ago | |
| triggerdotdev/trigger.devinternal-packages/run-engine/CLAUDE.md · 16k | CLAUDE.md | buildteststyle | 70/100 | 3 days ago | |
| triggerdotdev/trigger.devpackages/core/CLAUDE.md · 16k | CLAUDE.md | no sections | 31/100 | 3 days ago | |
| triggerdotdev/trigger.devpackages/redis-worker/CLAUDE.md · 16k | CLAUDE.md | test | 29/100 | 3 days ago | |
| triggerdotdev/trigger.devpackages/trigger-sdk/CLAUDE.md · 16k | CLAUDE.md | do-not | 54/100 | 3 days ago | |
| triggerdotdev/trigger.devpackages/cli-v3/CLAUDE.md · 16k | CLAUDE.md | deploymentdo-notdocs | 51/100 | 3 days ago |
Diff against .cursor/rules/executing-commands.mdc Diff against .cursor/rules/webapp.mdc Diff against .cursor/rules/writing-tasks.mdc Diff against .github/copilot-instructions.md Diff against AGENTS.md Diff against apps/supervisor/CLAUDE.md Diff against apps/webapp/CLAUDE.md Diff against internal-packages/clickhouse/CLAUDE.md Diff against internal-packages/database/CLAUDE.md Diff against internal-packages/run-engine/CLAUDE.md Diff against packages/core/CLAUDE.md Diff against packages/redis-worker/CLAUDE.md Diff against packages/trigger-sdk/CLAUDE.md Diff against packages/cli-v3/CLAUDE.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
