Skip to content

Commit

Permalink
exporter/metric: Add support to export Distribution with Exemplars an…
Browse files Browse the repository at this point in the history
…d Exponential Histograms. (#777)

* exporter/metric: Add support to export Distribution with Exemplars.

* example/metric: Add expoential histogram example.

* Update example.go.

* exporter/metric: Transform ExponentialHistogram to Distribution.

* example: Update date.

* example: Use views for histogram.

* Fixed ExponentialHist to Distribution translation.

* Add more distribution metric views to example.go.

* Fix typo.

* Remove local dev artifacts.

* Tidy go.mod.

* Update dependencies.

* Further update dependencies.

* Go mod tidy.

* Removed debuggin and unused code.

* Fix example parameters and logs.

* Use `positiveBucketCounts` for mean calculation.

* Fix linter errors.

* Use `s` units instead of `ms`.

* Use `collector/metric.go` implementation of `exponentialHistogramPoint` as reference for `expHistToDistribution`.

* Write to `workload.googleapis.com` instead of `custom.googleapis.com`

* Add `dashboard.json` to visualize `example.go`

* Fix `expHistToDistribution`

* Use correct type `ExponentialHistogramDataPoint`.

* Fix usage of `math.IsNan`

* Add `TODO` for missing `[]attachments` to exemplars exporting.

* Set copyright year to `2024`

* Update example/metric/exponential_histogram/example.go

Co-authored-by: David Ashpole <dashpole@google.com>
Signed-off-by: Francisco Valente Castro <1435136+franciscovalentecastro@users.noreply.github.com>

* Add support for `int64` ExponentialHistogram.

* Pass all views once to `WithView`.

* Remove `workloadMetricsPrefixFormatter`.

---------

Signed-off-by: Francisco Valente Castro <1435136+franciscovalentecastro@users.noreply.github.com>
Co-authored-by: David Ashpole <dashpole@google.com>
  • Loading branch information
franciscovalentecastro and dashpole committed Mar 4, 2024
1 parent 87124ac commit c7b17b6
Show file tree
Hide file tree
Showing 5 changed files with 1,071 additions and 1 deletion.
367 changes: 367 additions & 0 deletions example/metric/exponential_histogram/dashboard.json
@@ -0,0 +1,367 @@
{
"displayName": "Exponential Histogram",
"dashboardFilters": [],
"mosaicLayout": {
"columns": 48,
"tiles": [
{
"xPos": 17,
"width": 15,
"height": 17,
"widget": {
"title": "Linear Buckets - latency_b",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"legendTemplate": "Latency",
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_b\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"width": 17,
"height": 17,
"widget": {
"title": "Exponential Buckets - latency_a",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"legendTemplate": "Latency",
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_a\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"xPos": 32,
"width": 16,
"height": 17,
"widget": {
"title": "Default Buckets - latency_c",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"legendTemplate": "Latency",
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_c\" resource.type=\"gce_instance\" metadata.system_labels.\"name\"=\"exemplar-dev\" resource.label.\"project_id\"=\"fcovalente-dev\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"yPos": 17,
"width": 17,
"height": 16,
"widget": {
"title": "Exponential Buckets - latency_shifted_a",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_shifted_a\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"xPos": 17,
"yPos": 17,
"width": 15,
"height": 16,
"widget": {
"title": "Linear Buckets - latency_shifted_b",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_shifted_b\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"xPos": 32,
"yPos": 17,
"width": 16,
"height": 16,
"widget": {
"title": "Default Buckets - latency_shifted_c",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_shifted_c\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"yPos": 33,
"width": 17,
"height": 16,
"widget": {
"title": "Exponential Buckets - latency_multimodal_a",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_multimodal_a\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"xPos": 17,
"yPos": 33,
"width": 15,
"height": 16,
"widget": {
"title": "Linear Buckets - latency_multimodal_b",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_multimodal_b\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
},
{
"xPos": 32,
"yPos": 33,
"width": 16,
"height": 16,
"widget": {
"title": "Default Buckets - latency_multimodal_c",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"breakdowns": [],
"dimensions": [],
"measures": [],
"minAlignmentPeriod": "60s",
"plotType": "HEATMAP",
"targetAxis": "Y1",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [],
"perSeriesAligner": "ALIGN_DELTA"
},
"filter": "metric.type=\"workload.googleapis.com/latency_multimodal_c\" resource.type=\"gce_instance\""
}
}
}
],
"thresholds": [],
"yAxis": {
"label": "",
"scale": "LINEAR"
}
}
}
}
]
},
"labels": {}
}

0 comments on commit c7b17b6

Please sign in to comment.