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

Commit 11d1527

Browse files
authored
Prepare for 0.4.0 release (#604)
Release opencensus-0.4.0 and multiple new versions of ext packages. This release includes breaking changes related to the context API and stats/metrics exporters. It also adds a dependency on the new opencensus-context package.
1 parent 1da32f6 commit 11d1527

File tree

81 files changed

+307
-187
lines changed

Some content is hidden

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

81 files changed

+307
-187
lines changed

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
branch = True
33
omit =
44
# Test cases
5+
context/*/tests/*
56
contrib/*/tests/*
67
# Auto generated files
78
contrib/opencensus-ext-jaeger/opencensus/ext/jaeger/trace_exporter/gen/*
@@ -19,6 +20,8 @@ exclude_lines =
1920
# Ignore debug-only repr
2021
def __repr__
2122
omit =
23+
# Test cases
24+
context/*/tests/*
2225
# Side-effect introduced by namespace packages
2326
contrib/*/opencensus/__init__.py
2427
contrib/*/opencensus/ext/__init__.py

CHANGELOG.md

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

33
## Unreleased
44

5+
## 0.4.0
6+
Released 2019-04-08
7+
8+
- Multiple bugfixes
9+
- Use separate context package instead of threadlocals for execution context
10+
([#573](https://github.com/census-instrumentation/opencensus-python/pull/573))
11+
512
## 0.3.0
613
Released 2019-03-11
714

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

3-
## Unreleased
3+
## 0.1.0
4+
Released 2019-04-08
45

5-
- Add this changelog.
6+
- Initial version

context/opencensus-context/opencensus/common/runtime_context/__init__.py

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

15-
import sys
15+
16+
try:
17+
import contextvars
18+
except ImportError:
19+
contextvars = None
20+
1621
import threading
1722

1823
__all__ = ['RuntimeContext']
@@ -132,7 +137,6 @@ class _AsyncRuntimeContext(_RuntimeContext):
132137

133138
class Slot(object):
134139
def __init__(self, name, default):
135-
import contextvars
136140
self.name = name
137141
self.contextvar = contextvars.ContextVar(name)
138142
self.default = default if callable(default) else (lambda: default)
@@ -169,6 +173,5 @@ def register_slot(cls, name, default=None):
169173

170174

171175
RuntimeContext = _ThreadLocalRuntimeContext()
172-
173-
if sys.version_info >= (3, 7):
176+
if contextvars:
174177
RuntimeContext = _AsyncRuntimeContext()

context/opencensus-context/setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@
3838
description='OpenCensus Runtime Context',
3939
include_package_data=True,
4040
long_description=open('README.rst').read(),
41-
install_requires=[],
41+
install_requires=[
42+
# contextvars backport for Python 3.6
43+
'contextvars ; python_version >= "3.6" and python_version < "3.7"',
44+
],
4245
extras_require={},
4346
license='Apache-2.0',
4447
packages=find_packages(exclude=('examples', 'tests',)),
4548
namespace_packages=[],
46-
url='https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-context', # noqa: E501
49+
url='https://github.com/census-instrumentation/opencensus-python/tree/master/context/opencensus-context', # noqa: E501
4750
zip_safe=False,
4851
)

context/opencensus-context/tests/test_runtime_context.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,39 @@ def test_register_duplicate(self):
3333
RuntimeContext.register_slot('dup'),
3434
RuntimeContext.register_slot('dup'),
3535
])
36+
37+
def test_get_non_existing(self):
38+
self.assertRaises(AttributeError, lambda: RuntimeContext.non_existing)
39+
40+
def test_set_non_existing(self):
41+
def set_non_existing():
42+
RuntimeContext.non_existing = 1
43+
44+
self.assertRaises(AttributeError, set_non_existing)
45+
46+
def test_clear(self):
47+
RuntimeContext.register_slot('baz')
48+
RuntimeContext.baz = 123
49+
self.assertEqual(RuntimeContext.baz, 123)
50+
RuntimeContext.clear()
51+
self.assertEqual(RuntimeContext.baz, None)
52+
53+
def test_with_current_context(self):
54+
from threading import Thread
55+
56+
RuntimeContext.register_slot('operation_id')
57+
58+
def work(name):
59+
self.assertEqual(RuntimeContext.operation_id, 'foo')
60+
RuntimeContext.operation_id = name
61+
self.assertEqual(RuntimeContext.operation_id, name)
62+
63+
RuntimeContext.operation_id = 'foo'
64+
thread = Thread(
65+
target=RuntimeContext.with_current_context(work),
66+
args=('bar'),
67+
)
68+
thread.start()
69+
thread.join()
70+
71+
self.assertEqual(RuntimeContext.operation_id, 'foo')

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.1.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'

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.1
6+
Released 2019-04-08
7+
8+
- Cosmetic changes
9+
510
## 0.1.0
611
Released 2019-03-19
712

contrib/opencensus-ext-dbapi/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.4.dev0, < 1.0.0',
42+
'opencensus >= 0.3.0, < 1.0.0',
4343
],
4444
extras_require={},
4545
license='Apache-2.0',

0 commit comments

Comments
 (0)