Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/opentelemetry/metrics/__init__.py: 100%
7 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:35 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:35 +0000
1# Copyright The OpenTelemetry Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15"""
16The OpenTelemetry metrics API describes the classes used to generate
17metrics.
19The :class:`.MeterProvider` provides users access to the :class:`.Meter` which in
20turn is used to create :class:`.Instrument` objects. The :class:`.Instrument` objects are
21used to record measurements.
23This module provides abstract (i.e. unimplemented) classes required for
24metrics, and a concrete no-op implementation :class:`.NoOpMeter` that allows applications
25to use the API package alone without a supporting implementation.
27To get a meter, you need to provide the package name from which you are
28calling the meter APIs to OpenTelemetry by calling `MeterProvider.get_meter`
29with the calling instrumentation name and the version of your package.
31The following code shows how to obtain a meter using the global :class:`.MeterProvider`::
33 from opentelemetry.metrics import get_meter
35 meter = get_meter("example-meter")
36 counter = meter.create_counter("example-counter")
38.. versionadded:: 1.10.0
39.. versionchanged:: 1.12.0rc
40"""
42from opentelemetry.metrics._internal import (
43 Meter,
44 MeterProvider,
45 NoOpMeter,
46 NoOpMeterProvider,
47 get_meter,
48 get_meter_provider,
49 set_meter_provider,
50)
51from opentelemetry.metrics._internal.instrument import (
52 Asynchronous,
53 CallbackOptions,
54 CallbackT,
55 Counter,
56 Histogram,
57 Instrument,
58 NoOpCounter,
59 NoOpHistogram,
60 NoOpObservableCounter,
61 NoOpObservableGauge,
62 NoOpObservableUpDownCounter,
63 NoOpUpDownCounter,
64 ObservableCounter,
65 ObservableGauge,
66 ObservableUpDownCounter,
67 Synchronous,
68 UpDownCounter,
69)
70from opentelemetry.metrics._internal.observation import Observation
72for obj in [
73 Counter,
74 Synchronous,
75 Asynchronous,
76 CallbackOptions,
77 get_meter_provider,
78 get_meter,
79 Histogram,
80 Meter,
81 MeterProvider,
82 Instrument,
83 NoOpCounter,
84 NoOpHistogram,
85 NoOpMeter,
86 NoOpMeterProvider,
87 NoOpObservableCounter,
88 NoOpObservableGauge,
89 NoOpObservableUpDownCounter,
90 NoOpUpDownCounter,
91 ObservableCounter,
92 ObservableGauge,
93 ObservableUpDownCounter,
94 Observation,
95 set_meter_provider,
96 UpDownCounter,
97]:
98 obj.__module__ = __name__
100__all__ = [
101 "CallbackOptions",
102 "MeterProvider",
103 "NoOpMeterProvider",
104 "Meter",
105 "Counter",
106 "NoOpCounter",
107 "UpDownCounter",
108 "NoOpUpDownCounter",
109 "Histogram",
110 "NoOpHistogram",
111 "ObservableCounter",
112 "NoOpObservableCounter",
113 "ObservableUpDownCounter",
114 "Instrument",
115 "Synchronous",
116 "Asynchronous",
117 "NoOpObservableGauge",
118 "ObservableGauge",
119 "NoOpObservableUpDownCounter",
120 "get_meter",
121 "get_meter_provider",
122 "set_meter_provider",
123 "Observation",
124 "CallbackT",
125 "NoOpMeter",
126]