Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.
This repository was archived by the owner on Aug 10, 2023. It is now read-only.

Repeating calls on addTaggedMetrics() doesn't return existing metrics #25

@chengB12

Description

@chengB12

If we call addTaggedMetrics() with same name/tags, but different counter instances,
registry.addTaggedMetric will pass without error, however, the second call actually has no effect
Proof:

it('test behavior of wavefront metrics', () => {
        const registry: wfMetrics.Registry = new wfMetrics.Registry({})
        const tag1 = new wfMetrics.Counter()
        registry.addTaggedMetric('test.metrics.counter.tagged', tag1, { tag: '1' })
        const tag2 = new wfMetrics.Counter()
        registry.addTaggedMetric('test.metrics.counter.tagged', tag2, { tag: '1' })
        const realCounter = registry.getMetric('test.metrics.counter.tagged-tags=[["tag","1"]]')
        expect(realCounter).eq(tag1)
})

Rational: we have dynamically generated tags, and we don't know if a counter of same key/tags already exists unless we keep in-memory track of metrics we created, naturally, we call addTaggedMetrics() multiple times, and expect to having original counter.

solution:
make addTaggedMetrics() return existing metric if there is already one in registry,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions