Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Additionally, the OpenAI integration now sets `gen_ai.operation.name` to `chat`
- The `update_current_span` API was removed.
- The `sentry_sdk.tracing` module was removed, including the `Span`, `Transaction`, `NoOpSpan`, and `TransactionSource` classes. Import tracing primitives from `sentry_sdk.traces` instead. `TransactionSource` was replaced by `sentry_sdk.traces.SegmentNameSource`, which has the same values. The span classes from 2.x's span streaming mode, `sentry_sdk.traces.StreamedSpan` and `NoOpStreamedSpan`, are now called `Span` and `NoOpSpan`; the old names remain available as aliases.
- The `stream_gen_ai_spans` option was removed. All spans are streamed now. If you previously set `stream_gen_ai_spans=False`, note that GenAI integrations no longer truncate messages (previously, only the last message was kept and truncated), and the OpenAI, Anthropic, LangChain, LiteLLM, and OpenAI Agents integrations no longer replace binary content in messages (for example, base64-encoded images) with `[Filtered]`. To prevent prompts and responses from being sent, set `data_collection`'s `gen_ai` `inputs` and/or `outputs` to `False`.
- The `trace_lifecycle` option (both top-level and experimental) was removed. Span streaming is now the only tracing mode.
- Span streaming is now the only tracing mode. The experimental `trace_lifecycle` option was removed. The top-level `trace_lifecycle` option is still accepted, but any value other than `"stream"` is ignored and logs a warning.

### Integrations

Expand Down
6 changes: 6 additions & 0 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ def _record_lost_event(

try:
_client_init_debug.set(self.options["debug"])

if self.options["trace_lifecycle"] not in (None, "stream"):
logger.warning(
"Span streaming is the only tracing mode. Ignoring unknown trace_lifecycle value."
)

self.transport = make_transport(self.options)

self.monitor = None
Expand Down
5 changes: 5 additions & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ def __init__(
attach_stacktrace: bool = True,
ca_certs: "Optional[str]" = None,
traces_sample_rate: "Optional[float]" = None,
trace_lifecycle: "Optional[str]" = None,
traces_sampler: "Optional[TracesSampler]" = None,
profiler_mode: "Optional[ContinuousProfilerMode]" = None,
profile_lifecycle: 'Literal["manual", "trace"]' = "manual",
Expand Down Expand Up @@ -1853,6 +1854,10 @@ def __init__(
If you want to disable all tracing you need to set `traces_sample_rate=None`. In this case, no new traces
will be started and no incoming traces will be continued.

:param trace_lifecycle: Controls how traces are sent. Span streaming is the only supported tracing mode,
so the only accepted value is `"stream"`. Other values are ignored and a warning is logged.
This option only exists for backwards compatibility with 2.x and has no effect.

:param traces_sampler: A function responsible for determining the percentage chance a given service span will be
sent to Sentry.

Expand Down
19 changes: 19 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,25 @@ def test_client_debug_option_enabled(sentry_init, caplog):
assert "OK" in caplog.text


@pytest.mark.parametrize(
"trace_lifecycle,warns",
[
(None, False),
("stream", False),
("static", True),
("unknown", True),
],
)
def test_trace_lifecycle_option(sentry_init, caplog, trace_lifecycle, warns):
sentry_init(debug=True, trace_lifecycle=trace_lifecycle)

warning = (
"Span streaming is the only tracing mode. "
"Ignoring unknown trace_lifecycle value."
)
assert (warning in caplog.text) is warns


@pytest.mark.tests_internal_exceptions
@pytest.mark.parametrize("with_client", (True, False))
def test_client_debug_option_disabled(with_client, sentry_init, caplog):
Expand Down
Loading