├── CHANGES.rst ├── MANIFEST.in ├── examples ├── webapp1 │ ├── src │ │ ├── requirements.txt │ │ └── app.py │ ├── docker-compose.yml │ ├── Dockerfile.py3 │ ├── docker-compose-infra.yml │ ├── config │ │ └── prometheus │ │ │ └── prometheus.yml │ └── README.md └── README.rst ├── tox.ini ├── setup.py ├── tests └── test_aiohttp_prometheus.py ├── .gitignore ├── aiohttp_prometheus └── __init__.py ├── README.rst └── LICENSE /CHANGES.rst: -------------------------------------------------------------------------------- 1 | Changes 2 | ======= 3 | 4 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include CHANGES.rst 3 | include README.rst 4 | -------------------------------------------------------------------------------- /examples/webapp1/src/requirements.txt: -------------------------------------------------------------------------------- 1 | git+http://github.com/amitsaha/aiohttp-prometheus.git#egg=aiohttp_prometheus 2 | -------------------------------------------------------------------------------- /examples/webapp1/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | webapp: 5 | image: amitsaha/aiohttp_app1 6 | container_name: webapp 7 | expose: 8 | - 8080 9 | ports: 10 | - 8080:8080 11 | volumes: 12 | - ./src:/application 13 | -------------------------------------------------------------------------------- /examples/README.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | `Simple aiohttp web application <./webapp1>`__ 5 | 6 | This is a basic example of how to integrate `aiohttp_promtheus` into a `aiohttp` 7 | web application. It includes docker compose files for starting the web application, 8 | promtheus server and grafana. The prometheus server will be available at 9 | ``localhost:9090``. 10 | -------------------------------------------------------------------------------- /examples/webapp1/Dockerfile.py3: -------------------------------------------------------------------------------- 1 | FROM python:3.6.1-alpine 2 | ADD . /application 3 | WORKDIR /application 4 | 5 | RUN set -e; \ 6 | apk add --no-cache --virtual .build-deps \ 7 | gcc \ 8 | libc-dev \ 9 | linux-headers \ 10 | git \ 11 | ; \ 12 | pip install -r src/requirements.txt; \ 13 | apk del .build-deps; 14 | EXPOSE 8080 15 | VOLUME /application 16 | CMD python app.py 17 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | 3 | envlist = check, py35 4 | 5 | [testenv] 6 | 7 | deps = 8 | pytest 9 | aiohttp 10 | prometheus_client 11 | 12 | commands = 13 | pytest -s tests {posargs} 14 | 15 | basepython: 16 | py35: python3.5 17 | 18 | [testenv:check] 19 | 20 | deps = 21 | wheel 22 | flake8 23 | pyflakes>=1.0.0 24 | 25 | commands = 26 | flake8 --max-line-length=119 aiohttp_prometheus tests 27 | 28 | basepython: 29 | python3.5 30 | -------------------------------------------------------------------------------- /examples/webapp1/docker-compose-infra.yml: -------------------------------------------------------------------------------- 1 | # Based off https://github.com/vegasbrianc/prometheus 2 | version: '2' 3 | 4 | volumes: 5 | prometheus_data: {} 6 | grafana_data: {} 7 | 8 | services: 9 | prometheus: 10 | image: prom/prometheus 11 | container_name: prometheus 12 | volumes: 13 | - ./config/prometheus/:/etc/prometheus/ 14 | - prometheus_data:/prometheus 15 | command: 16 | - '-config.file=/etc/prometheus/prometheus.yml' 17 | - '-storage.local.path=/prometheus' 18 | expose: 19 | - 9090 20 | ports: 21 | - 9090:9090 22 | grafana: 23 | image: grafana/grafana 24 | depends_on: 25 | - prometheus 26 | ports: 27 | - 3000:3000 28 | volumes: 29 | - grafana_data:/var/lib/grafana 30 | environment: 31 | - GF_SECURITY_ADMIN_PASSWORD=foobar 32 | - GF_USERS_ALLOW_SIGN_UP=false 33 | -------------------------------------------------------------------------------- /examples/webapp1/src/app.py: -------------------------------------------------------------------------------- 1 | from aiohttp import web 2 | from aiohttp_prometheus import setup_metrics 3 | import asyncio 4 | 5 | @asyncio.coroutine 6 | def error_middleware(app, handler): 7 | 8 | @asyncio.coroutine 9 | def middleware_handler(request): 10 | try: 11 | response = yield from handler(request) 12 | return response 13 | except web.HTTPException as ex: 14 | resp = web.Response(body=str(ex), status=ex.status) 15 | return resp 16 | except Exception as ex: 17 | resp = web.Response(body=str(ex), status=500) 18 | return resp 19 | 20 | return middleware_handler 21 | 22 | async def test(request): 23 | name = request.match_info.get('name', "Anonymous") 24 | text = "Hello, " + name 25 | return web.Response(text=text) 26 | 27 | async def test1(request): 28 | 1/0 29 | 30 | if __name__ == '__main__': 31 | app = web.Application(middlewares=[error_middleware]) 32 | setup_metrics(app, "webapp_1") 33 | app.router.add_get('/test', test) 34 | app.router.add_get('/test1', test1) 35 | 36 | web.run_app(app, port=8080) 37 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | import os 3 | 4 | 5 | install_requires = ['aiohttp>=1.0.2', 'prometheus_client>=0.0.19'] 6 | 7 | def read(f): 8 | return open(os.path.join(os.path.dirname(__file__), f)).read().strip() 9 | 10 | version = 0.1 11 | setup(name='aiohttp_prometheus', 12 | version=version, 13 | description=("prometheus middleware for aiohttp.web"), 14 | long_description='\n\n'.join((read('README.rst'), read('CHANGES.rst'))), 15 | classifiers=[ 16 | 'License :: OSI Approved :: Apache Software License', 17 | 'Intended Audience :: Developers', 18 | 'Programming Language :: Python', 19 | 'Programming Language :: Python :: 3', 20 | 'Programming Language :: Python :: 3.4', 21 | 'Programming Language :: Python :: 3.5', 22 | 'Topic :: Internet :: WWW/HTTP'], 23 | author='Amit Saha', 24 | author_email='amitsaha.in@gmail.com', 25 | url='https://github.com/amitsaha/aiohttp-prometheus/', 26 | license='Apache 2', 27 | packages=['aiohttp_prometheus'], 28 | install_requires=install_requires, 29 | include_package_data=True,) 30 | -------------------------------------------------------------------------------- /tests/test_aiohttp_prometheus.py: -------------------------------------------------------------------------------- 1 | from aiohttp.test_utils import ( 2 | loop_context, 3 | TestClient as _TestClient 4 | ) 5 | from aiohttp_prometheus import setup_metrics 6 | from aiohttp import web 7 | import pytest 8 | import asyncio 9 | 10 | 11 | @pytest.fixture 12 | def app(): 13 | app = web.Application() 14 | setup_metrics(app, 'test_app') 15 | return app 16 | 17 | 18 | @pytest.yield_fixture 19 | def loop(): 20 | with loop_context() as loop: 21 | yield loop 22 | 23 | 24 | @pytest.yield_fixture 25 | def test_client(loop, app): 26 | client = _TestClient(app, loop=loop) 27 | loop.run_until_complete(client.start_server()) 28 | yield client 29 | loop.run_until_complete(client.close()) 30 | 31 | 32 | def test_metrics_route(loop, test_client): 33 | @asyncio.coroutine 34 | def test_get_metrics(): 35 | resp = yield from test_client.request('GET', '/metrics') 36 | assert resp.status == 200 37 | text = yield from resp.text() 38 | assert 'request_latency_seconds' in text 39 | assert 'requests_total' in text 40 | assert 'requests_in_progress' in text 41 | loop.run_until_complete(test_get_metrics()) 42 | -------------------------------------------------------------------------------- /examples/webapp1/config/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # By default, scrape targets every 15 seconds. 4 | evaluation_interval: 15s # By default, scrape targets every 15 seconds. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | monitor: 'my-project' 11 | 12 | # A scrape configuration containing exactly one endpoint to scrape: 13 | # Here it's Prometheus itself. 14 | scrape_configs: 15 | # The job name is added as a label `job=` to any timeseries scraped from this config. 16 | - job_name: 'prometheus' 17 | 18 | # Override the global default and scrape targets from this job every 5 seconds. 19 | scrape_interval: 5s 20 | 21 | # metrics_path defaults to '/metrics' 22 | # scheme defaults to 'http'. 23 | 24 | static_configs: 25 | - targets: ['localhost:9090'] 26 | - job_name: 'webapp' 27 | 28 | # Override the global default and scrape targets from this job every 5 seconds. 29 | scrape_interval: 5s 30 | 31 | # metrics_path defaults to '/metrics' 32 | # scheme defaults to 'http'. 33 | static_configs: 34 | - targets: ['webapp:8080'] 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | -------------------------------------------------------------------------------- /aiohttp_prometheus/__init__.py: -------------------------------------------------------------------------------- 1 | from prometheus_client import Counter, Gauge, Histogram, CONTENT_TYPE_LATEST 2 | import time 3 | import asyncio 4 | from aiohttp import web 5 | import prometheus_client 6 | 7 | 8 | def prom_middleware(app_name): 9 | @asyncio.coroutine 10 | def factory(app, handler): 11 | @asyncio.coroutine 12 | def middleware_handler(request): 13 | try: 14 | request['start_time'] = time.time() 15 | request.app['REQUEST_IN_PROGRESS'].labels( 16 | app_name, request.path, request.method).inc() 17 | response = yield from handler(request) 18 | resp_time = time.time() - request['start_time'] 19 | request.app['REQUEST_LATENCY'].labels(app_name, request.path).observe(resp_time) 20 | request.app['REQUEST_IN_PROGRESS'].labels(app_name, request.path, request.method).dec() 21 | request.app['REQUEST_COUNT'].labels( 22 | app_name, request.method, request.path, response.status).inc() 23 | return response 24 | except Exception as ex: 25 | raise 26 | return middleware_handler 27 | return factory 28 | 29 | 30 | async def metrics(request): 31 | resp = web.Response(body=prometheus_client.generate_latest()) 32 | resp.content_type = CONTENT_TYPE_LATEST 33 | return resp 34 | 35 | 36 | def setup_metrics(app, app_name): 37 | app['REQUEST_COUNT'] = Counter( 38 | 'requests_total', 'Total Request Count', 39 | ['app_name', 'method', 'endpoint', 'http_status'] 40 | ) 41 | app['REQUEST_LATENCY'] = Histogram( 42 | 'request_latency_seconds', 'Request latency', 43 | ['app_name', 'endpoint'] 44 | ) 45 | 46 | app['REQUEST_IN_PROGRESS'] = Gauge( 47 | 'requests_in_progress_total', 'Requests in progress', 48 | ['app_name', 'endpoint', 'method'] 49 | ) 50 | 51 | app.middlewares.insert(0, prom_middleware(app_name)) 52 | app.router.add_get("/metrics", metrics) 53 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Prometheus middleware for ``aiohttp`` 2 | ------------------------------------- 3 | 4 | ``aiohttp_prometheus`` adds support for exporting `prometheus metrics `__ to 5 | `aiohttp `__ applications. It is implemented as a 6 | `aiohttp middleware `__. 7 | 8 | Currently, it exports the following metrics via the ``/metrics`` endpoint: 9 | 10 | - ``request_latency_seconds``: Latency of a request in seconds. 11 | 12 | + *Labels exported*: ``endpoint``, ``app_name`` 13 | 14 | - ``requests_total``: Request count. 15 | 16 | + *Labels exported*: ``app_name``, ``method`` (HTTP method), ``endpoint``, ``http_status`` (HTTP status) 17 | 18 | - ``requests_in_progress_total``: In progress requests. 19 | 20 | + *Labels exported*: ``app_name``, ``endpoint``, ``method`` (HTTP method) 21 | 22 | 23 | Install 24 | ======= 25 | 26 | I will be publishing to PyPI soon, but for now specifying the following in your ``requirements.txt`` file will 27 | install the ``master`` version of the package from github: 28 | 29 | .. code:: 30 | 31 | git+http://github.com/amitsaha/aiohttp-prometheus.git#egg=aiohttp_prometheus 32 | 33 | 34 | Usage 35 | ===== 36 | 37 | The ``aiohttp_prometheus`` package exports a single function ``setup_metrics(app, 'app_name')`` 38 | which takes in the following arguments: 39 | 40 | - ``app``: The application object returned via ``web.Application()`` 41 | - The second argument is the web application name which identifies the web application and 42 | used to set the ``app_name`` label above 43 | 44 | Briefly, the following is all you need to do to measure and export prometheus 45 | metrics from your ``aiohttp`` web application: 46 | 47 | .. code:: 48 | 49 | from aiohttp_prometheus import setup_metrics 50 | from aiohttp import web 51 | app = web.Application() 52 | setup_metrics(app, "mywebapp") 53 | 54 | For complete examples, please see `examples <./examples>`__. 55 | 56 | Discussions 57 | =========== 58 | 59 | Please file a `issue `__ 60 | to file a comment, report an issue or make a suggestion. 61 | -------------------------------------------------------------------------------- /examples/webapp1/README.md: -------------------------------------------------------------------------------- 1 | # Example usage of `aiohttp_prometheus` 2 | 3 | See ``src`` for the application code. 4 | 5 | ## Building Docker image 6 | 7 | The Python 3 based [Dockerfile](Dockerfile.py3) uses an Alpine Linux base image 8 | and expects the application source code to be volume mounted at `/application` 9 | when run. 10 | 11 | To build the image: 12 | 13 | ``` 14 | $ docker build -t amitsaha/aiohttp_app1 -f Dockerfile.py3 . 15 | ``` 16 | 17 | ## Running the application 18 | 19 | We can just run the web application as follows: 20 | 21 | ``` 22 | $ docker run -ti -p 8080:8080 -v `pwd`/src:/application amitsaha/aiohttp_app1 23 | ``` 24 | 25 | ## Bringing up the web application, along with prometheus 26 | 27 | The [docker-compse.yml](docker-compose.yml) brings up the `webapp` service which is our web application 28 | using the image `amitsaha/flask_app` we built above. The [docker-compose-infra.yml](docker-compose-infra.yml) 29 | file brings up the `prometheus` service and also starts the `grafana` service which 30 | is available on port 3000. The config directory contains a `prometheus.yml` file 31 | which sets up the targets for prometheus to scrape. The scrape configuration 32 | looks as follows: 33 | 34 | ``` 35 | # A scrape configuration containing exactly one endpoint to scrape: 36 | # Here it's Prometheus itself. 37 | scrape_configs: 38 | # The job name is added as a label `job=` to any timeseries scraped from this config. 39 | - job_name: 'prometheus' 40 | 41 | # Override the global default and scrape targets from this job every 5 seconds. 42 | scrape_interval: 5s 43 | 44 | # metrics_path defaults to '/metrics' 45 | # scheme defaults to 'http'. 46 | 47 | static_configs: 48 | - targets: ['localhost:9090'] 49 | - job_name: 'webapp' 50 | 51 | # Override the global default and scrape targets from this job every 5 seconds. 52 | scrape_interval: 5s 53 | 54 | # metrics_path defaults to '/metrics' 55 | # scheme defaults to 'http'. 56 | static_configs: 57 | - targets: ['webapp:8080'] 58 | ``` 59 | 60 | Prometheus scrapes itself, which is the first target above. The second target 61 | is the our web application on port 5000. 62 | Since these services are running via `docker-compose`, `webapp` automatically resolves to the IP of the webapp container. 63 | 64 | To bring up all the services: 65 | 66 | ``` 67 | $ docker-compose -f docker-compose.yml -f docker-compose-infra.yml up 68 | ``` 69 | 70 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 Amit Saha 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------