@@ -18,7 +18,7 @@ import {DistributionValue, LabelKey, LabelValue, MetricDescriptor as OCMetricDes
1818import * as assert from 'assert' ;
1919
2020import { StackdriverStatsExporter } from '../src/stackdriver-monitoring' ;
21- import { createDisplayName , createDistribution , createLabelDescriptor , createMetric , createMetricDescriptorData , createMetricKind , createPoint , createTimeSeriesList , createValueType , getMetricType , OPENCENSUS_TASK_VALUE_DEFAULT } from '../src/stackdriver-stats-utils' ;
21+ import { createMetricDescriptorData , createTimeSeriesList , OPENCENSUS_TASK_VALUE_DEFAULT , TEST_ONLY } from '../src/stackdriver-stats-utils' ;
2222import { Distribution , MetricDescriptor , MetricKind , ValueType } from '../src/types' ;
2323
2424const METRIC_NAME = 'metric-name' ;
@@ -29,39 +29,43 @@ describe('Stackdriver Stats Exporter Utils', () => {
2929 describe ( 'createMetricKind()' , ( ) => {
3030 it ( 'should return a Stackdriver MetricKind' , ( ) => {
3131 assert . strictEqual (
32- createMetricKind ( MetricDescriptorType . CUMULATIVE_INT64 ) ,
32+ TEST_ONLY . createMetricKind ( MetricDescriptorType . CUMULATIVE_INT64 ) ,
3333 MetricKind . CUMULATIVE ) ;
3434 assert . strictEqual (
35- createMetricKind ( MetricDescriptorType . GAUGE_INT64 ) , MetricKind . GAUGE ) ;
35+ TEST_ONLY . createMetricKind ( MetricDescriptorType . GAUGE_INT64 ) ,
36+ MetricKind . GAUGE ) ;
3637 assert . strictEqual (
37- createMetricKind ( MetricDescriptorType . GAUGE_DOUBLE ) ,
38+ TEST_ONLY . createMetricKind ( MetricDescriptorType . GAUGE_DOUBLE ) ,
3839 MetricKind . GAUGE ) ;
3940 assert . strictEqual (
40- createMetricKind ( MetricDescriptorType . SUMMARY ) ,
41+ TEST_ONLY . createMetricKind ( MetricDescriptorType . SUMMARY ) ,
4142 MetricKind . UNSPECIFIED ) ;
4243 } ) ;
4344 } ) ;
4445
4546 describe ( 'createValueType()' , ( ) => {
4647 it ( 'should return a Stackdriver ValueType' , ( ) => {
4748 assert . strictEqual (
48- createValueType ( MetricDescriptorType . GAUGE_DOUBLE ) , ValueType . DOUBLE ) ;
49+ TEST_ONLY . createValueType ( MetricDescriptorType . GAUGE_DOUBLE ) ,
50+ ValueType . DOUBLE ) ;
4951 assert . strictEqual (
50- createValueType ( MetricDescriptorType . CUMULATIVE_INT64 ) ,
52+ TEST_ONLY . createValueType ( MetricDescriptorType . CUMULATIVE_INT64 ) ,
5153 ValueType . INT64 ) ;
5254 assert . strictEqual (
53- createValueType ( MetricDescriptorType . GAUGE_INT64 ) , ValueType . INT64 ) ;
55+ TEST_ONLY . createValueType ( MetricDescriptorType . GAUGE_INT64 ) ,
56+ ValueType . INT64 ) ;
5457 assert . strictEqual (
55- createValueType ( MetricDescriptorType . CUMULATIVE_DOUBLE ) ,
58+ TEST_ONLY . createValueType ( MetricDescriptorType . CUMULATIVE_DOUBLE ) ,
5659 ValueType . DOUBLE ) ;
5760 assert . strictEqual (
58- createValueType ( MetricDescriptorType . CUMULATIVE_DISTRIBUTION ) ,
61+ TEST_ONLY . createValueType (
62+ MetricDescriptorType . CUMULATIVE_DISTRIBUTION ) ,
5963 ValueType . DISTRIBUTION ) ;
6064 assert . strictEqual (
61- createValueType ( MetricDescriptorType . GAUGE_DISTRIBUTION ) ,
65+ TEST_ONLY . createValueType ( MetricDescriptorType . GAUGE_DISTRIBUTION ) ,
6266 ValueType . DISTRIBUTION ) ;
6367 assert . strictEqual (
64- createValueType ( MetricDescriptorType . SUMMARY ) ,
68+ TEST_ONLY . createValueType ( MetricDescriptorType . SUMMARY ) ,
6569 ValueType . VALUE_TYPE_UNSPECIFIED ) ;
6670 } ) ;
6771 } ) ;
@@ -70,7 +74,7 @@ describe('Stackdriver Stats Exporter Utils', () => {
7074 const labelKeys : LabelKey [ ] = [ { 'key' : 'key' , 'description' : 'desc' } ] ;
7175
7276 it ( 'should return a Stackdriver LabelDescriptor' , ( ) => {
73- assert . deepStrictEqual ( createLabelDescriptor ( labelKeys ) , [
77+ assert . deepStrictEqual ( TEST_ONLY . createLabelDescriptor ( labelKeys ) , [
7478 { description : 'desc' , key : 'key' , valueType : 'STRING' } , {
7579 description : 'Opencensus task identifier' ,
7680 key : 'opencensus_task' ,
@@ -83,15 +87,16 @@ describe('Stackdriver Stats Exporter Utils', () => {
8387 describe ( 'createDisplayName()' , ( ) => {
8488 it ( 'should return a Stackdriver DisplayName' , ( ) => {
8589 assert . strictEqual (
86- createDisplayName ( 'demo/latency' , 'custom.googleapis.com/opencensus' ) ,
90+ TEST_ONLY . createDisplayName (
91+ 'demo/latency' , 'custom.googleapis.com/opencensus' ) ,
8792 'custom.googleapis.com/opencensus/demo/latency' ) ;
8893 } ) ;
8994 } ) ;
9095
91- describe ( 'getMetricType ()' , ( ) => {
96+ describe ( 'createMetricType ()' , ( ) => {
9297 it ( 'should return a Stackdriver MetricType' , ( ) => {
9398 assert . strictEqual (
94- getMetricType ( 'demo/latency' , 'opencensus' ) ,
99+ TEST_ONLY . createMetricType ( 'demo/latency' , 'opencensus' ) ,
95100 'opencensus/demo/latency' ) ;
96101 } ) ;
97102 } ) ;
@@ -108,7 +113,7 @@ describe('Stackdriver Stats Exporter Utils', () => {
108113 } ;
109114
110115 it ( 'should return a Stackdriver Metric' , ( ) => {
111- const metric = createMetric (
116+ const metric = TEST_ONLY . createMetric (
112117 metricDescriptor , labelValues ,
113118 StackdriverStatsExporter . CUSTOM_OPENCENSUS_DOMAIN ) ;
114119 assert . strictEqual (
@@ -120,8 +125,8 @@ describe('Stackdriver Stats Exporter Utils', () => {
120125
121126 it ( 'should return a Stackdriver Metric With External Metric Domain' , ( ) => {
122127 const prometheusDomain = 'external.googleapis.com/prometheus/' ;
123- const metric =
124- createMetric ( metricDescriptor , labelValues , prometheusDomain ) ;
128+ const metric = TEST_ONLY . createMetric (
129+ metricDescriptor , labelValues , prometheusDomain ) ;
125130 assert . strictEqual ( metric . type , `${ prometheusDomain } ${ METRIC_NAME } ` ) ;
126131 assert . deepStrictEqual (
127132 metric . labels ,
@@ -130,7 +135,8 @@ describe('Stackdriver Stats Exporter Utils', () => {
130135
131136 it ( 'should return a Stackdriver Metric With Empty Label' , ( ) => {
132137 const prometheusDomain = 'external.googleapis.com/prometheus/' ;
133- const metric = createMetric ( metricDescriptor , [ ] , prometheusDomain ) ;
138+ const metric =
139+ TEST_ONLY . createMetric ( metricDescriptor , [ ] , prometheusDomain ) ;
134140 assert . strictEqual ( metric . type , `${ prometheusDomain } ${ METRIC_NAME } ` ) ;
135141 assert . deepStrictEqual (
136142 metric . labels , { 'opencensus_task' : OPENCENSUS_TASK_VALUE_DEFAULT } ) ;
@@ -146,7 +152,8 @@ describe('Stackdriver Stats Exporter Utils', () => {
146152 buckets : [ { count : 3 } , { count : 1 } , { count : 2 } , { count : 4 } ] ,
147153 } ;
148154 it ( 'should return a Stackdriver Distribution' , ( ) => {
149- const distribution : Distribution = createDistribution ( distributionValue ) ;
155+ const distribution : Distribution =
156+ TEST_ONLY . createDistribution ( distributionValue ) ;
150157
151158 assert . strictEqual ( distribution . count , 3 ) ;
152159 assert . strictEqual ( distribution . mean , 0.6666666666666666 ) ;
@@ -238,7 +245,7 @@ describe('Stackdriver Stats Exporter Utils', () => {
238245 } ;
239246
240247 it ( 'should return a Stackdriver Point' , ( ) => {
241- const pt = createPoint ( doublePoint , null , ValueType . DOUBLE ) ;
248+ const pt = TEST_ONLY . createPoint ( doublePoint , null , ValueType . DOUBLE ) ;
242249
243250 assert . deepStrictEqual ( pt , {
244251 value : { doubleValue : 12345678.2 } ,
@@ -247,7 +254,8 @@ describe('Stackdriver Stats Exporter Utils', () => {
247254 } ) ;
248255
249256 it ( 'should return a Stackdriver Cumulative Point' , ( ) => {
250- const pt = createPoint ( intPoint , startTimestamp , ValueType . INT64 ) ;
257+ const pt =
258+ TEST_ONLY . createPoint ( intPoint , startTimestamp , ValueType . INT64 ) ;
251259
252260 assert . deepStrictEqual ( pt , {
253261 value : { int64Value : 12345678 } ,
@@ -259,7 +267,7 @@ describe('Stackdriver Stats Exporter Utils', () => {
259267 } ) ;
260268
261269 it ( 'should return a Stackdriver Distribution Point' , ( ) => {
262- const pt = createPoint (
270+ const pt = TEST_ONLY . createPoint (
263271 distributionPoint , startTimestamp , ValueType . DISTRIBUTION ) ;
264272
265273 assert . deepStrictEqual ( pt , {
0 commit comments