Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit e8ae63f

Browse files
authored
0.5.0 release (#630)
New packages: - opencensus-ext-azure 0.1.0 Minor version updates: - opencensus 0.5.0 - opencensus-ext-django 0.3.0 - opencensus-ext-flask 0.3.0 - opencensus-ext-grpc 0.2.0 - opencensus-ext-ocagent 0.3.0 - opencensus-ext-pyramid 0.3.0 - opencensus-ext-stackdriver 0.3.0 Micro version updates: - opencensus-ext-dbapi 0.1.2 - opencensus-ext-google-cloud-clientlibs 0.1.2 - opencensus-ext-httplib 0.1.2 - opencensus-ext-jaeger 0.2.1 - opencensus-ext-mysql 0.1.2 - opencensus-ext-postgresql 0.1.2 - opencensus-ext-prometheus 0.2.1 - opencensus-ext-pymongo 0.1.2 - opencensus-ext-pymysql 0.1.2 - opencensus-ext-requests 0.1.2 - opencensus-ext-sqlalchemy 0.1.2 - opencensus-ext-threading 0.1.2 - opencensus-ext-zipkin 0.2.1
1 parent 9a07314 commit e8ae63f

File tree

68 files changed

+272
-131
lines changed

Some content is hidden

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

68 files changed

+272
-131
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
## Unreleased
44

5+
## 0.5.0
6+
Released 2019-04-24
7+
58
- Add cumulative API
69
([#626](https://github.com/census-instrumentation/opencensus-python/pull/626))
710

11+
## 0.4.1
12+
Released 2019-04-11
13+
14+
- Allow for metrics with empty label keys and values
15+
([#611](https://github.com/census-instrumentation/opencensus-python/pull/611),
16+
[#614](https://github.com/census-instrumentation/opencensus-python/pull/614))
17+
818
## 0.4.0
919
Released 2019-04-08
1020

README.rst

Lines changed: 39 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -103,114 +103,71 @@ Alternatively, you can explicitly start and end a span:
103103
Customization
104104
-------------
105105

106-
Samplers
107-
~~~~~~~~
106+
There are several things you can customize in OpenCensus:
108107

109-
You can specify different samplers when initializing a tracer, default
110-
is using ``AlwaysOnSampler``, the other options are ``AlwaysOffSampler``
111-
and ``ProbabilitySampler``
108+
* **Blacklist**, which excludes certain hosts and paths from being tracked.
109+
By default, the health check path for the App Engine flexible environment is
110+
not tracked, you can turn it on by excluding it from the blacklist setting.
112111

113-
.. code:: python
114-
115-
from opencensus.trace.samplers import probability
116-
from opencensus.trace import tracer as tracer_module
117-
118-
# Sampling the requests at the rate equals 0.5
119-
sampler = probability.ProbabilitySampler(rate=0.5)
120-
tracer = tracer_module.Tracer(sampler=sampler)
121-
122-
Exporters
123-
~~~~~~~~~
124-
125-
By default, the traces are printed to stdout in JSON format. You can choose
126-
different exporters to send the traces to. There are three built-in exporters,
127-
which are ``opencensus.trace.print_exporter``, ``opencensus.trace.file_exporter``
128-
and ``opencensus.trace.logging_exporter``, other exporters are provided as
129-
`extensions <#trace-exporter>`__.
130-
131-
This example shows how to configure OpenCensus to save the traces to a
132-
file:
133-
134-
.. code:: python
135-
136-
from opencensus.trace import file_exporter
137-
from opencensus.trace.tracers import context_tracer
112+
* **Exporter**, which sends the traces.
113+
By default, the traces are printed to stdout in JSON format. You can choose
114+
different exporters to send the traces to. There are three built-in exporters,
115+
which are ``PrintExporter``, ``FileExporter`` and ``LoggingExporter``, the
116+
other exporters are provided as `extensions <#trace-exporter>`__.
138117

139-
exporter = file_exporter.FileExporter(file_name='traces')
140-
tracer = context_tracer.ContextTracer(exporter=exporter)
118+
* **Sampler**, which determines how traces are sampled.
119+
The default sampler is ``AlwaysOnSampler``, other samplers include the
120+
``AlwaysOffSampler`` and ``ProbabilitySampler``.
141121

142-
Propagators
143-
~~~~~~~~~~~
122+
* **Propagator**, which serializes and deserializes the
123+
``SpanContext`` and its headers. The default propagator is
124+
``TraceContextPropagator``, other propagators include
125+
``BinaryFormatPropagator``, ``GoogleCloudFormatPropagator`` and
126+
``TextFormatPropagator``.
144127

145-
You can specify the propagator type for serializing and deserializing the
146-
``SpanContext`` and its headers. The default propagator is
147-
``TraceContextPropagator``, the rest options are ``BinaryFormatPropagator``,
148-
``GoogleCloudFormatPropagator`` and ``TextFormatPropagator``.
149128

150-
This example shows how to use the ``GoogleCloudFormatPropagator``:
151-
152-
.. code:: python
153-
154-
from opencensus.trace.propagation import google_cloud_format
155-
156-
propagator = google_cloud_format.GoogleCloudFormatPropagator()
157-
158-
# Deserialize
159-
span_context = propagator.from_header(header)
160-
161-
# Serialize
162-
header = propagator.to_header(span_context)
163-
164-
This example shows how to use the ``TraceContextPropagator``:
129+
You can customize while initializing a tracer.
165130

166131
.. code:: python
167132
168133
import requests
169134
170135
from opencensus.trace import config_integration
171-
from opencensus.trace.propagation.trace_context_http_header_format import TraceContextPropagator
172-
from opencensus.trace.tracer import Tracer
136+
from opencensus.trace import file_exporter
137+
from opencensus.trace import tracer as tracer_module
138+
from opencensus.trace.propagation import google_cloud_format
139+
from opencensus.trace.samplers import probability
173140
174141
config_integration.trace_integrations(['httplib'])
175-
tracer = Tracer(propagator=TraceContextPropagator())
142+
143+
tracer = tracer_module.Tracer(
144+
exporter=file_exporter.FileExporter(file_name='traces'),
145+
propagator=google_cloud_format.GoogleCloudFormatPropagator(),
146+
sampler=probability.ProbabilitySampler(rate=0.5),
147+
)
176148
177149
with tracer.span(name='parent'):
178150
with tracer.span(name='child'):
179151
response = requests.get('http://localhost:5000')
180152
181-
Blacklist Paths
182-
~~~~~~~~~~~~~~~
183-
184-
You can specify which paths you do not want to trace by configuring the
185-
blacklist paths.
186-
187-
This example shows how to configure the blacklist to ignore the ``_ah/health`` endpoint
188-
for a Flask application:
153+
You can use a configuration file for Flask/Django/Pyramid. For more
154+
information, please read the
155+
`individual integration documentation <#integration>`_.
189156

190157
.. code:: python
191158
192-
from opencensus.trace.ext.flask.flask_middleware import FlaskMiddleware
193-
194-
app = flask.Flask(__name__)
195-
196-
blacklist_paths = ['_ah/health']
197-
middleware = FlaskMiddleware(app, blacklist_paths=blacklist_paths)
198-
199-
For Django, you can configure the blacklist in the ``OPENCENSUS`` in ``settings.py``:
200-
201-
.. code:: python
202-
203-
OPENCENSUS: {
159+
'OPENCENSUS': {
204160
'TRACE': {
205-
...
206-
'BLACKLIST_PATHS': ['_ah/health',],
161+
'BLACKLIST_HOSTNAMES': ['localhost', '127.0.0.1'],
162+
'BLACKLIST_PATHS': ['_ah/health'],
163+
'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)',
164+
'EXPORTER': '''opencensus.ext.ocagent.trace_exporter.TraceExporter(
165+
service_name='foobar',
166+
)''',
167+
'PROPAGATOR': 'opencensus.trace.propagation.google_cloud_format.GoogleCloudFormatPropagator()',
207168
}
208169
}
209170
210-
211-
.. note:: By default, the health check path for the App Engine flexible environment is not traced,
212-
but you can turn it on by excluding it from the blacklist setting.
213-
214171
------------
215172
Extensions
216173
------------

context/opencensus-context/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
## Unreleased
4+
35
## 0.1.0
46
Released 2019-04-08
57

context/opencensus-context/README.rst

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,74 @@ OpenCensus Runtime Context
55

66
.. |pypi| image:: https://badge.fury.io/py/opencensus-context.svg
77
:target: https://pypi.org/project/opencensus-context/
8+
9+
The **OpenCensus Runtime Context** provides in-process context propagation.
10+
By default, ``thread local storage`` is used for Python 2.7, 3.4 and 3.5;
11+
``contextvars`` is used for Python >= 3.6, which provides ``asyncio`` support.
12+
13+
Installation
14+
------------
15+
16+
This library is installed by default with ``opencensus``, there is no need
17+
to install it explicitly.
18+
19+
Usage
20+
-----
21+
22+
In most cases context propagation happens automatically within a process,
23+
following the control flow of threads and asynchronous coroutines. The runtime
24+
context is a dictionary stored in a `context variable <https://docs.python.org/3/library/contextvars.html>`_
25+
when available, and in `thread local storage <https://docs.python.org/2/library/threading.html#threading.local>`_
26+
otherwise.
27+
28+
There are cases where you may want to propagate the context explicitly:
29+
30+
Explicit Thread Creation
31+
~~~~~~~~~~~~~~~~~~~~~~~~
32+
33+
.. code:: python
34+
35+
from threading import Thread
36+
from opencensus.common.runtime_context import RuntimeContext
37+
38+
def work(name):
39+
# here you will get the context from the parent thread
40+
print(RuntimeContext)
41+
42+
thread = Thread(
43+
# propagate context explicitly
44+
target=RuntimeContext.with_current_context(work),
45+
args=('foobar',),
46+
)
47+
thread.start()
48+
thread.join()
49+
50+
Thread Pool
51+
~~~~~~~~~~~
52+
53+
.. code:: python
54+
55+
from multiprocessing.dummy import Pool as ThreadPool
56+
from opencensus.common.runtime_context import RuntimeContext
57+
58+
def work(name):
59+
# here you will get the context from the parent thread
60+
print(RuntimeContext)
61+
62+
pool = ThreadPool(2)
63+
# propagate context explicitly
64+
pool.map(RuntimeContext.with_current_context(work), [
65+
'bear',
66+
'cat',
67+
'dog',
68+
'horse',
69+
'rabbit',
70+
])
71+
pool.close()
72+
pool.join()
73+
74+
References
75+
----------
76+
77+
* `Examples <https://github.com/census-instrumentation/opencensus-python/tree/master/context/opencensus-context/examples>`_
78+
* `OpenCensus Project <https://opencensus.io/>`_

context/opencensus-context/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = '0.2.dev0'
15+
__version__ = '0.1.0'

contrib/opencensus-correlation/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = '0.2.dev0'
15+
__version__ = '0.1.0'
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
22

33
## Unreleased
4-
- Initial project skeleton
4+
5+
## 0.1.0
6+
Released 2019-04-24
7+
8+
- Initial release

contrib/opencensus-ext-azure/opencensus/ext/azure/common/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = '0.1.dev0'
15+
__version__ = '0.1.0'

contrib/opencensus-ext-azure/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
include_package_data=True,
4040
long_description=open('README.rst').read(),
4141
install_requires=[
42-
'opencensus >= 0.5.dev0, < 1.0.0',
42+
'opencensus >= 0.5.0, < 1.0.0',
4343
'requests >= 2.19.0',
4444
],
4545
extras_require={},

contrib/opencensus-ext-dbapi/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Unreleased
44

5+
## 0.1.2
6+
Released 2019-04-24
7+
8+
- Updated docs and examples
9+
510
## 0.1.1
611
Released 2019-04-08
712

0 commit comments

Comments
 (0)