opentelemetry.sdk.metrics package¶
Submodules¶
-
opentelemetry.sdk.metrics.
get_labels_as_key
(labels)[source]¶ Gets a list of labels that can be used as a key in a dictionary.
-
class
opentelemetry.sdk.metrics.
BaseBoundInstrument
(value_type, enabled, aggregator)[source]¶ Bases:
object
Class containing common behavior for all bound metric instruments.
Bound metric instruments are responsible for operating on data for metric instruments for a specific set of labels.
- Parameters
value_type (
Type
[~ValueT]) – The type of values for this bound instrument (int, float).enabled (
bool
) – True if the originating instrument is enabled.aggregator (
Aggregator
) – The aggregator for this bound metric instrument. Will handle aggregation upon updates and checkpointing of values for exporting.
-
class
opentelemetry.sdk.metrics.
BoundCounter
(value_type, enabled, aggregator)[source]¶ Bases:
opentelemetry.metrics.BoundCounter
,opentelemetry.sdk.metrics.BaseBoundInstrument
-
add
(value)[source]¶ See
opentelemetry.metrics.BoundCounter.add
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
BoundMeasure
(value_type, enabled, aggregator)[source]¶ Bases:
opentelemetry.metrics.BoundMeasure
,opentelemetry.sdk.metrics.BaseBoundInstrument
-
record
(value)[source]¶ See
opentelemetry.metrics.BoundMeasure.record
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
Metric
(name, description, unit, value_type, meter, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.metrics.Metric
Base class for all metric types.
Also known as metric instrument. This is the class that is used to represent a metric that is to be continuously recorded and tracked. Each metric has a set of bound metrics that are created from the metric. See
BaseBoundInstrument
for information on bound metric instruments.-
BOUND_INSTR_TYPE
¶ alias of
BaseBoundInstrument
-
bind
(labels)[source]¶ See
opentelemetry.metrics.Metric.bind
.- Return type
-
UPDATE_FUNCTION
(y)¶
-
-
class
opentelemetry.sdk.metrics.
Counter
(name, description, unit, value_type, meter, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.sdk.metrics.Metric
,opentelemetry.metrics.Counter
See
opentelemetry.metrics.Counter
.-
BOUND_INSTR_TYPE
¶ alias of
BoundCounter
-
add
(value, labels)[source]¶ See
opentelemetry.metrics.Counter.add
.- Return type
None
-
UPDATE_FUNCTION
(value, labels)¶ See
opentelemetry.metrics.Counter.add
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
Measure
(name, description, unit, value_type, meter, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.sdk.metrics.Metric
,opentelemetry.metrics.Measure
See
opentelemetry.metrics.Measure
.-
BOUND_INSTR_TYPE
¶ alias of
BoundMeasure
-
record
(value, labels)[source]¶ See
opentelemetry.metrics.Measure.record
.- Return type
None
-
UPDATE_FUNCTION
(value, labels)¶ See
opentelemetry.metrics.Measure.record
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
Observer
(callback, name, description, unit, value_type, meter, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.metrics.Observer
-
class
opentelemetry.sdk.metrics.
Record
(metric, labels, aggregator)[source]¶ Bases:
object
Container class used for processing in the
Batcher
-
class
opentelemetry.sdk.metrics.
Meter
(instrumentation_info, stateful, resource=<opentelemetry.sdk.resources.Resource object>)[source]¶ Bases:
opentelemetry.metrics.Meter
See
opentelemetry.metrics.Meter
.- Parameters
instrumentation_info (
InstrumentationInfo
) – TheInstrumentationInfo
for this meter.stateful (
bool
) – Indicates whether the meter is stateful.
-
collect
()[source]¶ Collects all the metrics created with this
Meter
for export.Utilizes the batcher to create checkpoints of the current values in each aggregator belonging to the metrics that were created with this meter instance.
- Return type
None
-
record_batch
(labels, record_tuples)[source]¶ See
opentelemetry.metrics.Meter.record_batch
.- Return type
None
-
create_metric
(name, description, unit, value_type, metric_type, label_keys=(), enabled=True)[source]¶ See
opentelemetry.metrics.Meter.create_metric
.- Return type
~MetricT
-
register_observer
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Registers an
Observer
metric instrument.- Parameters
callback (
Callable
[[Observer
],None
]) – Callback invoked each collection interval with the observer as argument.name (
str
) – The name of the metric.description (
str
) – Human-readable description of the metric.unit (
str
) – Unit of the metric values following the UCUM convention (https://unitsofmeasure.org/ucum.html).value_type (
Type
[~ValueT]) – The type of values being recorded by the metric.label_keys (
Sequence
[str
]) – The keys for the labels with dynamic values.enabled (
bool
) – Whether to report the metric by default.
Returns: A new
Observer
metric instrument.- Return type
-
class
opentelemetry.sdk.metrics.
MeterProvider
(resource=<opentelemetry.sdk.resources.Resource object>)[source]¶ Bases:
opentelemetry.metrics.MeterProvider
-
get_meter
(instrumenting_module_name, stateful=True, instrumenting_library_version='')[source]¶ Returns a
Meter
for use by the given instrumentation library.This function may return different
Meter
types (e.g. a no-op meter vs. a functional meter).- Parameters
instrumenting_module_name (
str
) –The name of the instrumenting module (usually just
__name__
).This should not be the name of the module that is instrumented but the name of the module doing the instrumentation. E.g., instead of
"requests"
, use"opentelemetry.ext.http_requests"
.stateful – True/False to indicate whether the meter will be stateful. True indicates the meter computes checkpoints from over the process lifetime. False indicates the meter computes checkpoints which describe the updates of a single collection period (deltas).
instrumenting_library_version (
str
) – Optional. The version string of the instrumenting library. Usually this should be the same aspkg_resources.get_distribution(instrumenting_library_name).version
.
- Return type
-