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

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

Open
chengB12 opened this issue Jan 29, 2021 · 0 comments
Open

Comments

@chengB12
Copy link
Contributor

chengB12 commented Jan 29, 2021

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,

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant