Skip to content

Commit e8550bb

Browse files
committed
Replace '.' with '_' in prometheus
Signed-off-by: Harshil Gupta <[email protected]>
1 parent 125eb04 commit e8550bb

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

internal/storage/metricstore/elasticsearch/reader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ func TestGetCallRateBucketsToPoints_ErrorCases(t *testing.T) {
10021002
}
10031003
}
10041004

1005-
func TestGetLabelValues(t *testing.T) {
1005+
func TestGetAttributeValues(t *testing.T) {
10061006
// Define test cases to cover various scenarios
10071007
testCases := []struct {
10081008
name string
@@ -1219,7 +1219,7 @@ func compareBoolQuery(t *testing.T, expected, actual map[string]any) {
12191219
// Handle the case where actual filter is either array or single object
12201220
actualFilter, exists := actualBool["filter"]
12211221
if !exists {
1222-
t.Errorf("Expected filter but not found in actual query")
1222+
t.Error("Expected filter but not found in actual query")
12231223
return
12241224
}
12251225

internal/storage/metricstore/elasticsearch/testdata/output_attribute_key_values.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@
6363
"path_3": {}
6464
}
6565
}
66-
}
66+
}

internal/storage/metricstore/prometheus/metricstore/reader.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (m MetricsReader) GetAttributeValues(ctx context.Context, params *metricsto
264264
defer span.End()
265265

266266
span.SetAttributes(
267-
attribute.String("label_name", params.AttributeKey),
267+
attribute.String("attribute_name", params.AttributeKey),
268268
attribute.String("service", params.ServiceName),
269269
)
270270
// Build match[] selectors to filter by service names if provided
@@ -273,7 +273,8 @@ func (m MetricsReader) GetAttributeValues(ctx context.Context, params *metricsto
273273
matchers = append(matchers, fmt.Sprintf("{service_name=%q}", params.ServiceName))
274274
}
275275

276-
values, warnings, err := m.client.LabelValues(ctx, params.AttributeKey, matchers, time.Time{}, time.Time{})
276+
escapedKey := strings.ReplaceAll(params.AttributeKey, ".", "_")
277+
values, warnings, err := m.client.LabelValues(ctx, escapedKey, matchers, time.Time{}, time.Time{})
277278
if err != nil {
278279
span.RecordError(err)
279280
span.SetStatus(codes.Error, err.Error())

internal/storage/metricstore/prometheus/metricstore/reader_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ func assertMetrics(t *testing.T, gotMetrics *metrics.MetricFamily, wantLabels ma
10151015
assert.InDelta(t, float64(9223372036854), actualVal, 0.01)
10161016
}
10171017

1018-
func TestGetLabelValues(t *testing.T) {
1018+
func TestGetAttributeValues(t *testing.T) {
10191019
for _, tc := range []struct {
10201020
name string
10211021
labelName string
@@ -1031,7 +1031,7 @@ func TestGetLabelValues(t *testing.T) {
10311031
name: "get span_kind values for a specific service",
10321032
labelName: "span_kind",
10331033
serviceName: "emailservice",
1034-
wantPromQuery: `label_values(span_kind)`,
1034+
wantPromQuery: `attribute_name(span_kind)`,
10351035
wantValues: []string{"SPAN_KIND_SERVER", "SPAN_KIND_CLIENT", "SPAN_KIND_PRODUCER", "SPAN_KIND_CONSUMER"},
10361036
responsePayloadFile: "testdata/attribute_key_values_response.json",
10371037
wantError: false,
@@ -1041,7 +1041,7 @@ func TestGetLabelValues(t *testing.T) {
10411041
name: "handle server error",
10421042
labelName: "operation_name",
10431043
serviceName: "frontend",
1044-
wantPromQuery: `label_values(operation_name)`,
1044+
wantPromQuery: `attribute_name(operation_name)`,
10451045
wantError: true,
10461046
errorStatus: http.StatusInternalServerError,
10471047
},

0 commit comments

Comments
 (0)