aidputils.agents.toolkit.metrics_util¶
Utility helpers for creating and recording OpenTelemetry metrics for toolkit components.
- class aidputils.agents.toolkit.metrics_util.MetricUtility(meter_name: str)[source]¶
Bases:
objectSmall wrapper around an OpenTelemetry meter.
This helper keeps toolkit code concise by centralizing the common pattern of:
creating a meter for a logical component, and
creating and incrementing counters with optional attributes.
- Parameters:
meter_name – The OpenTelemetry meter scope name used to group emitted metrics.
Initialize the metric utility with a named meter.
- create_counter(name: str, description: str = '')[source]¶
Create and return a counter instrument.
- Parameters:
name – Metric name exposed to the telemetry backend.
description – Optional human-readable description for dashboards and observability tools.
- increment_counter(counter, value: int = 1, attributes: dict | None = None) None[source]¶
Increment a counter safely.
- Parameters:
counter – The OpenTelemetry counter returned by
create_counter().value – Amount to add to the counter.
attributes – Optional dimension map attached to the metric sample.
Notes
Metric emission should never break the calling workflow. Any telemetry errors are logged and suppressed.