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
7 changes: 7 additions & 0 deletions opencensus/metrics/export/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def __init__(self, descriptor, time_series):
self._descriptor = descriptor
self._check_type()

def __repr__(self):
return ('{}(descriptor.name="{}")'
.format(
type(self).__name__,
self.descriptor.name
))

@property
def time_series(self):
return self._time_series
Expand Down
11 changes: 11 additions & 0 deletions opencensus/metrics/export/metric_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ def __init__(self, name, description, unit, type_, label_keys):
self._type = type_
self._label_keys = label_keys

def __repr__(self):
type_name = MetricDescriptorType.to_type_class(self.type).__name__
return ('{}(name="{}", description="{}", unit={}, type={})'
.format(
type(self).__name__,
self.name,
self.description,
self.unit,
type_name,
))

@property
def name(self):
return self._name
Expand Down
8 changes: 8 additions & 0 deletions opencensus/metrics/export/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ def value(self):
def timestamp(self):
"""Returns the Timestamp when this Point was recorded."""
return self._timestamp

def __repr__(self):
return ("{}(value={}, timestamp={})"
.format(
type(self).__name__,
self.value,
self.timestamp
))
9 changes: 9 additions & 0 deletions opencensus/metrics/export/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def __init__(self, label_values, points, start_timestamp):
self._points = points
self._start_timestamp = start_timestamp

def __repr__(self):
return ('{}(points={}, label_values={}, start_timestamp={})'
.format(
type(self).__name__,
self.points,
self.label_values,
self.start_timestamp
))

@property
def start_timestamp(self):
return self._start_timestamp
Expand Down
7 changes: 7 additions & 0 deletions opencensus/metrics/export/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class ValueDouble(Value):
def __init__(self, value):
super(ValueDouble, self).__init__(value)

def __repr__(self):
return ("{}({})"
.format(
type(self).__name__,
self.value,
))


class ValueLong(Value):
"""A 64-bit integer.
Expand Down
14 changes: 14 additions & 0 deletions opencensus/metrics/label_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ def __init__(self, key, description):
self._key = key
self._description = description

def __repr__(self):
if self.description:
return ('{}({}, description="{}")'
.format(
type(self).__name__,
self.key,
self.description
))
return ("{}({})"
.format(
type(self).__name__,
self.key,
))

@property
def key(self):
"""the key for the label"""
Expand Down
7 changes: 7 additions & 0 deletions opencensus/metrics/label_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class LabelValue(object):
def __init__(self, value=None):
self._value = value

def __repr__(self):
return ("{}({})"
.format(
type(self).__name__,
self.value,
))

@property
def value(self):
"""the value for the label"""
Expand Down
28 changes: 28 additions & 0 deletions opencensus/stats/aggregation_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def __init__(self, sum_data):
super(SumAggregationDataFloat, self).__init__(sum_data)
self._sum_data = sum_data

def __repr__(self):
return ("{}({})"
.format(
type(self).__name__,
self.sum_data,
))

def add_sample(self, value, timestamp=None, attachments=None):
"""Allows the user to add a sample to the Sum Aggregation Data
The value of the sample is then added to the current sum data
Expand Down Expand Up @@ -100,6 +107,13 @@ def __init__(self, count_data):
super(CountAggregationData, self).__init__(count_data)
self._count_data = count_data

def __repr__(self):
return ("{}({})"
.format(
type(self).__name__,
self.count_data,
))

def add_sample(self, value, timestamp=None, attachments=None):
"""Adds a sample to the current Count Aggregation Data and adds 1 to
the count data"""
Expand Down Expand Up @@ -194,6 +208,13 @@ def __init__(self,
assert len(counts_per_bucket) == len(bounds) + 1
self._counts_per_bucket = counts_per_bucket

def __repr__(self):
return ("{}({})"
.format(
type(self).__name__,
self.count_data,
))

@property
def mean_data(self):
"""The current mean data"""
Expand Down Expand Up @@ -340,6 +361,13 @@ def __init__(self, value):
super(LastValueAggregationData, self).__init__(value)
self._value = value

def __repr__(self):
return ("{}({})"
.format(
type(self).__name__,
self.value,
))

def add_sample(self, value, timestamp=None, attachments=None):
"""Adds a sample to the current
LastValue Aggregation Data and overwrite
Expand Down