Skip to content

Commit

Permalink
Fix GMP metric name handling (#622)
Browse files Browse the repository at this point in the history
* Add broken integration test cases for the GMP exporter

* Fix handling of degenerate OTLP metric names in GMP exporter

* Add test case with prometheus.googleapis.com

* Fix GMP-style metric name to be fully correct
  • Loading branch information
quentinmit committed Apr 7, 2023
1 parent 3e802e2 commit 02fd6f2
Show file tree
Hide file tree
Showing 3 changed files with 290 additions and 3 deletions.
Expand Up @@ -379,10 +379,101 @@
}
]
}
},
{
"name":"otlp.test.gauge",
"description":"Normal metric name",
"unit":"seconds",
"gauge":{
"dataPoints":[
{
"timeUnixNano":"1649443516286000000",
"asDouble":0.00699415
}
]
}
},
{
"name":"workload.googleapis.com/otlp.test.prefix1",
"description":"URI-style metric name",
"unit":"seconds",
"gauge":{
"dataPoints":[
{
"timeUnixNano":"1649443516286000000",
"asDouble":0.00699415
}
]
}
},
{
"name":".invalid.googleapis.com/otlp.test.prefix2",
"description":"URI-style metric name with invalid domain",
"unit":"seconds",
"gauge":{
"dataPoints":[
{
"timeUnixNano":"1649443516286000000",
"asDouble":0.00699415
}
]
}
},
{
"name":"otlp.test.prefix3/workload.googleapis.com/abc",
"description":"Broken URI-style metric name",
"unit":"seconds",
"gauge":{
"dataPoints":[
{
"timeUnixNano":"1649443516286000000",
"asDouble":0.00699415
}
]
}
},
{
"name":"WORKLOAD.GOOGLEAPIS.COM/otlp.test.prefix4",
"description":"Uppercase URI-style metric name",
"unit":"seconds",
"gauge":{
"dataPoints":[
{
"timeUnixNano":"1649443516286000000",
"asDouble":0.00699415
}
]
}
},
{
"name":"WORKLOAD.googleapis.com/otlp.test.prefix5",
"description":"Partial uppercase URI-style metric name",
"unit":"seconds",
"gauge":{
"dataPoints":[
{
"timeUnixNano":"1649443516286000000",
"asDouble":0.00699415
}
]
}
},
{
"name":"prometheus.googleapis.com/otlp_test_prefix6/gauge",
"description":"GMP metric names are not special",
"unit":"seconds",
"gauge":{
"dataPoints":[
{
"timeUnixNano":"1649443516286000000",
"asDouble":0.00699415
}
]
}
}
]
}
]
}
]
}
}
Expand Up @@ -704,6 +704,202 @@
}
]
},
{
"metric": {
"type": "prometheus.googleapis.com/otlp_test_gauge/gauge"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "rabbitmq-test-dev",
"instance": "10.92.5.2:15692",
"job": "demo",
"location": "us-central1-c",
"namespace": "default"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"doubleValue": 0.00699415
}
}
],
"unit": "seconds"
},
{
"metric": {
"type": "prometheus.googleapis.com/workload_googleapis_com_otlp_test_prefix1/gauge"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "rabbitmq-test-dev",
"instance": "10.92.5.2:15692",
"job": "demo",
"location": "us-central1-c",
"namespace": "default"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"doubleValue": 0.00699415
}
}
],
"unit": "seconds"
},
{
"metric": {
"type": "prometheus.googleapis.com/invalid_googleapis_com_otlp_test_prefix2/gauge"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "rabbitmq-test-dev",
"instance": "10.92.5.2:15692",
"job": "demo",
"location": "us-central1-c",
"namespace": "default"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"doubleValue": 0.00699415
}
}
],
"unit": "seconds"
},
{
"metric": {
"type": "prometheus.googleapis.com/otlp_test_prefix3_workload_googleapis_com_abc/gauge"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "rabbitmq-test-dev",
"instance": "10.92.5.2:15692",
"job": "demo",
"location": "us-central1-c",
"namespace": "default"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"doubleValue": 0.00699415
}
}
],
"unit": "seconds"
},
{
"metric": {
"type": "prometheus.googleapis.com/WORKLOAD_GOOGLEAPIS_COM_otlp_test_prefix4/gauge"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "rabbitmq-test-dev",
"instance": "10.92.5.2:15692",
"job": "demo",
"location": "us-central1-c",
"namespace": "default"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"doubleValue": 0.00699415
}
}
],
"unit": "seconds"
},
{
"metric": {
"type": "prometheus.googleapis.com/WORKLOAD_googleapis_com_otlp_test_prefix5/gauge"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "rabbitmq-test-dev",
"instance": "10.92.5.2:15692",
"job": "demo",
"location": "us-central1-c",
"namespace": "default"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"doubleValue": 0.00699415
}
}
],
"unit": "seconds"
},
{
"metric": {
"type": "prometheus.googleapis.com/prometheus_googleapis_com_otlp_test_prefix6_gauge/gauge"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "rabbitmq-test-dev",
"instance": "10.92.5.2:15692",
"job": "demo",
"location": "us-central1-c",
"namespace": "default"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"doubleValue": 0.00699415
}
}
],
"unit": "seconds"
},
{
"metric": {
"type": "prometheus.googleapis.com/target_info/gauge",
Expand Down Expand Up @@ -765,7 +961,7 @@
"startTime": "1970-01-01T00:00:00Z"
},
"value": {
"int64Value": "22"
"int64Value": "29"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion exporter/collector/metrics.go
Expand Up @@ -929,7 +929,7 @@ func (m *metricMapper) metricNameToType(name string, metric pmetric.Metric) (str
if err != nil {
return "", err
}
return path.Join(m.getMetricNamePrefix(name), metricName), nil
return path.Join(m.getMetricNamePrefix(metricName), metricName), nil
}

// defaultGetMetricName does not (further) customize the baseName.
Expand Down

0 comments on commit 02fd6f2

Please sign in to comment.