Development¶
How to develop, test, and contribute to the plugin.
Setup¶
# Clone
git clone https://github.com/henrikrexed/openclaw-observability-plugin.git
cd openclaw-observability-plugin
# Install dependencies
npm install
# Link to OpenClaw (live development)
openclaw plugins install -l .
# Restart gateway to pick up the plugin
openclaw gateway restart
Project Structure¶
openclaw-observability-plugin/
├── index.ts # Plugin entry point
├── src/
│ ├── config.ts # Configuration parsing
│ ├── telemetry.ts # OTel SDK setup (providers, exporters, instruments)
│ ├── openllmetry.ts # GenAI instrumentation status check
│ └── hooks.ts # OpenClaw event hooks
├── collector/
│ └── otel-collector-config.yaml # OTel Collector config
├── docs/ # MkDocs documentation
├── openclaw.plugin.json # Plugin manifest
├── package.json
├── tsconfig.json
├── mkdocs.yml
└── docker-compose.yaml
Development Workflow¶
1. Make Changes¶
Edit the TypeScript files in src/ or index.ts.
2. Restart Gateway¶
OpenClaw uses jiti to load TypeScript at runtime, so no build step is needed:
3. Verify¶
# Check plugin loaded
openclaw otel
# Check gateway logs for [otel] messages
tail -f ~/.openclaw/gateway.log | grep otel
4. Test with Debug Exporter¶
For quick development, use the collector's debug exporter to see spans in stdout:
Every exported span/metric will appear in the collector logs.
Type Checking¶
Note
The plugin uses OpenClaw's plugin API via any types since the SDK types aren't published separately yet. Once openclaw/plugin-sdk is published, we'll add proper type imports.
Testing Locally Without a Backend¶
You can run with just the debug exporter (no Dynatrace/Grafana needed):
-
Edit
collector/otel-collector-config.yaml: -
Start the collector:
docker compose up -d - Watch spans:
docker compose logs -f otel-collector - Send messages to your OpenClaw agent — you'll see spans appear in the logs
Adding New Metrics¶
-
Define the instrument in
src/telemetry.ts: -
Record values in
src/hooks.tsorindex.ts: -
Document in
docs/telemetry/metrics.md
Adding New Spans¶
-
Use the tracer in
src/hooks.ts: -
Document in
docs/telemetry/traces.md
Building the Documentation¶
# Install MkDocs (one-time)
pip install mkdocs-material
# Serve locally
mkdocs serve
# Build static site
mkdocs build
# Deploy to GitHub Pages
mkdocs gh-deploy
Publishing to npm¶
When ready to publish as an installable OpenClaw plugin:
# Update version in package.json and openclaw.plugin.json
npm version patch
# Publish
npm publish --access public
Users can then install with:
Contributing¶
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run type-check:
npm run typecheck - Test with a local collector
- Submit a pull request
Commit Convention¶
Use conventional commits:
feat: add new metric for session durationfix: handle missing tool name in hookdocs: update Dynatrace setup guiderefactor: simplify config parsing