Skip to content

Commit

Permalink
Merge branch 'decode-values-from-otel-resource-attributes' of https:/…
Browse files Browse the repository at this point in the history
…/github.com/shalevr/opentelemetry-python into decode-values-from-otel-resource-attributes

* 'decode-values-from-otel-resource-attributes' of https://github.com/shalevr/opentelemetry-python:
  Avoid generator in _ViewInstrumentMatch.collect() (open-telemetry#3035)
  • Loading branch information
shalevr committed Nov 28, 2022
2 parents 15dfa47 + a22536c commit 3e02f52
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
# Otherwise, set variable to the commit of your branch on
# opentelemetry-python-contrib which is compatible with these Core repo
# changes.
CONTRIB_REPO_SHA: c6134843900e2eeb1b8b3383a897b38cc0905c38
CONTRIB_REPO_SHA: main
# This is needed because we do not clone the core repo in contrib builds anymore.
# When running contrib builds as part of core builds, we use actions/checkout@v2 which
# does not set an environment variable (simply just runs tox), which is different when
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3026](https://github.com/open-telemetry/opentelemetry-python/pull/3026))
- Add missing entry points for OTLP/HTTP exporter
([#3027](https://github.com/open-telemetry/opentelemetry-python/pull/3027))
- Fix: Avoid generator in metrics _ViewInstrumentMatch.collect()
([#3035](https://github.com/open-telemetry/opentelemetry-python/pull/3035)

## Version 1.14.0/0.35b0 (2022-11-04)

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Please take a look at this list first, your contributions may belong in one of t

# Find the right branch

The default branch for this repo is `main`. Changes that pertain to `metrics` go into the `metrics` branch. Any changes that pertain to components marked as `stable` in the [specifications](https://github.com/open-telemetry/opentelemetry-specification) or anything that is not `metrics` related go into this branch.
The default branch for this repo is `main`. All feature work is accomplished on branches from `main`.

## Find a Buddy and get Started Quickly!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from logging import getLogger
from threading import Lock
from time import time_ns
from typing import Dict, Iterable
from typing import Dict, List, Sequence

from opentelemetry.metrics import Instrument
from opentelemetry.sdk.metrics._internal.aggregation import (
Expand Down Expand Up @@ -126,12 +126,14 @@ def collect(
self,
aggregation_temporality: AggregationTemporality,
collection_start_nanos: int,
) -> Iterable[DataPointT]:
) -> Sequence[DataPointT]:

data_points: List[DataPointT] = []
with self._lock:
for aggregation in self._attributes_aggregation.values():
data_point = aggregation.collect(
aggregation_temporality, collection_start_nanos
)
if data_point is not None:
yield data_point
data_points.append(data_point)
return data_points
4 changes: 2 additions & 2 deletions opentelemetry-sdk/tests/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ def test_duplicate_instrument_aggregate_data(self):
self.assertEqual(metric_0.name, "counter")
self.assertEqual(metric_0.unit, "unit")
self.assertEqual(metric_0.description, "description")
self.assertEqual(next(metric_0.data.data_points).value, 3)
self.assertEqual(next(iter(metric_0.data.data_points)).value, 3)

metric_1 = scope_metrics[1].metrics[0]

self.assertEqual(metric_1.name, "counter")
self.assertEqual(metric_1.unit, "unit")
self.assertEqual(metric_1.description, "description")
self.assertEqual(next(metric_1.data.data_points).value, 7)
self.assertEqual(next(iter(metric_1.data.data_points)).value, 7)

0 comments on commit 3e02f52

Please sign in to comment.