# Metrics Policy

> Type: Policy. Boundaries of observability metrics and instrumentation.

## Purpose

Metrics help explain a running application’s condition: for example, where latency is growing or how often an error occurs. Measurements are chosen to answer a concrete operational question. A small, stable set is usually easier to use and maintain.

Application state, storage and synchronization remain the responsibilities of the corresponding project mechanisms.

## Metric Design

- Use only limited and predictable sets of measurement values.
- Do not use `requestId`, tool IDs, timestamps, error texts, stack trace and other high cardinal values ​​as measurements unless explicitly necessary.
- Do not record secrets, tokens, credentials, or sensitive data in metrics.
- Do not duplicate information in metrics that is already fully presented in the logs.

## Instrumentation limits

- The specific metrics system code must remain within the existing metrics layer or infrastructure.
- Domain and the main application logic should not directly depend on the metrics system.
- You should instrument existing execution boundaries rather than rebuild the application for the sake of collecting metrics.
- Metric collection cannot be extended to unrelated components without first agreeing on the scope of the change.

## Reliability

Metrics are auxiliary observability data and are collected by best effort. Their collection should consume limited resources and not create unlimited queues, endless retry, memory growth, or significant delay to the main operation.

Metric collection and delivery remain independent of the main operation: an unavailable monitoring system must leave the business result, control flow and API behavior unchanged.

## Consistency between projects

Use consistent metric names, units and field semantics for the same operations and concepts across projects, including Node.js and Python projects. Also aim for compatible document structures.

You cannot change the overall metrics contract in just one project if this would lead to divergence of equivalent metrics between components.
