Skip to content

Commit ff80d11

Browse files
authored
componentize trace.ext.flask (census-instrumentation#532)
* componentize trace.ext.flask * update system test * added doc * update doc * fix typo * doc cleanup * change opencensus-ext-flask version to 0.1.dev0
1 parent 1d8bf1c commit ff80d11

File tree

14 files changed

+127
-12
lines changed

14 files changed

+127
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
- Initial version.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
OpenCensus Flask Integration
2+
============================================================================
3+
4+
Installation
5+
------------
6+
7+
::
8+
9+
pip install opencensus-ext-flask
10+
11+
Usage
12+
-----
13+
14+
.. code:: python
15+
16+
from flask import Flask
17+
from opencensus.ext.flask.flask_middleware import FlaskMiddleware
18+
from opencensus.trace.propagation.trace_context_http_header_format import TraceContextPropagator
19+
20+
app = Flask(__name__)
21+
middleware = FlaskMiddleware(app, propagator=TraceContextPropagator(), blacklist_paths=['_ah/health'])
22+
23+
@app.route('/')
24+
def hello():
25+
return 'Hello World!'
26+
27+
if __name__ == '__main__':
28+
import logging
29+
logger = logging.getLogger('werkzeug')
30+
logger.setLevel(logging.ERROR)
31+
app.run(host='localhost', port=8080, threaded=True)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bdist_wheel]
2+
universal = 1
Lines changed: 51 additions & 0 deletions
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-flask',
21+
version=__version__, # noqa
22+
author='OpenCensus Authors',
23+
author_email='census-developers@googlegroups.com',
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 Flask Integration',
39+
include_package_data=True,
40+
long_description=open('README.rst').read(),
41+
install_requires=[
42+
'flask >= 0.12.3, < 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-flask',
50+
zip_safe=False,
51+
)

tests/unit/trace/ext/flask/test_flask_middleware.py renamed to contrib/opencensus-ext-flask/tests/test_flask_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import flask
2222
import mock
2323

24+
from opencensus.ext.flask import flask_middleware
2425
from opencensus.trace import execution_context
2526
from opencensus.trace import span as span_module
2627
from opencensus.trace import span_data
@@ -32,7 +33,6 @@
3233
from opencensus.trace.exporters import stackdriver_exporter
3334
from opencensus.trace.exporters import zipkin_exporter
3435
from opencensus.trace.exporters.ocagent import trace_exporter
35-
from opencensus.trace.ext.flask import flask_middleware
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
Lines changed: 15 additions & 0 deletions
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'

0 commit comments

Comments
 (0)