otelcontext

command module
v0.2.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 47 Imported by: 0

README

OtelContext

CI Security (OSS-CLI) OpenSSF Scorecard OpenSSF Best Practices Release Beta Go Version Frontend Version

A self-hosted OTLP observability platform in a single Go binary — OTLP gRPC + HTTP ingest, GraphRAG-powered root-cause analysis, multi-tenant storage, and a built-in MCP server for AI agents.

For teams who want traces, logs, and metrics in one place without standing up a Collector + Prometheus + Loki + Tempo stack.

Documentation

  • Operators: docs/OPERATIONS.md — first run, production checklist, backup, incident response, upgrades.
  • AI agents / contributors: CLAUDE.md — architecture, GraphRAG, MCP tools, conventions.
  • Env reference: .env.example — every supported environment variable with defaults.

Quick start

# 1. Build
go build -o otelcontext .

# 2. Run with an API key (dev-friendly — SQLite, plaintext HTTP)
export API_KEY="$(openssl rand -hex 32)"
./otelcontext

The server listens on:

  • OTLP gRPC: :4317
  • HTTP API + OTLP HTTP + UI + MCP: :8080
  • Prometheus: :8080/metrics/prometheus
  • Probes: :8080/live, :8080/ready

Send an OTLP log via HTTP:

curl -sS -X POST http://localhost:8080/v1/logs \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "resourceLogs": [{
      "resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "demo"}}]},
      "scopeLogs": [{"logRecords": [{
        "timeUnixNano": "'$(date +%s)000000000'",
        "severityText": "INFO",
        "body": {"stringValue": "hello otelcontext"}
      }]}]
    }]
  }'

Then query it back:

curl -sS -H "Authorization: Bearer $API_KEY" \
  "http://localhost:8080/api/logs?limit=5" | jq .

Switching databases

Default is SQLite (otelcontext.db in the working dir). Override via env vars:

# PostgreSQL
DB_DRIVER=postgres \
DB_DSN="host=localhost user=otel password=otel dbname=otelcontext port=5432 sslmode=disable" \
./otelcontext

# MySQL
DB_DRIVER=mysql \
DB_DSN="root:password@tcp(localhost:3306)/otelcontext?charset=utf8mb4&parseTime=True&loc=Local" \
./otelcontext

See .env.example for SQL Server and Azure Entra (passwordless Postgres) configurations.

OTLP Integration

OtelContext accepts OTLP gRPC on :4317 and OTLP HTTP on :8080/v1/{traces,logs,metrics}. Point any OpenTelemetry Collector (or SDK) at it:

exporters:
  otlp/otelcontext:
    endpoint: "localhost:4317"
    tls:
      insecure: true

service:
  pipelines:
    traces:
      exporters: [otlp/otelcontext]
    logs:
      exporters: [otlp/otelcontext]
    metrics:
      exporters: [otlp/otelcontext]

See docs/otel-collector-example.yaml for a complete example.

Features

  • OTLP gRPC + HTTP ingest — traces, logs, metrics; gzip and protobuf/JSON supported.
  • GraphRAG — layered in-memory graph with error-chain, impact, and root-cause queries.
  • Drain log clustering — deterministic template mining, persisted across restarts.
  • MCP server — 21 tools exposing the platform to AI agents over JSON-RPC 2.0 + SSE.
  • Multi-tenancy — per-row tenant_id, X-Tenant-ID header / x-tenant-id gRPC metadata.
  • Adaptive sampling — always-on for errors and slow spans, probabilistic otherwise.
  • DLQ — durable typed envelopes with disk-bounded replay.
  • Self-instrumentation — export OtelContext's own spans via OTEL_EXPORTER_OTLP_ENDPOINT.

Security

See SECURITY.md for the vulnerability reporting process. The security posture (OSV-Scanner, Trivy, Semgrep, Gitleaks, jscpd, SBOM, Scorecard) is described in CLAUDE.md under "Security & Supply Chain".

License

See LICENSE.md.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
ai
api
api/views
Package views provides explicit JSON view models for the HTTP API.
Package views provides explicit JSON view models for the HTTP API.
graph
Package graph provides an in-memory service dependency graph rebuilt periodically from recent span data.
Package graph provides an in-memory service dependency graph rebuilt periodically from recent span data.
graphrag
Package graphrag provides a layered in-memory graph for real-time observability retrieval — error chains, root cause analysis, impact analysis.
Package graphrag provides a layered in-memory graph for real-time observability retrieval — error chains, root cause analysis, impact analysis.
httpconst
Package httpconst centralises HTTP header names and content-type strings shared by the API, MCP, and OTLP-HTTP handlers so the same literal isn't duplicated across packages.
Package httpconst centralises HTTP header names and content-type strings shared by the API, MCP, and OTLP-HTTP handlers so the same literal isn't duplicated across packages.
mcp
Package mcp implements the HTTP Streamable MCP (Model Context Protocol) server over JSON-RPC 2.0 with SSE streaming, allowing any AI agent (Claude, GPT, Cursor, etc.) to discover and call OtelContext tools natively.
Package mcp implements the HTTP Streamable MCP (Model Context Protocol) server over JSON-RPC 2.0 with SSE streaming, allowing any AI agent (Claude, GPT, Cursor, etc.) to discover and call OtelContext tools natively.
tls
Package tlsbootstrap provides zero-friction self-signed certificate generation for development and internal deployments.
Package tlsbootstrap provides zero-friction self-signed certificate generation for development and internal deployments.
tsdb
Package tsdb provides an in-memory ring buffer for per-metric sliding windows with pre-computed aggregates.
Package tsdb provides an in-memory ring buffer for per-metric sliding windows with pre-computed aggregates.
ui
vectordb
Package vectordb provides an embedded TF-IDF / cosine-similarity vector index for semantic log search.
Package vectordb provides an embedded TF-IDF / cosine-similarity vector index for semantic log search.
test
authservice command
orderservice command
paymentservice command
shippingservice command
userservice command

Jump to

Keyboard shortcuts

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