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

MetricNamesStore doesn't properly initialize #70

Closed
bwangfdu opened this issue Jul 2, 2018 · 2 comments
Closed

MetricNamesStore doesn't properly initialize #70

bwangfdu opened this issue Jul 2, 2018 · 2 comments

Comments

@bwangfdu
Copy link

bwangfdu commented Jul 2, 2018

I find the 3.0.1 version not working when there is an variable in Grafana template when using metrics() as query. It reports "Template variables could not be initialized: Cannot read property 'regexp' of undefined" if I use metrics() and reports "Template variables could not be initialized: Cannot read property 'then' of undefined" if I use metrics(myprefix).
After debugging with Chrome, I find MetricNamesStore.initialize():Promise<string[]> is never called in page load, and when calling get(): Promise<string[]>, the initialized property is false and fetchingPromise is undefined. After an explicit calling initialize(), using metrics(myprefix) is recovered. But metrics() still no luck.

This is my fixed get():

public get(): Promise<string[]> {
        if (this.initialized) {
            return this.promiseUtils.resolvedPromise(this.metricNames);
        } else {
            return this.initialize();
        }
    }
@jifwin
Copy link
Contributor

jifwin commented Jul 2, 2018

Thanks for reporting that. I refactored that a bit into a single function. Fixed on master (3.0.2)

@jifwin jifwin closed this as completed Jul 2, 2018
@bwangfdu
Copy link
Author

bwangfdu commented Jul 2, 2018 via email

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

2 participants