__init__.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.
  14. """
  15. The OpenTelemetry metrics API describes the classes used to generate
  16. metrics.
  17. The :class:`.MeterProvider` provides users access to the :class:`.Meter` which in
  18. turn is used to create :class:`.Instrument` objects. The :class:`.Instrument` objects are
  19. used to record measurements.
  20. This module provides abstract (i.e. unimplemented) classes required for
  21. metrics, and a concrete no-op implementation :class:`.NoOpMeter` that allows applications
  22. to use the API package alone without a supporting implementation.
  23. To get a meter, you need to provide the package name from which you are
  24. calling the meter APIs to OpenTelemetry by calling `MeterProvider.get_meter`
  25. with the calling instrumentation name and the version of your package.
  26. The following code shows how to obtain a meter using the global :class:`.MeterProvider`::
  27. from opentelemetry.metrics import get_meter
  28. meter = get_meter("example-meter")
  29. counter = meter.create_counter("example-counter")
  30. .. versionadded:: 1.10.0
  31. .. versionchanged:: 1.12.0rc
  32. """
  33. from opentelemetry.metrics._internal import (
  34. Meter,
  35. MeterProvider,
  36. NoOpMeter,
  37. NoOpMeterProvider,
  38. get_meter,
  39. get_meter_provider,
  40. set_meter_provider,
  41. )
  42. from opentelemetry.metrics._internal.instrument import (
  43. Asynchronous,
  44. CallbackOptions,
  45. CallbackT,
  46. Counter,
  47. Histogram,
  48. Instrument,
  49. NoOpCounter,
  50. NoOpHistogram,
  51. NoOpObservableCounter,
  52. NoOpObservableGauge,
  53. NoOpObservableUpDownCounter,
  54. NoOpUpDownCounter,
  55. ObservableCounter,
  56. ObservableGauge,
  57. ObservableUpDownCounter,
  58. Synchronous,
  59. UpDownCounter,
  60. )
  61. from opentelemetry.metrics._internal.instrument import Gauge as _Gauge
  62. from opentelemetry.metrics._internal.instrument import NoOpGauge as _NoOpGauge
  63. from opentelemetry.metrics._internal.observation import Observation
  64. for obj in [
  65. Counter,
  66. Synchronous,
  67. Asynchronous,
  68. CallbackOptions,
  69. _Gauge,
  70. _NoOpGauge,
  71. get_meter_provider,
  72. get_meter,
  73. Histogram,
  74. Meter,
  75. MeterProvider,
  76. Instrument,
  77. NoOpCounter,
  78. NoOpHistogram,
  79. NoOpMeter,
  80. NoOpMeterProvider,
  81. NoOpObservableCounter,
  82. NoOpObservableGauge,
  83. NoOpObservableUpDownCounter,
  84. NoOpUpDownCounter,
  85. ObservableCounter,
  86. ObservableGauge,
  87. ObservableUpDownCounter,
  88. Observation,
  89. set_meter_provider,
  90. UpDownCounter,
  91. ]:
  92. obj.__module__ = __name__
  93. __all__ = [
  94. "CallbackOptions",
  95. "MeterProvider",
  96. "NoOpMeterProvider",
  97. "Meter",
  98. "Counter",
  99. "_Gauge",
  100. "_NoOpGauge",
  101. "NoOpCounter",
  102. "UpDownCounter",
  103. "NoOpUpDownCounter",
  104. "Histogram",
  105. "NoOpHistogram",
  106. "ObservableCounter",
  107. "NoOpObservableCounter",
  108. "ObservableUpDownCounter",
  109. "Instrument",
  110. "Synchronous",
  111. "Asynchronous",
  112. "NoOpObservableGauge",
  113. "ObservableGauge",
  114. "NoOpObservableUpDownCounter",
  115. "get_meter",
  116. "get_meter_provider",
  117. "set_meter_provider",
  118. "Observation",
  119. "CallbackT",
  120. "NoOpMeter",
  121. ]