Skip to content

Commit 0336f3e

Browse files
authored
Merge branch 'master' into tracer_provider_force_flush
2 parents b4277bf + e119285 commit 0336f3e

File tree

42 files changed

+422
-159
lines changed

Some content is hidden

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

42 files changed

+422
-159
lines changed

docs-requirements.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ sphinx-rtd-theme~=0.4
33
sphinx-autodoc-typehints~=1.10.2
44

55
# Required by ext packages
6-
opentracing~=2.2.0
76
Deprecated>=1.2.6
8-
thrift>=0.10.0
9-
pymongo~=3.1
7+
PyMySQL~=0.9.3
108
flask~=1.0
11-
mysql-connector-python ~= 8.0
12-
wrapt >= 1.0.0, < 2.0.0
13-
psycopg2-binary >= 2.7.3.1
14-
prometheus_client >= 0.5.0, < 1.0.0
9+
mysql-connector-python~=8.0
10+
opentracing~=2.2.0
11+
prometheus_client>=0.5.0,<1.0.0
12+
psycopg2-binary>=2.7.3.1
13+
pymongo~=3.1
14+
redis>=2.6
15+
thrift>=0.10.0
16+
wrapt >=1.0.0,<2.0.0

docs/examples/auto-instrumentation/README.md

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ $ source auto_instrumentation/bin/activate
5555
# Installation
5656

5757
```sh
58-
$ pip install opentelemetry-api
5958
$ pip install opentelemetry-sdk
6059
$ pip install opentelemetry-auto-instrumentation
61-
$ pip install ext/opentelemetry-ext-flask
62-
$ pip install flask
60+
$ pip install opentelemetry-ext-flask
6361
$ pip install requests
6462
```
6563

@@ -71,42 +69,97 @@ This is done in 2 separate consoles, one to run each of the scripts that make up
7169

7270
```sh
7371
$ source auto_instrumentation/bin/activate
74-
$ python opentelemetry-python/opentelemetry-auto-instrumentation/example/server_instrumented.py
72+
$ python opentelemetry-python/docs/examples/auto-instrumentation/server_instrumented.py
7573
```
7674

7775
```sh
7876
$ source auto_instrumentation/bin/activate
79-
$ python opentelemetry-python/opentelemetry-auto-instrumentation/example/client.py testing
77+
$ python opentelemetry-python/docs/examples/auto-instrumentation/client.py testing
8078
```
8179

8280
The execution of `server_instrumented.py` should return an output similar to:
8381

8482
```sh
85-
Hello, testing!
86-
Span(name="serv_request", context=SpanContext(trace_id=0x9c0e0ce8f7b7dbb51d1d6e744a4dad49, span_id=0xd1ba3ec4c76a0d7f, trace_state={}), kind=SpanKind.INTERNAL, parent=None, start_time=2020-03-19T00:06:31.275719Z, end_time=2020-03-19T00:06:31.275920Z)
87-
127.0.0.1 - - [18/Mar/2020 18:06:31] "GET /serv_request?helloStr=Hello%2C+testing%21 HTTP/1.1" 200 -
83+
{
84+
"name": "server_request",
85+
"context": {
86+
"trace_id": "0xfa002aad260b5f7110db674a9ddfcd23",
87+
"span_id": "0x8b8bbaf3ca9c5131",
88+
"trace_state": "{}"
89+
},
90+
"kind": "SpanKind.SERVER",
91+
"parent_id": null,
92+
"start_time": "2020-04-30T17:28:57.886397Z",
93+
"end_time": "2020-04-30T17:28:57.886490Z",
94+
"status": {
95+
"canonical_code": "OK"
96+
},
97+
"attributes": {
98+
"component": "http",
99+
"http.method": "GET",
100+
"http.server_name": "127.0.0.1",
101+
"http.scheme": "http",
102+
"host.port": 8082,
103+
"http.host": "localhost:8082",
104+
"http.target": "/server_request?param=testing",
105+
"net.peer.ip": "127.0.0.1",
106+
"net.peer.port": 52872,
107+
"http.flavor": "1.1"
108+
},
109+
"events": [],
110+
"links": []
111+
}
88112
```
89113

90114
## Execution of an automatically instrumented server
91115

92116
Now, kill the execution of `server_instrumented.py` with `ctrl + c` and run this instead:
93117

94118
```sh
95-
$ opentelemetry-auto-instrumentation opentelemetry-python/opentelemetry-auto-instrumentation/example/server_uninstrumented.py
119+
$ opentelemetry-auto-instrumentation python docs/examples/auto-instrumentation/server_uninstrumented.py
96120
```
97121

98122
In the console where you previously executed `client.py`, run again this again:
99123

100124
```sh
101-
$ python opentelemetry-python/opentelemetry-auto-instrumentation/example/client.py testing
125+
$ python opentelemetry-python/docs/examples/auto-instrumentation/client.py testing
102126
```
103127

104128
The execution of `server_uninstrumented.py` should return an output similar to:
105129

106130
```sh
107-
Hello, testing!
108-
Span(name="serv_request", context=SpanContext(trace_id=0xf26b28b5243e48f5f96bfc753f95f3f0, span_id=0xbeb179a095d087ed, trace_state={}), kind=SpanKind.SERVER, parent=<opentelemetry.trace.DefaultSpan object at 0x7f1a20a54908>, start_time=2020-03-19T00:24:18.828561Z, end_time=2020-03-19T00:24:18.845127Z)
109-
127.0.0.1 - - [18/Mar/2020 18:24:18] "GET /serv_request?helloStr=Hello%2C+testing%21 HTTP/1.1" 200 -
131+
{
132+
"name": "server_request",
133+
"context": {
134+
"trace_id": "0x9f528e0b76189f539d9c21b1a7a2fc24",
135+
"span_id": "0xd79760685cd4c269",
136+
"trace_state": "{}"
137+
},
138+
"kind": "SpanKind.SERVER",
139+
"parent_id": "0xb4fb7eee22ef78e4",
140+
"start_time": "2020-04-30T17:10:02.400604Z",
141+
"end_time": "2020-04-30T17:10:02.401858Z",
142+
"status": {
143+
"canonical_code": "OK"
144+
},
145+
"attributes": {
146+
"component": "http",
147+
"http.method": "GET",
148+
"http.server_name": "127.0.0.1",
149+
"http.scheme": "http",
150+
"host.port": 8082,
151+
"http.host": "localhost:8082",
152+
"http.target": "/server_request?param=testing",
153+
"net.peer.ip": "127.0.0.1",
154+
"net.peer.port": 48240,
155+
"http.flavor": "1.1",
156+
"http.route": "/server_request",
157+
"http.status_text": "OK",
158+
"http.status_code": 200
159+
},
160+
"events": [],
161+
"links": []
162+
}
110163
```
111164

112-
As you can see, both outputs are equivalentsince the automatic instrumentation does what the manual instrumentation does too.
165+
Both outputs are equivalent since the automatic instrumentation does what the manual instrumentation does too.

docs/examples/auto-instrumentation/server_instrumented.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from flask import Flask, request
1616

1717
from opentelemetry import propagators, trace
18+
from opentelemetry.ext.wsgi import collect_request_attributes
1819
from opentelemetry.sdk.trace import TracerProvider
1920
from opentelemetry.sdk.trace.export import (
2021
ConsoleSpanExporter,
@@ -38,6 +39,8 @@ def server_request():
3839
parent=propagators.extract(
3940
lambda dict_, key: dict_.get(key, []), request.headers
4041
)["current-span"],
42+
kind=trace.SpanKind.SERVER,
43+
attributes=collect_request_attributes(request.environ),
4144
):
4245
print(request.args.get("param"))
4346
return "served"

docs/examples/http/README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ HTTP Integration Example
33

44
This example shows how to use
55
:doc:`WSGI Middleware <../../ext/wsgi/wsgi>`
6-
and :doc:`requests <../../ext/http_requests/http_requests>` integrations to
6+
and :doc:`requests <../../ext/requests/requests>` integrations to
77
instrument an HTTP client and server in Python.
88

99
The source files required to run this example are available :scm_web:`here <docs/examples/http/>`.
@@ -16,7 +16,7 @@ Installation
1616
pip install opentelemetry-api
1717
pip install opentelemetry-sdk
1818
pip install opentelemetry-ext-wsgi
19-
pip install opentelemetry-ext-http-requests
19+
pip install opentelemetry-ext-requests
2020
pip install flask
2121
2222
@@ -60,6 +60,6 @@ Useful links
6060
- OpenTelemetry_
6161
- :doc:`../../api/trace`
6262
- :doc:`../../ext/wsgi/wsgi`
63-
- :doc:`../../ext/http_requests/http_requests`
63+
- :doc:`../../ext/requests/requests`
6464

6565
.. _OpenTelemetry: https://github.com/open-telemetry/opentelemetry-python/

docs/examples/http/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import requests
2020

2121
from opentelemetry import trace
22-
from opentelemetry.ext import http_requests
22+
from opentelemetry.ext.requests import RequestsInstrumentor
2323
from opentelemetry.sdk.trace import TracerProvider
2424
from opentelemetry.sdk.trace.export import (
2525
BatchExportSpanProcessor,
@@ -32,7 +32,7 @@
3232
trace.set_tracer_provider(TracerProvider())
3333

3434
# Enable instrumentation in the requests library.
35-
http_requests.RequestsInstrumentor().instrument()
35+
RequestsInstrumentor().instrument()
3636

3737
# Configure a console span exporter.
3838
exporter = ConsoleSpanExporter()

docs/examples/http/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import requests
2121

2222
from opentelemetry import trace
23-
from opentelemetry.ext import http_requests
23+
from opentelemetry.ext.requests import RequestsInstrumentor
2424
from opentelemetry.ext.wsgi import OpenTelemetryMiddleware
2525
from opentelemetry.sdk.trace import TracerProvider
2626
from opentelemetry.sdk.trace.export import (
@@ -36,7 +36,7 @@
3636
# Integrations are the glue that binds the OpenTelemetry API and the
3737
# frameworks and libraries that are used together, automatically creating
3838
# Spans and propagating context as appropriate.
39-
http_requests.RequestsInstrumentor().instrument()
39+
RequestsInstrumentor().instrument()
4040
app = flask.Flask(__name__)
4141
app.wsgi_app = OpenTelemetryMiddleware(app.wsgi_app)
4242

docs/examples/opentelemetry-example-app/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"typing; python_version<'3.5'",
3838
"opentelemetry-api",
3939
"opentelemetry-sdk",
40-
"opentelemetry-ext-http-requests",
40+
"opentelemetry-ext-requests",
4141
"opentelemetry-ext-flask",
4242
"flask",
4343
"requests",

docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import flask
2020
import requests
2121

22-
import opentelemetry.ext.http_requests
22+
import opentelemetry.ext.requests
2323
from opentelemetry import trace
2424
from opentelemetry.ext.flask import FlaskInstrumentor
2525
from opentelemetry.sdk.trace import TracerProvider
@@ -33,7 +33,7 @@
3333
# It must be done before instrumenting any library
3434
trace.set_tracer_provider(TracerProvider())
3535

36-
opentelemetry.ext.http_requests.RequestsInstrumentor().instrument()
36+
opentelemetry.ext.requests.RequestsInstrumentor().instrument()
3737
FlaskInstrumentor().instrument()
3838

3939
trace.get_tracer_provider().add_span_processor(

docs/ext/grpc/grpc.client_interceptor.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/ext/grpc/grpc.rst

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
.. include:: ../../../ext/opentelemetry-ext-grpc/README.rst
2-
3-
Submodules
4-
----------
5-
6-
.. toctree::
7-
8-
grpc.client_interceptor
9-
grpc.server_interceptor
1+
OpenTelemetry gRPC Integration
2+
==============================
103

114
Module contents
125
---------------

0 commit comments

Comments
 (0)