Skip to content

Commit e5558a6

Browse files
authored
Cleanup start_transaction usages (#3884)
1 parent 0f34b49 commit e5558a6

29 files changed

+118
-118
lines changed

sentry_sdk/integrations/aws_lambda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs):
160160
headers = {}
161161

162162
with sentry_sdk.continue_trace(headers):
163-
with sentry_sdk.start_transaction(
163+
with sentry_sdk.start_span(
164164
op=OP.FUNCTION_AWS,
165165
name=aws_context.function_name,
166166
source=TRANSACTION_SOURCE_COMPONENT,

sentry_sdk/integrations/celery/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def _inner(*args, **kwargs):
313313
# something such as attribute access can fail.
314314
headers = args[3].get("headers") or {}
315315
with sentry_sdk.continue_trace(headers):
316-
with sentry_sdk.start_transaction(
316+
with sentry_sdk.start_span(
317317
op=OP.QUEUE_TASK_CELERY,
318318
name=task.name,
319319
source=TRANSACTION_SOURCE_TASK,

sentry_sdk/integrations/gcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def sentry_func(functionhandler, gcp_event, *args, **kwargs):
8787
headers = gcp_event.headers
8888

8989
with sentry_sdk.continue_trace(headers):
90-
with sentry_sdk.start_transaction(
90+
with sentry_sdk.start_span(
9191
op=OP.FUNCTION_GCP,
9292
name=environ.get("FUNCTION_NAME", ""),
9393
source=TRANSACTION_SOURCE_COMPONENT,

sentry_sdk/integrations/grpc/aio/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def wrapped(request, context):
4545

4646
# What if the headers are empty?
4747
with sentry_sdk.continue_trace(dict(context.invocation_metadata())):
48-
with sentry_sdk.start_transaction(
48+
with sentry_sdk.start_span(
4949
op=OP.GRPC_SERVER,
5050
name=name,
5151
source=TRANSACTION_SOURCE_CUSTOM,

sentry_sdk/integrations/grpc/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def behavior(request, context):
3939
metadata = dict(context.invocation_metadata())
4040

4141
with sentry_sdk.continue_trace(metadata):
42-
with sentry_sdk.start_transaction(
42+
with sentry_sdk.start_span(
4343
op=OP.GRPC_SERVER,
4444
name=name,
4545
source=TRANSACTION_SOURCE_CUSTOM,

sentry_sdk/integrations/tornado.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _handle_request_impl(self):
125125
scope.add_event_processor(processor)
126126

127127
with sentry_sdk.continue_trace(headers):
128-
with sentry_sdk.start_transaction(
128+
with sentry_sdk.start_span(
129129
op=OP.HTTP_SERVER,
130130
# Like with all other integrations, this is our
131131
# fallback transaction in case there is no route.

sentry_sdk/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,7 @@ def ensure_integration_enabled(
18021802
```python
18031803
@ensure_integration_enabled(MyIntegration, my_function)
18041804
def patch_my_function():
1805-
with sentry_sdk.start_transaction(...):
1805+
with sentry_sdk.start_span(...):
18061806
return my_function()
18071807
```
18081808
"""

tests/integrations/aiohttp/test_aiohttp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
HTTPUnavailableForLegalReasons,
1616
)
1717

18-
from sentry_sdk import capture_message, start_transaction
18+
from sentry_sdk import capture_message, start_span
1919
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
2020
from tests.conftest import ApproxDict
2121

@@ -417,7 +417,7 @@ async def hello(request):
417417
# The aiohttp_client is instrumented so will generate the sentry-trace header and add request.
418418
# Get the sentry-trace header from the request so we can later compare with transaction events.
419419
client = await aiohttp_client(app)
420-
with start_transaction():
420+
with start_span(name="request"):
421421
# Headers are only added to the span if there is an active transaction
422422
resp = await client.get("/")
423423

@@ -496,7 +496,7 @@ async def handler(request):
496496

497497
raw_server = await aiohttp_raw_server(handler)
498498

499-
with start_transaction():
499+
with start_span(name="breadcrumb"):
500500
events = capture_events()
501501

502502
client = await aiohttp_client(raw_server)
@@ -538,7 +538,7 @@ async def handler(request):
538538

539539
raw_server = await aiohttp_raw_server(handler)
540540

541-
with start_transaction(
541+
with start_span(
542542
name="/interactions/other-dogs/new-dog",
543543
op="greeting.sniff",
544544
) as transaction:
@@ -573,7 +573,7 @@ async def handler(request):
573573

574574
raw_server = await aiohttp_raw_server(handler)
575575

576-
with start_transaction(
576+
with start_span(
577577
name="/interactions/other-dogs/new-dog",
578578
op="greeting.sniff",
579579
) as transaction:

tests/integrations/anthropic/test_anthropic.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def __call__(self, *args, **kwargs):
4242
except ImportError:
4343
from anthropic.types.content_block import ContentBlock as TextBlock
4444

45-
from sentry_sdk import start_transaction
45+
from sentry_sdk import start_span
4646
from sentry_sdk.consts import OP, SPANDATA
4747
from sentry_sdk.integrations.anthropic import AnthropicIntegration
4848

@@ -90,7 +90,7 @@ def test_nonstreaming_create_message(
9090
}
9191
]
9292

93-
with start_transaction(name="anthropic"):
93+
with start_span(name="anthropic"):
9494
response = client.messages.create(
9595
max_tokens=1024, messages=messages, model="model"
9696
)
@@ -160,7 +160,7 @@ async def test_nonstreaming_create_message_async(
160160
}
161161
]
162162

163-
with start_transaction(name="anthropic"):
163+
with start_span(name="anthropic"):
164164
response = await client.messages.create(
165165
max_tokens=1024, messages=messages, model="model"
166166
)
@@ -263,7 +263,7 @@ def test_streaming_create_message(
263263
}
264264
]
265265

266-
with start_transaction(name="anthropic"):
266+
with start_span(name="anthropic"):
267267
message = client.messages.create(
268268
max_tokens=1024, messages=messages, model="model", stream=True
269269
)
@@ -368,7 +368,7 @@ async def test_streaming_create_message_async(
368368
}
369369
]
370370

371-
with start_transaction(name="anthropic"):
371+
with start_span(name="anthropic"):
372372
message = await client.messages.create(
373373
max_tokens=1024, messages=messages, model="model", stream=True
374374
)
@@ -500,7 +500,7 @@ def test_streaming_create_message_with_input_json_delta(
500500
}
501501
]
502502

503-
with start_transaction(name="anthropic"):
503+
with start_span(name="anthropic"):
504504
message = client.messages.create(
505505
max_tokens=1024, messages=messages, model="model", stream=True
506506
)
@@ -639,7 +639,7 @@ async def test_streaming_create_message_with_input_json_delta_async(
639639
}
640640
]
641641

642-
with start_transaction(name="anthropic"):
642+
with start_span(name="anthropic"):
643643
message = await client.messages.create(
644644
max_tokens=1024, messages=messages, model="model", stream=True
645645
)
@@ -736,7 +736,7 @@ def test_span_origin(sentry_init, capture_events):
736736
}
737737
]
738738

739-
with start_transaction(name="anthropic"):
739+
with start_span(name="anthropic"):
740740
client.messages.create(max_tokens=1024, messages=messages, model="model")
741741

742742
(event,) = events
@@ -763,7 +763,7 @@ async def test_span_origin_async(sentry_init, capture_events):
763763
}
764764
]
765765

766-
with start_transaction(name="anthropic"):
766+
with start_span(name="anthropic"):
767767
await client.messages.create(max_tokens=1024, messages=messages, model="model")
768768

769769
(event,) = events

tests/integrations/arq/test_arq.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import pytest
33

4-
from sentry_sdk import get_client, start_transaction
4+
from sentry_sdk import get_client, start_span
55
from sentry_sdk.integrations.arq import ArqIntegration
66

77
import arq.worker
@@ -292,7 +292,7 @@ async def dummy_job(_):
292292

293293
events = capture_events()
294294

295-
with start_transaction() as transaction:
295+
with start_span(name="test") as transaction:
296296
await pool.enqueue_job("dummy_job")
297297

298298
(event,) = events
@@ -343,7 +343,7 @@ async def dummy_job(_):
343343

344344
events = capture_events()
345345

346-
with start_transaction():
346+
with start_span(name="job"):
347347
await pool.enqueue_job("dummy_job")
348348

349349
(event,) = events

0 commit comments

Comments
 (0)