Skip to content

Commit b2490ed

Browse files
authored
Add unit when creating metric descriptors (#218)
1 parent bbef9bc commit b2490ed

15 files changed

+43
-14
lines changed

opentelemetry-exporter-gcp-monitoring/src/opentelemetry/exporter/cloud_monitoring/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def _get_metric_descriptor(
145145
type=descriptor_type,
146146
display_name=metric.name,
147147
description=metric.description or "",
148+
unit=metric.unit or "",
148149
)
149150
seen_keys: Set[str] = set()
150151
for data_point in metric.data.data_points:

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_counter[float].json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "CUMULATIVE",
1919
"type": "workload.googleapis.com/mycounter",
20+
"unit": "{myunit}",
2021
"valueType": "DOUBLE"
2122
},
2223
"name": "projects/fakeproject"
@@ -54,7 +55,8 @@
5455
"node_id": ""
5556
},
5657
"type": "generic_node"
57-
}
58+
},
59+
"unit": "{myunit}"
5860
}
5961
]
6062
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_counter[int].json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "CUMULATIVE",
1919
"type": "workload.googleapis.com/mycounter",
20+
"unit": "{myunit}",
2021
"valueType": "INT64"
2122
},
2223
"name": "projects/fakeproject"
@@ -54,7 +55,8 @@
5455
"node_id": ""
5556
},
5657
"type": "generic_node"
57-
}
58+
},
59+
"unit": "{myunit}"
5860
}
5961
]
6062
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_histogram_default_buckets.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "CUMULATIVE",
1919
"type": "workload.googleapis.com/myhistogram",
20+
"unit": "{myunit}",
2021
"valueType": "DISTRIBUTION"
2122
},
2223
"name": "projects/fakeproject"
@@ -96,7 +97,8 @@
9697
"node_id": ""
9798
},
9899
"type": "generic_node"
99-
}
100+
},
101+
"unit": "{myunit}"
100102
}
101103
]
102104
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_histogram_single_bucket.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "CUMULATIVE",
1919
"type": "workload.googleapis.com/myhistogram",
20+
"unit": "{myunit}",
2021
"valueType": "DISTRIBUTION"
2122
},
2223
"name": "projects/fakeproject"
@@ -68,7 +69,8 @@
6869
"node_id": ""
6970
},
7071
"type": "generic_node"
71-
}
72+
},
73+
"unit": "{myunit}"
7274
}
7375
]
7476
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_invalid_label_keys.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
],
1212
"metricKind": "CUMULATIVE",
1313
"type": "workload.googleapis.com/mycounter",
14+
"unit": "{myunit}",
1415
"valueType": "INT64"
1516
},
1617
"name": "projects/fakeproject"
@@ -46,7 +47,8 @@
4647
"node_id": ""
4748
},
4849
"type": "generic_node"
49-
}
50+
},
51+
"unit": "{myunit}"
5052
}
5153
]
5254
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_observable_counter[float].json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "CUMULATIVE",
1919
"type": "workload.googleapis.com/myobservablecounter",
20+
"unit": "{myunit}",
2021
"valueType": "DOUBLE"
2122
},
2223
"name": "projects/fakeproject"
@@ -54,7 +55,8 @@
5455
"node_id": ""
5556
},
5657
"type": "generic_node"
57-
}
58+
},
59+
"unit": "{myunit}"
5860
}
5961
]
6062
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_observable_counter[int].json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "CUMULATIVE",
1919
"type": "workload.googleapis.com/myobservablecounter",
20+
"unit": "{myunit}",
2021
"valueType": "INT64"
2122
},
2223
"name": "projects/fakeproject"
@@ -54,7 +55,8 @@
5455
"node_id": ""
5556
},
5657
"type": "generic_node"
57-
}
58+
},
59+
"unit": "{myunit}"
5860
}
5961
]
6062
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_observable_gauge[float].json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "GAUGE",
1919
"type": "workload.googleapis.com/myobservablegauge",
20+
"unit": "{myunit}",
2021
"valueType": "DOUBLE"
2122
},
2223
"name": "projects/fakeproject"
@@ -53,7 +54,8 @@
5354
"node_id": ""
5455
},
5556
"type": "generic_node"
56-
}
57+
},
58+
"unit": "{myunit}"
5759
}
5860
]
5961
}

opentelemetry-exporter-gcp-monitoring/tests/__snapshots__/test_cloud_monitoring/test_observable_gauge[int].json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"metricKind": "GAUGE",
1919
"type": "workload.googleapis.com/myobservablegauge",
20+
"unit": "{myunit}",
2021
"valueType": "INT64"
2122
},
2223
"name": "projects/fakeproject"
@@ -53,7 +54,8 @@
5354
"node_id": ""
5455
},
5556
"type": "generic_node"
56-
}
57+
},
58+
"unit": "{myunit}"
5759
}
5860
]
5961
}

0 commit comments

Comments
 (0)