No description
Find a file
2026-08-21 13:24:36 +00:00
.agents Add .gitignore and ignore pycache and local export state 2026-08-21 13:24:36 +00:00
.devcontainer Configure Python feature, fix OTLP exporter hook script reference, and add README 2026-08-21 13:24:27 +00:00
.gitignore Add .gitignore and ignore pycache and local export state 2026-08-21 13:24:36 +00:00
README.md Configure Python feature, fix OTLP exporter hook script reference, and add README 2026-08-21 13:24:27 +00:00

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 PostInvocation and Stop hooks.
  • 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_step in .otel_export_state.json to 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.