Skip to content

Commit

Permalink
add support for exponential histograms in the GMP exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed May 30, 2024
1 parent 51ae889 commit 3ac20a6
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 6 deletions.
2 changes: 2 additions & 0 deletions exporter/collector/googlemanagedprometheus/naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func (c Config) GetMetricName(baseName string, metric pmetric.Metric) (string, e
}
return compliantName + "/summary", nil
case pmetric.MetricTypeHistogram:
fallthrough
case pmetric.MetricTypeExponentialHistogram:
return compliantName + "/histogram", nil
default:
return "", fmt.Errorf("unsupported metric datatype: %v", metric.Type())
Expand Down
8 changes: 4 additions & 4 deletions exporter/collector/googlemanagedprometheus/naming_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ func TestGetMetricName(t *testing.T) {
expected: "hello/histogram",
},
{
desc: "other",
baseName: "other",
desc: "exponential histogram",
baseName: "hello",
metric: func(m pmetric.Metric) {
m.SetName("other")
m.SetName("hello")
m.SetEmptyExponentialHistogram()
},
expectErr: true,
expected: "hello/histogram",
},
{
desc: "untyped gauge with feature gate enabled returns unknown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ var MetricsTestCases = []TestCase{
// prometheus_target is not supported by the SDK
SkipForSDK: true,
},
{
Name: "[GMP] Exponential Histogram becomes a GCM Distribution with exponential bucketOptions and a /histogram suffix",
OTLPInputFixturePath: "testdata/fixtures/metrics/exponential_histogram.json",
ExpectFixturePath: "testdata/fixtures/metrics/exponential_histogram_gmp_expect.json",
ConfigureCollector: configureGMPCollector,
// prometheus_target is not supported by the SDK
SkipForSDK: true,
},
{
Name: "[GMP] Summary becomes a GCM Cumulative for sum/count, Gauges for quantiles",
OTLPInputFixturePath: "testdata/fixtures/metrics/summary.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,208 @@
{
"name": "projects/fakeprojectid",
"timeSeries": [
{
"metric": {
"type": "prometheus.googleapis.com/durationhist_seconds/histogram"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "",
"instance": "",
"job": "",
"location": "",
"namespace": ""
}
},
"metricKind": "CUMULATIVE",
"valueType": "DISTRIBUTION",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z",
"startTime": "1970-01-01T00:00:00Z"
},
"value": {
"distributionValue": {
"count": "10000",
"mean": 198.4636328211394,
"bucketOptions": {
"exponentialBuckets": {
"numFiniteBuckets": 113,
"growthFactor": 1.0442737824274138,
"scale": 98.70149282610706
}
},
"bucketCounts": [
"0",
"646",
"736",
"733",
"639",
"606",
"585",
"480",
"481",
"411",
"436",
"366",
"304",
"309",
"270",
"226",
"210",
"238",
"169",
"181",
"178",
"149",
"132",
"131",
"117",
"109",
"89",
"107",
"80",
"78",
"75",
"56",
"73",
"59",
"51",
"46",
"53",
"22",
"31",
"35",
"24",
"23",
"31",
"18",
"8",
"16",
"12",
"15",
"13",
"12",
"12",
"12",
"7",
"7",
"7",
"9",
"5",
"4",
"4",
"8",
"6",
"3",
"1",
"4",
"2",
"2",
"4",
"5",
"1",
"2",
"2",
"1",
"0",
"1",
"2",
"2",
"1",
"0",
"0",
"2",
"1",
"2",
"1",
"0",
"2",
"0",
"0",
"2",
"0",
"1",
"1",
"0",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0",
"1",
"1",
"0",
"1",
"0"
]
}
}
}
],
"unit": "s"
},
{
"metric": {
"type": "prometheus.googleapis.com/foohist_seconds/histogram"
},
"resource": {
"type": "prometheus_target",
"labels": {
"cluster": "",
"instance": "",
"job": "",
"location": "",
"namespace": ""
}
},
"metricKind": "CUMULATIVE",
"valueType": "DISTRIBUTION",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z",
"startTime": "1970-01-01T00:00:00Z"
},
"value": {
"distributionValue": {
"count": "7",
"mean": 1.7857142857142858,
"bucketOptions": {
"exponentialBuckets": {
"numFiniteBuckets": 3,
"growthFactor": 4,
"scale": 0.25
}
},
"bucketCounts": [
"2",
"1",
"3",
"1",
"0"
]
}
}
}
],
"unit": "s"
},
{
"metric": {
"type": "prometheus.googleapis.com/target_info/gauge"
Expand Down Expand Up @@ -55,7 +257,7 @@
"startTime": "1970-01-01T00:00:00Z"
},
"value": {
"int64Value": "1"
"int64Value": "3"
}
}
]
Expand Down Expand Up @@ -410,5 +612,6 @@
}
}
]
}
},
"userAgent": "opentelemetry-collector-contrib latest grpc-go/1.63.2"
}

0 comments on commit 3ac20a6

Please sign in to comment.