Skip to content

Commit 75213cb

Browse files
docs: Document top-level start_transaction function (#2924)
Although the @scopemethod decorator should take care of adding this documentation comment to start_transaction, the decorator does not appear to work when hovering over the sentry_sdk.start_transaction function in VSCode. Adding the doc comment explicitly allows the documentation to be shown when hovering in VSCode, but it does not change the output of our API docs, which still uses the @scopemethod output. This is the final PR in this repository that addresses getsentry/sentry-docs#5082; the last step to closing that issue will be to add a link in the docs to start_transaction in our API docs. We can only do this once 2.0 is released.
1 parent b38f9c7 commit 75213cb

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

sentry_sdk/api.py

+30
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,36 @@ def start_transaction(
288288
**kwargs, # type: Unpack[TransactionKwargs]
289289
):
290290
# type: (...) -> Union[Transaction, NoOpSpan]
291+
"""
292+
Start and return a transaction on the current scope.
293+
294+
Start an existing transaction if given, otherwise create and start a new
295+
transaction with kwargs.
296+
297+
This is the entry point to manual tracing instrumentation.
298+
299+
A tree structure can be built by adding child spans to the transaction,
300+
and child spans to other spans. To start a new child span within the
301+
transaction or any span, call the respective `.start_child()` method.
302+
303+
Every child span must be finished before the transaction is finished,
304+
otherwise the unfinished spans are discarded.
305+
306+
When used as context managers, spans and transactions are automatically
307+
finished at the end of the `with` block. If not using context managers,
308+
call the `.finish()` method.
309+
310+
When the transaction is finished, it will be sent to Sentry with all its
311+
finished child spans.
312+
313+
:param transaction: The transaction to start. If omitted, we create and
314+
start a new transaction.
315+
:param instrumenter: This parameter is meant for internal use only.
316+
:param custom_sampling_context: The transaction's custom sampling context.
317+
:param kwargs: Optional keyword arguments to be passed to the Transaction
318+
constructor. See :py:class:`sentry_sdk.tracing.Transaction` for
319+
available arguments.
320+
"""
291321
return Scope.get_current_scope().start_transaction(
292322
transaction, instrumenter, custom_sampling_context, **kwargs
293323
)

0 commit comments

Comments
 (0)