Skip to content

Add GitHub Copilot repository instructions with development workflow guidance #3118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# OpenTelemetry Rust Copilot Instructions

This repository contains the OpenTelemetry implementation for Rust. When working with this codebase, please follow these guidelines:

## Development Tools and Commands

1. **Use clippy, rustfmt, and cargo check regularly.**
- Run `cargo clippy --workspace --all-targets --all-features` for comprehensive linting
- Run `cargo fmt --all` to format code consistently
- Run `cargo check --workspace` to verify compilation

2. **Use the provided development scripts:**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot perhaps its easier to just do cargo build/test from the individual crate when working on features for that crate alone. and scripts are anyway run in CI checks, but they can used for a final check, not something to do with each change etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the development workflow guidance to emphasize individual crate commands for focused development and position the scripts as final validation tools. Changes committed in dcdeb96.

- Run `./scripts/precommit.sh` before committing (runs format, lint, and test)
- Run `./scripts/lint.sh` for comprehensive linting across all features
- Run `./scripts/test.sh` for running tests

## Workspace Structure

This is a Cargo workspace containing multiple crates:
- `opentelemetry` - Core API crate
- `opentelemetry-sdk` - SDK implementation
- `opentelemetry-otlp` - OTLP exporter
- `opentelemetry-stdout` - Stdout exporter
- And many more specialized crates

When making changes, consider the impact across the entire workspace.

## Feature Flags and Compilation

- This codebase uses extensive feature flags for signals (`traces`, `metrics`, `logs`)
- Experimental features are behind the `otel_unstable` feature flag
- Use `cargo hack --each-feature` to test across feature combinations
- Some crates like `opentelemetry-prometheus` are outside the main workspace

## Code Standards

- **MSRV**: Minimum Supported Rust Version is 1.75
- **Error Handling**: Wrap errors in signal-specific types (`TraceError`, `MetricError`, `LogsError`)
- **Commits**: Use conventional commit format (e.g., `feat:`, `fix:`, `docs:`)
- **Testing**: Run `cargo test --workspace` for comprehensive testing
- **Documentation**: Include examples in documentation and maintain README files

## OpenTelemetry Specifics

- Follow the OpenTelemetry specification
- Prioritize functionality over structural compliance with spec
- Use Rust idioms rather than forcing spec API patterns
- Configuration priority: Environment variables > compile-time config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot code should have higher priority than env variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the configuration priority order to prioritize compile-time config over environment variables. Changes committed in commit 8b5a9e2.

- Use `#[cfg(feature = "otel_unstable")]` for experimental features

## Build Requirements

- For `opentelemetry-otlp`: Requires `protoc` (Protocol Buffers compiler)
- Clone with submodules: `git clone --recurse-submodule`
- Set `PROTOC` environment variable if needed: `export PROTOC=$(which protoc)`

## Testing and Validation

- Run benchmarks with `cargo bench` for performance-sensitive changes
- Test examples in the `examples/` directory to ensure they work
- Validate changes don't break existing behavior across workspace
- Consider impact on different runtime features (`rt-tokio`, etc.)
Loading