feat(testing): add contract marker, strict cardinality caps, and OTel GenAI aliases - #1654
Open
AdityaShome wants to merge 6 commits into
Open
AdityaShome wants to merge 6 commits into
AdityaShome wants to merge 6 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is a direct extension of the initial Prometheus integration in #1633. It builds on that exporter foundation by adding schema version signaling, stricter cardinality safety controls, and OTel-aligned dual-publish aliases, without changing the existing mofa_llm_* contract.
This PR delivers three production-focused observability upgrades for Prometheus metrics in MoFA:
All changes are implemented in:
prometheus.rsWhat Changed
1) Metrics contract stabilization marker
mofa_metrics_contract_info{version="v1alpha1"} 12) Strict label/cardinality controls
MAX_CARDINALITY_LIMIT_PER_DIMENSION = 10000 -> 1(existing behavior preserved)> 1000 -> 1000(new guard)3) OTel GenAI metric alignment (non-breaking dual-publish)
mofa_llm_*metrics intact:gen_ai_client_operation_duration_seconds(histogram alias)gen_ai_client_token_usage_total(counter alias, withtoken_type=input|output)Execution Flow:
flowchart TD A["Metrics snapshot"] --> B["Exporter render pipeline"] B --> C["Emit contract marker"] C --> C1["Contract info version v1alpha1"] B --> D["Apply cardinality sanitization"] D --> D1["Clamp lower bound to 1"] D --> D2["Clamp upper bound to 1000"] D1 --> E["Render bounded series"] D2 --> E E --> F["Render existing mofa llm metrics"] F --> F1["Input tokens total"] F --> F2["Output tokens total"] F --> F3["Request duration histogram"] E --> G["Dual publish OTel aliases"] G --> G1["Token usage total with token_type"] G --> G2["Operation duration histogram"] F --> H["Final metrics payload"] G --> H C1 --> H H --> I["Prometheus scrape and dashboards"]Backward Compatibility
mofa_llm_*metrics are unchanged.Validation
cargo test -p mofa-monitoring dashboard::prometheus::tests:: -- --nocaptureWhy this matters