|
| 1 | +# Copilot Instructions for OpenTelemetry Semantic Conventions |
| 2 | + |
| 3 | +## Overview |
| 4 | +These instructions guide AI assistants in reviewing pull requests for the |
| 5 | +OpenTelemetry Semantic Conventions repository. Follow these guidelines to |
| 6 | +ensure consistency, quality, and adherence to established standards. |
| 7 | + |
| 8 | +This repository contains semantic conventions supported by the OpenTelemetry ecosystem. |
| 9 | + |
| 10 | +**CRITICAL REVIEW CRITERIA**: New areas require special scrutiny and must meet |
| 11 | +these requirements: |
| 12 | + |
| 13 | +#### Prerequisites for New Convention Areas |
| 14 | +- **Domain Expertise**: Must have a group of people familiar with the domain |
| 15 | +- **Active Involvement**: Contributors must be involved with instrumentation |
| 16 | + efforts in that area |
| 17 | +- **Long-term Commitment**: Must have committed maintainers to be point of contact for: |
| 18 | + pull requests, issues, question, ongoing maintenance |
| 19 | + |
| 20 | +#### Process for New Areas |
| 21 | +1. **Project Management**: Follow [OpenTelemetry project management](https://github.com/open-telemetry/community/blob/main/project-management.md) guidelines |
| 22 | +2. **Codeowners**: New areas MUST have assigned codeowners |
| 23 | + |
| 24 | +## General Review Principles |
| 25 | +- **YAML Models**: All attributes, metrics, and conventions are formally defined |
| 26 | + in YAML files under `model/` directory |
| 27 | + - Validate against [schema](https://github.com/open-telemetry/weaver/blob/main/schemas/semconv.schema.json) |
| 28 | + - Verify all new conventions are documented with clear `brief` and `note` sections |
| 29 | + - Validate that examples are realistic and helpful |
| 30 | + - Confirm proper use of RFC 2119 keywords (MUST, SHOULD, MAY, etc.) |
| 31 | + |
| 32 | +- **Scope**: ensure contributions belong here: |
| 33 | + - **SHOULD be included:** |
| 34 | + - Instrumentations hosted in OpenTelemetry |
| 35 | + - Common attributes and conventions used across multiple instrumentations |
| 36 | + - Conventions that benefit from centralized policy enforcement |
| 37 | + |
| 38 | + - **SHOULD NOT be included:** |
| 39 | + - Instrumentations following external schemas not fully compatible with OpenTelemetry |
| 40 | + - Domain-specific conventions better maintained in their own repositories |
| 41 | + |
| 42 | +### Naming Conventions |
| 43 | + |
| 44 | +- **Attributes/Metrics/Events**: Use lowercase with dot-separated namespaces |
| 45 | + (e.g., `service.name`) |
| 46 | +- **Multi-word components**: Use snake_case (e.g., `http.response.status_code`) |
| 47 | +- **Abbreviations**: Only use widely recognized abbreviations (HTTP, CPU, AWS, etc.) |
| 48 | +- **Namespacing**: Ensure proper namespace hierarchy and avoid name collisions |
| 49 | +- **No reuse**: Different entities cannot share the same name within their category |
| 50 | + |
| 51 | +## Attribute Guidelines |
| 52 | + |
| 53 | +### New Attribute Requirements |
| 54 | + |
| 55 | +- Must have clear benefit to end users |
| 56 | +- Should be used by spans/metrics/events/entities |
| 57 | +- Must follow stability progression (development → stable) |
| 58 | +- Should reuse existing attributes when possible |
| 59 | +- Check against existing namespaces before creating new ones |
| 60 | + |
| 61 | +### Attribute Definition Standards |
| 62 | + |
| 63 | +- Use appropriate type (string, int, double, boolean, array, enum) |
| 64 | +- Define enums for short, closed sets of values |
| 65 | +- Use template type only for dynamic names (last segment only) |
| 66 | +- Avoid unbounded values (>1KB strings, >1000 element arrays) |
| 67 | +- Avoid high-cardinality attributes in metrics |
| 68 | +- Mark PII/sensitive data with warnings |
| 69 | + |
| 70 | +### Attribute Types and Usage |
| 71 | + |
| 72 | +- **Timestamps**: Use string in ISO 8601 format |
| 73 | +- **Arrays**: Must be homogeneous; use separate attributes for different concepts |
| 74 | +- **Complex values**: Flatten into multiple attributes when possible |
| 75 | +- **Template attributes**: For user-defined key-value pairs (e.g., HTTP headers) |
| 76 | + |
| 77 | +## Event Guidelines |
| 78 | + |
| 79 | +- SHOULD have attributes for additional context |
| 80 | +- SHOULD NOT use body |
| 81 | + |
| 82 | +## Entity Requirements |
| 83 | + |
| 84 | +- Use `type: entity` with proper `name` field for entity groups |
| 85 | +- Distinguish between `identifying` and `descriptive` attribute roles |
| 86 | +- Identifying attributes must be minimally sufficient for unique identification and |
| 87 | + must not change during entity lifespan |
| 88 | +- Use proper namespacing based on discovery mechanism (e.g., `k8s.*` for Kubernetes) |
| 89 | +- Use `entity_associations` field to link signals with appropriate entities |
| 90 | + |
| 91 | +## Error Handling Conventions |
| 92 | + |
| 93 | +### Error Recording Standards |
| 94 | +- **Spans**: Set status to Error, populate `error.type`, set description when helpful |
| 95 | +- **Metrics**: Include `error.type` attribute for filtering and analysis |
| 96 | +- **Exceptions**: Record as span events or log records using SDK APIs |
| 97 | +- **Consistency**: Same `error.type` across spans and metrics for same operation |
| 98 | + |
| 99 | +## Common Issues to Flag |
| 100 | + |
| 101 | +- Creating attributes without referenicng them in spans/metrics/events/entities |
| 102 | +- Creating new attributes without clear use case or instrumentation that will use them |
| 103 | +- Creating overly generic attributes without established standards |
| 104 | +- Duplicating existing functionality |
| 105 | +- Missing or inadequate documentation |
| 106 | +- Missing, incorrect YAML syntax or schema violations |
| 107 | +- Inconsistent naming patterns |
| 108 | +- Missing required fields or metadata |
| 109 | +- Performance or security concerns not addressed |
| 110 | + |
| 111 | +## Review Response Guidelines |
| 112 | + |
| 113 | +- Explain rationale behind suggestions |
| 114 | +- Reference relevant documentation sections |
| 115 | +- Provide specific examples of improvements |
| 116 | +- Suggest alternatives when rejecting proposals |
| 117 | + |
| 118 | +## Resources and References |
| 119 | + |
| 120 | +- [How to Define Conventions](../docs/general/how-to-define-semantic-conventions.md) |
| 121 | +- [YAML Model Documentation](../model/README.md) |
| 122 | +- [Naming Guidelines](../docs/general/naming.md) |
| 123 | +- [Attribute Requirement Levels](../docs/general/attribute-requirement-level.md) |
| 124 | +- [Error Recording](../docs/general/recording-errors.md) |
| 125 | +- [Event Conventions](../docs/general/events.md) |
| 126 | + |
0 commit comments