Contributing to Micromegas¶
We welcome contributions to the Micromegas project! Here are some ways you can contribute:
Reporting Bugs¶
If you find a bug, please open an issue on our GitHub Issues page. Please include:
- A clear and concise description of the bug.
- Steps to reproduce the behavior.
- Expected behavior.
- Screenshots or error messages if applicable.
- Your operating system and Micromegas version.
Suggesting Enhancements¶
We're always looking for ways to improve Micromegas. If you have an idea for a new feature or an improvement to an existing one, please open an issue on our GitHub Issues page. Please include:
- A clear and concise description of the enhancement.
- Why you think it would be valuable to the project.
- Any potential use cases.
Code Contributions¶
We welcome code contributions! If you'd like to contribute code, please follow these steps:
- Fork the repository and clone it to your local machine.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-nameorgit checkout -b bugfix/your-bug-fix-name. - Make your changes and ensure your code adheres to the project's coding style and conventions.
- Write tests for your changes, if applicable.
- Run existing tests to ensure nothing is broken.
- Commit your changes with a clear and concise commit message.
- Push your branch to your forked repository.
- Open a Pull Request to the
mainbranch of the Micromegas repository. Please provide a detailed description of your changes.
Development Setup¶
For information on setting up your local development environment, please refer to the Getting Started guide.
Monorepo Structure¶
Micromegas uses a monorepo structure with npm workspaces for JavaScript/TypeScript components and Cargo workspaces for Rust components.
Repository Layout¶
micromegas/
├── rust/ # Rust workspace (main application)
│ ├── Cargo.toml # Root Cargo workspace
│ ├── analytics/ # Analytics engine
│ ├── tracing/ # Instrumentation library
│ ├── telemetry-ingestion-srv/
│ ├── flight-sql-srv/
│ └── ...
├── grafana/ # Grafana datasource plugin
│ ├── package.json
│ ├── src/
│ └── pkg/ # Go backend
├── typescript/ # Shared TypeScript packages
│ └── types/ # @micromegas/types package
├── python/ # Python client
│ └── micromegas/ # Poetry package
├── package.json # Root npm workspace
└── CONTRIBUTING.md # This file
Rust Workspace (Primary)¶
The Rust workspace is located in rust/ and contains the core Micromegas platform. This is the main workspace of the project.
Commands (run from rust/ directory):
cargo build # Build all crates
cargo test # Run all tests
cargo fmt # Format code (REQUIRED before commit)
cargo clippy --workspace -- -D warnings # Lint
CI validation script:
Python Package¶
The Python client uses Poetry for dependency management.
Location: python/micromegas/
Commands (run from python/micromegas/):
poetry install # Install dependencies
poetry run pytest # Run tests
poetry run black <file> # Format code (REQUIRED before commit)
TypeScript/JavaScript Workspaces¶
The repository uses npm workspaces to manage TypeScript/JavaScript packages, with yarn as the package manager.
- Root workspace (
package.json): Defines workspaces and shared dev dependencies grafana/: Grafana FlightSQL datasource plugin (React + Go backend)typescript/types/: Shared TypeScript type definitions (@micromegas/types)
Important: Always use yarn, not npm, to avoid lockfile conflicts.
Working with All Components¶
Installing Dependencies¶
Rust (from rust/ directory):
Python (from python/micromegas/ directory):
TypeScript/JavaScript (from repository root, use yarn):
Go (for Grafana backend, from grafana/ directory):
Building Components¶
Rust workspace:
Python package:
TypeScript/JavaScript workspaces (use yarn):
yarn workspaces run build # Build all workspaces (from root)
cd grafana && yarn build # Grafana plugin only
cd typescript/types && yarn build # Shared types only
For the Grafana plugin development:
Running Tests¶
Rust workspace:
Python package:
TypeScript/JavaScript workspaces (use yarn):
yarn workspaces run test # Test all workspaces (from root)
cd grafana && yarn test:ci # Grafana plugin tests only
Linting¶
Rust workspace:
cd rust && cargo clippy --workspace -- -D warnings
cd rust && cargo fmt # Format (REQUIRED before commit)
Python package:
TypeScript/JavaScript workspaces (use yarn):
yarn workspaces run lint # Lint all workspaces (from root)
cd grafana && yarn lint:fix # Grafana plugin only
Grafana Plugin Development¶
The Grafana plugin requires both Node.js and Go:
Prerequisites:
- Node.js 16+ (18.20.8 recommended)
- Go 1.23+ (for backend plugin)
- yarn (package manager for this repository)
- mage (for Go builds): go install github.com/magefile/mage@latest
Development workflow:
cd grafana
# Install dependencies
yarn install --ignore-engines
# Build Go backend binaries
mage -v build
# Start development server with hot reload
yarn dev
# Run tests
yarn test:ci
# Run linting
yarn lint
# Build production bundle
yarn build
Starting Grafana with the plugin:
cd grafana
yarn server # Starts Grafana with docker compose (includes --build)
# Access Grafana at http://localhost:3000
Code Style and Conventions¶
Rust¶
- Dependencies in alphabetical order in Cargo.toml files
- Error handling: Use
expect()with descriptive messages in tests, useanyhowin library code - Run
cargo fmtbefore any commit - Use inline format arguments:
format!("value: {variable}") - Always use
prelude::*when importing from prelude modules
TypeScript/JavaScript¶
- Follow existing ESLint configuration in each workspace
- Use Prettier for formatting
- Run
npm run lint:fixbefore committing - Prefer functional components and hooks in React code
Python¶
- Use Black for formatting (required before commit)
- Follow PEP 8 guidelines
- Use type hints where appropriate
Commit Messages¶
- Keep messages clear and concise
- Follow existing commit message patterns in the repository
Thank you for contributing to Micromegas!