From 338d411d2f010583b86103ff7b16863cab67cdd6 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Mon, 6 May 2024 12:19:41 -0700 Subject: [PATCH 01/10] Mock otel-instr 0.45b0 --- .../instrumentation/bootstrap_gen.py | 96 +++++++++---------- .../opentelemetry/instrumentation/version.py | 2 +- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index 55d2f498a1..8b7fb690ed 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -18,175 +18,175 @@ libraries = [ { "library": "aio_pika >= 7.2.0, < 10.0.0", - "instrumentation": "opentelemetry-instrumentation-aio-pika==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-aio-pika==0.45b0", }, { "library": "aiohttp ~= 3.0", - "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.45b0", }, { "library": "aiopg >= 0.13.0, < 2.0.0", - "instrumentation": "opentelemetry-instrumentation-aiopg==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-aiopg==0.45b0", }, { "library": "asgiref ~= 3.0", - "instrumentation": "opentelemetry-instrumentation-asgi==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-asgi==0.45b0", }, { "library": "asyncpg >= 0.12.0", - "instrumentation": "opentelemetry-instrumentation-asyncpg==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-asyncpg==0.45b0", }, { "library": "boto~=2.0", - "instrumentation": "opentelemetry-instrumentation-boto==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-boto==0.45b0", }, { "library": "boto3 ~= 1.0", - "instrumentation": "opentelemetry-instrumentation-boto3sqs==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-boto3sqs==0.45b0", }, { "library": "botocore ~= 1.0", - "instrumentation": "opentelemetry-instrumentation-botocore==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-botocore==0.45b0", }, { "library": "cassandra-driver ~= 3.25", - "instrumentation": "opentelemetry-instrumentation-cassandra==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-cassandra==0.45b0", }, { "library": "scylla-driver ~= 3.25", - "instrumentation": "opentelemetry-instrumentation-cassandra==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-cassandra==0.45b0", }, { "library": "celery >= 4.0, < 6.0", - "instrumentation": "opentelemetry-instrumentation-celery==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-celery==0.45b0", }, { "library": "confluent-kafka >= 1.8.2, <= 2.3.0", - "instrumentation": "opentelemetry-instrumentation-confluent-kafka==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-confluent-kafka==0.45b0", }, { "library": "django >= 1.10", - "instrumentation": "opentelemetry-instrumentation-django==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-django==0.45b0", }, { "library": "elasticsearch >= 6.0", - "instrumentation": "opentelemetry-instrumentation-elasticsearch==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-elasticsearch==0.45b0", }, { "library": "falcon >= 1.4.1, < 3.1.2", - "instrumentation": "opentelemetry-instrumentation-falcon==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-falcon==0.45b0", }, { "library": "fastapi ~= 0.58", - "instrumentation": "opentelemetry-instrumentation-fastapi==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-fastapi==0.45b0", }, { "library": "flask >= 1.0", - "instrumentation": "opentelemetry-instrumentation-flask==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-flask==0.45b0", }, { "library": "grpcio ~= 1.27", - "instrumentation": "opentelemetry-instrumentation-grpc==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-grpc==0.45b0", }, { "library": "httpx >= 0.18.0", - "instrumentation": "opentelemetry-instrumentation-httpx==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-httpx==0.45b0", }, { "library": "jinja2 >= 2.7, < 4.0", - "instrumentation": "opentelemetry-instrumentation-jinja2==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-jinja2==0.45b0", }, { "library": "kafka-python >= 2.0", - "instrumentation": "opentelemetry-instrumentation-kafka-python==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-kafka-python==0.45b0", }, { "library": "mysql-connector-python ~= 8.0", - "instrumentation": "opentelemetry-instrumentation-mysql==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-mysql==0.45b0", }, { "library": "mysqlclient < 3", - "instrumentation": "opentelemetry-instrumentation-mysqlclient==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-mysqlclient==0.45b0", }, { "library": "pika >= 0.12.0", - "instrumentation": "opentelemetry-instrumentation-pika==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-pika==0.45b0", }, { "library": "psycopg >= 3.1.0", - "instrumentation": "opentelemetry-instrumentation-psycopg==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-psycopg==0.45b0", }, { "library": "psycopg2 >= 2.7.3.1", - "instrumentation": "opentelemetry-instrumentation-psycopg2==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-psycopg2==0.45b0", }, { "library": "pymemcache >= 1.3.5, < 5", - "instrumentation": "opentelemetry-instrumentation-pymemcache==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-pymemcache==0.45b0", }, { "library": "pymongo >= 3.1, < 5.0", - "instrumentation": "opentelemetry-instrumentation-pymongo==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-pymongo==0.45b0", }, { "library": "PyMySQL < 2", - "instrumentation": "opentelemetry-instrumentation-pymysql==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-pymysql==0.45b0", }, { "library": "pyramid >= 1.7", - "instrumentation": "opentelemetry-instrumentation-pyramid==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-pyramid==0.45b0", }, { "library": "redis >= 2.6", - "instrumentation": "opentelemetry-instrumentation-redis==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-redis==0.45b0", }, { "library": "remoulade >= 0.50", - "instrumentation": "opentelemetry-instrumentation-remoulade==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-remoulade==0.45b0", }, { "library": "requests ~= 2.0", - "instrumentation": "opentelemetry-instrumentation-requests==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-requests==0.45b0", }, { "library": "scikit-learn ~= 0.24.0", - "instrumentation": "opentelemetry-instrumentation-sklearn==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-sklearn==0.45b0", }, { "library": "sqlalchemy", - "instrumentation": "opentelemetry-instrumentation-sqlalchemy==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-sqlalchemy==0.45b0", }, { "library": "starlette ~= 0.13.0", - "instrumentation": "opentelemetry-instrumentation-starlette==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-starlette==0.45b0", }, { "library": "psutil >= 5", - "instrumentation": "opentelemetry-instrumentation-system-metrics==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-system-metrics==0.45b0", }, { "library": "tornado >= 5.1.1", - "instrumentation": "opentelemetry-instrumentation-tornado==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-tornado==0.45b0", }, { "library": "tortoise-orm >= 0.17.0", - "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.45b0", }, { "library": "pydantic >= 1.10.2", - "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.45b0", }, { "library": "urllib3 >= 1.0.0, < 3.0.0", - "instrumentation": "opentelemetry-instrumentation-urllib3==0.46b0.dev", + "instrumentation": "opentelemetry-instrumentation-urllib3==0.45b0", }, ] default_instrumentations = [ - "opentelemetry-instrumentation-asyncio==0.46b0.dev", - "opentelemetry-instrumentation-aws-lambda==0.46b0.dev", - "opentelemetry-instrumentation-dbapi==0.46b0.dev", - "opentelemetry-instrumentation-logging==0.46b0.dev", - "opentelemetry-instrumentation-sqlite3==0.46b0.dev", - "opentelemetry-instrumentation-urllib==0.46b0.dev", - "opentelemetry-instrumentation-wsgi==0.46b0.dev", + "opentelemetry-instrumentation-asyncio==0.45b0", + "opentelemetry-instrumentation-aws-lambda==0.45b0", + "opentelemetry-instrumentation-dbapi==0.45b0", + "opentelemetry-instrumentation-logging==0.45b0", + "opentelemetry-instrumentation-sqlite3==0.45b0", + "opentelemetry-instrumentation-urllib==0.45b0", + "opentelemetry-instrumentation-wsgi==0.45b0", ] diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py index ff4933b20b..6deb7c3d9e 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.46b0.dev" +__version__ = "0.45b0" From 4adee01718dd299d7723233d6746ca0b44c4ba6d Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Mon, 6 May 2024 12:19:58 -0700 Subject: [PATCH 02/10] Mock LoggingInstr 0.45b0 --- .../opentelemetry-instrumentation-logging/pyproject.toml | 2 +- .../src/opentelemetry/instrumentation/logging/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml b/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml index 57572ce634..db7220567c 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.46b0.dev", + "opentelemetry-instrumentation == 0.45b0", ] [project.optional-dependencies] diff --git a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py index 17627b21dc..40576e3ded 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py +++ b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py @@ -12,6 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.46b0.dev" +__version__ = "0.45b0" _instruments = tuple() From 635fe3a4fc939a39cf3c57d0d415cc19d37fd8d6 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Mon, 6 May 2024 14:51:27 -0700 Subject: [PATCH 03/10] Mock util-http 0.45b0 --- .../src/opentelemetry/util/http/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py b/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py index ff4933b20b..6deb7c3d9e 100644 --- a/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py +++ b/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.46b0.dev" +__version__ = "0.45b0" From 5da2ef2caddcf48cd56acf35ae6a0f02648b5c01 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Mon, 6 May 2024 14:55:05 -0700 Subject: [PATCH 04/10] Mock requests,wsgi instr 0.45b0 --- .../opentelemetry-instrumentation-requests/pyproject.toml | 6 +++--- .../src/opentelemetry/instrumentation/requests/version.py | 2 +- .../opentelemetry-instrumentation-wsgi/pyproject.toml | 6 +++--- .../src/opentelemetry/instrumentation/wsgi/version.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml b/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml index 6252ab3de9..e263d529be 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml @@ -25,9 +25,9 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.46b0.dev", - "opentelemetry-semantic-conventions == 0.46b0.dev", - "opentelemetry-util-http == 0.46b0.dev", + "opentelemetry-instrumentation@git+https://github.com/tammy-baylis-swi/opentelemetry-python-contrib.git@sw-upgrade-otel#subdirectory=opentelemetry-instrumentation", + "opentelemetry-semantic-conventions@git+https://github.com/tammy-baylis-swi/opentelemetry-python.git@sw-upgrade-otel#subdirectory=opentelemetry-semantic-conventions", + "opentelemetry-util-http@git+https://github.com/tammy-baylis-swi/opentelemetry-python-contrib.git@sw-upgrade-otel#subdirectory=util/opentelemetry-util-http", ] [project.optional-dependencies] diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py index ff4933b20b..6deb7c3d9e 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.46b0.dev" +__version__ = "0.45b0" diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml index e3e8bca651..952d8c66ed 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml @@ -25,9 +25,9 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.46b0.dev", - "opentelemetry-semantic-conventions == 0.46b0.dev", - "opentelemetry-util-http == 0.46b0.dev", + "opentelemetry-instrumentation@git+https://github.com/tammy-baylis-swi/opentelemetry-python-contrib.git@sw-upgrade-otel#subdirectory=opentelemetry-instrumentation", + "opentelemetry-semantic-conventions@git+https://github.com/tammy-baylis-swi/opentelemetry-python.git@sw-upgrade-otel#subdirectory=opentelemetry-semantic-conventions", + "opentelemetry-util-http@git+https://github.com/tammy-baylis-swi/opentelemetry-python-contrib.git@sw-upgrade-otel#subdirectory=util/opentelemetry-util-http", ] [project.optional-dependencies] diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py index ff4933b20b..6deb7c3d9e 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.46b0.dev" +__version__ = "0.45b0" From 3a328ebe9b070d987e631e5490376a518184203e Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Mon, 6 May 2024 15:06:29 -0700 Subject: [PATCH 05/10] allow-direct-ref true for reqs,wsgi instr --- .../opentelemetry-instrumentation-requests/pyproject.toml | 3 +++ .../opentelemetry-instrumentation-wsgi/pyproject.toml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml b/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml index e263d529be..2b96ab1b1b 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml @@ -44,6 +44,9 @@ Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/ [tool.hatch.version] path = "src/opentelemetry/instrumentation/requests/version.py" +[tool.hatch.metadata] +allow-direct-references = true + [tool.hatch.build.targets.sdist] include = [ "/src", diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml index 952d8c66ed..4391a1a801 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml @@ -39,6 +39,9 @@ Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/ [tool.hatch.version] path = "src/opentelemetry/instrumentation/wsgi/version.py" +[tool.hatch.metadata] +allow-direct-references = true + [tool.hatch.build.targets.sdist] include = [ "/src", From 92b15ac38e0d4eb34d007e16021163016fea0ad5 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Wed, 8 May 2024 09:52:19 -0700 Subject: [PATCH 06/10] Debug lines --- .../instrumentation/requests/__init__.py | 15 +++++++++++++ .../opentelemetry/instrumentation/_semconv.py | 21 +++++++++++++++++++ .../instrumentation/instrumentor.py | 5 +++++ 3 files changed, 41 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py index 12797d6f5e..eb546cb082 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py @@ -125,6 +125,9 @@ def _instrument( :code:`requests.session.Session.request` (this includes :code:`requests.get`, etc.).""" + print("!!! init.py _instrument with opt_in_mode:") + print("%s", sem_conv_opt_in_mode) + # Since # https://github.com/psf/requests/commit/d72d1162142d1bf8b1b5711c664fbbd674f349d1 # (v0.7.0, Oct 23, 2011), get, post, etc are implemented via request which @@ -209,6 +212,9 @@ def get_or_create_headers(): except ValueError: pass + print("!!! RequestsInstrumentor start_as_current_span with span_attributes:") + print("%s", span_attributes) + with tracer.start_as_current_span( span_name, kind=SpanKind.CLIENT, attributes=span_attributes ) as span, set_ip_on_next_http_connection(span): @@ -312,6 +318,8 @@ def get_or_create_headers(): if exception is not None: raise exception.with_traceback(exception.__traceback__) + print("Attributes updated: %s", span_attributes) + return result instrumented_send.opentelemetry_instrumentation_requests_applied = True @@ -376,9 +384,16 @@ def _instrument(self, **kwargs): ``excluded_urls``: A string containing a comma-delimited list of regexes used to exclude URLs from tracking """ + print("!!! RequestsInstrumentor _instrument with kwargs:") + print("%s", kwargs) + semconv_opt_in_mode = _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.HTTP, ) + + print("Then got semconv_opt_in_mode (no hyphen):") + print("%s", semconv_opt_in_mode) + schema_url = _get_schema_url(semconv_opt_in_mode) tracer_provider = kwargs.get("tracer_provider") tracer = get_tracer( diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py index efe3c75f70..93ec8afdff 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py @@ -119,6 +119,10 @@ def _initialize(cls): # Users can pass in comma delimited string for opt-in options # Only values for http stability are supported for now opt_in = os.environ.get(OTEL_SEMCONV_STABILITY_OPT_IN, "") + + print("!!! SemconvStability._initialize") + print("Got opt_in from env var: %s", opt_in) + opt_in_list = [] if opt_in: opt_in_list = [s.strip() for s in opt_in.split(",")] @@ -130,6 +134,9 @@ def _initialize(cls): http_opt_in = _HTTPStabilityMode.HTTP_DUP elif _HTTPStabilityMode.HTTP.value in opt_in_list: http_opt_in = _HTTPStabilityMode.HTTP + + print("Using http_opt_in %s", http_opt_in) + _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING[ _OpenTelemetryStabilitySignalType.HTTP ] = http_opt_in @@ -141,6 +148,16 @@ def _get_opentelemetry_stability_opt_in_mode( cls, signal_type: _OpenTelemetryStabilitySignalType, ) -> _HTTPStabilityMode: + print("!!! _semconv.get_otel_stability") + print("signal_type: %s", signal_type) + print("_OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING: %s", _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING) + print( + "retval: %s", + _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get( + signal_type, _HTTPStabilityMode.DEFAULT + ) + ) + return _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get( signal_type, _HTTPStabilityMode.DEFAULT ) @@ -224,10 +241,14 @@ def _set_http_status_code(result, code, sem_conv_opt_in_mode): def _set_http_url(result, url, sem_conv_opt_in_mode): + print("!!! _semconv._set_http_url got opt_in_mode: %s", sem_conv_opt_in_mode) + if _report_old(sem_conv_opt_in_mode): set_string_attribute(result, SpanAttributes.HTTP_URL, url) + print("set_string_attr with key %s, url %s", SpanAttributes.HTTP_URL, url) if _report_new(sem_conv_opt_in_mode): set_string_attribute(result, SpanAttributes.URL_FULL, url) + print("set_string_attr with key %s, url %s", SpanAttributes.URL_FULL, url) def _set_http_scheme(result, scheme, sem_conv_opt_in_mode): diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py index c612bfeceb..0699729f3c 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py @@ -96,6 +96,9 @@ def instrument(self, **kwargs): ``opentelemetry-instrument`` command does. """ + print("!!! Starting BaseInstrumentor.instrument with kwargs:") + print("%s", kwargs) + if self._is_instrumented_by_opentelemetry: _LOG.warning("Attempting to instrument while already instrumented") return None @@ -111,6 +114,8 @@ def instrument(self, **kwargs): # initialize semantic conventions opt-in if needed _OpenTelemetrySemanticConventionStability._initialize() + print("Base instrumentor calling self._instrument with kwargs:") + print("%s", kwargs) result = self._instrument( # pylint: disable=assignment-from-no-return **kwargs ) From 61db33c6124bf37fdc535e9fc4aae76e2b7ea461 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Wed, 8 May 2024 13:46:10 -0700 Subject: [PATCH 07/10] Revert "Debug lines" This reverts commit 92b15ac38e0d4eb34d007e16021163016fea0ad5. --- .../instrumentation/requests/__init__.py | 15 ------------- .../opentelemetry/instrumentation/_semconv.py | 21 ------------------- .../instrumentation/instrumentor.py | 5 ----- 3 files changed, 41 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py index eb546cb082..12797d6f5e 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py @@ -125,9 +125,6 @@ def _instrument( :code:`requests.session.Session.request` (this includes :code:`requests.get`, etc.).""" - print("!!! init.py _instrument with opt_in_mode:") - print("%s", sem_conv_opt_in_mode) - # Since # https://github.com/psf/requests/commit/d72d1162142d1bf8b1b5711c664fbbd674f349d1 # (v0.7.0, Oct 23, 2011), get, post, etc are implemented via request which @@ -212,9 +209,6 @@ def get_or_create_headers(): except ValueError: pass - print("!!! RequestsInstrumentor start_as_current_span with span_attributes:") - print("%s", span_attributes) - with tracer.start_as_current_span( span_name, kind=SpanKind.CLIENT, attributes=span_attributes ) as span, set_ip_on_next_http_connection(span): @@ -318,8 +312,6 @@ def get_or_create_headers(): if exception is not None: raise exception.with_traceback(exception.__traceback__) - print("Attributes updated: %s", span_attributes) - return result instrumented_send.opentelemetry_instrumentation_requests_applied = True @@ -384,16 +376,9 @@ def _instrument(self, **kwargs): ``excluded_urls``: A string containing a comma-delimited list of regexes used to exclude URLs from tracking """ - print("!!! RequestsInstrumentor _instrument with kwargs:") - print("%s", kwargs) - semconv_opt_in_mode = _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.HTTP, ) - - print("Then got semconv_opt_in_mode (no hyphen):") - print("%s", semconv_opt_in_mode) - schema_url = _get_schema_url(semconv_opt_in_mode) tracer_provider = kwargs.get("tracer_provider") tracer = get_tracer( diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py index 93ec8afdff..efe3c75f70 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py @@ -119,10 +119,6 @@ def _initialize(cls): # Users can pass in comma delimited string for opt-in options # Only values for http stability are supported for now opt_in = os.environ.get(OTEL_SEMCONV_STABILITY_OPT_IN, "") - - print("!!! SemconvStability._initialize") - print("Got opt_in from env var: %s", opt_in) - opt_in_list = [] if opt_in: opt_in_list = [s.strip() for s in opt_in.split(",")] @@ -134,9 +130,6 @@ def _initialize(cls): http_opt_in = _HTTPStabilityMode.HTTP_DUP elif _HTTPStabilityMode.HTTP.value in opt_in_list: http_opt_in = _HTTPStabilityMode.HTTP - - print("Using http_opt_in %s", http_opt_in) - _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING[ _OpenTelemetryStabilitySignalType.HTTP ] = http_opt_in @@ -148,16 +141,6 @@ def _get_opentelemetry_stability_opt_in_mode( cls, signal_type: _OpenTelemetryStabilitySignalType, ) -> _HTTPStabilityMode: - print("!!! _semconv.get_otel_stability") - print("signal_type: %s", signal_type) - print("_OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING: %s", _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING) - print( - "retval: %s", - _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get( - signal_type, _HTTPStabilityMode.DEFAULT - ) - ) - return _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get( signal_type, _HTTPStabilityMode.DEFAULT ) @@ -241,14 +224,10 @@ def _set_http_status_code(result, code, sem_conv_opt_in_mode): def _set_http_url(result, url, sem_conv_opt_in_mode): - print("!!! _semconv._set_http_url got opt_in_mode: %s", sem_conv_opt_in_mode) - if _report_old(sem_conv_opt_in_mode): set_string_attribute(result, SpanAttributes.HTTP_URL, url) - print("set_string_attr with key %s, url %s", SpanAttributes.HTTP_URL, url) if _report_new(sem_conv_opt_in_mode): set_string_attribute(result, SpanAttributes.URL_FULL, url) - print("set_string_attr with key %s, url %s", SpanAttributes.URL_FULL, url) def _set_http_scheme(result, scheme, sem_conv_opt_in_mode): diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py index 0699729f3c..c612bfeceb 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py @@ -96,9 +96,6 @@ def instrument(self, **kwargs): ``opentelemetry-instrument`` command does. """ - print("!!! Starting BaseInstrumentor.instrument with kwargs:") - print("%s", kwargs) - if self._is_instrumented_by_opentelemetry: _LOG.warning("Attempting to instrument while already instrumented") return None @@ -114,8 +111,6 @@ def instrument(self, **kwargs): # initialize semantic conventions opt-in if needed _OpenTelemetrySemanticConventionStability._initialize() - print("Base instrumentor calling self._instrument with kwargs:") - print("%s", kwargs) result = self._instrument( # pylint: disable=assignment-from-no-return **kwargs ) From 0b8eae823daee54afc908d5d1354487fdd660dfc Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Wed, 8 May 2024 15:28:34 -0700 Subject: [PATCH 08/10] Mock flask instr 0.45b0 --- .../pyproject.toml | 11 +++++++---- .../opentelemetry/instrumentation/flask/version.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml b/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml index 2bc1335a51..8b6f2b9989 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml @@ -25,10 +25,10 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.46b0.dev", - "opentelemetry-instrumentation-wsgi == 0.46b0.dev", - "opentelemetry-semantic-conventions == 0.46b0.dev", - "opentelemetry-util-http == 0.46b0.dev", + "opentelemetry-instrumentation@git+https://github.com/tammy-baylis-swi/opentelemetry-python-contrib.git@sw-upgrade-otel#subdirectory=opentelemetry-instrumentation", + "opentelemetry-instrumentation-wsgi@git+https://github.com/tammy-baylis-swi/opentelemetry-python-contrib.git@sw-upgrade-otel#subdirectory=instrumentation/opentelemetry-instrumentation-wsgi", + "opentelemetry-semantic-conventions@git+https://github.com/tammy-baylis-swi/opentelemetry-python.git@sw-upgrade-otel#subdirectory=opentelemetry-semantic-conventions", + "opentelemetry-util-http@git+https://github.com/tammy-baylis-swi/opentelemetry-python-contrib.git@sw-upgrade-otel#subdirectory=util/opentelemetry-util-http", "packaging >= 21.0", "importlib-metadata >= 4.0", ] @@ -47,6 +47,9 @@ Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/ [tool.hatch.version] path = "src/opentelemetry/instrumentation/flask/version.py" +[tool.hatch.metadata] +allow-direct-references = true + [tool.hatch.build.targets.sdist] include = [ "/src", diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py index ff4933b20b..6deb7c3d9e 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.46b0.dev" +__version__ = "0.45b0" From 7784702dbcabb43b598547c8ed4d57a499ff6f79 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Wed, 8 May 2024 16:01:55 -0700 Subject: [PATCH 09/10] Debug lots --- .../instrumentation/requests/__init__.py | 15 ++++++++++++ .../instrumentation/wsgi/__init__.py | 12 ++++++++++ .../opentelemetry/instrumentation/_semconv.py | 23 +++++++++++++++++++ .../instrumentation/instrumentor.py | 5 ++++ 4 files changed, 55 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py index 12797d6f5e..eb546cb082 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py @@ -125,6 +125,9 @@ def _instrument( :code:`requests.session.Session.request` (this includes :code:`requests.get`, etc.).""" + print("!!! init.py _instrument with opt_in_mode:") + print("%s", sem_conv_opt_in_mode) + # Since # https://github.com/psf/requests/commit/d72d1162142d1bf8b1b5711c664fbbd674f349d1 # (v0.7.0, Oct 23, 2011), get, post, etc are implemented via request which @@ -209,6 +212,9 @@ def get_or_create_headers(): except ValueError: pass + print("!!! RequestsInstrumentor start_as_current_span with span_attributes:") + print("%s", span_attributes) + with tracer.start_as_current_span( span_name, kind=SpanKind.CLIENT, attributes=span_attributes ) as span, set_ip_on_next_http_connection(span): @@ -312,6 +318,8 @@ def get_or_create_headers(): if exception is not None: raise exception.with_traceback(exception.__traceback__) + print("Attributes updated: %s", span_attributes) + return result instrumented_send.opentelemetry_instrumentation_requests_applied = True @@ -376,9 +384,16 @@ def _instrument(self, **kwargs): ``excluded_urls``: A string containing a comma-delimited list of regexes used to exclude URLs from tracking """ + print("!!! RequestsInstrumentor _instrument with kwargs:") + print("%s", kwargs) + semconv_opt_in_mode = _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.HTTP, ) + + print("Then got semconv_opt_in_mode (no hyphen):") + print("%s", semconv_opt_in_mode) + schema_url = _get_schema_url(semconv_opt_in_mode) tracer_provider = kwargs.get("tracer_provider") tracer = get_tracer( diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py index 0a873d0fc3..7562aa50ea 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py @@ -311,6 +311,8 @@ def collect_request_attributes( """Collects HTTP request attributes from the PEP3333-conforming WSGI environ and returns a dictionary to be used as span creation attributes. """ + print("!!! wsgi.collect_request_attrs with %s", sem_conv_opt_in_mode) + result = {} _set_http_method( result, @@ -380,6 +382,7 @@ def collect_request_attributes( if flavor: _set_http_flavor_version(result, flavor, sem_conv_opt_in_mode) + print("!!! wsgi.collect_request_attrs result: %s", result) return result @@ -543,11 +546,16 @@ def __init__( tracer_provider=None, meter_provider=None, ): + print("!!! Middleware init (wsgi)") + # initialize semantic conventions opt-in if needed _OpenTelemetrySemanticConventionStability._initialize() sem_conv_opt_in_mode = _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.HTTP, ) + + print("with sem_conv_opt_in_mode: %s", sem_conv_opt_in_mode) + self.wsgi = wsgi self.tracer = trace.get_tracer( __name__, @@ -623,6 +631,8 @@ def __call__(self, environ, start_response): environ: A WSGI environment. start_response: The WSGI start_response callable. """ + print("!!! __call__ with self.mode %s", self._sem_conv_opt_in_mode) + req_attrs = collect_request_attributes( environ, self._sem_conv_opt_in_mode ) @@ -631,6 +641,8 @@ def __call__(self, environ, start_response): self._sem_conv_opt_in_mode, ) + print("req_attrs: %s", req_attrs) + span, token = _start_internal_or_server_span( tracer=self.tracer, span_name=get_default_span_name(environ), diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py index efe3c75f70..3419ecb054 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py @@ -119,6 +119,10 @@ def _initialize(cls): # Users can pass in comma delimited string for opt-in options # Only values for http stability are supported for now opt_in = os.environ.get(OTEL_SEMCONV_STABILITY_OPT_IN, "") + + print("!!! SemconvStability._initialize") + print("Got opt_in from env var: %s", opt_in) + opt_in_list = [] if opt_in: opt_in_list = [s.strip() for s in opt_in.split(",")] @@ -130,6 +134,9 @@ def _initialize(cls): http_opt_in = _HTTPStabilityMode.HTTP_DUP elif _HTTPStabilityMode.HTTP.value in opt_in_list: http_opt_in = _HTTPStabilityMode.HTTP + + print("Using http_opt_in %s", http_opt_in) + _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING[ _OpenTelemetryStabilitySignalType.HTTP ] = http_opt_in @@ -141,6 +148,16 @@ def _get_opentelemetry_stability_opt_in_mode( cls, signal_type: _OpenTelemetryStabilitySignalType, ) -> _HTTPStabilityMode: + print("!!! _semconv.get_otel_stability") + print("signal_type: %s", signal_type) + print("_OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING: %s", _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING) + print( + "retval: %s", + _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get( + signal_type, _HTTPStabilityMode.DEFAULT + ) + ) + return _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get( signal_type, _HTTPStabilityMode.DEFAULT ) @@ -224,10 +241,14 @@ def _set_http_status_code(result, code, sem_conv_opt_in_mode): def _set_http_url(result, url, sem_conv_opt_in_mode): + print("!!! _semconv._set_http_url got opt_in_mode: %s", sem_conv_opt_in_mode) + if _report_old(sem_conv_opt_in_mode): set_string_attribute(result, SpanAttributes.HTTP_URL, url) + print("set_string_attr with key %s, url %s", SpanAttributes.HTTP_URL, url) if _report_new(sem_conv_opt_in_mode): set_string_attribute(result, SpanAttributes.URL_FULL, url) + print("set_string_attr with key %s, url %s", SpanAttributes.URL_FULL, url) def _set_http_scheme(result, scheme, sem_conv_opt_in_mode): @@ -275,8 +296,10 @@ def _set_http_network_protocol_version(result, version, sem_conv_opt_in_mode): def _set_http_net_host(result, host, sem_conv_opt_in_mode): if _report_old(sem_conv_opt_in_mode): + print("!!! _semconv._set_http_net host via mode %s as %s", sem_conv_opt_in_mode, SpanAttributes.NET_HOST_NAME) set_string_attribute(result, SpanAttributes.NET_HOST_NAME, host) if _report_new(sem_conv_opt_in_mode): + print("!!! _semconv._set_http_net host via mode %s as %s", sem_conv_opt_in_mode, SpanAttributes.SERVER_ADDRESS) set_string_attribute(result, SpanAttributes.SERVER_ADDRESS, host) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py index c612bfeceb..0699729f3c 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py @@ -96,6 +96,9 @@ def instrument(self, **kwargs): ``opentelemetry-instrument`` command does. """ + print("!!! Starting BaseInstrumentor.instrument with kwargs:") + print("%s", kwargs) + if self._is_instrumented_by_opentelemetry: _LOG.warning("Attempting to instrument while already instrumented") return None @@ -111,6 +114,8 @@ def instrument(self, **kwargs): # initialize semantic conventions opt-in if needed _OpenTelemetrySemanticConventionStability._initialize() + print("Base instrumentor calling self._instrument with kwargs:") + print("%s", kwargs) result = self._instrument( # pylint: disable=assignment-from-no-return **kwargs ) From 2999b77219818f9cd58ec9c0306900f09ad71fa2 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Mon, 13 May 2024 10:48:12 -0700 Subject: [PATCH 10/10] Test: updated bootstrap error handling --- .../instrumentation/bootstrap.py | 41 ++++++++++------- .../instrumentation/bootstrap_gen.py | 7 ++- scripts/otel_packaging.py | 46 +++++++------------ 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py index 0c8f0aa3c4..6f86a539b2 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py @@ -14,8 +14,14 @@ import argparse import logging -import subprocess import sys +from subprocess import ( + PIPE, + CalledProcessError, + Popen, + SubprocessError, + check_call, +) import pkg_resources @@ -34,7 +40,7 @@ def wrapper(package=None): if package: return func(package) return func() - except subprocess.SubprocessError as exp: + except SubprocessError as exp: cmd = getattr(exp, "cmd", None) if cmd: msg = f'Error calling system command "{" ".join(cmd)}"' @@ -48,18 +54,21 @@ def wrapper(package=None): @_syscall def _sys_pip_install(package): # explicit upgrade strategy to override potential pip config - subprocess.check_call( - [ - sys.executable, - "-m", - "pip", - "install", - "-U", - "--upgrade-strategy", - "only-if-needed", - package, - ] - ) + try: + check_call( + [ + sys.executable, + "-m", + "pip", + "install", + "-U", + "--upgrade-strategy", + "only-if-needed", + package, + ] + ) + except CalledProcessError as error: + print(error) def _pip_check(): @@ -70,8 +79,8 @@ def _pip_check(): 'opentelemetry-instrumentation-flask 1.0.1 has requirement opentelemetry-sdk<2.0,>=1.0, but you have opentelemetry-sdk 0.5.' To not be too restrictive, we'll only check for relevant packages. """ - with subprocess.Popen( - [sys.executable, "-m", "pip", "check"], stdout=subprocess.PIPE + with Popen( + [sys.executable, "-m", "pip", "check"], stdout=PIPE ) as check_pipe: pip_check = check_pipe.communicate()[0].decode() pip_check_lower = pip_check.lower() diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index 8b7fb690ed..0bd94e2330 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -24,6 +24,10 @@ "library": "aiohttp ~= 3.0", "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.45b0", }, + { + "library": "aiohttp ~= 3.0", + "instrumentation": "opentelemetry-instrumentation-aiohttp-server==0.45b0", + }, { "library": "aiopg >= 0.13.0, < 2.0.0", "instrumentation": "opentelemetry-instrumentation-aiopg==0.45b0", @@ -187,6 +191,7 @@ "opentelemetry-instrumentation-dbapi==0.45b0", "opentelemetry-instrumentation-logging==0.45b0", "opentelemetry-instrumentation-sqlite3==0.45b0", + "opentelemetry-instrumentation-threading==0.45b0", "opentelemetry-instrumentation-urllib==0.45b0", "opentelemetry-instrumentation-wsgi==0.45b0", -] +] \ No newline at end of file diff --git a/scripts/otel_packaging.py b/scripts/otel_packaging.py index c6c11c45fa..2f42e44189 100644 --- a/scripts/otel_packaging.py +++ b/scripts/otel_packaging.py @@ -12,55 +12,43 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tomli import load -from os import path, listdir -from subprocess import check_output, CalledProcessError -from requests import get +import os +import subprocess +from subprocess import CalledProcessError -scripts_path = path.dirname(path.abspath(__file__)) -root_path = path.dirname(scripts_path) -instrumentations_path = path.join(root_path, "instrumentation") +import tomli + +scripts_path = os.path.dirname(os.path.abspath(__file__)) +root_path = os.path.dirname(scripts_path) +instrumentations_path = os.path.join(root_path, "instrumentation") def get_instrumentation_packages(): - for pkg in sorted(listdir(instrumentations_path)): - pkg_path = path.join(instrumentations_path, pkg) - if not path.isdir(pkg_path): + for pkg in sorted(os.listdir(instrumentations_path)): + pkg_path = os.path.join(instrumentations_path, pkg) + if not os.path.isdir(pkg_path): continue - error = f"Could not get version for package {pkg}" - try: - hatch_version = check_output( + version = subprocess.check_output( "hatch version", shell=True, cwd=pkg_path, - universal_newlines=True + universal_newlines=True, ) - except CalledProcessError as exc: print(f"Could not get hatch version from path {pkg_path}") print(exc.output) + raise exc - try: - response = get(f"https://pypi.org/pypi/{pkg}/json", timeout=10) - - except Exception: - print(error) - continue - - if response.status_code != 200: - print(error) - continue - - pyproject_toml_path = path.join(pkg_path, "pyproject.toml") + pyproject_toml_path = os.path.join(pkg_path, "pyproject.toml") with open(pyproject_toml_path, "rb") as file: - pyproject_toml = load(file) + pyproject_toml = tomli.load(file) instrumentation = { "name": pyproject_toml["project"]["name"], - "version": hatch_version.strip(), + "version": version.strip(), "instruments": pyproject_toml["project"]["optional-dependencies"][ "instruments" ],