Skip to content

chore: Make start_span fail if unsupported args are provided #4201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 9, 2025
7 changes: 5 additions & 2 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh

### Removed

- Spans no longer have a `description`. Use `name` instead.
- Dropped support for Python 3.6.
- The `enable_tracing` `init` option has been removed. Configure `traces_sample_rate` directly.
- The `propagate_traces` `init` option has been removed. Use `trace_propagation_targets` instead.
Expand All @@ -157,11 +156,15 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
- `profiles_sample_rate` and `profiler_mode` were removed from options available via `_experiments`. Use the top-level `profiles_sample_rate` and `profiler_mode` options instead.
- `Transport.capture_event` has been removed. Use `Transport.capture_envelope` instead.
- Function transports are no longer supported. Subclass the `Transport` instead.
- `start_transaction` (`start_span`) no longer takes the following arguments:
- `trace_id`, `baggage`: use `continue_trace` for propagation from headers or environment variables
- `same_process_as_parent`
- `span_id`
- `parent_span_id`: you can supply a `parent_span` instead
- Setting `Scope.transaction` directly is no longer supported. Use `Scope.set_transaction_name()` instead.
- Passing a list or `None` for `failed_request_status_codes` in the Starlette integration is no longer supported. Pass a set of integers instead.
- The `span` argument of `Scope.trace_propagation_meta` is no longer supported.
- Setting `Scope.user` directly is no longer supported. Use `Scope.set_user()` instead.
- `start_transaction` (`start_span`) no longer takes a `baggage` argument. Use the `continue_trace()` context manager instead to propagate baggage.
- Dropped support for Django versions below 2.0.
- Dropped support for trytond versions below 5.0.
- Dropped support for Falcon versions below 3.0.
Expand Down
9 changes: 3 additions & 6 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,9 @@ def __init__(
only_if_parent=False, # type: bool
parent_span=None, # type: Optional[Span]
otel_span=None, # type: Optional[OtelSpan]
**_, # type: dict[str, object]
):
# type: (...) -> None
"""
For backwards compatibility with old the old Span interface, this class
accepts arbitrary keyword arguments, in addition to the ones explicitly
listed in the signature. These additional arguments are ignored.

If otel_span is passed explicitly, just acts as a proxy.

If only_if_parent is True, just return an INVALID_SPAN
Expand Down Expand Up @@ -284,6 +279,8 @@ def __init__(
attributes[SentrySpanAttribute.OP] = op
if source is not None:
attributes[SentrySpanAttribute.SOURCE] = source
if description is not None:
attributes[SentrySpanAttribute.DESCRIPTION] = description
if sampled is not None:
attributes[SentrySpanAttribute.CUSTOM_SAMPLED] = sampled

Expand Down Expand Up @@ -543,7 +540,7 @@ def timestamp(self):

def start_child(self, **kwargs):
# type: (**Any) -> Span
return Span(sampled=self.sampled, parent_span=self, **kwargs)
return Span(parent_span=self, **kwargs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't make sense to propagate the sampled flag to the children as it's only taken into account for root spans in the sampler (by design)


def iter_headers(self):
# type: () -> Iterator[Tuple[str, str]]
Expand Down
Loading