cli

command module
v0.1.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 2 Imported by: 0

README ΒΆ

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

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
Show Detailed Information
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

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL