Skip to content

Add API support for providing fallback for KeyValues #6564

@jonatan-ivanov

Description

@jonatan-ivanov

Applying KeyValues conditionally can lead into issues for example Prometheus require that all time-series (observation) with the same name have the same set of labels (low cardinality key names).

For example this can cause an error on if both branches (color = null and color = "red") are executed.

if (color != null) {
    observation.lowCardinalityKeyValue("color", color);
}

Instead of it, users should do something like this:

observation.lowCardinalityKeyValue("color", color != null ? color : "unknown");

We should make this easier for the users and harder to make this mistake.

See:

Validation could be also added: main...jonatan-ivanov:micrometer:validate-keyvalues

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions