Skip to content

Register metrics by metric name and labels #13

@ghost91-

Description

@ghost91-

Currently, metrics are stored as Metric[Metric] inside a Registry. I think that it would be better to store them as Metric[Metric.Id] instead, where Metric.Id is a struct containing the Metric's name and labels (other properties could also be contained, the idea is taken from Micrometer where type, description and baseUnit are also part of the Id, but they are not relevant for hashing). Metric.Id added as a new property id to all metrics. We can then register metrics like this:

    void register(Metric m)
    {
        synchronized(this)
        {
            this._metrics[m.id] = m;
        }
    }

There are several reasons for this:

  • It makes sure we cannot register different Metrics with the same name / labels, which currently is possible but makes no sense
  • It allows to build convenience functions into the registry / metrics to get or register metrics by name and tags

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions