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

Rename "handle" to "bound metric instrument" #470

Merged
merged 11 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 5 additions & 5 deletions examples/metrics/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@

# Bound instrument usage

# You can record metrics with bound metric instruments. Bound metric instruments
# are created by passing in a labelset. A bound metric instrument is
# essentially metric data that corresponds to a specific set of labels.
# Therefore, getting a bound metric instrument using the same set of labels will
# yield the same bound metric instrument.
# You can record metrics with bound metric instruments. Bound metric
# instruments are created by passing in a labelset. A bound metric instrument
# is essentially metric data that corresponds to a specific set of labels.
# Therefore, getting a bound metric instrument using the same set of labels
# will yield the same bound metric instrument.
bound_counter = counter.bind(label_set)
bound_counter.add(100)

Expand Down
13 changes: 7 additions & 6 deletions opentelemetry-api/src/opentelemetry/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def bind(self, label_set: LabelSet) -> "object":

Bound metric instruments are useful to reduce the cost of repeatedly
recording a metric with a pre-defined set of label values. All metric
kinds (counter, measure) support declaring a set of required label keys.
The values corresponding to these keys should be specified in every
bound metric instrument. "Unspecified" label values, in cases where a
bound metric instrument is requested but a value was not provided are
permitted.
kinds (counter, measure) support declaring a set of required label
keys. The values corresponding to these keys should be specified in
every bound metric instrument. "Unspecified" label values, in cases
where a bound metric instrument is requested but a value was not
provided are permitted.

Args:
label_set: `LabelSet` to associate with the bound instrument.
Expand Down Expand Up @@ -183,7 +183,8 @@ def record(self, value: ValueT, label_set: LabelSet) -> None:


class Observer(abc.ABC):
"""An observer type metric instrument used to capture a current set of values.
"""An observer type metric instrument used to capture a current set of
values.


Observer instruments are asynchronous, a callback is invoked with the
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
# limitations under the License.

import logging
from collections import OrderedDict
from typing import Dict, Sequence, Tuple, Type

from opentelemetry import metrics as metrics_api
from opentelemetry.sdk.metrics.export.aggregate import Aggregator
from opentelemetry.sdk.metrics.export.batcher import Batcher, UngroupedBatcher
from opentelemetry.sdk.metrics.export.batcher import UngroupedBatcher
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
from opentelemetry.util import time_ns
Expand Down