Skip to content

Commit f7a9a29

Browse files
committed
More changes
1 parent 4235d30 commit f7a9a29

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

docs/platforms/python/tracing/span-lifecycle/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ with sentry_sdk.start_span(op="http.client", name="Fetch User Data"):
202202

203203
# Database operation
204204
with sentry_sdk.start_span(op="db", name="Save User"):
205-
db.execute(
205+
db.execute(
206206
"INSERT INTO users (name, email) VALUES (%s, %s)",
207207
(user.name, user.email),
208208
)

docs/platforms/python/tracing/span-lifecycle/index__v3.x.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import sentry_sdk
2323

2424
# Start a span for a task
2525
with sentry_sdk.start_span(op="task", name="Create User"):
26-
# Your code here
2726
# The span will automatically end when exiting this block
2827
user = create_user(email="[email protected]")
2928
send_welcome_email(user)
@@ -136,7 +135,7 @@ with sentry_sdk.start_span(name="Background Task", op="task", only_as_child_span
136135

137136
### Adding Span Attributes
138137

139-
Span attributes customize information you can get through tracing. This information can be found in the traces views in Sentry, once you drill into a span. You can capture additional context with span attributes. These can be key-value pairs of various Python types.
138+
Span attributes customize information you can get through tracing. This information can be found in the traces views in Sentry, once you drill into a span. You can capture additional context with span attributes. These are key-value pairs where the keys are non-empty strings and the values are either primitive Python types (excluding `None`), or a list of a single primitive Python type.
140139

141140
```python
142141
import sentry_sdk
@@ -146,7 +145,7 @@ with sentry_sdk.start_span(op="db", name="Query Users") as span:
146145
users = db.query("SELECT * FROM users WHERE active = true")
147146

148147
# You can add more data during execution
149-
span.set_data("result_count", len(users))
148+
span.set_attribute("result_count", len(users))
150149
```
151150

152151
You can also add attributes to an existing span:
@@ -158,8 +157,8 @@ import sentry_sdk
158157
span = sentry_sdk.get_current_span()
159158
if span:
160159
# Set individual data points
161-
span.set_data("user_id", user.id)
162-
span.set_data("request_size", len(request.body))
160+
span.set_attribute("user_id", user.id)
161+
span.set_attribute("request_size", len(request.body))
163162
```
164163

165164
### Adding Attributes to All Spans
@@ -214,7 +213,7 @@ with sentry_sdk.start_span(op="http.client", name="Fetch User Data"):
214213

215214
# Database operation
216215
with sentry_sdk.start_span(op="db", name="Save User"):
217-
db.execute(
216+
db.execute(
218217
"INSERT INTO users (name, email) VALUES (%s, %s)",
219218
(user.name, user.email),
220219
)
@@ -241,7 +240,7 @@ with sentry_sdk.start_span(op="task", name="Process Payment") as span:
241240
else:
242241
# Mark the span as failed
243242
span.set_status("error")
244-
span.set_data("error_reason", result.error)
243+
span.set_attribute("error_reason", str(result.error))
245244
except Exception:
246245
# Span will automatically be marked as failed when an exception occurs
247246
raise

0 commit comments

Comments
 (0)