Browse Source

stackdriver: change reducer mapping for distribution metrics

- Distribution metrics are now mapped to more reducers
when the metric kind is cumulative.
- The witdth of the metrics dropdown is now much wider.
- Changed the text from Select Aggregation to Select Reducer
to line up with the UI in Stackdriver.
Daniel Lee 6 years ago
parent
commit
35fc0c5329

+ 2 - 1
public/app/plugins/datasource/stackdriver/components/Aggregations.test.tsx

@@ -49,7 +49,8 @@ describe('Aggregations', () => {
       });
       it('', () => {
         const options = wrapper.state().aggOptions[0].options;
-        expect(options.length).toEqual(5);
+
+        expect(options.length).toEqual(10);
         expect(options.map(o => o.value)).toEqual(expect.arrayContaining(['REDUCE_NONE']));
       });
     });

+ 1 - 1
public/app/plugins/datasource/stackdriver/components/Aggregations.tsx

@@ -73,7 +73,7 @@ export class Aggregations extends React.Component<Props, State> {
               value={crossSeriesReducer}
               variables={templateSrv.variables}
               options={aggOptions}
-              placeholder="Select Aggregation"
+              placeholder="Select Reducer"
               className="width-15"
             />
           </div>

+ 1 - 1
public/app/plugins/datasource/stackdriver/components/Metrics.tsx

@@ -185,7 +185,7 @@ export class Metrics extends React.Component<Props, State> {
                 },
               ]}
               placeholder="Select Metric"
-              className="width-15"
+              className="width-26"
             />
           </div>
           <div className="gf-form gf-form--grow">

+ 1 - 1
public/app/plugins/datasource/stackdriver/components/__snapshots__/Aggregations.test.tsx.snap

@@ -28,7 +28,7 @@ Array [
             <div
               className="css-0 gf-form-select-box__placeholder"
             >
-              Select Aggregation
+              Select Reducer
             </div>
             <div
               className="css-0"

+ 2 - 2
public/app/plugins/datasource/stackdriver/components/__snapshots__/QueryEditor.test.tsx.snap

@@ -72,7 +72,7 @@ Array [
         Metric
       </span>
       <div
-        className="css-0 gf-form-input gf-form-input--form-dropdown width-15"
+        className="css-0 gf-form-input gf-form-input--form-dropdown width-26"
         onKeyDown={[Function]}
       >
         <div
@@ -196,7 +196,7 @@ Array [
             <div
               className="css-0 gf-form-select-box__placeholder"
             >
-              Select Aggregation
+              Select Reducer
             </div>
             <div
               className="css-0"

+ 5 - 5
public/app/plugins/datasource/stackdriver/constants.ts

@@ -189,7 +189,7 @@ export const aggOptions = [
       ValueTypes.BOOL,
       ValueTypes.STRING,
     ],
-    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA],
+    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA, MetricKind.CUMULATIVE],
   },
   {
     text: 'count true',
@@ -207,25 +207,25 @@ export const aggOptions = [
     text: '99th percentile',
     value: 'REDUCE_PERCENTILE_99',
     valueTypes: [ValueTypes.INT64, ValueTypes.DOUBLE, ValueTypes.MONEY, ValueTypes.DISTRIBUTION],
-    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA],
+    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA, MetricKind.CUMULATIVE],
   },
   {
     text: '95th percentile',
     value: 'REDUCE_PERCENTILE_95',
     valueTypes: [ValueTypes.INT64, ValueTypes.DOUBLE, ValueTypes.MONEY, ValueTypes.DISTRIBUTION],
-    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA],
+    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA, MetricKind.CUMULATIVE],
   },
   {
     text: '50th percentile',
     value: 'REDUCE_PERCENTILE_50',
     valueTypes: [ValueTypes.INT64, ValueTypes.DOUBLE, ValueTypes.MONEY, ValueTypes.DISTRIBUTION],
-    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA],
+    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA, MetricKind.CUMULATIVE],
   },
   {
     text: '5th percentile',
     value: 'REDUCE_PERCENTILE_05',
     valueTypes: [ValueTypes.INT64, ValueTypes.DOUBLE, ValueTypes.MONEY, ValueTypes.DISTRIBUTION],
-    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA],
+    metricKinds: [MetricKind.GAUGE, MetricKind.DELTA, MetricKind.CUMULATIVE],
   },
 ];