mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Metrics summary * Update query * Remove colors * Update states * Add group by into its own component * Add group by to search and traceql tabs * Add spacing for group by * Update span kind values * Update span status code values * Update query based on target + group by * Cleanup * Only add targetQuery if not empty * Add kind=server to table * Update groupBy query logic * Add feature toggle * Use feature toggle * Self review * Update target query * Make gen-cue * Tweak query * Update states * useRef for onChange * Fix for steaming in search tab * Add loading state tests * metricsSummary tests * Datasource tests * Review updates * Update aria-label * Update test * Simplify response state * More manual testing and feedback from sync call * Prettier and fix test * Remove group by component from traceql tab * Cleanup, tests, error messages * Add feature tracking
130 lines
4.3 KiB
TypeScript
130 lines
4.3 KiB
TypeScript
import { v1Tags, v2Tags } from './SearchTraceQLEditor/utils.test';
|
|
import { TraceqlSearchScope } from './dataquery.gen';
|
|
import { TempoDatasource } from './datasource';
|
|
import TempoLanguageProvider from './language_provider';
|
|
import { Scope } from './types';
|
|
|
|
describe('Language_provider', () => {
|
|
describe('should get correct metrics summary tags', () => {
|
|
it('for API v1 tags', async () => {
|
|
const lp = setup(v1Tags);
|
|
const tags = lp.getMetricsSummaryTags();
|
|
expect(tags).toEqual(['bar', 'foo']);
|
|
});
|
|
|
|
it('for API v2 intrinsic tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getMetricsSummaryTags(TraceqlSearchScope.Intrinsic);
|
|
expect(tags).toEqual(['duration', 'kind', 'name', 'status']);
|
|
});
|
|
|
|
it('for API v2 resource tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getMetricsSummaryTags(TraceqlSearchScope.Resource);
|
|
expect(tags).toEqual(['cluster', 'container']);
|
|
});
|
|
|
|
it('for API v2 span tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getMetricsSummaryTags(TraceqlSearchScope.Span);
|
|
expect(tags).toEqual(['db']);
|
|
});
|
|
|
|
it('for API v2 unscoped tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getMetricsSummaryTags(TraceqlSearchScope.Unscoped);
|
|
expect(tags).toEqual(['cluster', 'container', 'db']);
|
|
});
|
|
});
|
|
|
|
describe('should get correct tags', () => {
|
|
it('for API v1 tags', async () => {
|
|
const lp = setup(v1Tags);
|
|
const tags = lp.getTags();
|
|
expect(tags).toEqual(['bar', 'foo', 'status']);
|
|
});
|
|
|
|
it('for API v2 resource tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getTags(TraceqlSearchScope.Resource);
|
|
expect(tags).toEqual(['cluster', 'container']);
|
|
});
|
|
|
|
it('for API v2 span tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getTags(TraceqlSearchScope.Span);
|
|
expect(tags).toEqual(['db']);
|
|
});
|
|
|
|
it('for API v2 unscoped tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getTags(TraceqlSearchScope.Unscoped);
|
|
expect(tags).toEqual(['cluster', 'container', 'db']);
|
|
});
|
|
});
|
|
|
|
describe('should get correct traceql autocomplete tags', () => {
|
|
it('for API v1 tags', async () => {
|
|
const lp = setup(v1Tags);
|
|
const tags = lp.getTraceqlAutocompleteTags();
|
|
expect(tags).toEqual(['bar', 'foo', 'status']);
|
|
});
|
|
|
|
it('for API v2 resource tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getTraceqlAutocompleteTags(TraceqlSearchScope.Resource);
|
|
expect(tags).toEqual(['cluster', 'container']);
|
|
});
|
|
|
|
it('for API v2 span tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getTraceqlAutocompleteTags(TraceqlSearchScope.Span);
|
|
expect(tags).toEqual(['db']);
|
|
});
|
|
|
|
it('for API v2 unscoped tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getTraceqlAutocompleteTags(TraceqlSearchScope.Unscoped);
|
|
expect(tags).toEqual(['cluster', 'container', 'db']);
|
|
});
|
|
|
|
it('for API v2 tags with no scope', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getTraceqlAutocompleteTags();
|
|
expect(tags).toEqual(['cluster', 'container', 'db']);
|
|
});
|
|
});
|
|
|
|
describe('should get correct autocomplete tags', () => {
|
|
it('for API v1 tags', async () => {
|
|
const lp = setup(v1Tags);
|
|
const tags = lp.getAutocompleteTags();
|
|
expect(tags).toEqual(['bar', 'foo', 'status', 'status.code']);
|
|
});
|
|
|
|
it('for API v2 tags', async () => {
|
|
const lp = setup(undefined, v2Tags);
|
|
const tags = lp.getAutocompleteTags();
|
|
expect(tags).toEqual(['cluster', 'container', 'db', 'duration', 'kind', 'name', 'status']);
|
|
});
|
|
});
|
|
|
|
const setup = (tagsV1?: string[], tagsV2?: Scope[]) => {
|
|
const datasource: TempoDatasource = {
|
|
search: {
|
|
filters: [],
|
|
},
|
|
} as unknown as TempoDatasource;
|
|
|
|
const lp = new TempoLanguageProvider(datasource);
|
|
if (tagsV1) {
|
|
lp.setV1Tags(tagsV1);
|
|
} else if (tagsV2) {
|
|
lp.setV2Tags(tagsV2);
|
|
}
|
|
datasource.languageProvider = lp;
|
|
|
|
return lp;
|
|
};
|
|
});
|