Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-95827, NH-96119 Upgrade to Otel Python 1.28.1/0.49b1, testrelease 3.3.0.0 #450

Merged
merged 14 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/solarwinds/apm-python/compare/rel-3.2.0...HEAD)
## [Unreleased](https://github.com/solarwinds/apm-python/compare/rel-3.3.0...HEAD)

## [3.3.0.0](https://github.com/solarwinds/apm-python/releases/tag/rel-3.3.0) - 2024-11-12

### Changed
- Fixed CodeQL warnings ([#445](https://github.com/solarwinds/apm-python/pull/445), [#446](https://github.com/solarwinds/apm-python/pull/446))
- Upgraded OpenTelemetry API/SDK and instrumentation 1.28.1/0.49b1, remove `pkg_resources` usage ([#450](https://github.com/solarwinds/apm-python/pull/450))

## [3.2.0](https://github.com/solarwinds/apm-python/releases/tag/rel-3.2.0) - 2024-10-08

Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,14 @@ install-lambda-modules:
rm -rf ${target_dir}
@echo -e "Creating target directory ${target_dir} for AWS Lambda layer artifacts."
mkdir -p ${target_dir}/python
@echo -e "Install setuptools"
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do /opt/python/$${PYBIN}/bin/pip install setuptools; done
@echo -e "Install upstream dependencies to include in layer"
@/opt/python/cp38-cp38/bin/pip3.8 install -t ${target_dir}/python -r lambda/requirements.txt
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do /opt/python/$${PYBIN}/bin/pip install -t ${target_dir}/python -r lambda/requirements.txt; done
@echo -e "Install other version-specific .so files for deps"
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do /opt/python/$${PYBIN}/bin/pip install -t ${target_dir}/$${PYBIN} -r lambda/requirements-so.txt; done
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do cp ${target_dir}/$${PYBIN}/charset_normalizer/*.so ${target_dir}/python/charset_normalizer/ && cp ${target_dir}/$${PYBIN}/grpc/_cython/*.so ${target_dir}/python/grpc/_cython/ && cp ${target_dir}/$${PYBIN}/wrapt/*.so ${target_dir}/python/wrapt/; done
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do rm -rf ${target_dir}/$${PYBIN} ; done
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do /opt/python/$${PYBIN}/bin/pip install -t ${target_dir}/$${PYBIN} -r lambda/requirements-so.txt; done
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do cp ${target_dir}/$${PYBIN}/charset_normalizer/*.so ${target_dir}/python/charset_normalizer/ && cp ${target_dir}/$${PYBIN}/grpc/_cython/*.so ${target_dir}/python/grpc/_cython/ && cp ${target_dir}/$${PYBIN}/wrapt/*.so ${target_dir}/python/wrapt/; done
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do rm -rf ${target_dir}/$${PYBIN} ; done
@echo -e "Install upstream dependencies without deps to include in layer"
@/opt/python/cp38-cp38/bin/pip3.8 install -t ${target_dir}/nodeps -r lambda/requirements-nodeps.txt --no-deps
@echo -e "Install solarwinds_apm to be packed up in zip archive to target directory."
Expand Down
6 changes: 3 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opentelemetry-test-utils==0.48b0
opentelemetry-instrumentation-flask==0.48b0
opentelemetry-instrumentation-requests==0.48b0
opentelemetry-test-utils==0.49b1
opentelemetry-instrumentation-flask==0.49b1
opentelemetry-instrumentation-requests==0.49b1
pytest
pytest-cov
pytest-mock
Expand Down
23 changes: 12 additions & 11 deletions lambda/check_lambda_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,23 @@ if [ ! -f "python/opentelemetry/instrumentation/aws_lambda/__init__.py" ]; then
exit 1
fi

expected_otel_files="./python/opentelemetry/exporter/otlp/proto/common/version.py
./python/opentelemetry/exporter/otlp/proto/grpc/version.py
./python/opentelemetry/exporter/otlp/proto/http/version.py
./python/opentelemetry/exporter/otlp/version.py
./python/opentelemetry/instrumentation/botocore/version.py"
found_otel_files=$(find ./python/opentelemetry/exporter ./python/opentelemetry/instrumentation/botocore -regextype sed -regex ".*/version.py" | sort -k1)
expected_otel_files="./python/opentelemetry/instrumentation/botocore/version.py
./python/opentelemetry/instrumentation/logging/version.py"
found_otel_files=$(find ./python/opentelemetry/instrumentation/botocore ./python/opentelemetry/instrumentation/logging -regextype sed -regex ".*/version.py" | sort -k1)
if [[ ! "$found_otel_files" =~ $expected_otel_files ]]; then
echo "FAILED: Missing key opentelemetry dependency version files"
echo "FAILED: Missing key OpenTelemetry instrumentor dependency files"
exit 1
fi

# An additional check for those packages now following PEP 420
expected_otel_files_pep420="./python/opentelemetry/sdk/version/__init__.py"
found_otel_files_pep420=$(find ./python/opentelemetry/sdk -regextype sed -regex ".*/version/__init__.py" | sort -k1)
# These packages also follow PEP 420 better
expected_otel_files_pep420="./python/opentelemetry/exporter/otlp/proto/common/version/__init__.py
./python/opentelemetry/exporter/otlp/proto/grpc/version/__init__.py
./python/opentelemetry/exporter/otlp/proto/http/version/__init__.py
./python/opentelemetry/exporter/otlp/version/__init__.py
./python/opentelemetry/sdk/version/__init__.py"
found_otel_files_pep420=$(find ./python/opentelemetry/exporter ./python/opentelemetry/sdk -regextype sed -regex ".*/version/__init__.py" | sort -k1)
if [[ ! "$found_otel_files_pep420" =~ $expected_otel_files_pep420 ]]; then
echo "FAILED: Missing key opentelemetry dependency version files (PEP 420)"
echo "FAILED: Missing key OpenTelemetry SDK and/or exporter dependency files"
exit 1
fi

Expand Down
58 changes: 29 additions & 29 deletions lambda/requirements-nodeps.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
opentelemetry-instrumentation-aiohttp-client==0.48b0
opentelemetry-util-http==0.48b0
opentelemetry-instrumentation-aiohttp-client==0.49b1
opentelemetry-util-http==0.49b1
asgiref~=3.8
opentelemetry-instrumentation-asgi==0.48b0
opentelemetry-instrumentation-asyncpg==0.48b0
opentelemetry-instrumentation-boto==0.48b0
opentelemetry-instrumentation-botocore==0.48b0
opentelemetry-instrumentation-celery==0.48b0
opentelemetry-instrumentation-dbapi==0.48b0
opentelemetry-instrumentation-django==0.48b0
opentelemetry-instrumentation-elasticsearch==0.48b0
opentelemetry-instrumentation-fastapi==0.48b0
opentelemetry-instrumentation-falcon==0.48b0
opentelemetry-instrumentation-flask==0.48b0
opentelemetry-instrumentation-grpc==0.48b0
opentelemetry-instrumentation-jinja2==0.48b0
opentelemetry-instrumentation-logging==0.48b0
opentelemetry-instrumentation-mysql==0.48b0
opentelemetry-instrumentation-psycopg2==0.48b0
opentelemetry-instrumentation-pymemcache==0.48b0
opentelemetry-instrumentation-pymongo==0.48b0
opentelemetry-instrumentation-pymysql==0.48b0
opentelemetry-instrumentation-pyramid==0.48b0
opentelemetry-instrumentation-redis==0.48b0
opentelemetry-instrumentation-requests==0.48b0
opentelemetry-instrumentation-sqlalchemy==0.48b0
opentelemetry-instrumentation-sqlite3==0.48b0
opentelemetry-instrumentation-starlette==0.48b0
opentelemetry-instrumentation-tornado==0.48b0
opentelemetry-instrumentation-wsgi==0.48b0
opentelemetry-instrumentation-asgi==0.49b1
opentelemetry-instrumentation-asyncpg==0.49b1
opentelemetry-instrumentation-boto==0.49b1
opentelemetry-instrumentation-botocore==0.49b1
opentelemetry-instrumentation-celery==0.49b1
opentelemetry-instrumentation-dbapi==0.49b1
opentelemetry-instrumentation-django==0.49b1
opentelemetry-instrumentation-elasticsearch==0.49b1
opentelemetry-instrumentation-fastapi==0.49b1
opentelemetry-instrumentation-falcon==0.49b1
opentelemetry-instrumentation-flask==0.49b1
opentelemetry-instrumentation-grpc==0.49b1
opentelemetry-instrumentation-jinja2==0.49b1
opentelemetry-instrumentation-logging==0.49b1
opentelemetry-instrumentation-mysql==0.49b1
opentelemetry-instrumentation-psycopg2==0.49b1
opentelemetry-instrumentation-pymemcache==0.49b1
opentelemetry-instrumentation-pymongo==0.49b1
opentelemetry-instrumentation-pymysql==0.49b1
opentelemetry-instrumentation-pyramid==0.49b1
opentelemetry-instrumentation-redis==0.49b1
opentelemetry-instrumentation-requests==0.49b1
opentelemetry-instrumentation-sqlalchemy==0.49b1
opentelemetry-instrumentation-sqlite3==0.49b1
opentelemetry-instrumentation-starlette==0.49b1
opentelemetry-instrumentation-tornado==0.49b1
opentelemetry-instrumentation-wsgi==0.49b1
8 changes: 4 additions & 4 deletions lambda/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
opentelemetry-exporter-otlp==1.27.0
opentelemetry-exporter-otlp-proto-grpc==1.27.0
opentelemetry-exporter-otlp-proto-http==1.27.0
opentelemetry-instrumentation-aws-lambda==0.48b0
opentelemetry-exporter-otlp==1.28.1
opentelemetry-exporter-otlp-proto-grpc==1.28.1
opentelemetry-exporter-otlp-proto-http==1.28.1
opentelemetry-instrumentation-aws-lambda==0.49b1
packaging
jaraco.text
platformdirs
Expand Down
2 changes: 1 addition & 1 deletion lambda/tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
opentelemetry-instrumentation-aws-lambda == 0.48b0
opentelemetry-instrumentation-aws-lambda == 0.49b1
opentelemetry-propagator-aws-xray == 1.0.2
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
'opentelemetry-api == 1.27.0',
'opentelemetry-sdk == 1.27.0',
'opentelemetry-exporter-otlp == 1.27.0',
'opentelemetry-instrumentation == 0.48b0',
'opentelemetry-instrumentation-logging == 0.48b0',
'opentelemetry-api == 1.28.1',
'opentelemetry-sdk == 1.28.1',
'opentelemetry-exporter-otlp == 1.28.1',
'opentelemetry-instrumentation == 0.49b1',
'opentelemetry-instrumentation-logging == 0.49b1',
]

[project.urls]
Expand Down
11 changes: 7 additions & 4 deletions solarwinds_apm/apm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
OTEL_TRACES_EXPORTER,
)
from opentelemetry.sdk.resources import Resource
from pkg_resources import iter_entry_points
from opentelemetry.util._importlib_metadata import entry_points

import solarwinds_apm.apm_noop as noop_extension
from solarwinds_apm import apm_logging
Expand Down Expand Up @@ -391,9 +391,12 @@ def _calculate_agent_enabled_config(self) -> bool:
!= INTL_SWO_DEFAULT_TRACES_EXPORTER
):
next(
iter_entry_points(
"opentelemetry_traces_exporter",
environ_exporter_name,
iter(
# pylint: disable=too-many-function-args
entry_points(
group="opentelemetry_traces_exporter",
name=environ_exporter_name,
)
)
)
except StopIteration:
Expand Down
66 changes: 42 additions & 24 deletions solarwinds_apm/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
BatchSpanProcessor,
SimpleSpanProcessor,
)
from pkg_resources import get_distribution, iter_entry_points, load_entry_point
from opentelemetry.util._importlib_metadata import entry_points, version

from solarwinds_apm import apm_logging
from solarwinds_apm.apm_config import SolarWindsApmConfig
Expand Down Expand Up @@ -189,11 +189,14 @@ def _configure_sampler(
trace.set_tracer_provider(trace.NoOpTracerProvider())
return
try:
sampler = load_entry_point(
"solarwinds_apm",
"opentelemetry_traces_sampler",
self._DEFAULT_SW_TRACES_SAMPLER,
)(apm_config, reporter, oboe_api)
sampler = next(
iter(
entry_points(
group="opentelemetry_traces_sampler",
name=self._DEFAULT_SW_TRACES_SAMPLER,
)
)
).load()(apm_config, reporter, oboe_api)
except Exception as ex:
logger.exception("A exception was raised: %s", ex)
logger.exception(
Expand Down Expand Up @@ -339,20 +342,27 @@ def _configure_traces_exporter(
exporter = None
try:
if exporter_name == INTL_SWO_DEFAULT_TRACES_EXPORTER:
exporter = load_entry_point(
"solarwinds_apm",
"opentelemetry_traces_exporter",
exporter_name,
)(
exporter = next(
iter(
entry_points(
group="opentelemetry_traces_exporter",
name=exporter_name,
)
)
).load()(
reporter,
apm_txname_manager,
apm_fwkv_manager,
apm_config,
)
else:
exporter = next(
iter_entry_points(
"opentelemetry_traces_exporter", exporter_name
iter(
# pylint: disable=too-many-function-args
entry_points(
group="opentelemetry_traces_exporter",
name=exporter_name,
)
)
).load()()
except Exception as ex:
Expand Down Expand Up @@ -419,9 +429,11 @@ def _configure_metrics_exporter(
exporter = None
try:
exporter = next(
iter_entry_points(
"opentelemetry_metrics_exporter",
exporter_name,
iter(
entry_points(
group="opentelemetry_metrics_exporter",
name=exporter_name,
)
)
).load()(preferred_temporality=temporality_delta)
except Exception as ex:
Expand Down Expand Up @@ -534,8 +546,11 @@ def _configure_logs_exporter(
exporter = None
try:
exporter = next(
iter_entry_points(
"opentelemetry_logs_exporter", exporter_name
iter(
entry_points(
group="opentelemetry_logs_exporter",
name=exporter_name,
)
)
).load()()
except Exception as ex:
Expand Down Expand Up @@ -577,8 +592,11 @@ def _configure_propagator(self) -> None:
try:
propagators.append(
next(
iter_entry_points(
"opentelemetry_propagator", propagator_name
iter(
entry_points(
group="opentelemetry_propagator",
name=propagator_name,
)
)
).load()()
)
Expand Down Expand Up @@ -659,7 +677,9 @@ def _add_all_instrumented_python_framework_versions(
package_to_exclude = package_to_exclude.split(",")
package_to_exclude = [x.strip() for x in package_to_exclude]

for entry_point in iter_entry_points("opentelemetry_instrumentor"):
for entry_point in iter(
entry_points(group="opentelemetry_instrumentor")
):
if entry_point.name in package_to_exclude:
logger.debug(
"Skipping version lookup for library %s because excluded",
Expand Down Expand Up @@ -750,9 +770,7 @@ def _add_all_instrumented_python_framework_versions(
f"{entry_point_name}.connector"
].__version__
elif entry_point_name == "pyramid":
version_keys[instr_key] = get_distribution(
entry_point_name
).version
version_keys[instr_key] = version(entry_point_name)
elif entry_point_name == "sqlite3":
version_keys[instr_key] = sys.modules[
entry_point_name
Expand Down
2 changes: 1 addition & 1 deletion solarwinds_apm/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL,
)
from opentelemetry.sdk.version import __version__ as sdk_version
from pkg_resources import EntryPoint
from opentelemetry.util._importlib_metadata import EntryPoint

from solarwinds_apm.apm_config import SolarWindsApmConfig
from solarwinds_apm.apm_constants import (
Expand Down
4 changes: 2 additions & 2 deletions solarwinds_apm/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from opentelemetry.sdk.trace.export import SpanExporter
from opentelemetry.trace import SpanKind
from pkg_resources import get_distribution
from opentelemetry.util._importlib_metadata import version

from solarwinds_apm.apm_constants import (
INTL_SWO_LIBOBOE_TXN_NAME_KEY_PREFIX,
Expand Down Expand Up @@ -251,7 +251,7 @@ def _add_info_instrumented_framework(self, span, evt) -> None:
f"{framework}.connector"
].__version__
elif framework == "pyramid":
version_str = get_distribution(framework).version
version_str = version(framework)
elif framework == "sqlite3":
version_str = sys.modules[framework].sqlite_version
elif framework == "tornado":
Expand Down
2 changes: 1 addition & 1 deletion solarwinds_apm/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.2.0"
__version__ = "3.3.0.0"
Loading
Loading