Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions opencensus/metrics/export/metric_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def __init__(self, name, description, unit, type_, label_keys):
if type_ not in MetricDescriptorType:
raise ValueError("Invalid type")

if not label_keys:
raise ValueError("label_keys must not be empty or null")
if label_keys is None:
raise ValueError("label_keys must not be None")

if any(key is None for key in label_keys):
raise ValueError("label_keys must not contain null keys")
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/metrics/export/test_metric_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def test_null_label_keys(self):
NAME, DESCRIPTION, UNIT,
metric_descriptor.MetricDescriptorType.GAUGE_DOUBLE, None)

def test_empty_label_keys(self):
metric_descriptor.MetricDescriptor(
NAME, DESCRIPTION, UNIT,
metric_descriptor.MetricDescriptorType.GAUGE_DOUBLE, [])

def test_null_label_key_values(self):
with self.assertRaises(ValueError):
metric_descriptor.MetricDescriptor(
Expand Down