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

Commit 3809c9e

Browse files
authored
Fix missing tags for HTTP metrics (#538)
1 parent c85ca67 commit 3809c9e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/opencensus-exporter-prometheus/src/prometheus-stats.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,16 @@ export class PrometheusStatsExporter implements StatsEventListener {
103103
private getLabelValues(columns: TagKey[], tags: Map<TagKey, TagValue>):
104104
labelValues {
105105
const labels: labelValues = {};
106+
107+
// TODO: Consider make original tags map with string:TagValue type.
108+
const tagsWithStringKey: Map<string, TagValue|undefined> = new Map();
109+
for (const key of tags.keys()) {
110+
tagsWithStringKey.set(key.name, tags.get(key));
111+
}
112+
106113
columns.forEach((tagKey) => {
107-
if (tags.has(tagKey)) {
108-
const tagValue = tags.get(tagKey);
114+
if (tagsWithStringKey.has(tagKey.name)) {
115+
const tagValue = tagsWithStringKey.get(tagKey.name);
109116
if (tagValue) {
110117
labels[tagKey.name] = tagValue.value;
111118
}

packages/opencensus-exporter-prometheus/test/test-prometheus-stats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Prometheus Stats Exporter', () => {
2424
const prometheusServerUrl = `http://localhost:${options.port}/metrics`;
2525
const tagKey1 = {name: 'tagKey1'};
2626
const tagValue1 = {value: 'tagValue1'};
27-
const tagKeys = [tagKey1];
27+
const tagKeys = [{name: 'tagKey1'}];
2828
const tagMap = new TagMap();
2929
tagMap.set(tagKey1, tagValue1);
3030

0 commit comments

Comments
 (0)