Skip to content

Commit

Permalink
0.5.0 release (#630)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
c24t authored Apr 24, 2019
1 parent 9a07314 commit e8ae63f
Show file tree
Hide file tree
Showing 68 changed files with 272 additions and 131 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

## Unreleased

## 0.5.0
Released 2019-04-24

- Add cumulative API
([#626](https://github.com/census-instrumentation/opencensus-python/pull/626))

## 0.4.1
Released 2019-04-11

- Allow for metrics with empty label keys and values
([#611](https://github.com/census-instrumentation/opencensus-python/pull/611),
[#614](https://github.com/census-instrumentation/opencensus-python/pull/614))

## 0.4.0
Released 2019-04-08

Expand Down
121 changes: 39 additions & 82 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,114 +103,71 @@ Alternatively, you can explicitly start and end a span:
Customization
-------------

Samplers
~~~~~~~~
There are several things you can customize in OpenCensus:

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

.. code:: python
from opencensus.trace.samplers import probability
from opencensus.trace import tracer as tracer_module
# Sampling the requests at the rate equals 0.5
sampler = probability.ProbabilitySampler(rate=0.5)
tracer = tracer_module.Tracer(sampler=sampler)
Exporters
~~~~~~~~~

By default, the traces are printed to stdout in JSON format. You can choose
different exporters to send the traces to. There are three built-in exporters,
which are ``opencensus.trace.print_exporter``, ``opencensus.trace.file_exporter``
and ``opencensus.trace.logging_exporter``, other exporters are provided as
`extensions <#trace-exporter>`__.

This example shows how to configure OpenCensus to save the traces to a
file:

.. code:: python
from opencensus.trace import file_exporter
from opencensus.trace.tracers import context_tracer
* **Exporter**, which sends the traces.
By default, the traces are printed to stdout in JSON format. You can choose
different exporters to send the traces to. There are three built-in exporters,
which are ``PrintExporter``, ``FileExporter`` and ``LoggingExporter``, the
other exporters are provided as `extensions <#trace-exporter>`__.

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

Propagators
~~~~~~~~~~~
* **Propagator**, which serializes and deserializes the
``SpanContext`` and its headers. The default propagator is
``TraceContextPropagator``, other propagators include
``BinaryFormatPropagator``, ``GoogleCloudFormatPropagator`` and
``TextFormatPropagator``.

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

This example shows how to use the ``GoogleCloudFormatPropagator``:

.. code:: python
from opencensus.trace.propagation import google_cloud_format
propagator = google_cloud_format.GoogleCloudFormatPropagator()
# Deserialize
span_context = propagator.from_header(header)
# Serialize
header = propagator.to_header(span_context)
This example shows how to use the ``TraceContextPropagator``:
You can customize while initializing a tracer.

.. code:: python
import requests
from opencensus.trace import config_integration
from opencensus.trace.propagation.trace_context_http_header_format import TraceContextPropagator
from opencensus.trace.tracer import Tracer
from opencensus.trace import file_exporter
from opencensus.trace import tracer as tracer_module
from opencensus.trace.propagation import google_cloud_format
from opencensus.trace.samplers import probability
config_integration.trace_integrations(['httplib'])
tracer = Tracer(propagator=TraceContextPropagator())
tracer = tracer_module.Tracer(
exporter=file_exporter.FileExporter(file_name='traces'),
propagator=google_cloud_format.GoogleCloudFormatPropagator(),
sampler=probability.ProbabilitySampler(rate=0.5),
)
with tracer.span(name='parent'):
with tracer.span(name='child'):
response = requests.get('http://localhost:5000')
Blacklist Paths
~~~~~~~~~~~~~~~

You can specify which paths you do not want to trace by configuring the
blacklist paths.

This example shows how to configure the blacklist to ignore the ``_ah/health`` endpoint
for a Flask application:
You can use a configuration file for Flask/Django/Pyramid. For more
information, please read the
`individual integration documentation <#integration>`_.

.. code:: python
from opencensus.trace.ext.flask.flask_middleware import FlaskMiddleware
app = flask.Flask(__name__)
blacklist_paths = ['_ah/health']
middleware = FlaskMiddleware(app, blacklist_paths=blacklist_paths)
For Django, you can configure the blacklist in the ``OPENCENSUS`` in ``settings.py``:

.. code:: python
OPENCENSUS: {
'OPENCENSUS': {
'TRACE': {
...
'BLACKLIST_PATHS': ['_ah/health',],
'BLACKLIST_HOSTNAMES': ['localhost', '127.0.0.1'],
'BLACKLIST_PATHS': ['_ah/health'],
'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)',
'EXPORTER': '''opencensus.ext.ocagent.trace_exporter.TraceExporter(
service_name='foobar',
)''',
'PROPAGATOR': 'opencensus.trace.propagation.google_cloud_format.GoogleCloudFormatPropagator()',
}
}
.. note:: By default, the health check path for the App Engine flexible environment is not traced,
but you can turn it on by excluding it from the blacklist setting.

------------
Extensions
------------
Expand Down
2 changes: 2 additions & 0 deletions context/opencensus-context/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

## Unreleased

## 0.1.0
Released 2019-04-08

Expand Down
71 changes: 71 additions & 0 deletions context/opencensus-context/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,74 @@ OpenCensus Runtime Context

.. |pypi| image:: https://badge.fury.io/py/opencensus-context.svg
:target: https://pypi.org/project/opencensus-context/

The **OpenCensus Runtime Context** provides in-process context propagation.
By default, ``thread local storage`` is used for Python 2.7, 3.4 and 3.5;
``contextvars`` is used for Python >= 3.6, which provides ``asyncio`` support.

Installation
------------

This library is installed by default with ``opencensus``, there is no need
to install it explicitly.

Usage
-----

In most cases context propagation happens automatically within a process,
following the control flow of threads and asynchronous coroutines. The runtime
context is a dictionary stored in a `context variable <https://docs.python.org/3/library/contextvars.html>`_
when available, and in `thread local storage <https://docs.python.org/2/library/threading.html#threading.local>`_
otherwise.

There are cases where you may want to propagate the context explicitly:

Explicit Thread Creation
~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python
from threading import Thread
from opencensus.common.runtime_context import RuntimeContext
def work(name):
# here you will get the context from the parent thread
print(RuntimeContext)
thread = Thread(
# propagate context explicitly
target=RuntimeContext.with_current_context(work),
args=('foobar',),
)
thread.start()
thread.join()
Thread Pool
~~~~~~~~~~~

.. code:: python
from multiprocessing.dummy import Pool as ThreadPool
from opencensus.common.runtime_context import RuntimeContext
def work(name):
# here you will get the context from the parent thread
print(RuntimeContext)
pool = ThreadPool(2)
# propagate context explicitly
pool.map(RuntimeContext.with_current_context(work), [
'bear',
'cat',
'dog',
'horse',
'rabbit',
])
pool.close()
pool.join()
References
----------

* `Examples <https://github.com/census-instrumentation/opencensus-python/tree/master/context/opencensus-context/examples>`_
* `OpenCensus Project <https://opencensus.io/>`_
2 changes: 1 addition & 1 deletion context/opencensus-context/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '0.2.dev0'
__version__ = '0.1.0'
2 changes: 1 addition & 1 deletion contrib/opencensus-correlation/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '0.2.dev0'
__version__ = '0.1.0'
6 changes: 5 additions & 1 deletion contrib/opencensus-ext-azure/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog

## Unreleased
- Initial project skeleton

## 0.1.0
Released 2019-04-24

- Initial release
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '0.1.dev0'
__version__ = '0.1.0'
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-azure/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
include_package_data=True,
long_description=open('README.rst').read(),
install_requires=[
'opencensus >= 0.5.dev0, < 1.0.0',
'opencensus >= 0.5.0, < 1.0.0',
'requests >= 2.19.0',
],
extras_require={},
Expand Down
5 changes: 5 additions & 0 deletions contrib/opencensus-ext-dbapi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## 0.1.2
Released 2019-04-24

- Updated docs and examples

## 0.1.1
Released 2019-04-08

Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-dbapi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
include_package_data=True,
long_description=open('README.rst').read(),
install_requires=[
'opencensus >= 0.5.dev0, < 1.0.0',
'opencensus >= 0.5.0, < 1.0.0',
],
extras_require={},
license='Apache-2.0',
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-dbapi/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '0.2.dev0'
__version__ = '0.1.2'
6 changes: 6 additions & 0 deletions contrib/opencensus-ext-django/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Changelog

## Unreleased

## 0.3.0
Released 2019-04-24

- Decoupled exporter specific logic from configuration
- Prevent anymonous user error on old django versions
([#603](https://github.com/census-instrumentation/opencensus-python/pull/603))

## 0.2.0
Released 2019-04-08
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-django/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
long_description=open('README.rst').read(),
install_requires=[
'Django >= 1.11.0, <= 1.11.20',
'opencensus >= 0.5.dev0, < 1.0.0',
'opencensus >= 0.5.0, < 1.0.0',
],
extras_require={},
license='Apache-2.0',
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-django/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '0.3.dev0'
__version__ = '0.3.0'
4 changes: 4 additions & 0 deletions contrib/opencensus-ext-flask/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## Unreleased

## 0.3.0
Released 2019-04-24

- Decoupled exporter specific logic from configuration

## 0.2.0
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-flask/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
long_description=open('README.rst').read(),
install_requires=[
'flask >= 0.12.3, < 2.0.0',
'opencensus >= 0.5.dev0, < 1.0.0',
'opencensus >= 0.5.0, < 1.0.0',
],
extras_require={},
license='Apache-2.0',
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-flask/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '0.3.dev0'
__version__ = '0.3.0'
5 changes: 5 additions & 0 deletions contrib/opencensus-ext-google-cloud-clientlibs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## 0.1.2
Released 2019-04-24

- Updated docs and examples

## 0.1.1
Released 2019-04-08

Expand Down
Loading

0 comments on commit e8ae63f

Please sign in to comment.