Skip to content

Commit

Permalink
Simplify bootstrap and generate code
Browse files Browse the repository at this point in the history
- We now automatically generate bootstrap_gen.py file from the list of instrumentations present in the source tree.
- Bootstrap command now uses consumes this auto-generated list instead of keeping it's own local copy.
- We no longer uninstall packages before installing them as instrumentation package no longer specify libraries as dependencies so the edge cases are no longer there.
- We no longer try to install an incompatible version or force upgrade/downgrade an installed version. This used to leave systems in broken states which should happen no more.
  • Loading branch information
owais committed May 31, 2021
1 parent 4a8b32b commit 48e65d7
Show file tree
Hide file tree
Showing 47 changed files with 1,316 additions and 213 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tox-environment: [ "docker-tests", "lint", "docs" ]
tox-environment: [ "docker-tests", "lint", "docs", "generate" ]
name: ${{ matrix.tox-environment }}
runs-on: ubuntu-latest
steps:
Expand All @@ -102,3 +102,7 @@ jobs:
key: v2-misc-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt', 'docs-requirements.txt') }}
- name: run tox
run: tox -e ${{ matrix.tox-environment }}
- name: Ensure generated code is up to date
if: matrix.tox-environment == 'generate'
run: >-
git diff --exit-code || (echo 'Generated code is out of date, please run "tox -e generate" and commit the changes in this PR.' && exit 1)
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.egg
*.egg-info
dist
dist-info
build
eggs
parts
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.2.0-0.21b0...HEAD)

### Changed
- `opentelemetry-bootstrap` not longer forcibly removes and re-installs libraries and their instrumentations.
This means running bootstrap will not auto-upgrade existing dependencies and as a result not cause dependency
conflicts.
([#514](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/514))
- `opentelemetry-instrumentation-asgi` Set the response status code on the server span
([#478](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/478))
- `opentelemetry-instrumentation-tornado` Fixed cases where description was used with non-
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Below is a checklist of things to be mindful of when implementing a new instrume
- Extends from [BaseInstrumentor](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py#L26)
- Supports auto-instrumentation
- Add an entry point (ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-requests/setup.cfg#L56)
- Add instrumentation package to `bootstrap.py` (https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py#L37)
- Run `python scripts/setup.py` followed by `python scripts/generate_instrumentation_bootstrap.py` after adding a new instrumentation package.
- Functionality that is common amongst other instrumentation and can be abstracted [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation)
- Request/response [hooks](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/408) for http instrumentations
- `suppress_instrumentation` functionality
Expand Down
3 changes: 1 addition & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-r gen-requirements.txt
pylint~=2.6
flake8~=3.7
isort~=5.6
black>=19.3b0,==19.*
httpretty~=1.0
mypy==0.790
sphinx
Expand Down
4 changes: 4 additions & 0 deletions gen-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
astor~=0.8.1
isort~=5.6
black>=19.3b0,==19.*
jinja2~=2.7
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


import os
import distutils.cmd
import json
from configparser import ConfigParser

import setuptools
Expand Down Expand Up @@ -66,6 +68,32 @@

extras_require["test"] = test_deps


class JSONMetadataCommand(distutils.cmd.Command):

description = (
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
"auto-generate code in other places",
)
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
metadata = {
"name": config["metadata"]["name"],
"version": PACKAGE_INFO["__version__"],
"instruments": PACKAGE_INFO["_instruments"],
}
print(json.dumps(metadata))


setuptools.setup(
version=PACKAGE_INFO["__version__"], extras_require=extras_require
cmdclass={"meta": JSONMetadataCommand},
version=PACKAGE_INFO["__version__"],
extras_require=extras_require,
)
30 changes: 29 additions & 1 deletion instrumentation/opentelemetry-instrumentation-aiopg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


import os
import distutils.cmd
import json
from configparser import ConfigParser

import setuptools
Expand Down Expand Up @@ -56,6 +58,32 @@

extras_require["test"] = test_deps


class JSONMetadataCommand(distutils.cmd.Command):

description = (
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
"auto-generate code in other places",
)
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
metadata = {
"name": config["metadata"]["name"],
"version": PACKAGE_INFO["__version__"],
"instruments": PACKAGE_INFO["_instruments"],
}
print(json.dumps(metadata))


setuptools.setup(
version=PACKAGE_INFO["__version__"], extras_require=extras_require
cmdclass={"meta": JSONMetadataCommand},
version=PACKAGE_INFO["__version__"],
extras_require=extras_require,
)
30 changes: 29 additions & 1 deletion instrumentation/opentelemetry-instrumentation-asgi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


import os
import distutils.cmd
import json
from configparser import ConfigParser

import setuptools
Expand Down Expand Up @@ -56,6 +58,32 @@

extras_require["test"] = test_deps


class JSONMetadataCommand(distutils.cmd.Command):

description = (
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
"auto-generate code in other places",
)
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
metadata = {
"name": config["metadata"]["name"],
"version": PACKAGE_INFO["__version__"],
"instruments": PACKAGE_INFO["_instruments"],
}
print(json.dumps(metadata))


setuptools.setup(
version=PACKAGE_INFO["__version__"], extras_require=extras_require
cmdclass={"meta": JSONMetadataCommand},
version=PACKAGE_INFO["__version__"],
extras_require=extras_require,
)
30 changes: 29 additions & 1 deletion instrumentation/opentelemetry-instrumentation-asyncpg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


import os
import distutils.cmd
import json
from configparser import ConfigParser

import setuptools
Expand Down Expand Up @@ -66,6 +68,32 @@

extras_require["test"] = test_deps


class JSONMetadataCommand(distutils.cmd.Command):

description = (
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
"auto-generate code in other places",
)
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
metadata = {
"name": config["metadata"]["name"],
"version": PACKAGE_INFO["__version__"],
"instruments": PACKAGE_INFO["_instruments"],
}
print(json.dumps(metadata))


setuptools.setup(
version=PACKAGE_INFO["__version__"], extras_require=extras_require
cmdclass={"meta": JSONMetadataCommand},
version=PACKAGE_INFO["__version__"],
extras_require=extras_require,
)
30 changes: 29 additions & 1 deletion instrumentation/opentelemetry-instrumentation-boto/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


import os
import distutils.cmd
import json
from configparser import ConfigParser

import setuptools
Expand Down Expand Up @@ -56,6 +58,32 @@

extras_require["test"] = test_deps


class JSONMetadataCommand(distutils.cmd.Command):

description = (
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
"auto-generate code in other places",
)
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
metadata = {
"name": config["metadata"]["name"],
"version": PACKAGE_INFO["__version__"],
"instruments": PACKAGE_INFO["_instruments"],
}
print(json.dumps(metadata))


setuptools.setup(
version=PACKAGE_INFO["__version__"], extras_require=extras_require
cmdclass={"meta": JSONMetadataCommand},
version=PACKAGE_INFO["__version__"],
extras_require=extras_require,
)
30 changes: 29 additions & 1 deletion instrumentation/opentelemetry-instrumentation-botocore/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


import os
import distutils.cmd
import json
from configparser import ConfigParser

import setuptools
Expand Down Expand Up @@ -66,6 +68,32 @@

extras_require["test"] = test_deps


class JSONMetadataCommand(distutils.cmd.Command):

description = (
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
"auto-generate code in other places",
)
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
metadata = {
"name": config["metadata"]["name"],
"version": PACKAGE_INFO["__version__"],
"instruments": PACKAGE_INFO["_instruments"],
}
print(json.dumps(metadata))


setuptools.setup(
version=PACKAGE_INFO["__version__"], extras_require=extras_require
cmdclass={"meta": JSONMetadataCommand},
version=PACKAGE_INFO["__version__"],
extras_require=extras_require,
)
30 changes: 29 additions & 1 deletion instrumentation/opentelemetry-instrumentation-celery/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


import os
import distutils.cmd
import json
from configparser import ConfigParser

import setuptools
Expand Down Expand Up @@ -56,6 +58,32 @@

extras_require["test"] = test_deps


class JSONMetadataCommand(distutils.cmd.Command):

description = (
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
"auto-generate code in other places",
)
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
metadata = {
"name": config["metadata"]["name"],
"version": PACKAGE_INFO["__version__"],
"instruments": PACKAGE_INFO["_instruments"],
}
print(json.dumps(metadata))


setuptools.setup(
version=PACKAGE_INFO["__version__"], extras_require=extras_require
cmdclass={"meta": JSONMetadataCommand},
version=PACKAGE_INFO["__version__"],
extras_require=extras_require,
)
Loading

0 comments on commit 48e65d7

Please sign in to comment.