Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit dfa4612

Browse files
authored
Fix Metric: LabelValue (#195)
* Fix Metric: LabelValue * Add package-lock
1 parent d4b3d80 commit dfa4612

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencensus-core/src/metrics/export/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ export interface TimeSeries {
136136
}
137137

138138
/** The LabelValue type. null value indicates an unset. */
139-
export type LabelValue = string|null;
139+
export interface LabelValue {
140+
/** The value for the label. */
141+
readonly value: string|null;
142+
}
140143

141144
/** A timestamped measurement. */
142145
export interface Point {

packages/opencensus-core/src/stats/metric-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export class MetricUtils {
7373
* @param tags
7474
*/
7575
static tagValuesToLabelValues(tags: Tags): LabelValue[] {
76-
return Object.keys(tags).map(key => tags[key] as LabelValue);
76+
return Object.keys(tags).map(key => {
77+
return {value: tags[key]} as LabelValue;
78+
});
7779
}
7880
}

packages/opencensus-core/test/test-metric-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('MetricUtil', () => {
4848
it('should convert tag values to label values', () => {
4949
const tags: Tags = {test: 'test1', tag: 'test2', empty: '', fake: null};
5050
assert.deepStrictEqual(
51-
MetricUtils.tagValuesToLabelValues(tags), ['test1', 'test2', '', null]);
51+
MetricUtils.tagValuesToLabelValues(tags),
52+
[{value: 'test1'}, {value: 'test2'}, {value: ''}, {value: null}]);
5253
});
5354
});

0 commit comments

Comments
 (0)