No description
- Python 100%
| .agents | ||
| .devcontainer | ||
| .gitignore | ||
| README.md | ||
Antigravity OpenTelemetry Usage & Cost Exporter
This repository contains the otel-usage-exporter plugin for Antigravity, which tracks token usage and cost metrics across conversation transcripts and exports them to an OpenTelemetry collector via OTLP/HTTP.
Features
- Automatic Transcript Parsing: Parses Antigravity JSONL transcript logs on
PostInvocationandStophooks. - OTLP Metrics Export: Emits standard GenAI OpenTelemetry metrics:
gen_ai.client.token.usage: Counter for input and output token counts tagged by model and conversation ID.antigravity.cost.estimate: Counter for estimated request costs in USD.
- State Management: Tracks
last_processed_stepin.otel_export_state.jsonto prevent duplicate metric reporting.
Configuration
OpenTelemetry Collector Endpoint
By default, the script sends OTLP metrics to http://100.77.122.84:4318/v1/metrics. You can customize the collector endpoint by setting the environment variable:
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT="http://<your-collector-host>:4318/v1/metrics"
Plugin Hooks Configuration
The plugin hooks are configured in .agents/plugins/otel-usage-exporter/hooks.json:
{
"otel-usage-exporter": {
"enabled": true,
"PostInvocation": [
{
"type": "command",
"command": "python3 ./scripts/export_otel.py",
"timeout": 15
}
],
"Stop": [
{
"type": "command",
"command": "python3 ./scripts/export_otel.py",
"timeout": 15
}
]
}
}
Setup & Prerequisites
- Python 3: Requires Python 3.10+ with standard library modules.
- Devcontainer: Standard Python feature (
ghcr.io/devcontainers/features/python:1) is included in.devcontainer/devcontainer.json.