Lawrence CLI β Detect, Analyze, and Auto-Instrument OpenTelemetry Code
Lawrence CLI helps you quickly identify which programming languages and OpenTelemetry libraries a project uses, detect common misconfigurations, and produce actionable findings in text or JSON.
It can then generate instrumentation code using built-in templates or your preferred coding agent (GitHub Copilot CLI, Gemini, Claude, OpenAI).
Run in dry-run mode to preview changes or output ready-to-use scaffolding for immediate integration.
Features
- π Multi-Language Support: Analyze Go, Python, JavaScript, Java, .NET, Ruby, PHP
- π¦ Library Detection: Automatically detect OpenTelemetry libraries and versions
- β οΈ Issue Detection: Find common problems and get actionable recommendations
- π§ Extensible: Add custom detectors and language support
- π Multiple Output Formats: Text, JSON output options
Installation
Quick Install (Recommended)
curl -sSL https://raw.githubusercontent.com/getlawrence/cli/main/install.sh | bash
Using Go Install
go install github.com/getlawrence/cli@latest
Make sure $GOPATH/bin
is in your $PATH
:
export PATH=$PATH:$(go env GOPATH)/bin
Using Homebrew (macOS/Linux)
brew tap getlawrence/homebrew-tap
brew install lawrence
Download Pre-built Binaries
Download the latest release from the releases page.
Available for:
- Linux (x64, ARM64)
- macOS (x64, ARM64)
- Windows (x64, ARM64)
Using Docker
docker run --rm -v $(pwd):/workspace ghcr.io/getlawrence/cli analyze /workspace
From Source
git clone https://github.com/getlawrence/cli.git
cd cli
go build -o lawrence
Quick Start
Analyze Current Directory
lawrence analyze
Analyze Specific Project
lawrence analyze /path/to/your/project
Get JSON Output
lawrence analyze --output json
lawrence analyze --detailed
Commands
analyze
Analyze a codebase for OpenTelemetry usage and issues.
lawrence analyze [path] [flags]
Flags:
-d, --detailed Show detailed analysis including file-level information
-l, --languages strings Limit analysis to specific languages (go, python, java, etc.)
--categories strings Limit issues to specific categories
-o, --output string Output format (text, json) (default "text")
codegen
Analyze a codebase and generate OpenTelemetry instrumentation using AI or templates.
lawrence codegen [path] --mode template --dry-run
Flags:
-l, --language string Target language (go, javascript, python, java, dotnet, ruby, php)
-a, --agent string Preferred coding agent (gemini, claude, openai, github)
--list-agents List available coding agents
--list-templates List available templates
--list-strategies List available generation strategies
--mode string Generation mode (ai, template)
-o, --output string Output directory (template mode)
--dry-run Show what would be generated without writing files
-c, --config string Path to advanced OpenTelemetry config YAML
Advanced configuration (YAML)
You can pass a config file with advanced OpenTelemetry settings (instrumentations, propagators, sampler, exporters):
# otel.yaml
service_name: my-service
service_version: 1.2.3
environment: production
instrumentations: [http, express]
propagators: [tracecontext, baggage, b3]
sampler:
type: traceidratio
ratio: 0.2
exporters:
traces:
type: otlp
protocol: http
endpoint: https://otel-collector.example.com/v1/traces
insecure: false
Use it with:
lawrence codegen --mode template --config ./otel.yaml
Supported Languages
Language |
Library Detection |
Import Analysis |
Package Files |
Go |
β
|
β
|
go.mod, go.sum |
Python |
β
|
β
|
requirements.txt, pyproject.toml, setup.py |
JavaScript |
β
|
β
|
package.json, lockfiles |
Java |
β
|
β
|
pom.xml, gradle files |
.NET |
β
|
β
|
.csproj, packages.config |
Ruby |
β
|
β
|
Gemfile, Gemfile.lock |
PHP |
β
|
β
|
composer.json, composer.lock |
See Contributing to add support for your language.
Examples
Basic Analysis
$ lawrence analyze
π OpenTelemetry Analysis Results
=================================
π Project Path: /path/to/project
π£οΈ Languages Detected: [go]
π¦ OpenTelemetry Libraries: 3
β οΈ Issues Found: 1
π¦ OpenTelemetry Libraries Found:
---------------------------------
β’ go.opentelemetry.io/otel (v1.21.0) - go
β’ go.opentelemetry.io/otel/trace (v1.21.0) - go
β’ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp (v0.46.0) - go
βΉοΈ Information (1):
1. Missing metrics collection
OpenTelemetry libraries found but no metrics instrumentation detected
π‘ Add OpenTelemetry metrics to monitor application performance and health
JSON Output
$ lawrence analyze --output json
{
"analysis": {
"root_path": "/path/to/project",
"detected_languages": ["go"],
"libraries": [
{
"name": "go.opentelemetry.io/otel",
"version": "v1.21.0",
"language": "go",
"import_path": "go.opentelemetry.io/otel",
"package_file": "/path/to/project/go.mod"
}
]
},
"issues": [...]
}
License
MIT License - see LICENSE for details.
Support