Skip to content

Commit

Permalink
Add timestamps to aggregators and OTLP metrics exporter (#1199)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl authored Oct 12, 2020
1 parent 5f2cbfa commit 04792d5
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 186 deletions.
2 changes: 2 additions & 0 deletions exporter/opentelemetry-exporter-otlp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Add timestamps to OTLP exporter
([#1199](https://github.com/open-telemetry/opentelemetry-python/pull/1199))
- Update OpenTelemetry protos to v0.5.0
([#1143](https://github.com/open-telemetry/opentelemetry-python/pull/1143))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def _get_data_points(
data_point_class(
labels=string_key_values,
value=view_data.aggregator.current,
start_time_unix_nano=(
view_data.aggregator.last_checkpoint_timestamp
),
time_unix_nano=(
view_data.aggregator.last_update_timestamp
),
)
)
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from collections import OrderedDict
from unittest import TestCase
from unittest.mock import patch

from opentelemetry.exporter.otlp.metrics_exporter import OTLPMetricsExporter
from opentelemetry.proto.collector.metrics.v1.metrics_service_pb2 import (
Expand Down Expand Up @@ -59,9 +60,12 @@ def setUp(self):
resource,
)

def test_translate_metrics(self):
@patch("opentelemetry.sdk.metrics.export.aggregate.time_ns")
def test_translate_metrics(self, mock_time_ns):
# pylint: disable=no-member

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

self.counter_metric_record.instrument.add(1, OrderedDict([("a", "b")]))

expected = ExportMetricsServiceRequest(
Expand Down Expand Up @@ -91,6 +95,7 @@ def test_translate_metrics(self):
)
],
value=1,
time_unix_nano=1,
)
],
aggregation_temporality=(
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Add timestamps to aggregators
([#1199](https://github.com/open-telemetry/opentelemetry-python/pull/1199))
- Add Global Error Handler
([#1080](https://github.com/open-telemetry/opentelemetry-python/pull/1080))
- Update sampling result names
Expand Down
Loading

0 comments on commit 04792d5

Please sign in to comment.