Skip to content

Commit 594ed31

Browse files
authored
Merge branch 'master' into feature
2 parents 7785468 + 39fa078 commit 594ed31

File tree

274 files changed

+10249
-1239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+10249
-1239
lines changed

Diff for: .flake8

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ exclude =
2020
ext/opentelemetry-ext-jaeger/build/*
2121
docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/grpc/gen/
2222
docs/examples/opentelemetry-example-app/build/*
23+
opentelemetry-proto/src/opentelemetry/proto/

Diff for: .isort.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ line_length=79
1313
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
1414
multi_line_output=3
1515
skip=target
16-
skip_glob=**/gen/*,.venv*/*,venv*/*
16+
skip_glob=**/gen/*,.venv*/*,venv*/*,**/proto/*
1717
known_first_party=opentelemetry,opentelemetry_example_app
1818
known_third_party=psutil,pytest,redis,redis_opentracing

Diff for: .pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extension-pkg-whitelist=
77

88
# Add files or directories to the blacklist. They should be base names, not
99
# paths.
10-
ignore=CVS,gen
10+
ignore=CVS,gen,proto
1111

1212
# Add files or directories matching the regex patterns to the blacklist. The
1313
# regex matches against base names, not paths.

Diff for: README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,30 @@ Meeting notes are available as a public [Google doc](https://docs.google.com/doc
103103

104104
Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)):
105105

106-
- [Carlos Alberto Cortez](https://github.com/carlosalberto), LightStep
106+
- [Carlos Alberto Cortez](https://github.com/carlosalberto), Lightstep
107+
- [Tahir H. Butt](https://github.com/majorgreys) DataDog
107108
- [Chris Kleinknecht](https://github.com/c24t), Google
108109
- [Diego Hurtado](https://github.com/ocelotl)
109110
- [Hector Hernandez](https://github.com/hectorhdzg), Microsoft
110-
- [Leighton Chen](https://github.com/lzchen), Microsoft
111111
- [Mauricio Vásquez](https://github.com/mauriciovasquezbernal), Kinvolk
112112
- [Reiley Yang](https://github.com/reyang), Microsoft
113113

114114
*Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver).*
115115

116116
Maintainers ([@open-telemetry/python-maintainers](https://github.com/orgs/open-telemetry/teams/python-maintainers)):
117117

118-
- [Alex Boten](https://github.com/codeboten), LightStep
118+
- [Alex Boten](https://github.com/codeboten), Lightstep
119+
- [Leighton Chen](https://github.com/lzchen), Microsoft
119120
- [Yusuke Tsutsumi](https://github.com/toumorokoshi), Zillow Group
120121

122+
*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).*
123+
121124
### Thanks to all the people who already contributed!
122125

123126
<a href="https://github.com/open-telemetry/opentelemetry-python/graphs/contributors">
124127
<img src="https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-python" />
125128
</a>
126129

127-
*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).*
128-
129130
## Release Schedule
130131

131132
OpenTelemetry Python is under active development.

Diff for: dev-requirements.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ pylint==2.4.4
22
flake8==3.7.9
33
isort~=4.3
44
black>=19.3b0,==19.*
5-
mypy==0.740
5+
mypy==0.770
66
sphinx~=2.1
77
sphinx-rtd-theme~=0.4
88
sphinx-autodoc-typehints~=1.10.2
99
pytest!=5.2.3
1010
pytest-cov>=2.8
11-
readme-renderer~=24.0
12-
httpretty~=1.0
13-
opentracing~=2.2.0
11+
readme-renderer~=24.0

Diff for: docs-requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ mysql-connector-python~=8.0
1414
opentracing~=2.2.0
1515
prometheus_client>=0.5.0,<1.0.0
1616
psycopg2-binary>=2.7.3.1
17+
pymemcache~=1.3
1718
pymongo~=3.1
19+
pyramid>=1.7
1820
redis>=2.6
1921
sqlalchemy>=1.0
2022
thrift>=0.10.0
2123
wrapt>=1.0.0,<2.0.0
2224
psutil~=5.7.0
2325
boto~=2.0
2426
google-cloud-trace >=0.23.0
27+
google-cloud-monitoring>=0.36.0
28+
botocore~=1.0
29+
starlette~=0.13

Diff for: docs/api/trace.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Submodules
88

99
trace.sampling
1010
trace.status
11+
trace.span
1112

1213
Module contents
1314
---------------
1415

15-
.. automodule:: opentelemetry.trace
16+
.. automodule:: opentelemetry.trace

Diff for: docs/api/trace.span.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
opentelemetry.trace.span
2+
========================
3+
4+
.. automodule:: opentelemetry.trace.span
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

Diff for: docs/auto_instrumentation/auto_instrumentation.rst

-15
This file was deleted.

Diff for: docs/auto_instrumentation/instrumentor.rst

-7
This file was deleted.

Diff for: docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
source_dirs = [
2828
os.path.abspath("../opentelemetry-api/src/"),
2929
os.path.abspath("../opentelemetry-sdk/src/"),
30-
os.path.abspath("../opentelemetry-auto-instrumentation/src/"),
30+
os.path.abspath("../opentelemetry-instrumentation/src/"),
3131
]
3232

3333
ext = "../ext"

Diff for: docs/examples/auto-instrumentation/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Installation
7272
.. code:: sh
7373
7474
$ pip install opentelemetry-sdk
75-
$ pip install opentelemetry-auto-instrumentation
75+
$ pip install opentelemetry-instrumentation
7676
$ pip install opentelemetry-ext-flask
7777
$ pip install requests
7878
@@ -138,7 +138,7 @@ and run this instead:
138138

139139
.. code:: sh
140140
141-
$ opentelemetry-auto-instrumentation python server_uninstrumented.py
141+
$ opentelemetry-instrument python server_uninstrumented.py
142142
143143
In the console where you previously executed ``client.py``, run again
144144
this again:

Diff for: docs/examples/basic_meter/basic_metrics.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
from opentelemetry import metrics
2727
from opentelemetry.sdk.metrics import Counter, MeterProvider, ValueRecorder
2828
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter
29-
from opentelemetry.sdk.metrics.export.controller import PushController
30-
31-
stateful = True
3229

3330
print(
3431
"Starting example, values will be printed to the console every 5 seconds."
@@ -37,17 +34,21 @@
3734
# Stateful determines whether how metrics are collected: if true, metrics
3835
# accumulate over the process lifetime. If false, metrics are reset at the
3936
# beginning of each collection interval.
40-
metrics.set_meter_provider(MeterProvider(stateful))
37+
stateful = True
38+
39+
# Sets the global MeterProvider instance
40+
metrics.set_meter_provider(MeterProvider())
41+
4142
# The Meter is responsible for creating and recording metrics. Each meter has a
4243
# unique name, which we set as the module's name here.
4344
meter = metrics.get_meter(__name__)
4445

4546
# Exporter to export metrics to the console
4647
exporter = ConsoleMetricsExporter()
4748

48-
# A PushController collects metrics created from meter and exports it via the
49-
# exporter every interval
50-
controller = PushController(meter=meter, exporter=exporter, interval=5)
49+
# start_pipeline will notify the MeterProvider to begin collecting/exporting
50+
# metrics with the given meter, exporter and interval in seconds
51+
metrics.get_meter_provider().start_pipeline(meter, exporter, 5)
5152

5253
# Metric instruments allow to capture measurements
5354
requests_counter = meter.create_metric(
@@ -77,7 +78,7 @@
7778
# Update the metric instruments using the direct calling convention
7879
requests_counter.add(25, staging_labels)
7980
requests_size.record(100, staging_labels)
80-
time.sleep(5)
81+
time.sleep(10)
8182

8283
requests_counter.add(50, staging_labels)
8384
requests_size.record(5000, staging_labels)

Diff for: docs/examples/basic_meter/calling_conventions.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
from opentelemetry import metrics
2222
from opentelemetry.sdk.metrics import Counter, MeterProvider, ValueRecorder
2323
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter
24-
from opentelemetry.sdk.metrics.export.controller import PushController
2524

2625
# Use the meter type provided by the SDK package
2726
metrics.set_meter_provider(MeterProvider())
2827
meter = metrics.get_meter(__name__)
29-
exporter = ConsoleMetricsExporter()
30-
controller = PushController(meter=meter, exporter=exporter, interval=5)
28+
metrics.get_meter_provider().start_pipeline(meter, ConsoleMetricsExporter(), 5)
3129

3230
requests_counter = meter.create_metric(
3331
name="requests",
@@ -62,7 +60,7 @@
6260
# You can record metrics directly using the metric instrument. You pass in
6361
# labels that you would like to record for.
6462
requests_counter.add(25, labels)
65-
time.sleep(5)
63+
time.sleep(10)
6664

6765
print("Updating using a bound instrument...")
6866
# You can record metrics with bound metric instruments. Bound metric

Diff for: docs/examples/basic_meter/observer.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919
import psutil
2020

2121
from opentelemetry import metrics
22-
from opentelemetry.sdk.metrics import MeterProvider
22+
from opentelemetry.sdk.metrics import MeterProvider, ValueObserver
2323
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter
24-
from opentelemetry.sdk.metrics.export.batcher import UngroupedBatcher
25-
from opentelemetry.sdk.metrics.export.controller import PushController
2624

2725
metrics.set_meter_provider(MeterProvider())
2826
meter = metrics.get_meter(__name__)
29-
exporter = ConsoleMetricsExporter()
30-
controller = PushController(meter=meter, exporter=exporter, interval=2)
27+
metrics.get_meter_provider().start_pipeline(meter, ConsoleMetricsExporter(), 5)
3128

3229

3330
# Callback to gather cpu usage
@@ -43,6 +40,7 @@ def get_cpu_usage_callback(observer):
4340
description="per-cpu usage",
4441
unit="1",
4542
value_type=float,
43+
observer_type=ValueObserver,
4644
label_keys=("cpu_number",),
4745
)
4846

@@ -59,6 +57,7 @@ def get_ram_usage_callback(observer):
5957
description="RAM memory usage",
6058
unit="1",
6159
value_type=float,
60+
observer_type=ValueObserver,
6261
label_keys=(),
6362
)
6463

Diff for: docs/examples/cloud_monitoring/README.rst

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Cloud Monitoring Exporter Example
2+
=================================
3+
4+
These examples show how to use OpenTelemetry to send metrics data to Cloud Monitoring.
5+
6+
7+
Basic Example
8+
-------------
9+
10+
To use this exporter you first need to:
11+
* `Create a Google Cloud project <https://console.cloud.google.com/projectcreate>`_.
12+
* Enable the Cloud Monitoring API (aka Stackdriver Monitoring API) in the project `here <https://console.cloud.google.com/apis/library?q=cloud_monitoring>`_.
13+
* Enable `Default Application Credentials <https://developers.google.com/identity/protocols/application-default-credentials>`_.
14+
15+
* Installation
16+
17+
.. code-block:: sh
18+
19+
pip install opentelemetry-api
20+
pip install opentelemetry-sdk
21+
pip install opentelemetry-exporter-cloud-monitoring
22+
23+
* Run example
24+
25+
.. code-block:: sh
26+
27+
python basic_metrics.py
28+
29+
Viewing Output
30+
--------------------------
31+
32+
After running the example:
33+
* Go to the `Cloud Monitoring Metrics Explorer page <https://console.cloud.google.com/monitoring/metrics-explorer>`_.
34+
* In "Find resource type and metric" enter "OpenTelemetry/request_counter".
35+
* You can filter by labels and change the graphical output here as well.

Diff for: docs/examples/cloud_monitoring/basic_metrics.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
# Copyright The OpenTelemetry Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
import time
17+
18+
from opentelemetry import metrics
19+
from opentelemetry.exporter.cloud_monitoring import (
20+
CloudMonitoringMetricsExporter,
21+
)
22+
from opentelemetry.sdk.metrics import Counter, MeterProvider
23+
24+
metrics.set_meter_provider(MeterProvider())
25+
meter = metrics.get_meter(__name__)
26+
metrics.get_meter_provider().start_pipeline(
27+
meter, CloudMonitoringMetricsExporter(), 5
28+
)
29+
30+
requests_counter = meter.create_metric(
31+
name="request_counter",
32+
description="number of requests",
33+
unit="1",
34+
value_type=int,
35+
metric_type=Counter,
36+
label_keys=("environment"),
37+
)
38+
39+
staging_labels = {"environment": "staging"}
40+
41+
for i in range(20):
42+
requests_counter.add(25, staging_labels)
43+
time.sleep(10)

Diff for: docs/examples/cloud_trace_exporter/README.rst

+19-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Basic Example
99

1010
To use this exporter you first need to:
1111
* A Google Cloud project. You can `create one here. <https://console.cloud.google.com/projectcreate>`_
12-
* Enable Cloud Trace API (aka StackDriver Trace API) in the project `here. <https://console.cloud.google.com/apis/library?q=cloud_trace>`_
12+
* Enable Cloud Trace API (aka Stackdriver Trace API) in the project `here. <https://console.cloud.google.com/apis/library?q=cloud_trace>`_
1313
* Enable `Default Application Credentials. <https://developers.google.com/identity/protocols/application-default-credentials>`_
1414

1515
* Installation
@@ -20,15 +20,31 @@ To use this exporter you first need to:
2020
pip install opentelemetry-sdk
2121
pip install opentelemetry-exporter-cloud-trace
2222
23-
* Run example
23+
* Run example locally
2424

2525
.. code-block:: sh
2626
27+
cd opentelemetry-python/docs/examples/cloud_trace_exporter
2728
python basic_trace.py
2829
2930
Checking Output
3031
--------------------------
3132

3233
After running any of these examples, you can go to `Cloud Trace overview <https://console.cloud.google.com/traces/list>`_ to see the results.
3334

34-
* `More information about exporters in general <https://opentelemetry-python.readthedocs.io/en/stable/getting-started.html#configure-exporters-to-emit-spans-elsewhere>`_
35+
36+
Further Reading
37+
--------------------------
38+
39+
* `More information about exporters in general <https://opentelemetry-python.readthedocs.io/en/stable/getting-started.html#configure-exporters-to-emit-spans-elsewhere>`_
40+
41+
Troubleshooting
42+
--------------------------
43+
44+
Running basic_trace.py hangs:
45+
#############################
46+
* Make sure you've setup Application Default Credentials. Either run ``gcloud auth application-default login`` or set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to be a path to a service account token file.
47+
48+
Getting error ``google.api_core.exceptions.ResourceExhausted: 429 Resource has been exhausted``:
49+
################################################################################################
50+
* Check that you've enabled the `Cloud Trace (Stackdriver Trace) API <https://console.cloud.google.com/apis/library?q=cloud_trace>`_

0 commit comments

Comments
 (0)