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

Commit 9f1fc3b

Browse files
authored
add support for label key description. (#136)
1 parent 5cd96ff commit 9f1fc3b

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/census-instrumentation/opencensus-proto v0.2.0
99
github.com/golang/protobuf v1.3.1
1010
github.com/google/go-cmp v0.2.0
11-
go.opencensus.io v0.20.2
11+
go.opencensus.io v0.21.0
1212
golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53
1313
golang.org/x/oauth2 v0.0.0-20190319182350-c85d3e98c914
1414
google.golang.org/api v0.3.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
9090
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
9191
go.opencensus.io v0.20.2 h1:NAfh7zF0/3/HqtMvJNZ/RFrSlCE6ZTlHmKfhL/Dm1Jk=
9292
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
93+
go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg=
94+
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
9395
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
9496
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
9597
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=

metrics.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (se *statsExporter) metricToMpbTs(ctx context.Context, metric *metricdata.M
162162
return timeSeries, nil
163163
}
164164

165-
func metricLabelsToTsLabels(defaults map[string]labelValue, labelKeys []string, labelValues []metricdata.LabelValue) (map[string]string, error) {
165+
func metricLabelsToTsLabels(defaults map[string]labelValue, labelKeys []metricdata.LabelKey, labelValues []metricdata.LabelValue) (map[string]string, error) {
166166
labels := make(map[string]string)
167167
// Fill in the defaults firstly, irrespective of if the labelKeys and labelValues are mismatched.
168168
for key, label := range defaults {
@@ -176,7 +176,7 @@ func metricLabelsToTsLabels(defaults map[string]labelValue, labelKeys []string,
176176

177177
for i, labelKey := range labelKeys {
178178
labelValue := labelValues[i]
179-
labels[sanitize(labelKey)] = labelValue.Value
179+
labels[sanitize(labelKey.Key)] = labelValue.Value
180180
}
181181

182182
return labels, nil
@@ -246,7 +246,7 @@ func (se *statsExporter) metricToMpbMetricDescriptor(metric *metricdata.Metric)
246246
return sdm, nil
247247
}
248248

249-
func metricLableKeysToLabels(defaults map[string]labelValue, labelKeys []string) []*labelpb.LabelDescriptor {
249+
func metricLableKeysToLabels(defaults map[string]labelValue, labelKeys []metricdata.LabelKey) []*labelpb.LabelDescriptor {
250250
labelDescriptors := make([]*labelpb.LabelDescriptor, 0, len(defaults)+len(labelKeys))
251251

252252
// Fill in the defaults first.
@@ -261,8 +261,8 @@ func metricLableKeysToLabels(defaults map[string]labelValue, labelKeys []string)
261261
// Now fill in those from the metric.
262262
for _, key := range labelKeys {
263263
labelDescriptors = append(labelDescriptors, &labelpb.LabelDescriptor{
264-
Key: sanitize(key),
265-
Description: "", // TODO: [rghetia] when descriptor is available use that.
264+
Key: sanitize(key.Key),
265+
Description: key.Description,
266266
ValueType: labelpb.LabelDescriptor_STRING, // We only use string tags
267267
})
268268
}

0 commit comments

Comments
 (0)