Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamps to aggregators and OTLP metrics exporter #1199

Merged
merged 6 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
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