metricskey

package
v1.0.182 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 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 metricskey declares the metric descriptors emitted by the assistant loop, for use with github.com/effective-security/metrics.

Metrics is the full slice of descriptors, ready to register with a collector:

err := metrics.Register(metricskey.Metrics...)

Counters tagged agent/model/org cover messages, bytes and tokens sent to and received from the LLM (including prompt-cache reads and writes), plus assistant call outcomes and output-parse errors. Counters tagged tool/model/org cover tool call outcomes, including calls to tools the model named but that were not registered. Samples record assistant and tool call durations.

The "agent" tag is assistants.IAssistant.Name() and the "org" tag is chatmodel.ChatContext.GetOrgID(), so naming assistants and setting the org ID is what makes per-assistant and per-tenant dashboards possible.

Index

Constants

This section is empty.

Variables

View Source
var (
	// StatsLLMMessagesSent is base for counter metric for total messages sent to LLM
	StatsLLMMessagesSent = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_messages_sent",
		Help:         "stats_llm_messages_sent provides total messages sent to LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMBytesSent = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_bytes_sent",
		Help:         "stats_llm_bytes_sent provides total bytes sent to LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMBytesReceived = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_bytes_received",
		Help:         "stats_llm_bytes_received provides total bytes received from LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMBytesTotal = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_bytes_total",
		Help:         "stats_llm_bytes_total provides total bytes sent and received from LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMInputTokens = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_input_tokens",
		Help:         "stats_llm_input_tokens provides total input tokens sent to LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMOutputTokens = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_output_tokens",
		Help:         "stats_llm_output_tokens provides total output tokens received from LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMCachedWriteTokens = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_cached_write_tokens",
		Help:         "stats_llm_cached_write_tokens provides total cached write tokens sent to LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMCachedReadTokens = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_cached_read_tokens",
		Help:         "stats_llm_cached_read_tokens provides total cached read tokens received from LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsLLMTotalTokens = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_total_tokens",
		Help:         "stats_llm_total_tokens provides total tokens sent and received from LLM",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsAssistantCallsSucceeded = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_assistant_calls_succeeded",
		Help:         "stats_assistant_calls_succeeded provides total assistant calls succeeded",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsAssistantCallsFailed = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_assistant_calls_failed",
		Help:         "stats_assistant_calls_failed provides total assistant calls failed",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsAssistantCallsRetried = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_assistant_calls_retried",
		Help:         "stats_assistant_calls_retried provides total assistant calls retried",
		RequiredTags: []string{"agent", "model", "org"},
	}

	StatsToolCallsSucceeded = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_tool_calls_succeeded",
		Help:         "stats_tool_calls_succeeded provides total tool calls succeeded",
		RequiredTags: []string{"tool", "model", "org"},
	}

	StatsToolCallsFailed = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_tool_calls_failed",
		Help:         "stats_tool_calls_failed provides total tool calls failed",
		RequiredTags: []string{"tool", "model", "org"},
	}

	StatsToolCallsNotFound = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_tool_calls_not_found",
		Help:         "stats_tool_calls_not_found provides total tool calls not found",
		RequiredTags: []string{"tool", "model", "org"},
	}

	StatsAssistantLLMParseErrors = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_assistant_llm_parse_errors",
		Help:         "stats_assistant_llm_parse_errors provides total assistant LLM parse errors",
		RequiredTags: []string{"agent", "model", "org"},
	}

	// StatsLLMModelSubstituted counts the model resolutions in which the LLM
	// factory replaced a configured model the provider no longer serves, or
	// does not allow, by another model of the same family.
	StatsLLMModelSubstituted = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_model_substituted",
		Help:         "stats_llm_model_substituted provides total model resolutions that used another model of the family than the one configured",
		RequiredTags: []string{"provider", "requested", "model"},
	}

	// StatsLLMModelListFailed counts the failed attempts of the LLM factory
	// to read the model list of a provider.
	StatsLLMModelListFailed = metrics.Describe{
		Type:         metrics.TypeCounter,
		Name:         "stats_llm_model_list_failed",
		Help:         "stats_llm_model_list_failed provides total failed fetches of a provider model list",
		RequiredTags: []string{"provider"},
	}
)

Stats

View Source
var (
	PerfAssistantCall = metrics.Describe{
		Type:         metrics.TypeSample,
		Name:         "perf_assistant_call",
		Help:         "perf_assistant_call provides duration of assistant call",
		RequiredTags: []string{"agent", "model", "org"},
	}

	PerfToolCall = metrics.Describe{
		Type:         metrics.TypeSample,
		Name:         "perf_tool_call",
		Help:         "perf_tool_call provides duration of tool call",
		RequiredTags: []string{"tool", "model", "org"},
	}
)

Perf

Metrics returns slice of metrics from this repo keep sorted by name

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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