Repository: census-instrumentation/opencensus-python
Pull request #523 (2019-02-25 21:45:18)

refactor namespace package - add the first contrib package
This is part of the effort for #445.

Eventually we want to move the integrations (e.g. MySQL, PostgreSQL) and perhaps exporters to separate packages.
We need to solve the packaging, releasing, test integration problems. I plan to use this W3C CorrelationContext package to verify the end-to-end flow before start to move existing stuff.



Patch:
diff --git a/contrib/opencensus-common-correlationcontext/README.rst b/contrib/opencensus-common-correlationcontext/README.rst
new file mode 100644
index 00000000..1f0ce73
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/README.rst
@@ -0,0 +1,2 @@
+W3C Correlation Context
+============================================================================
diff --git a/contrib/opencensus-common-correlationcontext/opencensus/__init__.py b/contrib/opencensus-common-correlationcontext/opencensus/__init__.py
new file mode 100644
index 00000000..69e3be5
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/opencensus/__init__.py
@@ -0,0 +1,1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__)
diff --git a/contrib/opencensus-common-correlationcontext/opencensus/common/__init__.py b/contrib/opencensus-common-correlationcontext/opencensus/common/__init__.py
new file mode 100644
index 00000000..69e3be5
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/opencensus/common/__init__.py
@@ -0,0 +1,1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__)
diff --git a/contrib/opencensus-common-correlationcontext/opencensus/common/correlationcontext/__init__.py b/contrib/opencensus-common-correlationcontext/opencensus/common/correlationcontext/__init__.py
new file mode 100644
index 00000000..df3230b
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/opencensus/common/correlationcontext/__init__.py
@@ -0,0 +1,18 @@
+# Copyright 2019, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from opencensus.common.correlationcontext.correlationcontext import CorrelationContext
+
+
+__all__ = ['CorrelationContext']
diff --git a/contrib/opencensus-common-correlationcontext/opencensus/common/correlationcontext/correlationcontext.py b/contrib/opencensus-common-correlationcontext/opencensus/common/correlationcontext/correlationcontext.py
new file mode 100644
index 00000000..5cae6e3
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/opencensus/common/correlationcontext/correlationcontext.py
@@ -0,0 +1,16 @@
+# Copyright 2019, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class CorrelationContext(object):
+    pass
diff --git a/contrib/opencensus-common-correlationcontext/setup.py b/contrib/opencensus-common-correlationcontext/setup.py
new file mode 100644
index 00000000..630cded
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/setup.py
@@ -0,0 +1,48 @@
+# Copyright 2019, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from setuptools import find_packages
+from setuptools import setup
+from version import __version__
+
+setup(
+    name='opencensus-common-correlationcontext',
+    version=__version__,  # noqa
+    author='OpenCensus Authors',
+    author_email='census-developers@googlegroups.com',
+    classifiers=[
+        'Intended Audience :: Developers',
+        'Development Status :: 3 - Alpha',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: Apache Software License',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
+    ],
+    description='W3C Correlation Context',
+    include_package_data=True,
+    long_description=open('README.rst').read(),
+    install_requires=[],
+    extras_require={},
+    license='Apache-2.0',
+    packages=find_packages(exclude=('tests',)),
+    namespace_packages=[],
+    url='https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-common-correlationcontext',
+    zip_safe=False,
+)
diff --git a/contrib/opencensus-common-correlationcontext/version.py b/contrib/opencensus-common-correlationcontext/version.py
new file mode 100644
index 00000000..ff18aeb
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/version.py
@@ -0,0 +1,15 @@
+# Copyright 2019, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+__version__ = '0.2.dev0'


Test patch:
diff --git a/contrib/opencensus-common-correlationcontext/tests/__init__.py b/contrib/opencensus-common-correlationcontext/tests/__init__.py
new file mode 100644
index 00000000..296af49
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/tests/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2019, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/contrib/opencensus-common-correlationcontext/tests/test_correlation_context.py b/contrib/opencensus-common-correlationcontext/tests/test_correlation_context.py
new file mode 100644
index 00000000..eb4dcd3
--- /dev/null
+++ b/contrib/opencensus-common-correlationcontext/tests/test_correlation_context.py
@@ -0,0 +1,20 @@
+# Copyright 2019, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+from opencensus.common.correlationcontext import CorrelationContext
+
+class CorrelationContextTest(unittest.TestCase):
+    def test_ctor_default(self):
+        self.assertTrue(CorrelationContext())