diff --git a/public/app/plugins/datasource/graphite/specs/store.test.ts b/public/app/plugins/datasource/graphite/specs/store.test.ts index 0a5ab8ba57e..059a83956ef 100644 --- a/public/app/plugins/datasource/graphite/specs/store.test.ts +++ b/public/app/plugins/datasource/graphite/specs/store.test.ts @@ -210,6 +210,20 @@ describe('Graphite actions', async () => { }); }); + it('current time range is passed when getting list of tags when editing', async () => { + const currentRange = { from: 0, to: 1 }; + ctx.state.range = currentRange; + await getTagsSelectables(ctx.state, 0, 'any'); + expect(ctx.state.datasource.getTagsAutoComplete).toBeCalledWith([], 'any', { range: currentRange }); + }); + + it('current time range is passed when getting list of tags for adding', async () => { + const currentRange = { from: 0, to: 1 }; + ctx.state.range = currentRange; + await getTagsAsSegmentsSelectables(ctx.state, 'any'); + expect(ctx.state.datasource.getTagsAutoComplete).toBeCalledWith([], 'any', { range: currentRange }); + }); + describe('when autocomplete for metric names is not available', () => { silenceConsoleOutput(); beforeEach(() => { diff --git a/public/app/plugins/datasource/graphite/state/providers.ts b/public/app/plugins/datasource/graphite/state/providers.ts index ade27bd9578..18ffc53c63b 100644 --- a/public/app/plugins/datasource/graphite/state/providers.ts +++ b/public/app/plugins/datasource/graphite/state/providers.ts @@ -106,7 +106,7 @@ export function getTagOperatorsSelectables(): Array { try { const tagExpressions = state.queryModel.renderTagExpressions(index); - const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix); + const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix, { range: state.range }); const altTags = map(values, 'text'); altTags.splice(0, 0, state.removeTagValue); @@ -134,7 +134,7 @@ async function getTagsAsSegments(state: GraphiteQueryEditorState, tagPrefix: str let tagsAsSegments: GraphiteSegment[]; try { const tagExpressions = state.queryModel.renderTagExpressions(); - const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix); + const values = await state.datasource.getTagsAutoComplete(tagExpressions, tagPrefix, { range: state.range }); tagsAsSegments = map(values, (val) => { return { value: val.text,