Skip to content
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
5 changes: 2 additions & 3 deletions sentry_sdk/integrations/boto3/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from sentry_sdk.integrations import DidNotEnable
from sentry_sdk.integrations.boto3._context import AwsCallContext
from sentry_sdk.integrations.boto3._instrumentation import (
_finish_span,
_get_error_attributes,
_get_response_attributes,
_instrument_streaming_body,
Expand Down Expand Up @@ -109,7 +108,7 @@ def sentry_patched_make_api_call(
with capture_internal_exceptions():
span.set_attributes(_get_response_attributes(parsed))
except BaseException as error:
_finish_span(span, error)
span.__exit__(type(error), error, error.__traceback__)
raise

streaming_body_instrumented = False
Expand All @@ -118,7 +117,7 @@ def sentry_patched_make_api_call(

# `StreamingBody`s finish their span when consumed or closed.
if not streaming_body_instrumented:
_finish_span(span)
span.end()
Comment thread
sentrivana marked this conversation as resolved.
Resolved
return parsed

BaseClient.__init__ = sentry_patched_init # type: ignore
Expand Down
16 changes: 5 additions & 11 deletions sentry_sdk/integrations/boto3/_instrumentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def _get_error_attributes(exception: "BaseException") -> "Attributes":


def _start_client_span(ctx: "AwsCallContext") -> "Optional[Span]":

client = sentry_sdk.get_client()
if client.get_integration(IDENTIFIER) is None:
return None
Expand Down Expand Up @@ -189,14 +188,6 @@ def _start_client_span(ctx: "AwsCallContext") -> "Optional[Span]":
)


def _finish_span(span: "Span", error: "Optional[BaseException]" = None) -> None:
with capture_internal_exceptions():
if error is None:
span.end()
else:
span.__exit__(type(error), error, error.__traceback__)


def _instrument_streaming_body(span: "Span", parsed: "Dict[str, Any]") -> bool:
if isinstance(span, NoOpSpan):
return False
Expand Down Expand Up @@ -235,8 +226,11 @@ def finish_span(error: "Optional[BaseException]" = None) -> None:
streaming_span.set_attributes(attributes)
span.set_attributes(attributes)

_finish_span(streaming_span, error)
_finish_span(span, error)
streaming_span.__exit__(type(error), error, error.__traceback__)
span.__exit__(type(error), error, error.__traceback__)
else:
streaming_span.end()
span.end()

def content_length_reached() -> bool:
content_length = getattr(body, "_content_length", None)
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/asgi/test_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def app(scope, receive, send):
await send({"type": "lifespan.shutdown.complete"})
return

with sentry_sdk.traces.start_span(name="child-span"):
with sentry_sdk.start_span(name="child-span"):
pass

await send(
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/sanic/test_sanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ def test_is_localhost_span_attribute(

@app.route("/child-span")
def child_span_handler_localhost(request):
with sentry_sdk.traces.start_span(name="child-span"):
with sentry_sdk.start_span(name="child-span"):
pass
return response.text("ok")

Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/wsgi/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ def test_is_localhost_attribute(
sentry_init, capture_items, client_kwargs, is_localhost
):
def dogpark(environ, start_response):
with sentry_sdk.traces.start_span(name="child-span"):
with sentry_sdk.start_span(name="child-span"):
pass
start_response("200 OK", [])
return ["woof"]
Expand All @@ -1110,7 +1110,7 @@ def dogpark(environ, start_response):

def test_user_agent_attribute(sentry_init, capture_items):
def dogpark(environ, start_response):
with sentry_sdk.traces.start_span(name="child-span"):
with sentry_sdk.start_span(name="child-span"):
pass
start_response("200 OK", [])
return ["woof"]
Expand Down
2 changes: 1 addition & 1 deletion tests/tracing/test_span_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def traces_sampler(sampling_context):

items = capture_items("span")

with sentry_sdk.traces.start_span(name="test"):
with sentry_sdk.start_span(name="test"):
...

sentry_sdk.flush()
Expand Down
Loading