Skip to content

Commit 262f04f

Browse files
c24tmauriciovasquezbernal
authored andcommitted
Version bump for 0.5.dev0 on master (open-telemetry#443)
Rename TracerSource to TracerProvider (open-telemetry#441) Following discussion in open-telemetry#434, align the name with the specification. Co-authored-by: Chris Kleinknecht <[email protected]> Fix new ext READMEs (open-telemetry#444) Some of the new ext packages had ReStructuredText errors. PyPI rejected the uploads for these packages with: HTTPError: 400 Client Error: The description failed to render for 'text/x-rst'. See https://pypi.org/help/#description-content-type for more information. for url: https://upload.pypi.org/legacy/ Adding attach/detach methods as per spec (open-telemetry#429) This change updates the Context API with the following: - removes the remove_value method - removes the set_current method - adds attach and detach methods Fixes open-telemetry#420 Co-authored-by: Chris Kleinknecht <[email protected]> Make Counter and MinMaxSumCount aggregators thread safe (open-telemetry#439) OT Collector trace exporter (open-telemetry#405) Based on the OpenCensus agent exporter. Fixes open-telemetry#343 Co-authored-by: Chris Kleinknecht <[email protected]> API: Renaming TraceOptions to TraceFlags (open-telemetry#450) Renaming TraceOptions to TraceFlags, which is the term used to describe the flags associated with the trace in the OpenTelemetry specification. Closes open-telemetry#434 api: Implement "named" meters + Remove "Batcher" from Meter constructor (open-telemetry#431) Implements open-telemetry#221. Also fixes open-telemetry#394. Stateful.py and stateless.py in metrics example folder are not changed to use the new loader in anticipation of open-telemetry#422 being merged first and removing them. Lastly, moves InstrumentationInfo from trace.py in the sdk to utils. Prepare to host on readthedocs.org (open-telemetry#452) sdk: Implement observer instrument (open-telemetry#425) Observer instruments are used to capture a current set of values at a point in time [1]. This commit extends the Meter interface to allow to register an observer instrument by pasing a callback that will be executed at collection time. The logic inside collection is updated to consider these instruments and a new ObserverAggregator is implemented. [1] https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/api-metrics.md#observer-instruments sdk: fix ConsoleSpanExporter (open-telemetry#455) 19d573a ("Add io and formatter options to console exporter (open-telemetry#412)") changed the way spans are printed by using write() instead of print(). In Python 3.x sys.stdout is line-buffered, so the spans were not being printed to the console at the right timing. This commit fixes that by adding an explicit flush() call at the end of the export function , it also changes the default formatter to include a line break. To be precise, only one of the changes was needed to solve the problem, but as a matter of completness both are included, i.e, to handle the case where the formatter chosen by the user doesn't append a line break. jaeger: Usage README Update for opentelemetry-ext-jaeger (open-telemetry#459) Usage docs for opentelemetry-ext-jaeger need to be updated after the change to `TracerSource` with v0.4. Looks like it was partially updated already. Users following the usage docs will currently run into this error: `AttributeError: 'Tracer' object has no attribute 'add_span_processor'` api: Implementing Propagators API to use Context (open-telemetry#446) Implementing Propagators API to use Context. Moving tracecontexthttptextformat to trace/propagation, as TraceContext is specific to trace rather that broader context propagation. Using attach/detach for wsgi and flask extensions, enabling activation of the full context rather that activating of a sub component such as traces. Adding a composite propagator. Co-authored-by: Mauricio Vásquez <[email protected]>
1 parent 8e79c3f commit 262f04f

File tree

122 files changed

+2869
-1433
lines changed

Some content is hidden

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

122 files changed

+2869
-1433
lines changed

.readthedocs.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
version: 2
4+
5+
sphinx:
6+
configuration: docs/conf.py
7+
8+
build:
9+
image: latest
10+
11+
python:
12+
version: 3.8
13+
install:
14+
- requirements: docs-requirements.txt

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ pip install -e ./ext/opentelemetry-ext-{integration}
5151

5252
```python
5353
from opentelemetry import trace
54-
from opentelemetry.sdk.trace import TracerSource
54+
from opentelemetry.sdk.trace import TracerProvider
5555
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
5656
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
5757

58-
trace.set_preferred_tracer_source_implementation(lambda T: TracerSource())
59-
trace.tracer_source().add_span_processor(
58+
trace.set_preferred_tracer_provider_implementation(lambda T: TracerProvider())
59+
trace.tracer_provider().add_span_processor(
6060
SimpleExportSpanProcessor(ConsoleSpanExporter())
6161
)
6262
tracer = trace.get_tracer(__name__)
@@ -70,12 +70,14 @@ with tracer.start_as_current_span('foo'):
7070

7171
```python
7272
from opentelemetry import metrics
73-
from opentelemetry.sdk.metrics import Counter, Meter
73+
from opentelemetry.sdk.metrics import Counter, MeterProvider
7474
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter
75+
from opentelemetry.sdk.metrics.export.controller import PushController
7576

76-
metrics.set_preferred_meter_implementation(lambda T: Meter())
77-
meter = metrics.meter()
77+
metrics.set_preferred_meter_provider_implementation(lambda _: MeterProvider())
78+
meter = metrics.get_meter(__name__)
7879
exporter = ConsoleMetricsExporter()
80+
controller = PushController(meter, exporter, 5)
7981

8082
counter = meter.create_metric(
8183
"available memory",
@@ -89,9 +91,6 @@ counter = meter.create_metric(
8991
label_values = ("staging",)
9092
counter_handle = counter.get_handle(label_values)
9193
counter_handle.add(100)
92-
93-
exporter.export([(counter, label_values)])
94-
exporter.shutdown()
9594
```
9695

9796
See the [API documentation](https://open-telemetry.github.io/opentelemetry-python/) for more detail, and the [examples folder](./examples) for a more sample code.

docs-requirements.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sphinx~=2.4
2+
sphinx-rtd-theme~=0.4
3+
sphinx-autodoc-typehints~=1.10.2
4+
5+
# Required by ext packages
6+
opentracing~=2.2.0
7+
Deprecated>=1.2.6
8+
thrift>=0.10.0
9+
pymongo~=3.1
10+
flask~=1.0

docs/opentelemetry.sdk.metrics.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Submodules
88

99
opentelemetry.sdk.metrics.export.aggregate
1010
opentelemetry.sdk.metrics.export.batcher
11+
opentelemetry.sdk.util.instrumentation
1112

1213
.. automodule:: opentelemetry.sdk.metrics
1314
:members:

docs/opentelemetry.sdk.trace.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Submodules
77
.. toctree::
88

99
opentelemetry.sdk.trace.export
10+
opentelemetry.sdk.util.instrumentation
1011

1112
.. automodule:: opentelemetry.sdk.trace
1213
:members:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
opentelemetry.sdk.util.instrumentation
2+
==========================================
3+
4+
.. automodule:: opentelemetry.sdk.util.instrumentation

examples/basic_tracer/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@ Click on the trace to view its details.
5353

5454
<p align="center"><img src="./images/jaeger-ui-detail.png?raw=true"/></p>
5555

56+
### Collector
57+
58+
* Start Collector
59+
60+
```sh
61+
$ pip install docker-compose
62+
$ cd docker
63+
$ docker-compose up
64+
65+
* Run the sample
66+
67+
$ pip install opentelemetry-ext-otcollector
68+
$ # from this directory
69+
$ EXPORTER=collector python tracer.py
70+
```
71+
72+
Collector is configured to export to Jaeger, follow Jaeger UI isntructions to find the traces.
73+
74+
75+
5676
## Useful links
5777
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
5878
- For more information on tracing in Python, visit: <https://github.com/open-telemetry/opentelemetry-python>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
receivers:
2+
opencensus:
3+
endpoint: "0.0.0.0:55678"
4+
5+
exporters:
6+
jaeger_grpc:
7+
endpoint: jaeger-all-in-one:14250
8+
logging: {}
9+
10+
processors:
11+
batch:
12+
queued_retry:
13+
14+
service:
15+
pipelines:
16+
traces:
17+
receivers: [opencensus]
18+
exporters: [jaeger_grpc, logging]
19+
processors: [batch, queued_retry]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: "2"
2+
services:
3+
4+
# Collector
5+
collector:
6+
image: omnition/opentelemetry-collector-contrib:latest
7+
command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"]
8+
volumes:
9+
- ./collector-config.yaml:/conf/collector-config.yaml
10+
ports:
11+
- "55678:55678"
12+
13+
jaeger-all-in-one:
14+
image: jaegertracing/all-in-one:latest
15+
ports:
16+
- "16686:16686"
17+
- "6831:6831/udp"
18+
- "6832:6832/udp"
19+
- "14268"
20+
- "14250"

examples/basic_tracer/tracer.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818

1919
from opentelemetry import trace
20-
from opentelemetry.sdk.trace import TracerSource
20+
from opentelemetry.sdk.trace import TracerProvider
2121
from opentelemetry.sdk.trace.export import (
2222
BatchExportSpanProcessor,
2323
ConsoleSpanExporter,
@@ -26,17 +26,28 @@
2626
if os.getenv("EXPORTER") == "jaeger":
2727
from opentelemetry.ext.jaeger import JaegerSpanExporter
2828

29+
print("Using JaegerSpanExporter")
2930
exporter = JaegerSpanExporter(
3031
service_name="basic-service",
3132
agent_host_name="localhost",
3233
agent_port=6831,
3334
)
35+
elif os.getenv("EXPORTER") == "collector":
36+
from opentelemetry.ext.otcollector.trace_exporter import (
37+
CollectorSpanExporter,
38+
)
39+
40+
print("Using CollectorSpanExporter")
41+
exporter = CollectorSpanExporter(
42+
service_name="basic-service", endpoint="localhost:55678"
43+
)
3444
else:
45+
print("Using ConsoleSpanExporter")
3546
exporter = ConsoleSpanExporter()
3647

3748
# The preferred tracer implementation must be set, as the opentelemetry-api
3849
# defines the interface with a no-op implementation.
39-
trace.set_preferred_tracer_source_implementation(lambda T: TracerSource())
50+
trace.set_preferred_tracer_provider_implementation(lambda T: TracerProvider())
4051

4152
# We tell OpenTelemetry who it is that is creating spans. In this case, we have
4253
# no real name (no setup.py), so we make one up. If we had a version, we would
@@ -46,7 +57,7 @@
4657
# SpanExporter receives the spans and send them to the target location.
4758
span_processor = BatchExportSpanProcessor(exporter)
4859

49-
trace.tracer_source().add_span_processor(span_processor)
60+
trace.tracer_provider().add_span_processor(span_processor)
5061
with tracer.start_as_current_span("foo"):
5162
with tracer.start_as_current_span("bar"):
5263
with tracer.start_as_current_span("baz"):

0 commit comments

Comments
 (0)