Skip to content

Commit 79f38e7

Browse files
committed
2 parents c6008b9 + d3bb228 commit 79f38e7

File tree

60 files changed

+1557
-930
lines changed

Some content is hidden

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

60 files changed

+1557
-930
lines changed

.isort.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ line_length=79
1414
multi_line_output=3
1515
skip=target
1616
skip_glob=ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/gen/*
17+
known_first_party=opentelemetry

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ python:
77
- '3.5'
88
- '3.6'
99
- '3.7'
10+
- '3.8'
1011
- 'pypy3.5'
11-
- '3.8-dev'
1212

13-
matrix:
14-
allow_failures:
15-
- python: '3.8-dev'
13+
#matrix:
14+
# allow_failures:
15+
# - python: '3.8-dev'
1616

1717
install:
1818
- pip install tox-travis

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If you are looking for someone to help you find a starting point and be a resour
1919
Gitter and find a buddy!
2020

2121
1. Join [Gitter.im](https://gitter.im) and join our [chat room](https://gitter.im/open-telemetry/opentelemetry-python).
22-
2. Post in the room with an introduction to yourself, what area you are interested in (checks issues marked "Help Wanted"),
22+
2. Post in the room with an introduction to yourself, what area you are interested in (check issues marked "Help Wanted"),
2323
and say you are looking for a buddy. We will match you with someone who has experience in that area.
2424

2525
Your OpenTelemetry buddy is your resource to talk to directly on all aspects of contributing to OpenTelemetry: providing
@@ -37,7 +37,7 @@ You can run:
3737
under multiple Python versions
3838
- `tox -e docs` to regenerate the API docs
3939
- `tox -e test-api` and `tox -e test-sdk` to run the API and SDK unit tests
40-
- `tox -e py37-test-api` to e.g. run the the API unit tests under a specific
40+
- `tox -e py37-test-api` to e.g. run the API unit tests under a specific
4141
Python version
4242
- `tox -e lint` to run lint checks on all code
4343

@@ -115,7 +115,7 @@ It's especially valuable to read through the [library guidelines](https://github
115115
OpenTelemetry is an evolving specification, one where the desires and
116116
use cases are clear, but the method to satisfy those uses cases are not.
117117

118-
As such, Contributions should provide functionality and behavior that
118+
As such, contributions should provide functionality and behavior that
119119
conforms to the specification, but the interface and structure is flexible.
120120

121121
It is preferable to have contributions follow the idioms of the language

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ exporter.export([(counter, label_values)])
9595
exporter.shutdown()
9696
```
9797

98-
See the [API
99-
documentation](https://open-telemetry.github.io/opentelemetry-python/) for more
100-
detail, and the
101-
[opentelemetry-example-app](./examples/opentelemetry-example-app/README.rst)
102-
for a complete example.
98+
See the [API documentation](https://open-telemetry.github.io/opentelemetry-python/) for more detail, and the [examples folder](./examples) for a more sample code.
99+
100+
## Extensions
101+
102+
### Third-party exporters
103+
104+
OpenTelemetry supports integration with the following third-party exporters.
105+
106+
- [Azure Monitor](https://github.com/microsoft/opentelemetry-exporters-python/tree/master/azure_monitor)
103107

104108
## Contributing
105109

@@ -162,16 +166,16 @@ estimates, and subject to change.
162166

163167
Future releases targets include:
164168

165-
| Component | Version | Target Date |
166-
| ----------------------------------- | ---------- | ---------------- |
167-
| Zipkin Trace Exporter | Alpha v0.3 | November 15 2019 |
168-
| W3C Correlation Context Propagation | Alpha v0.3 | November 15 2019 |
169-
| Support for Tags/Baggage | Alpha v0.3 | November 15 2019 |
170-
| Metrics Aggregation | Alpha v0.3 | November 15 2019 |
171-
| gRPC Integrations | Alpha v0.3 | November 15 2019 |
172-
| Prometheus Metrics Exporter | Alpha v0.3 | November 15 2019 |
169+
| Component | Version | Target Date |
170+
| ----------------------------------- | ---------- | --------------- |
171+
| Zipkin Trace Exporter | Alpha v0.3 | December 6 2019 |
172+
| W3C Correlation Context Propagation | Alpha v0.3 | December 6 2019 |
173+
| Support for Tags/Baggage | Alpha v0.3 | December 6 2019 |
174+
| Metrics Aggregation | Alpha v0.3 | December 6 2019 |
175+
| gRPC Integrations | Alpha v0.3 | December 6 2019 |
176+
| Prometheus Metrics Exporter | Alpha v0.3 | December 6 2019 |
173177

174178
| Component | Version | Target Date |
175179
| ---------------------- | ---------- | ---------------- |
176180
| OpenCensus Bridge | Alpha v0.4 | December 31 2019 |
177-
| Metrics SDK (Complete) | Alpha v0.4 | December 31 2019 |
181+
| Metrics SDK (Complete) | Alpha v0.4 | December 31 2019 |

docs/conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import os
1414
import sys
1515

16-
sys.path.insert(0, os.path.abspath("../opentelemetry-api/src/"))
16+
sys.path[:0] = [
17+
os.path.abspath("../opentelemetry-api/src/"),
18+
os.path.abspath("../ext/opentelemetry-ext-opentracing-shim/src/"),
19+
]
1720

1821

1922
# -- Project information -----------------------------------------------------
@@ -47,7 +50,13 @@
4750
"sphinx.ext.githubpages",
4851
]
4952

50-
intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}
53+
intersphinx_mapping = {
54+
"python": ("https://docs.python.org/3/", None),
55+
"opentracing": (
56+
"https://opentracing-python.readthedocs.io/en/latest/",
57+
None,
58+
),
59+
}
5160

5261
# http://www.sphinx-doc.org/en/master/config.html#confval-nitpicky
5362
# Sphinx will warn about all references where the target cannot be found.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ abstract types for OpenTelemetry implementations.
1919
opentelemetry.metrics
2020
opentelemetry.trace
2121
opentelemetry.util.loader
22+
opentelemetry.ext.opentracing_shim
2223

2324

2425
Indices and tables
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
opentelemetry.ext.opentracing_shim package
2+
==========================================
3+
4+
Module contents
5+
---------------
6+
7+
.. automodule:: opentelemetry.ext.opentracing_shim
8+
:no-show-inheritance:

examples/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Examples
2+
This folder contains various examples to demonstrate using OpenTelemetry.
3+
4+
##### basic_tracer
5+
This example shows how to use OpenTelemetry to instrument an application - e.g. a batch job.
6+
7+
##### http
8+
This example shows how to use [OpenTelemetryMiddleware](https://github.com/open-telemetry/opentelemetry-python/tree/master/ext/opentelemetry-ext-wsgi) and [requests](https://github.com/open-telemetry/opentelemetry-python/tree/master/ext/opentelemetry-ext-http-requests) integrations to instrument a client and a server.
9+
10+
##### opentelemetry-example-app
11+
This package is a complete example of an application instrumented with OpenTelemetry.

examples/basic_tracer/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Overview
2+
3+
This example shows how to use OpenTelemetry to instrument a Python application - e.g. a batch job.
4+
It supports exporting spans either to the console or to [Jaeger](https://www.jaegertracing.io).
5+
6+
## Installation
7+
8+
```sh
9+
$ pip install opentelemetry-api opentelemetry-sdk
10+
```
11+
12+
Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one)
13+
14+
## Run the Application
15+
16+
### Console
17+
18+
* Run the sample
19+
20+
```bash
21+
$ # from this directory
22+
$ python tracer.py
23+
```
24+
25+
The output will be displayed at the console
26+
27+
```bash
28+
AsyncRuntimeContext({'current_span': Span(name="baz", context=SpanContext(trace_id=0xf906f80f64d57c71ea8da4dfbbd2ddf2, span_id=0x5611c1407e06e4d7, trace_state={}))})
29+
Span(name="baz", context=SpanContext(trace_id=0xf906f80f64d57c71ea8da4dfbbd2ddf2, span_id=0x5611c1407e06e4d7, trace_state={}), kind=SpanKind.INTERNAL, parent=Span(name="bar", context=SpanContext(trace_id=0xf906f80f64d57c71ea8da4dfbbd2ddf2, span_id=0x1b9db0e0cc1a3f60, trace_state={})), start_time=2019-11-07T21:26:45.934412Z, end_time=2019-11-07T21:26:45.934567Z)
30+
Span(name="bar", context=SpanContext(trace_id=0xf906f80f64d57c71ea8da4dfbbd2ddf2, span_id=0x1b9db0e0cc1a3f60, trace_state={}), kind=SpanKind.INTERNAL, parent=Span(name="foo", context=SpanContext(trace_id=0xf906f80f64d57c71ea8da4dfbbd2ddf2, span_id=0x1d5d87441ec2f410, trace_state={})), start_time=2019-11-07T21:26:45.934396Z, end_time=2019-11-07T21:26:45.934576Z)
31+
Span(name="foo", context=SpanContext(trace_id=0xf906f80f64d57c71ea8da4dfbbd2ddf2, span_id=0x1d5d87441ec2f410, trace_state={}), kind=SpanKind.INTERNAL, parent=None, start_time=2019-11-07T21:26:45.934369Z, end_time=2019-11-07T21:26:45.934580Z)
32+
```
33+
34+
35+
### Jaeger
36+
37+
* Run the sample
38+
39+
```sh
40+
$ pip install opentelemetry-ext-jaeger
41+
$ # from this directory
42+
$ EXPORTER=jaeger python tracer.py
43+
```
44+
45+
#### Jaeger UI
46+
47+
Open the Jaeger UI in your browser [http://localhost:16686](http://localhost:16686)
48+
49+
<p align="center"><img src="images/jaeger-ui.png?raw=true"/></p>
50+
Select `basic-service` under *Service Name* and click on *Find Traces*.
51+
52+
Click on the trace to view its details.
53+
54+
<p align="center"><img src="./images/jaeger-ui-detail.png?raw=true"/></p>
55+
56+
## Useful links
57+
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
58+
- For more information on tracing in Python, visit: <https://github.com/open-telemetry/opentelemetry-python>
59+
60+
## LICENSE
61+
62+
Apache License 2.0
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=C0103
12
# Copyright 2019, OpenTelemetry Authors
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,13 +12,3 @@
1112
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1213
# See the License for the specific language governing permissions and
1314
# limitations under the License.
14-
15-
"""
16-
The opentelemetry-ext-azure-monitor package provides integration with
17-
Microsoft Azure Monitor.
18-
"""
19-
20-
from opentelemetry.ext.azure_monitor.trace import AzureMonitorSpanExporter
21-
from opentelemetry.ext.azure_monitor.version import __version__ # noqa
22-
23-
__all__ = ["AzureMonitorSpanExporter"]
Loading
251 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2019, 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.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2019, 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+
import os
15+
import subprocess
16+
import sys
17+
import unittest
18+
19+
20+
class TestBasicTracerExample(unittest.TestCase):
21+
def test_basic_tracer(self):
22+
dirpath = os.path.dirname(os.path.realpath(__file__))
23+
test_script = "{}/../tracer.py".format(dirpath)
24+
output = subprocess.check_output(
25+
(sys.executable, test_script)
26+
).decode()
27+
28+
self.assertIn('name="foo"', output)
29+
self.assertIn('name="bar"', output)
30+
self.assertIn('name="baz"', output)

examples/basic_tracer/tracer.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2019, OpenTelemetry Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import os
18+
19+
from opentelemetry import trace
20+
from opentelemetry.context import Context
21+
from opentelemetry.sdk.trace import Tracer
22+
from opentelemetry.sdk.trace.export import (
23+
BatchExportSpanProcessor,
24+
ConsoleSpanExporter,
25+
)
26+
27+
if os.getenv("EXPORTER") == "jaeger":
28+
from opentelemetry.ext.jaeger import JaegerSpanExporter
29+
30+
exporter = JaegerSpanExporter(
31+
service_name="basic-service",
32+
agent_host_name="localhost",
33+
agent_port=6831,
34+
)
35+
else:
36+
exporter = ConsoleSpanExporter()
37+
38+
# The preferred tracer implementation must be set, as the opentelemetry-api
39+
# defines the interface with a no-op implementation.
40+
trace.set_preferred_tracer_implementation(lambda T: Tracer())
41+
tracer = trace.tracer()
42+
43+
# SpanExporter receives the spans and send them to the target location.
44+
span_processor = BatchExportSpanProcessor(exporter)
45+
46+
tracer.add_span_processor(span_processor)
47+
with tracer.start_as_current_span("foo"):
48+
with tracer.start_as_current_span("bar"):
49+
with tracer.start_as_current_span("baz"):
50+
print(Context)

0 commit comments

Comments
 (0)