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

Commit

Permalink
Fix missing tags for HTTP metrics (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored May 20, 2019
1 parent c85ca67 commit 3809c9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/opencensus-exporter-prometheus/src/prometheus-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,16 @@ export class PrometheusStatsExporter implements StatsEventListener {
private getLabelValues(columns: TagKey[], tags: Map<TagKey, TagValue>):
labelValues {
const labels: labelValues = {};

// TODO: Consider make original tags map with string:TagValue type.
const tagsWithStringKey: Map<string, TagValue|undefined> = new Map();
for (const key of tags.keys()) {
tagsWithStringKey.set(key.name, tags.get(key));
}

columns.forEach((tagKey) => {
if (tags.has(tagKey)) {
const tagValue = tags.get(tagKey);
if (tagsWithStringKey.has(tagKey.name)) {
const tagValue = tagsWithStringKey.get(tagKey.name);
if (tagValue) {
labels[tagKey.name] = tagValue.value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Prometheus Stats Exporter', () => {
const prometheusServerUrl = `http://localhost:${options.port}/metrics`;
const tagKey1 = {name: 'tagKey1'};
const tagValue1 = {value: 'tagValue1'};
const tagKeys = [tagKey1];
const tagKeys = [{name: 'tagKey1'}];
const tagMap = new TagMap();
tagMap.set(tagKey1, tagValue1);

Expand Down

0 comments on commit 3809c9e

Please sign in to comment.