Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Oct 16, 2020
1 parent b6df065 commit 5026b9b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@
MetricsExportResult,
)
from opentelemetry.sdk.metrics.export.aggregate import (
SumAggregator,
MinMaxSumCountAggregator,
HistogramAggregator,
LastValueAggregator,
MinMaxSumCountAggregator,
SumAggregator,
ValueObserverAggregator,
)


logger = logging.getLogger(__name__)
DataPointT = TypeVar("DataPointT", IntDataPoint, DoubleDataPoint)

Expand Down Expand Up @@ -91,9 +90,8 @@ def _get_data_points(
return [
data_point_class(
labels=[
StringKeyValue(
key=str(label_key), value=str(label_value)
) for label_key, label_value in sdk_metric_record.labels
StringKeyValue(key=str(label_key), value=str(label_value))
for label_key, label_value in sdk_metric_record.labels
],
value=value,
start_time_unix_nano=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ def setUp(self):
resource = SDKResource(OrderedDict([("a", 1), ("b", False)]))
self.counter_metric_record = MetricRecord(
Counter(
"a",
"b",
"c",
"d",
"e",
int,
MeterProvider(resource=resource,).get_meter(__name__),
("d",),
("f",),
),
OrderedDict([("e", "f")]),
[("g", "h")],
SumAggregator(),
resource,
)
Expand All @@ -66,7 +66,9 @@ def test_translate_metrics(self, mock_time_ns):

mock_time_ns.configure_mock(**{"return_value": 1})

self.counter_metric_record.instrument.add(1, OrderedDict([("a", "b")]))
self.counter_metric_record.aggregator.checkpoint = 1
self.counter_metric_record.aggregator.initial_checkpoint_timestamp = 1
self.counter_metric_record.aggregator.last_update_timestamp = 1

expected = ExportMetricsServiceRequest(
resource_metrics=[
Expand All @@ -83,19 +85,20 @@ def test_translate_metrics(self, mock_time_ns):
InstrumentationLibraryMetrics(
metrics=[
OTLPMetric(
name="a",
description="b",
unit="c",
name="c",
description="d",
unit="e",
int_sum=IntSum(
data_points=[
IntDataPoint(
labels=[
StringKeyValue(
key="a", value="b"
key="g", value="h"
)
],
value=1,
time_unix_nano=1,
start_time_unix_nano=1,
)
],
aggregation_temporality=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def __init__(
exporter: MetricsExporter,
interval: int = 30,
meter=None,
labels: typing.Optional[typing.Dict[str, str]]=None,
config: typing.Optional[typing.Dict[str, typing.List[str]]]=None,
labels: typing.Optional[typing.Dict[str, str]] = None,
config: typing.Optional[typing.Dict[str, typing.List[str]]] = None,
):
self._labels = {} if labels is None else labels
if meter is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def merge(self, other):
)
self.initial_checkpoint_timestamp = max(
self.initial_checkpoint_timestamp,
other.initial_checkpoint_timestamp
other.initial_checkpoint_timestamp,
)

def _verify_type(self, other):
Expand Down

0 comments on commit 5026b9b

Please sign in to comment.