Skip to content

Commit

Permalink
Merge branch 'main' into custom-sw-build
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Jun 3, 2024
2 parents a1ef0e9 + 768694c commit f600d60
Show file tree
Hide file tree
Showing 163 changed files with 989 additions and 508 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 955c92e91b5cd4bcfb43c39efcef086b040471d2
CORE_REPO_SHA: 141a6a2e473ef7f0ec4915dfb71e3c0fa595283e

jobs:
instrumentations-0:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 955c92e91b5cd4bcfb43c39efcef086b040471d2
CORE_REPO_SHA: 141a6a2e473ef7f0ec4915dfb71e3c0fa595283e

jobs:
instrumentations-1:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 955c92e91b5cd4bcfb43c39efcef086b040471d2
CORE_REPO_SHA: 141a6a2e473ef7f0ec4915dfb71e3c0fa595283e

jobs:
lint-3_11:
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ jobs:
# rejected by pypi (e.g "3 - Beta"). This would cause a failure during the
# middle of the package upload causing the action to fail, and certain packages
# might have already been updated, this would be bad.
- name: Publish to TestPyPI
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.test_pypi_token }}
run: |
twine upload --repository testpypi --skip-existing --verbose dist/*
# EDIT: 5/31/2024 - TestPypi now requires a verified email. Commenting out as a temporary measure
# until we found TestPypi credentials.
# - name: Publish to TestPyPI
# env:
# TWINE_USERNAME: '__token__'
# TWINE_PASSWORD: ${{ secrets.test_pypi_token }}
# run: |
# twine upload --repository testpypi --skip-existing --verbose dist/*

- name: Publish to PyPI
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 47d5ad7aae5aef31238ca66e55dc550b307c7b35
CORE_REPO_SHA: 141a6a2e473ef7f0ec4915dfb71e3c0fa595283e

jobs:
misc:
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,4 @@ min-public-methods=2

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception".
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
24 changes: 22 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- `opentelemetry-instrumentation-httpx` Ensure httpx.get or httpx.request like methods are instrumented
([#2538](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2538))

## Version 1.25.0/0.46b0 (2024-05-31)

### Breaking changes

- Add return statement to Confluent kafka Producer poll() and flush() calls when instrumented by ConfluentKafkaInstrumentor().instrument_producer() ([#2527](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2527))
- Rename `type` attribute to `asgi.event.type` in `opentelemetry-instrumentation-asgi`
([#2300](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2300))
- Rename AwsLambdaInstrumentor span attributes `faas.id` to `cloud.resource_id`, `faas.execution` to `faas.invocation_id`
Expand All @@ -19,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2425](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2425))
- `opentelemetry-instrumentation-flask` Add `http.method` to `span.name`
([#2454](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2454))
- ASGI, FastAPI, Starlette: provide both send and receive hooks with `scope` and `message` for internal spans ([#2546](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2546))

### Added

Expand All @@ -36,9 +45,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2397](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2397)))
- `opentelemetry-processor-baggage` Initial release
([#2436](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2436))
- `opentelemetry-processor-baggage` Add baggage key predicate
([#2535](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2535))

### Fixed

- `opentelemetry-instrumentation-dbapi` Fix compatibility with Psycopg3 to extract libpq build version
([#2500](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2500))
- `opentelemetry-instrumentation-grpc` AioClientInterceptor should propagate with a Metadata object
([#2363](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2363))
- `opentelemetry-instrumentation-boto3sqs` Instrument Session and resource
Expand All @@ -53,6 +66,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2474](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2474))
- `opentelemetry-instrumentation-elasticsearch` Improved support for version 8
([#2420](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2420))
- `opentelemetry-instrumentation-elasticsearch` Disabling instrumentation with native OTel support enabled
([#2524](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2524))
- `opentelemetry-instrumentation-asyncio` Check for __name__ attribute in the coroutine
([#2521](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2521))
- `opentelemetry-instrumentation-requests` Fix wrong time unit for duration histogram
([#2553](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2553))
- `opentelemetry-util-http` Preserve brackets around literal IPv6 hosts ([#2552](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2552))
- `opentelemetry-util-redis` Fix net peer attribute for unix socket connection ([#2493](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2493))

## Version 1.24.0/0.45b0 (2024-03-28)

Expand Down Expand Up @@ -124,7 +145,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1959](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1959))
- `opentelemetry-resource-detector-azure` Added dependency for Cloud Resource ID attribute
([#2072](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2072))

## Version 1.21.0/0.42b0 (2023-11-01)

### Added
Expand Down Expand Up @@ -1538,4 +1559,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-resource-detector-azure` Suppress instrumentation for `urllib` call
([#2178](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2178))
- AwsLambdaInstrumentor handles and re-raises function exception ([#2245](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2245))

2 changes: 1 addition & 1 deletion _template/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.46b0.dev"
__version__ = "0.47b0.dev"
4 changes: 2 additions & 2 deletions eachdist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sortfirst=
ext/*

[stable]
version=1.25.0.dev
version=1.26.0.dev

packages=
opentelemetry-sdk
Expand All @@ -34,7 +34,7 @@ packages=
opentelemetry-api

[prerelease]
version=0.46b0.dev
version=0.47b0.dev

packages=
all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.46b0.dev"
__version__ = "0.47b0.dev"
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-richconsole/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
dependencies = [
"opentelemetry-api ~= 1.12",
"opentelemetry-sdk ~= 1.12",
"opentelemetry-semantic-conventions == 0.46b0.dev",
"opentelemetry-semantic-conventions == 0.47b0.dev",
"rich>=10.0.0",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.46b0.dev"
__version__ = "0.47b0.dev"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
]
dependencies = [
"opentelemetry-api ~= 1.5",
"opentelemetry-instrumentation == 0.46b0.dev",
"opentelemetry-instrumentation == 0.47b0.dev",
"wrapt >= 1.0.0, < 2.0.0",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.46b0.dev"
__version__ = "0.47b0.dev"
Original file line number Diff line number Diff line change
Expand Up @@ -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 == 0.47b0.dev",
"opentelemetry-semantic-conventions == 0.47b0.dev",
"opentelemetry-util-http == 0.47b0.dev",
"wrapt >= 1.0.0, < 2.0.0",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.46b0.dev"
__version__ = "0.47b0.dev"
Original file line number Diff line number Diff line change
Expand Up @@ -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 == 0.47b0.dev",
"opentelemetry-semantic-conventions == 0.47b0.dev",
"opentelemetry-util-http == 0.47b0.dev",
"wrapt >= 1.0.0, < 2.0.0",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.46b0.dev"
__version__ = "0.47b0.dev"
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ classifiers = [
]
dependencies = [
"opentelemetry-api ~= 1.12",
"opentelemetry-instrumentation == 0.46b0.dev",
"opentelemetry-instrumentation-dbapi == 0.46b0.dev",
"opentelemetry-instrumentation == 0.47b0.dev",
"opentelemetry-instrumentation-dbapi == 0.47b0.dev",
"wrapt >= 1.0.0, < 2.0.0",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.46b0.dev"
__version__ = "0.47b0.dev"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from unittest.mock import MagicMock

import aiopg
import psycopg2

import opentelemetry.instrumentation.aiopg
from opentelemetry import trace as trace_api
Expand Down Expand Up @@ -384,7 +385,9 @@ def test_span_failed(self):
span.attributes[SpanAttributes.DB_STATEMENT], "Test query"
)
self.assertIs(span.status.status_code, trace_api.StatusCode.ERROR)
self.assertEqual(span.status.description, "Exception: Test Exception")
self.assertEqual(
span.status.description, "ProgrammingError: Test Exception"
)

def test_executemany(self):
db_integration = AiopgIntegration(self.tracer, "testcomponent")
Expand Down Expand Up @@ -570,17 +573,17 @@ class MockCursor:
# pylint: disable=unused-argument, no-self-use
async def execute(self, query, params=None, throw_exception=False):
if throw_exception:
raise Exception("Test Exception")
raise psycopg2.ProgrammingError("Test Exception")

# pylint: disable=unused-argument, no-self-use
async def executemany(self, query, params=None, throw_exception=False):
if throw_exception:
raise Exception("Test Exception")
raise psycopg2.ProgrammingError("Test Exception")

# pylint: disable=unused-argument, no-self-use
async def callproc(self, query, params=None, throw_exception=False):
if throw_exception:
raise Exception("Test Exception")
raise psycopg2.ProgrammingError("Test Exception")

def close(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ classifiers = [
dependencies = [
"asgiref ~= 3.0",
"opentelemetry-api ~= 1.12",
"opentelemetry-instrumentation == 0.46b0.dev",
"opentelemetry-semantic-conventions == 0.46b0.dev",
"opentelemetry-util-http == 0.46b0.dev",
"opentelemetry-instrumentation == 0.47b0.dev",
"opentelemetry-semantic-conventions == 0.47b0.dev",
"opentelemetry-util-http == 0.47b0.dev",
]

[project.optional-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ async def hello():
.. code-block:: python
def server_request_hook(span: Span, scope: dict):
def server_request_hook(span: Span, scope: dict[str, Any]):
if span and span.is_recording():
span.set_attribute("custom_user_attribute_from_request_hook", "some-value")
def client_request_hook(span: Span, scope: dict):
def client_request_hook(span: Span, scope: dict[str, Any], message: dict[str, Any]):
if span and span.is_recording():
span.set_attribute("custom_user_attribute_from_client_request_hook", "some-value")
def client_response_hook(span: Span, message: dict):
def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, Any]):
if span and span.is_recording():
span.set_attribute("custom_user_attribute_from_response_hook", "some-value")
Expand Down Expand Up @@ -200,6 +200,11 @@ def client_response_hook(span: Span, message: dict):
from asgiref.compatibility import guarantee_single_callable

from opentelemetry import context, trace
from opentelemetry.instrumentation.asgi.types import (
ClientRequestHook,
ClientResponseHook,
ServerRequestHook,
)
from opentelemetry.instrumentation.asgi.version import __version__ # noqa
from opentelemetry.instrumentation.propagators import (
get_global_response_propagator,
Expand All @@ -212,7 +217,7 @@ def client_response_hook(span: Span, message: dict):
from opentelemetry.propagators.textmap import Getter, Setter
from opentelemetry.semconv.metrics import MetricInstruments
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import Span, set_span_in_context
from opentelemetry.trace import set_span_in_context
from opentelemetry.trace.status import Status, StatusCode
from opentelemetry.util.http import (
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS,
Expand All @@ -227,10 +232,6 @@ def client_response_hook(span: Span, message: dict):
remove_url_credentials,
)

_ServerRequestHookT = typing.Optional[typing.Callable[[Span, dict], None]]
_ClientRequestHookT = typing.Optional[typing.Callable[[Span, dict], None]]
_ClientResponseHookT = typing.Optional[typing.Callable[[Span, dict], None]]


class ASGIGetter(Getter[dict]):
def get(
Expand Down Expand Up @@ -454,10 +455,10 @@ class OpenTelemetryMiddleware:
Optional: Defaults to get_default_span_details.
server_request_hook: Optional callback which is called with the server span and ASGI
scope object for every incoming request.
client_request_hook: Optional callback which is called with the internal span and an ASGI
scope which is sent as a dictionary for when the method receive is called.
client_response_hook: Optional callback which is called with the internal span and an ASGI
event which is sent as a dictionary for when the method send is called.
client_request_hook: Optional callback which is called with the internal span, and ASGI
scope and event which are sent as dictionaries for when the method receive is called.
client_response_hook: Optional callback which is called with the internal span, and ASGI
scope and event which are sent as dictionaries for when the method send is called.
tracer_provider: The optional tracer provider to use. If omitted
the current globally configured one is used.
"""
Expand All @@ -468,9 +469,9 @@ def __init__(
app,
excluded_urls=None,
default_span_details=None,
server_request_hook: _ServerRequestHookT = None,
client_request_hook: _ClientRequestHookT = None,
client_response_hook: _ClientResponseHookT = None,
server_request_hook: ServerRequestHook = None,
client_request_hook: ClientRequestHook = None,
client_response_hook: ClientResponseHook = None,
tracer_provider=None,
meter_provider=None,
meter=None,
Expand Down Expand Up @@ -666,9 +667,9 @@ async def otel_receive():
with self.tracer.start_as_current_span(
" ".join((server_span_name, scope["type"], "receive"))
) as receive_span:
if callable(self.client_request_hook):
self.client_request_hook(receive_span, scope)
message = await receive()
if callable(self.client_request_hook):
self.client_request_hook(receive_span, scope, message)
if receive_span.is_recording():
if message["type"] == "websocket.receive":
set_status_code(receive_span, 200)
Expand All @@ -691,7 +692,7 @@ async def otel_send(message: dict[str, Any]):
" ".join((server_span_name, scope["type"], "send"))
) as send_span:
if callable(self.client_response_hook):
self.client_response_hook(send_span, message)
self.client_response_hook(send_span, scope, message)
if send_span.is_recording():
if message["type"] == "http.response.start":
status_code = message["status"]
Expand Down
Loading

0 comments on commit f600d60

Please sign in to comment.