opentelemetry.sdk.metrics package¶
Submodules¶
-
class
opentelemetry.sdk.metrics.
BaseBoundInstrument
(labels, metric)[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
-
class
opentelemetry.sdk.metrics.
BoundCounter
(labels, metric)[source]¶ Bases:
opentelemetry.metrics.BoundCounter
,opentelemetry.sdk.metrics.BaseBoundInstrument
-
add
(value)[source]¶ See
opentelemetry.metrics.BoundCounter.add
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
BoundUpDownCounter
(labels, metric)[source]¶ Bases:
opentelemetry.metrics.BoundUpDownCounter
,opentelemetry.sdk.metrics.BaseBoundInstrument
-
add
(value)[source]¶ See
opentelemetry.metrics.BoundUpDownCounter.add
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
BoundValueRecorder
(labels, metric)[source]¶ Bases:
opentelemetry.metrics.BoundValueRecorder
,opentelemetry.sdk.metrics.BaseBoundInstrument
-
record
(value)[source]¶ See
opentelemetry.metrics.BoundValueRecorder.record
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
Metric
(name, description, unit, value_type, meter, enabled=True)[source]¶ Bases:
opentelemetry.metrics.Metric
Base class for all synchronous metric types.
This is the class that is used to represent a metric that is to be synchronously recorded and tracked. Synchronous instruments are called inside a request, meaning they have an associated distributed context (i.e. Span context, baggage). Multiple metric events may occur for a synchronous instrument within a give collection interval.
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, 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.
UpDownCounter
(name, description, unit, value_type, meter, enabled=True)[source]¶ Bases:
opentelemetry.sdk.metrics.Metric
,opentelemetry.metrics.UpDownCounter
See
opentelemetry.metrics.UpDownCounter
.-
BOUND_INSTR_TYPE
¶ alias of
BoundUpDownCounter
-
add
(value, labels)[source]¶ See
opentelemetry.metrics.UpDownCounter.add
.- Return type
None
-
UPDATE_FUNCTION
(value, labels)¶ See
opentelemetry.metrics.UpDownCounter.add
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
ValueRecorder
(name, description, unit, value_type, meter, enabled=True)[source]¶ Bases:
opentelemetry.sdk.metrics.Metric
,opentelemetry.metrics.ValueRecorder
See
opentelemetry.metrics.ValueRecorder
.-
BOUND_INSTR_TYPE
¶ alias of
BoundValueRecorder
-
record
(value, labels)[source]¶ See
opentelemetry.metrics.ValueRecorder.record
.- Return type
None
-
UPDATE_FUNCTION
(value, labels)¶ See
opentelemetry.metrics.ValueRecorder.record
.- Return type
None
-
-
class
opentelemetry.sdk.metrics.
Observer
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.metrics.Observer
Base class for all asynchronous metric types.
Also known as Observers, observer metric instruments are asynchronous in that they are reported by a callback, once per collection interval, and lack context. They are permitted to report only one value per distinct label set per period.
-
class
opentelemetry.sdk.metrics.
SumObserver
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.sdk.metrics.Observer
,opentelemetry.metrics.SumObserver
-
class
opentelemetry.sdk.metrics.
UpDownSumObserver
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.sdk.metrics.Observer
,opentelemetry.metrics.UpDownSumObserver
-
class
opentelemetry.sdk.metrics.
ValueObserver
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Bases:
opentelemetry.sdk.metrics.Observer
,opentelemetry.metrics.ValueObserver
-
class
opentelemetry.sdk.metrics.
Record
(instrument, labels, aggregator)[source]¶ Bases:
object
Container class used for processing in the
Processor
-
class
opentelemetry.sdk.metrics.
Meter
(source, instrumentation_info)[source]¶ Bases:
opentelemetry.metrics.Meter
See
opentelemetry.metrics.Meter
.- Parameters
source (
MeterProvider
) – TheMeterProvider
that created this meter.instrumentation_info (
InstrumentationInfo
) – TheInstrumentationInfo
for this meter.
-
collect
()[source]¶ Collects all the metrics created with this
Meter
for export.Utilizes the processor 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_counter
(name, description, unit, value_type, enabled=True)[source]¶ See
opentelemetry.metrics.Meter.create_counter
.- Return type
-
create_updowncounter
(name, description, unit, value_type, enabled=True)[source]¶ See
opentelemetry.metrics.Meter.create_updowncounter
.- Return type
-
create_valuerecorder
(name, description, unit, value_type, enabled=True)[source]¶ See
opentelemetry.metrics.Meter.create_valuerecorder
.- Return type
-
register_sumobserver
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Registers an
SumObserver
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
SumObserver
metric instrument.- Return type
-
register_updownsumobserver
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Registers an
UpDownSumObserver
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
UpDownSumObserver
metric instrument.- Return type
-
register_valueobserver
(callback, name, description, unit, value_type, label_keys=(), enabled=True)[source]¶ Registers an
ValueObserver
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
ValueObserver
metric instrument.- Return type
-
class
opentelemetry.sdk.metrics.
MeterProvider
(stateful=True, resource=<opentelemetry.sdk.resources.Resource object>, shutdown_on_exit=True)[source]¶ Bases:
opentelemetry.metrics.MeterProvider
See
opentelemetry.metrics.MeterProvider
.- Parameters
-
get_meter
(instrumenting_module_name, instrumenting_library_version='')[source]¶ See
opentelemetry.metrics.MeterProvider
.get_meter.- Return type
-
start_pipeline
(meter, exporter=None, interval=15.0)[source]¶ Method to begin the collect/export pipeline.
- Parameters
meter (
Meter
) – The meter to collect metrics from.exporter (
Optional
[MetricsExporter
]) – The exporter to export metrics to.interval (
float
) – The collect/export interval in seconds.
- Return type
None