Skip to content

Commit 16d3ab3

Browse files
authored
refactor namespace package - componentize ocagent trace exporter (census-instrumentation#546)
* componentize ocagent trace exporter * remove unused file * sort import order * address review comments
1 parent cce5ac2 commit 16d3ab3

32 files changed

+115
-18
lines changed

contrib/opencensus-ext-django/tests/test_django_middleware.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
from django.test.utils import teardown_test_environment
2020

2121
from opencensus.common.transports import sync
22+
from opencensus.ext.ocagent import trace_exporter
2223
from opencensus.trace import execution_context
2324
from opencensus.trace import span as span_module
2425
from opencensus.trace import utils
2526
from opencensus.trace.exporters import print_exporter
2627
from opencensus.trace.exporters import zipkin_exporter
2728
from opencensus.trace.exporters import jaeger_exporter
28-
from opencensus.trace.exporters.ocagent import trace_exporter
2929
from opencensus.trace.propagation import google_cloud_format
3030
from opencensus.trace.samplers import always_on
3131
from opencensus.trace.samplers import probability

contrib/opencensus-ext-flask/tests/test_flask_middleware.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import mock
2323

2424
from opencensus.ext.flask import flask_middleware
25+
from opencensus.ext.ocagent import trace_exporter
2526
from opencensus.trace import execution_context
2627
from opencensus.trace import span as span_module
2728
from opencensus.trace import span_data
@@ -32,7 +33,6 @@
3233
from opencensus.trace.exporters import print_exporter
3334
from opencensus.trace.exporters import stackdriver_exporter
3435
from opencensus.trace.exporters import zipkin_exporter
35-
from opencensus.trace.exporters.ocagent import trace_exporter
3636
from opencensus.trace.propagation import google_cloud_format
3737
from opencensus.trace.samplers import always_off, always_on, ProbabilitySampler
3838
from opencensus.trace.span_context import SpanContext
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
- Initial version.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
OpenCensus OC-Agent Trace Exporter
2+
============================================================================
3+
4+
Installation
5+
------------
6+
7+
::
8+
9+
pip install opencensus-ext-ocagent
10+
11+
Usage
12+
-----
13+
14+
.. code:: python
15+
16+
# TBD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)

opencensus/trace/exporters/ocagent/trace_exporter.py renamed to contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/trace_exporter/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121

2222
from opencensus.common.transports import sync
2323
from opencensus.common.version import __version__
24-
from opencensus.trace.exporters import base
25-
from opencensus.trace.exporters.gen.opencensus.agent.common.v1 \
24+
from opencensus.ext.ocagent.trace_exporter import utils
25+
from opencensus.ext.ocagent.trace_exporter.gen.opencensus.agent.common.v1 \
2626
import common_pb2
27-
from opencensus.trace.exporters.gen.opencensus.agent.trace.v1 \
27+
from opencensus.ext.ocagent.trace_exporter.gen.opencensus.agent.trace.v1 \
2828
import trace_service_pb2
29-
from opencensus.trace.exporters.gen.opencensus.agent.trace.v1 \
29+
from opencensus.ext.ocagent.trace_exporter.gen.opencensus.agent.trace.v1 \
3030
import trace_service_pb2_grpc
31-
from opencensus.trace.exporters.ocagent import utils
31+
from opencensus.trace.exporters import base
3232

3333
# Default agent endpoint
3434
DEFAULT_ENDPOINT = 'localhost:55678'

opencensus/trace/exporters/gen/opencensus/agent/trace/v1/trace_service_pb2.py renamed to contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/trace_exporter/gen/opencensus/agent/trace/v1/trace_service_pb2.py

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

opencensus/trace/exporters/gen/opencensus/agent/trace/v1/trace_service_pb2_grpc.py renamed to contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/trace_exporter/gen/opencensus/agent/trace/v1/trace_service_pb2_grpc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from opencensus.trace.exporters.gen.opencensus.agent.trace.v1 import trace_service_pb2 as opencensus_dot_proto_dot_agent_dot_trace_dot_v1_dot_trace__service__pb2
4+
from opencensus.ext.ocagent.trace_exporter.gen.opencensus.agent.trace.v1 import trace_service_pb2 as opencensus_dot_proto_dot_agent_dot_trace_dot_v1_dot_trace__service__pb2
55

66

77
class TraceServiceStub(object):

opencensus/trace/exporters/gen/opencensus/trace/v1/trace_pb2.py renamed to contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/trace_exporter/gen/opencensus/trace/v1/trace_pb2.py

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

opencensus/trace/exporters/ocagent/utils.py renamed to contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/trace_exporter/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from google.protobuf.internal.well_known_types import ParseError
1818
from google.protobuf.timestamp_pb2 import Timestamp
1919
from google.protobuf.wrappers_pb2 import BoolValue, UInt32Value
20-
from opencensus.trace.exporters.gen.opencensus.trace.v1 import trace_pb2
20+
from opencensus.ext.ocagent.trace_exporter.gen.opencensus.trace.v1 \
21+
import trace_pb2
2122

2223

2324
def translate_to_trace_proto(span_data):
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bdist_wheel]
2+
universal = 1
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from setuptools import find_packages
16+
from setuptools import setup
17+
from version import __version__
18+
19+
setup(
20+
name='opencensus-ext-ocagent',
21+
version=__version__, # noqa
22+
author='OpenCensus Authors',
23+
author_email='[email protected]',
24+
classifiers=[
25+
'Intended Audience :: Developers',
26+
'Development Status :: 3 - Alpha',
27+
'Intended Audience :: Developers',
28+
'License :: OSI Approved :: Apache Software License',
29+
'Programming Language :: Python',
30+
'Programming Language :: Python :: 2',
31+
'Programming Language :: Python :: 2.7',
32+
'Programming Language :: Python :: 3',
33+
'Programming Language :: Python :: 3.4',
34+
'Programming Language :: Python :: 3.5',
35+
'Programming Language :: Python :: 3.6',
36+
'Programming Language :: Python :: 3.7',
37+
],
38+
description='OpenCensus OC-Agent Trace Exporter',
39+
include_package_data=True,
40+
long_description=open('README.rst').read(),
41+
install_requires=[
42+
'grpcio >= 1.0.0, < 2.0.0',
43+
'opencensus >= 0.2.dev0, < 1.0.0',
44+
],
45+
extras_require={},
46+
license='Apache-2.0',
47+
packages=find_packages(exclude=('tests',)),
48+
namespace_packages=[],
49+
url='https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-ocagent',
50+
zip_safe=False,
51+
)

tests/unit/trace/exporters/ocagent/test_trace_exporter.py renamed to contrib/opencensus-ext-ocagent/tests/test_trace_exporter.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
import unittest
2121

2222
from opencensus.common.version import __version__
23+
from opencensus.ext.ocagent.trace_exporter.gen.opencensus.trace.v1 \
24+
import trace_config_pb2
25+
from opencensus.ext.ocagent.trace_exporter import TraceExporter
2326
from opencensus.trace import span_context as span_context_module
2427
from opencensus.trace import span_data as span_data_module
25-
from opencensus.trace.exporters.gen.opencensus.trace.v1 import trace_config_pb2
26-
from opencensus.trace.exporters.ocagent.trace_exporter import TraceExporter
2728

2829

2930
SERVICE_NAME = 'my-service'

tests/unit/trace/exporters/ocagent/test_trace_exporter_utils.py renamed to contrib/opencensus-ext-ocagent/tests/test_trace_exporter_utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
from datetime import datetime, timedelta
1717
import unittest
1818

19+
from opencensus.ext.ocagent.trace_exporter import utils
20+
from opencensus.ext.ocagent.trace_exporter.gen.opencensus.trace.v1 \
21+
import trace_pb2
1922
from opencensus.trace import attributes as attributes_module
2023
from opencensus.trace import link as link_module
2124
from opencensus.trace import span as span_module
@@ -24,8 +27,6 @@
2427
from opencensus.trace import status as status_module
2528
from opencensus.trace import time_event as time_event_module
2629
from opencensus.trace import tracestate as tracestate_module
27-
from opencensus.trace.exporters.ocagent import utils
28-
from opencensus.trace.exporters.gen.opencensus.trace.v1 import trace_pb2
2930

3031

3132
class TestTraceExporterUtils(unittest.TestCase):
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__version__ = '0.1.dev0'

nox.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
def _install_dev_packages(session):
2222
session.install('-e', 'contrib/opencensus-correlation')
2323
session.install('-e', '.')
24+
2425
session.install('-e', 'contrib/opencensus-ext-dbapi')
2526
session.install('-e', 'contrib/opencensus-ext-django')
2627
session.install('-e', 'contrib/opencensus-ext-flask')
2728
session.install('-e', 'contrib/opencensus-ext-grpc')
2829
session.install('-e', 'contrib/opencensus-ext-httplib')
2930
session.install('-e', 'contrib/opencensus-ext-mysql')
31+
session.install('-e', 'contrib/opencensus-ext-ocagent')
3032
session.install('-e', 'contrib/opencensus-ext-postgresql')
3133
session.install('-e', 'contrib/opencensus-ext-pymongo')
3234
session.install('-e', 'contrib/opencensus-ext-pymysql')

0 commit comments

Comments
 (0)