Skip to content

Commit

Permalink
Add _ViewInstrumentMatch
Browse files Browse the repository at this point in the history
Fixes #2296
  • Loading branch information
ocelotl committed Dec 2, 2021
1 parent c19cf0b commit 8448599
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from threading import Lock
from typing import Callable, Dict, Iterable, List

from opentelemetry.sdk._metrics.aggregation import Aggregation
Expand All @@ -32,10 +33,40 @@ def __init__(
exemplar_reservoir: Callable,
resource: Resource,
):
pass
self._name = name
self._unit = unit
self._description = description

if attribute_keys is None:
self._attribute_keys = set()
else:
self._attribute_keys = set(attribute_keys.items())

self._extra_dimensions = extra_dimensions
self._aggregation = aggregation
self._exemplar_reservoir = exemplar_reservoir
self._attributes_aggregation = {}
self._lock = Lock()

def _process(self, measurement: Measurement) -> None:
pass
if measurement.attributes is None:
attributes = {}

else:
attributes = measurement.attributes

attributes = frozenset(
set(attributes).difference(self._attribute_keys)
)

if attributes not in self._attributes_aggregation.keys():
# FIXME how to handle aggregations that support config?
with self._lock:
self._attributes_aggregation[attributes] = self._aggregation[
attributes
]

self._attributes_aggregation[attributes].aggregate(measurement.amount)

def _collect(self, temporality: int) -> Iterable[Metric]:
pass

0 comments on commit 8448599

Please sign in to comment.