agentmetrics

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentmetrics exposes a Prometheus / OpenMetrics HTTP handler for a gopheragent BudgetTracker. It lives outside pkg/agent so applications that embed the agent loop in a CLI or batch tool do not transitively import net/http.

Usage:

bt := agent.NewBudgetTracker(100_000)
loop.OnEvent(bt.Handler())
http.Handle("/metrics", agentmetrics.Handler(bt))

The output is valid OpenMetrics 1.0 (and therefore Prometheus text format), so any Prometheus-compatible scraper can ingest it directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(bt *agent.BudgetTracker) http.Handler

Handler returns an http.Handler that renders the tracker's per-session token usage in OpenMetrics text format.

Metrics emitted:

  • gopheragent_session_prompt_tokens_total{session_key} (counter)
  • gopheragent_session_completion_tokens_total{session_key} (counter)
  • gopheragent_session_tokens_total{session_key} (counter, sum of the two above)
  • gopheragent_session_budget_tokens{session_key} (gauge, the configured ceiling)
  • gopheragent_session_budget_remaining_tokens{session_key} (gauge, budget - total; omitted when Budget == 0)

Cardinality note: every distinct session_key produces its own series. If the tracker is used with short-lived per-request keys, the caller should reset or evict entries when a session ends so the exporter does not carry a growing label set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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