Skip to content

Let health metrics override component attributes - #35

Merged
Aloento merged 1 commit into
mainfrom
feat/component-attribute-override
Nov 17, 2026
Merged

Aloento merged 1 commit into
mainfrom
feat/component-attribute-override

Conversation

@Aloento

@Aloento Aloento commented Nov 17, 2026

Copy link
Copy Markdown
Member

The reporter matches a status dashboard component by its name and the attributes of the environment, so services published as one global component (region: Global) never matched and their incidents were dropped with component not found in cache even after refresh.

A health metric definition accepts an optional component_attributes map now. It is merged over the environment attributes when the component is resolved: an attribute with the same name replaces the environment value, a missing one is appended.

Verified with cargo fmt -- --check, cargo clippy -- -D warnings, cargo test --all-targets (three unit tests cover the merge) and the regenerated doc/schemas/config-schema.json. Replaying the reporter's matching against the live GET /v2/components of both sites resolves the affected services to their components once the config uses the field.

The reporter identifies a status dashboard component by its name and the
attributes of the environment (for example `region: EU-DE`). A service that is
published as one global component therefore never matched: the component is
registered with `region: Global` and the environment attribute always injected
the region.

Add an optional `component_attributes` map to a health metric definition. It is
merged over the environment attributes when the component is built, so a
service can replace `region` or add an attribute for itself. The global
services (console, otc, helpcenter, architecture center, community, financial
dashboard) need it to be resolvable again.

Attributes that are not overridden keep their environment value; an unknown
attribute is appended.

@ecosquad-autoreview ecosquad-autoreview Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The change adds an optional component_attributes map to ServiceHealthDef so a health metric can override a single environment attribute (e.g. region: Global) when resolving its Status Dashboard component. The merge is implemented in merge_component_attributes (src/sd.rs:112), wired into the reporter (src/bin/reporter.rs:118), threaded through AppState::process_config (src/types.rs:247), and covered by three unit tests plus a regenerated JSON schema and docs.

All three ServiceHealthDef construction sites (types, the AppState builder, and the common.rs test helper) are updated consistently, and the new field is #[serde(default)] so existing configs keep parsing. The merge logic is correct: same-name override replaces, missing name is appended, and the result is sorted for determinism. The subset-based matching in find_component_id is unchanged and works with the merged attributes. Overall this is a clean, well-tested change — approve.

Findings

Warning

  • Override attributes that the target component doesn't have silently break matching (src/bin/reporter.rs:118, find_component_id in src/sd.rs). find_component_id requires the config attributes to be a subset of the cached component's attributes. Because the merge replaces/appends an override rather than validating it, a misconfigured component_attributes (e.g. an override value or name the live component does not actually expose) will not match any component and the incident will be dropped with component not found in cache even after refresh — the exact failure mode this PR is trying to fix, now with an extra, less obvious cause. Consider a startup log/debug line that emits the final merged attribute set per component so a mismatch can be spotted quickly against the GET /v2/components response. (The PR already validates against the live API, so this is a maintainability aid, not a blocker.)

Suggestion

  • Inconsistent ordering in merge_component_attributes (src/sd.rs:112). When overrides is None the function returns the environment attributes unsorted; when Some, it sorts the result. Functionally irrelevant (matching compares individual attributes, never the whole vec), but the asymmetry is a bit surprising. You could sort() before the early return too for consistency.
  • Non-deterministic input order (src/bin/reporter.rs): env_attrs is built by iterating env.attributes (a HashMap), so its order varies per run. This is currently harmless because both the merge output (when overridden) and the cache key are sorted, and find_component_id compares per-attribute. No action needed, just noting it relies on the sorted-key guarantee.

CI (build/test) was still queued at review time, so these findings are based on static reading only.

@Aloento
Aloento merged commit 7fa2940 into main Nov 17, 2026
9 checks passed
@Aloento
Aloento deleted the feat/component-attribute-override branch November 17, 2026 16:14
Aloento added a commit to stackmon/stackmon-config-preprod that referenced this pull request Nov 17, 2026
The build from stackmon/metrics-processor#35 understands `component_attributes`,
which the aligned config already declares for the global components.
Aloento added a commit to opentelekomcloud-infra/stackmon-config that referenced this pull request Nov 17, 2026
Builds from stackmon/metrics-processor#35, which lets a health metric override
the component attributes it is looked up with. The config that uses the field
is in #300; either order deploys without changing the current behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant