From 2e77bfc55560690809841e52ebd538dd7dc79253 Mon Sep 17 00:00:00 2001 From: Owais Lone Date: Thu, 2 Sep 2021 01:33:02 +0530 Subject: [PATCH] Added a script to generate readme file for root instrumentations (#647) directory This file lists down all instrumentations and the packages+versions they support. This is helpful to find out at a glance what is exactly supported. Co-authored-by: alrex --- instrumentation/README.md | 36 ++++++++++ scripts/generate_instrumentation_readme.py | 79 ++++++++++++++++++++++ tox.ini | 1 + 3 files changed, 116 insertions(+) create mode 100644 instrumentation/README.md create mode 100755 scripts/generate_instrumentation_readme.py diff --git a/instrumentation/README.md b/instrumentation/README.md new file mode 100644 index 000000000..8c59661d5 --- /dev/null +++ b/instrumentation/README.md @@ -0,0 +1,36 @@ + +| Instrumentation | Supported Packages | +| --------------- | ------------------ | +| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | +| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 | +| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | +| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | +| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 | +| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 | +| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | +| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | +| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | +| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | +| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon ~= 2.0 | +| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | +| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | +| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | +| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0, < 0.19.0 | +| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2~=2.7 | +| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | +| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | +| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | +| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache ~= 1.3 | +| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo ~= 3.1 | +| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL ~= 0.10.1 | +| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | +| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 | +| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 | +| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 | +| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy | +| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 | +| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 | +| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 6.0 | +| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | +| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | +| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | \ No newline at end of file diff --git a/scripts/generate_instrumentation_readme.py b/scripts/generate_instrumentation_readme.py new file mode 100755 index 000000000..4eaa8c907 --- /dev/null +++ b/scripts/generate_instrumentation_readme.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 + +# Copyright The OpenTelemetry 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 logging +import os + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger("instrumentation_readme_generator") + +_prefix = "opentelemetry-instrumentation-" + +header = """ +| Instrumentation | Supported Packages | +| --------------- | ------------------ |""" + + +def main(): + root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + base_instrumentation_path = os.path.join(root_path, "instrumentation") + + table = [header] + for instrumentation in sorted(os.listdir(base_instrumentation_path)): + instrumentation_path = os.path.join( + base_instrumentation_path, instrumentation + ) + if not os.path.isdir( + instrumentation_path + ) or not instrumentation.startswith(_prefix): + continue + + src_dir = os.path.join( + instrumentation_path, "src", "opentelemetry", "instrumentation" + ) + src_pkgs = [ + f + for f in os.listdir(src_dir) + if os.path.isdir(os.path.join(src_dir, f)) + ] + assert len(src_pkgs) == 1 + name = src_pkgs[0] + + pkg_info = {} + version_filename = os.path.join(src_dir, name, "package.py",) + with open(version_filename, encoding="utf-8") as fh: + exec(fh.read(), pkg_info) + + instruments = pkg_info["_instruments"] + if not instruments: + instruments = (name,) + + table.append( + "| [{0}](./{0}) | {1} |".format( + instrumentation, ",".join(instruments) + ) + ) + + with open( + os.path.join(base_instrumentation_path, "README.md"), + "w", + encoding="utf-8", + ) as fh: + fh.write("\n".join(table)) + + +if __name__ == "__main__": + main() diff --git a/tox.ini b/tox.ini index 5c20828a3..0fab90b21 100644 --- a/tox.ini +++ b/tox.ini @@ -447,3 +447,4 @@ deps = commands = {toxinidir}/scripts/generate_setup.py {toxinidir}/scripts/generate_instrumentation_bootstrap.py + {toxinidir}/scripts/generate_instrumentation_readme.py