Skip to content

Commit

Permalink
Added a script to generate readme file for root instrumentations (#647)
Browse files Browse the repository at this point in the history
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 <aboten@lightstep.com>
  • Loading branch information
owais and alrex authored Sep 1, 2021
1 parent b6e49ba commit 2e77bfc
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
36 changes: 36 additions & 0 deletions instrumentation/README.md
Original file line number Diff line number Diff line change
@@ -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 |
79 changes: 79 additions & 0 deletions scripts/generate_instrumentation_readme.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,4 @@ deps =
commands =
{toxinidir}/scripts/generate_setup.py
{toxinidir}/scripts/generate_instrumentation_bootstrap.py
{toxinidir}/scripts/generate_instrumentation_readme.py

0 comments on commit 2e77bfc

Please sign in to comment.