Skip to content

Commit

Permalink
Adds metrics API (open-telemetry#1887)
Browse files Browse the repository at this point in the history
* Adds metric prototype

Fixes open-telemetry#1835

* Fix docs

* Add API metrics doc

* Add missing docs

* Add files

* Adding docs

* Refactor to _initialize

* Refactor initialize

* Add more documentation

* Add exporter test

* Add process

* Fix tests

* Try to add aggregator_class argument

Tests are failing here

* Fix instrument parent classes

* Test default aggregator

* WIP

* Add prototype test

* Tests passing again

* Use right counters

* All tests passing

* Rearrange instrument storage

* Fix tests

* Add HTTP server test

* WIP

* WIP

* Add prototype

* WIP

* Fail the test

* WIP

* WIP

* WIP

* WIP

* Add views

* Discard instruments via views

* Fix tests

* WIP

* WIP

* Fix lint

* WIP

* Fix test

* Fix lint

* Fix method

* Fix lint

* Mypy workaround

* Skip if 3.6

* Fix lint

* Add reason

* Fix 3.6

* Fix run

* Fix lint

* Remove SDK metrics

* Remove SDK docs

* Remove metrics

* Remove assertnotraises mixin

* Revert sdk docs conf

* Remove SDK env var changes

* Fix unit checking

* Define positional-only arguments

* Add Metrics plans

* Add API tests

* WIP

* WIP test

* WIP

* WIP

* WIP

* Set provider test passing

* Use a fixture

* Add test for get_provider

* Rename tests

* WIP

* WIP

* WIP

* WIP

* Remove non specific requirement

* Add meter requirements

* Put all meter provider tests in one file

* Add meter tests

* Make attributes be passed as a dictionary

* Make some interfaces private

* Log an error instead

* Remove ASCII flag

* Add CHANGELOG entry

* Add instrument tests

* All tests passing

* Add test

* Add name tests

* Add unit tests

* Add description tests

* Add counter tests

* Add more tests

* Add Histogram tests

* Add observable gauge tests

* Add updowncounter tests

* Add observableupdowncounter tests

* Fix lint

* Fix docs

* Fix lint

* Ignore mypy

* Remove useless pylint skip

* Remove useless pylint skip

* Remove useless pylint skip

* Remove useless pylint skip

* Remove useless pylint skip

* Add locks to meter and meterprovider

* Add lock to instruments

* Fix fixmes

* Fix lint

* Add documentation placeholder

* Remove blank line as requested.

* Do not override Rlock

* Remove unecessary super calls

* Add missing super calls

* Remove plan files

* Add missing parameters

* Rename observe to callback

* Fix lint

* Rename to secure_instrument_name

* Remove locks

* Fix lint

* Remove args and kwargs

* Remove implementation that gives meters access to meter provider

* Allow creating async instruments with either a callback function or generator

* add additional test with callback form of observable counter

* add a test/example that reads measurements from proc stat

* implement cpu time integration test with generator too

Co-authored-by: Aaron Abbott <aaronabbott@google.com>
  • Loading branch information
ocelotl and aabmass committed Oct 29, 2021
1 parent 05e9fe1 commit 5f4cc99
Show file tree
Hide file tree
Showing 15 changed files with 2,139 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2207](https://github.com/open-telemetry/opentelemetry-python/pull/2207))
- remove `X-B3-ParentSpanId` for B3 propagator as per OpenTelemetry specification
([#2237](https://github.com/open-telemetry/opentelemetry-python/pull/2237))
- Add metrics API
([#1887](https://github.com/open-telemetry/opentelemetry-python/pull/1887))

## [1.6.2-0.25b2](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.2-0.25b2) - 2021-10-19

Expand Down
1 change: 1 addition & 0 deletions docs/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ OpenTelemetry Python API
baggage
context
trace
metrics
environment_variables
8 changes: 8 additions & 0 deletions docs/api/metrics.instrument.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
opentelemetry.metrics.instrument
================================

.. automodule:: opentelemetry.metrics.instrument
:members:
:private-members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/metrics.measurement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
opentelemetry.metrics.measurement
=================================

.. automodule:: opentelemetry.metrics.measurement
:members:
:undoc-members:
:show-inheritance:
15 changes: 15 additions & 0 deletions docs/api/metrics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
opentelemetry.metrics package
=============================

Submodules
----------

.. toctree::

metrics.instrument
metrics.measurement

Module contents
---------------

.. automodule:: opentelemetry.metrics
11 changes: 11 additions & 0 deletions opentelemetry-api/src/opentelemetry/environment_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@
"""
.. envvar:: OTEL_PYTHON_TRACER_PROVIDER
"""

OTEL_PYTHON_METER_PROVIDER = "OTEL_PYTHON_METER_PROVIDER"
"""
.. envvar:: OTEL_PYTHON_METER_PROVIDER
"""

OTEL_METRICS_EXPORTER = "OTEL_METRICS_EXPORTER"
"""
.. envvar:: OTEL_METRICS_EXPORTER
"""
Loading

0 comments on commit 5f4cc99

Please sign in to comment.