Skip to content

Commit

Permalink
Add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Nov 26, 2024
1 parent 92d122a commit c88ac3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `opentelemetry-instrumentation-starlette` Add type hints to the instrumentation
([#3045](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3045))
- `opentelemetry-instrumentation-sqlalchemy` Update unit tests to run with SQLALchemy 2
([#2976](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2976))
- Add `opentelemetry-instrumentation-openai-v2` to `opentelemetry-bootstrap`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
from opentelemetry.util.http import get_excluded_urls

if TYPE_CHECKING:
from typing import NotRequired, TypedDict, Unpack
from typing import TypedDict, Unpack

class InstrumentKwargs(TypedDict):
tracer_provider: NotRequired[TracerProvider]
meter_provider: NotRequired[MeterProvider]
server_request_hook: NotRequired[ServerRequestHook]
client_request_hook: NotRequired[ClientRequestHook]
client_response_hook: NotRequired[ClientResponseHook]
class InstrumentKwargs(TypedDict, total=False):
tracer_provider: TracerProvider
meter_provider: MeterProvider
server_request_hook: ServerRequestHook
client_request_hook: ClientRequestHook
client_response_hook: ClientResponseHook


_excluded_urls = get_excluded_urls("STARLETTE")
Expand Down Expand Up @@ -256,11 +256,7 @@ def instrument_app(

@staticmethod
def uninstrument_app(app: applications.Starlette):
app.user_middleware = [
x
for x in app.user_middleware
if x.cls is not OpenTelemetryMiddleware
]
app.user_middleware = [x for x in app.user_middleware if x.cls is not OpenTelemetryMiddleware]
app.middleware_stack = app.build_middleware_stack()
app._is_instrumented_by_opentelemetry = False

Expand All @@ -270,15 +266,9 @@ def instrumentation_dependencies(self) -> Collection[str]:
def _instrument(self, **kwargs: Unpack[InstrumentKwargs]):
self._original_starlette = applications.Starlette
_InstrumentedStarlette._tracer_provider = kwargs.get("tracer_provider")
_InstrumentedStarlette._server_request_hook = kwargs.get(
"server_request_hook"
)
_InstrumentedStarlette._client_request_hook = kwargs.get(
"client_request_hook"
)
_InstrumentedStarlette._client_response_hook = kwargs.get(
"client_response_hook"
)
_InstrumentedStarlette._server_request_hook = kwargs.get("server_request_hook")
_InstrumentedStarlette._client_request_hook = kwargs.get("client_request_hook")
_InstrumentedStarlette._client_response_hook = kwargs.get("client_response_hook")
_InstrumentedStarlette._meter_provider = kwargs.get("_meter_provider")

applications.Starlette = _InstrumentedStarlette
Expand Down

0 comments on commit c88ac3f

Please sign in to comment.