|
| 1 | +# Cursor Rules for Laravel OpenTelemetry Package |
| 2 | + |
| 3 | +## Code Style and Comments |
| 4 | +- Use English comments only - no Chinese or other languages |
| 5 | +- Follow PSR-12 coding standards |
| 6 | +- Use meaningful variable and method names |
| 7 | +- Add proper docblocks for all public methods and classes |
| 8 | + |
| 9 | +## OpenTelemetry Specific Rules |
| 10 | +- Always use OpenTelemetry semantic conventions (TraceAttributes) when available |
| 11 | +- Prefer standard semantic conventions over custom attribute names |
| 12 | +- Use proper span kinds (SERVER, CLIENT, INTERNAL, PRODUCER, CONSUMER) |
| 13 | +- Always handle exceptions in spans with proper error recording |
| 14 | + |
| 15 | +## Laravel Integration |
| 16 | +- Follow Laravel conventions for service providers, facades, and middleware |
| 17 | +- Use Laravel's container for dependency injection |
| 18 | +- Respect Laravel's configuration patterns |
| 19 | +- Check the `otel.enabled` config before registering any OpenTelemetry components |
| 20 | + |
| 21 | +## Documentation |
| 22 | +- Use English for all documentation and comments |
| 23 | +- Include usage examples in docblocks where appropriate |
| 24 | +- Document any custom attributes that don't have standard semantic conventions |
| 25 | +- Keep README and examples up to date with API changes |
| 26 | + |
| 27 | +## Error Handling |
| 28 | +- Always wrap span operations in try-catch blocks |
| 29 | +- Use proper OpenTelemetry status codes |
| 30 | +- Record exceptions with context information |
| 31 | +- Gracefully handle disabled OpenTelemetry scenarios |
| 32 | + |
| 33 | +## Performance |
| 34 | +- Avoid creating spans when OpenTelemetry is disabled |
| 35 | +- Use lazy loading for expensive operations |
| 36 | +- Consider the performance impact of attribute collection |
| 37 | +- Implement proper span lifecycle management |
0 commit comments