Skip to content

Commit d6420e1

Browse files
authored
fix(examples): Python SDK Metric Span tracing examples set data indiv… (#14360)
Examples for metric spans in the Python SDK set data for spans using a dictionary, which does not work when tested locally. Change this to set the span_data indivually instead. Fixes GH-14359 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 7e0635b commit d6420e1

File tree

1 file changed

+8
-14
lines changed
  • docs/platforms/python/tracing/span-metrics

1 file changed

+8
-14
lines changed

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ if span:
2525
# Add individual metrics
2626
span.set_data("database.rows_affected", 42)
2727
span.set_data("cache.hit_rate", 0.85)
28-
29-
# Add multiple metrics at once
30-
span.set_data({
31-
"memory.heap_used": 1024000,
32-
"queue.length": 15,
33-
"processing.duration_ms": 127
34-
})
28+
span.set_data("memory.heap_used", 1024000)
29+
span.set_data("queue.length", 15)
30+
span.set_data("processing.duration_ms", 127)
3531
```
3632

3733
### Best Practices for Span Data
@@ -52,13 +48,11 @@ with sentry_sdk.start_span(
5248
name="Database Query Metrics"
5349
) as span:
5450
# Set metrics after creating the span
55-
span.set_data({
56-
"db.query_type": "SELECT",
57-
"db.table": "users",
58-
"db.execution_time_ms": 45,
59-
"db.rows_returned": 100,
60-
"db.connection_pool_size": 5
61-
})
51+
span.set_data("db.query_type", "SELECT")
52+
span.set_data("db.table", "users")
53+
span.set_data("db.execution_time_ms", 45)
54+
span.set_data("db.rows_returned", 100)
55+
span.set_data("db.connection_pool_size", 5)
6256
# Your database operation here
6357
pass
6458
```

0 commit comments

Comments
 (0)