From 45f49c2e5bec50302ea4715603f698760b94580f Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 9 Nov 2018 10:29:22 +0100 Subject: [PATCH] stackdriver: remove services query type --- .../stackdriver/StackdriverMetricFindQuery.ts | 19 +------------------ .../components/TemplateQueryComponent.tsx | 6 +++--- .../datasource/stackdriver/functions.ts | 3 --- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts b/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts index dd7fe6a22e3..e3537cc9599 100644 --- a/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts +++ b/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts @@ -2,12 +2,7 @@ import has from 'lodash/has'; import isString from 'lodash/isString'; import { alignmentPeriods } from './constants'; import { MetricFindQueryTypes } from './types'; -import { - extractServicesFromMetricDescriptors, - getMetricTypesByService, - getAlignmentOptionsByMetric, - getAggregationOptionsByMetric, -} from './functions'; +import { getMetricTypesByService, getAlignmentOptionsByMetric, getAggregationOptionsByMetric } from './functions'; export default class StackdriverMetricFindQuery { constructor(private datasource) {} @@ -15,8 +10,6 @@ export default class StackdriverMetricFindQuery { async query(query: any) { try { switch (query.selectedQueryType) { - case MetricFindQueryTypes.Services: - return this.handleServiceQuery(); case MetricFindQueryTypes.MetricTypes: return this.handleMetricTypesQuery(query); case MetricFindQueryTypes.MetricLabels: @@ -39,16 +32,6 @@ export default class StackdriverMetricFindQuery { } } - async handleServiceQuery() { - const metricDescriptors = await this.datasource.getMetricTypes(this.datasource.projectName); - const services = extractServicesFromMetricDescriptors(metricDescriptors); - return services.map(s => ({ - text: s.serviceShortName, - value: s.name, - expandable: true, - })); - } - async handleMetricTypesQuery({ selectedService }) { if (!selectedService) { return []; diff --git a/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx b/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx index 8170521ff87..e9784d485dd 100644 --- a/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx +++ b/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx @@ -1,12 +1,12 @@ import React, { PureComponent } from 'react'; +import uniqBy from 'lodash/uniqBy'; import { TemplateQueryProps } from 'app/types/plugins'; import SimpleSelect from './SimpleSelect'; -import { getMetricTypes, extractServicesFromMetricDescriptors } from '../functions'; +import { getMetricTypes } from '../functions'; import { MetricFindQueryTypes, TemplateQueryComponentData } from '../types'; export class StackdriverTemplateQueryComponent extends PureComponent { queryTypes: Array<{ value: string; name: string }> = [ - { value: MetricFindQueryTypes.Services, name: 'Services' }, { value: MetricFindQueryTypes.MetricTypes, name: 'Metric Types' }, { value: MetricFindQueryTypes.MetricLabels, name: 'Metric Labels' }, { value: MetricFindQueryTypes.ResourceLabels, name: 'Resource Labels' }, @@ -38,7 +38,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent ({ + const services = uniqBy(metricDescriptors, 'service').map(m => ({ value: m.service, name: m.serviceShortName, })); diff --git a/public/app/plugins/datasource/stackdriver/functions.ts b/public/app/plugins/datasource/stackdriver/functions.ts index 30b4a7b84f6..79e8aa30325 100644 --- a/public/app/plugins/datasource/stackdriver/functions.ts +++ b/public/app/plugins/datasource/stackdriver/functions.ts @@ -1,8 +1,5 @@ -import uniqBy from 'lodash/uniqBy'; import { alignOptions, aggOptions } from './constants'; -export const extractServicesFromMetricDescriptors = metricDescriptors => uniqBy(metricDescriptors, 'service'); - export const getMetricTypesByService = (metricDescriptors, service) => metricDescriptors.filter(m => m.service === service);