Skip to content

Commit fef0ae1

Browse files
authored
Update index.mdx
updating to add parent inheritance to all examples.
1 parent b131bbf commit fef0ae1

File tree

1 file changed

+36
-1
lines changed
  • docs/platforms/python/tracing/configure-sampling

1 file changed

+36
-1
lines changed

docs/platforms/python/tracing/configure-sampling/index.mdx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ It is strongly recommended when using a custom `traces_sampler` that you respect
5353

5454
```python
5555
def traces_sampler(sampling_context):
56+
# Use the parent sampling decision if we have an incoming trace.
57+
# Note: we strongly recommend respecting the parent sampling decision,
58+
# as this ensures your traces will be complete!
59+
parent_sampling_decision = sampling_context.get("parent_sampled")
60+
if parent_sampling_decision is not None:
61+
return float(parent_sampling_decision)
62+
5663
ctx = sampling_context.get("transaction_context", {})
5764
name = ctx.get("name", "")
5865

@@ -79,6 +86,13 @@ sentry_sdk.init(
7986

8087
```python
8188
def traces_sampler(sampling_context):
89+
# Use the parent sampling decision if we have an incoming trace.
90+
# Note: we strongly recommend respecting the parent sampling decision,
91+
# as this ensures your traces will be complete!
92+
parent_sampling_decision = sampling_context.get("parent_sampled")
93+
if parent_sampling_decision is not None:
94+
return float(parent_sampling_decision)
95+
8296
ctx = sampling_context.get("transaction_context", {})
8397
environment = os.environ.get("ENVIRONMENT", "development")
8498

@@ -108,6 +122,13 @@ sentry_sdk.init(
108122

109123
```python
110124
def traces_sampler(sampling_context):
125+
# Use the parent sampling decision if we have an incoming trace.
126+
# Note: we strongly recommend respecting the parent sampling decision,
127+
# as this ensures your traces will be complete!
128+
parent_sampling_decision = sampling_context.get("parent_sampled")
129+
if parent_sampling_decision is not None:
130+
return float(parent_sampling_decision)
131+
111132
ctx = sampling_context.get("transaction_context", {})
112133
data = ctx.get("data", {})
113134

@@ -144,6 +165,13 @@ sentry_sdk.init(
144165

145166
```python
146167
def traces_sampler(sampling_context):
168+
# Use the parent sampling decision if we have an incoming trace.
169+
# Note: we strongly recommend respecting the parent sampling decision,
170+
# as this ensures your traces will be complete!
171+
parent_sampling_decision = sampling_context.get("parent_sampled")
172+
if parent_sampling_decision is not None:
173+
return float(parent_sampling_decision)
174+
147175
ctx = sampling_context.get("transaction_context", {})
148176
data = ctx.get("data", {})
149177

@@ -185,6 +213,13 @@ sentry_sdk.init(
185213

186214
```python
187215
def traces_sampler(sampling_context):
216+
# Use the parent sampling decision if we have an incoming trace.
217+
# Note: we strongly recommend respecting the parent sampling decision,
218+
# as this ensures your traces will be complete!
219+
parent_sampling_decision = sampling_context.get("parent_sampled")
220+
if parent_sampling_decision is not None:
221+
return float(parent_sampling_decision)
222+
188223
ctx = sampling_context.get("transaction_context", {})
189224
data = ctx.get("data", {})
190225

@@ -284,4 +319,4 @@ The two key headers are:
284319
- `sentry-trace`: Contains trace ID, span ID, and sampling decision
285320
- `baggage`: Contains additional trace metadata including sample rate
286321

287-
The Sentry Python SDK automatically attaches these headers to outgoing HTTP requests when using auto-instrumentation with libraries like `requests`, `urllib3`, or `httpx`. For other communication channels, you can manually propagate trace information. Learn more about customizing tracing in [custom trace propagation](/platforms/python/tracing/distributed-tracing/custom-trace-propagation/)
322+
The Sentry Python SDK automatically attaches these headers to outgoing HTTP requests when using auto-instrumentation with libraries like `requests`, `urllib3`, or `httpx`. For other communication channels, you can manually propagate trace information. Learn more about customizing tracing in [custom trace propagation](/platforms/python/tracing/distributed-tracing/custom-trace-propagation/)

0 commit comments

Comments
 (0)