sentry-python API reference
181 public APIs from sentry-python (getsentry/sentry-python) — 32 classes, 45 functions, 104 methods. Signatures extracted by static analysis of the actual source.
Repository: getsentry/sentry-python
| Kind | Count |
|---|---|
| Classes | 32 |
| Functions | 45 |
| Methods | 104 |
API list
class
sentry_sdk._queue.EmptyErrorException raised by Queue.get(block=0)/get_nowait().
class
sentry_sdk._queue.FullErrorException raised by Queue.put(block=0)/put_nowait().
class
sentry_sdk._queue.QueueCreate a queue object with a given maximum size.
method
sentry_sdk._queue.Queue.put(item, block=True, timeout=None)Put an item into the queue.
class
sentry_sdk._types.AnnotatedValueMeta information for a data field in the event payload.
func
sentry_sdk._werkzeug.get_host(environ:'Dict[str, str]', use_x_forwarded_for:bool=False) -> strReturn the host for the given WSGI environment.
func
sentry_sdk.ai.utils.get_modality_from_mime_type(mime_type:str) -> strInfer the content modality from a MIME type string.
func
sentry_sdk.ai.utils.parse_data_uri(url:str) -> 'Tuple[str, str]'Parse a data URI and return (mime_type, content).
func
sentry_sdk.ai.utils.set_conversation_id(conversation_id:str) -> NoneSet the conversation_id in the scope.
func
sentry_sdk.api.is_initialized() -> bool..
func
sentry_sdk.api.remove_attribute(attribute:str) -> NoneRemove an attribute.
func
sentry_sdk.api.set_attribute(attribute:str, value:'Any') -> NoneSet an attribute.
func
sentry_sdk.api.set_attributes(attributes:'dict[str, Any]') -> NoneSet multiple attributes.
func
sentry_sdk.api.set_measurement(name:str, value:float, unit:'MeasurementUnit'='') -> None..
class
sentry_sdk.attachments.AttachmentAdditional files/data to send along with an event.
method
sentry_sdk.attachments.Attachment.to_envelope_item() -> 'Item'Returns an envelope item for this attachment.
class
sentry_sdk.client.BaseClient..
method
sentry_sdk.client.BaseClient.is_active() -> bool..
class
sentry_sdk.client.NonRecordingClient..
class
sentry_sdk.consts.EndpointTypeThe type of an endpoint.
class
sentry_sdk.consts.SPANDATAAdditional information describing the type of the span.
class
sentry_sdk.consts.SPANSTATUSThe status of a Sentry span.
class
sentry_sdk.envelope.EnvelopeRepresents a Sentry Envelope.
method
sentry_sdk.envelope.Item.get_event() -> 'Optional[Event]'Returns an error event if there is one.
class
sentry_sdk.hub.Hub..
method
sentry_sdk.hub.Hub.add_breadcrumb(crumb:'Optional[Breadcrumb]'=None, hint:'Optional[BreadcrumbHint]'=None, **kwargs:'Any') -> None..
method
sentry_sdk.hub.Hub.bind_client(new:'Optional[BaseClient]') -> None..
method
sentry_sdk.hub.Hub.capture_event(event:'Event', hint:'Optional[Hint]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'..
method
sentry_sdk.hub.Hub.capture_exception(error:'Optional[Union[BaseException, ExcInfo]]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'..
method
sentry_sdk.hub.Hub.capture_message(message:str, level:'Optional[LogLevelStr]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'..
method
sentry_sdk.hub.Hub.client() -> 'Optional[BaseClient]'..
method
sentry_sdk.hub.Hub.continue_trace(environ_or_headers:'Dict[str, Any]', op:'Optional[str]'=None, name:'Optional[str]'=None, source:'Optional[str]'=None) -> 'Transaction'..
method
sentry_sdk.hub.Hub.end_session() -> None..
method
sentry_sdk.hub.Hub.flush(timeout:'Optional[float]'=None, callback:'Optional[Callable[[int, float], None]]'=None) -> None..
method
sentry_sdk.hub.Hub.get_baggage() -> 'Optional[str]'..
method
sentry_sdk.hub.Hub.get_integration(name_or_class:'Union[str, Type[Integration]]') -> 'Any'..
method
sentry_sdk.hub.Hub.get_traceparent() -> 'Optional[str]'..
method
sentry_sdk.hub.Hub.iter_trace_propagation_headers(span:'Optional[Span]'=None) -> 'Generator[Tuple[str, str], None, None]'..
method
sentry_sdk.hub.Hub.last_event_id() -> 'Optional[str]'Returns the last event ID.
method
sentry_sdk.hub.Hub.pop_scope_unsafe() -> 'Tuple[Optional[Client], Scope]'..
method
sentry_sdk.hub.Hub.resume_auto_session_tracking() -> None..
method
sentry_sdk.hub.Hub.run(callback:'Callable[[], T]') -> 'T'..
method
sentry_sdk.hub.Hub.scope() -> 'Scope'..
method
sentry_sdk.hub.Hub.start_session(session_mode:str='application') -> None..
method
sentry_sdk.hub.Hub.start_span(instrumenter:str=INSTRUMENTER.SENTRY, **kwargs:'Any') -> 'Span'..
method
sentry_sdk.hub.Hub.start_transaction(transaction:'Optional[Transaction]'=None, instrumenter:str=INSTRUMENTER.SENTRY, custom_sampling_context:'Optional[SamplingContext]'=None, **kwargs:'Unpack[TransactionKwargs]') -> 'Union[Transaction, NoOpSpan]'..
method
sentry_sdk.hub.Hub.stop_auto_session_tracking() -> None..
method
sentry_sdk.hub.Hub.trace_propagation_meta(span:'Optional[Span]'=None) -> str..
class
sentry_sdk.integrations.IntegrationBaseclass for all integrations.
method
sentry_sdk.integrations.Integration.setup_once() -> NoneInitialize the integration.
class
sentry_sdk.integrations._wsgi_common.RequestExtractorBase class for request extraction.
func
sentry_sdk.integrations.asyncio.enable_asyncio_integration(*args:'Any', **kwargs:'Any') -> NoneEnable AsyncioIntegration with the provided options.
func
sentry_sdk.integrations.beam.raise_exception() -> NoneRaise an exception.
class
sentry_sdk.integrations.cloud_resource_context.CLOUD_PLATFORMThe cloud platform.
class
sentry_sdk.integrations.cloud_resource_context.CLOUD_PROVIDERName of the cloud provider.
class
sentry_sdk.integrations.django.DjangoIntegrationAuto instrument a Django application.
func
sentry_sdk.integrations.django.signals_handlers.patch_signals() -> NonePatch django signal receivers to create a span.
class
sentry_sdk.integrations.google_genai.utils.UsageDataStructure for token usage data.
func
sentry_sdk.integrations.google_genai.utils.extract_finish_reasons(response:'GenerateContentResponse') -> 'Optional[List[str]]'Extract finish reasons from response candidates.
func
sentry_sdk.integrations.google_genai.utils.get_model_name(model:'Union[str, Model]') -> strExtract model name from model parameter.
func
sentry_sdk.integrations.google_genai.utils.set_span_data_for_request(span:'Union[Span, StreamedSpan]', integration:'Any', model:str, contents:'ContentListUnion', kwargs:'dict[str, Any]') -> NoneSet span data for the request.
func
sentry_sdk.integrations.google_genai.utils.set_span_data_for_response(span:'Union[Span, StreamedSpan]', integration:'Any', response:'GenerateContentResponse') -> NoneSet span data for the response.
func
sentry_sdk.integrations.google_genai.utils.wrapped_tool(tool:'Tool | Callable[..., Any]') -> 'Tool | Callable[..., Any]'Wrap a tool to emit execute_tool spans when called.
class
sentry_sdk.integrations.langchain.SentryLangchainCallbackCallback handler that creates Sentry spans.
method
sentry_sdk.integrations.langchain.SentryLangchainCallback.on_chat_model_end(response:'LLMResult', *run_id:'UUID', **kwargs:'Any') -> 'Any'Run when Chat Model ends running.
method
sentry_sdk.integrations.langchain.SentryLangchainCallback.on_chat_model_error(error:'Union[Exception, KeyboardInterrupt]', *run_id:'UUID', **kwargs:'Any') -> 'Any'Run when Chat Model errors.
method
sentry_sdk.integrations.langchain.SentryLangchainCallback.on_llm_end(response:'LLMResult', *run_id:'UUID', **kwargs:'Any') -> 'Any'Run when LLM ends running.
method
sentry_sdk.integrations.langchain.SentryLangchainCallback.on_llm_error(error:'BaseException', *run_id:'UUID', **kwargs:'Any') -> 'Any'Run when LLM errors.
method
sentry_sdk.integrations.langchain.SentryLangchainCallback.on_tool_end(output:str, *run_id:'UUID', **kwargs:'Any') -> 'Any'Run when tool ends running.
method
sentry_sdk.integrations.langchain.SentryLangchainCallback.on_tool_error(error:'BaseException', *run_id:'UUID', **kwargs:'Any') -> 'Any'Run when tool errors.
method
sentry_sdk.integrations.langchain.SentryLangchainCallback.on_tool_start(serialized:'Dict[str, Any]', input_str:str, *run_id:'UUID', **kwargs:'Any') -> 'Any'Run when tool starts running.
class
sentry_sdk.integrations.litellm.LiteLLMIntegrationLiteLLM integration for Sentry.
method
sentry_sdk.integrations.litellm.LiteLLMIntegration.setup_once() -> NoneSet up LiteLLM callbacks for monitoring.
class
sentry_sdk.integrations.otlp.OTLPIntegrationAutomatically setup OTLP ingestion from the DSN.
class
sentry_sdk.integrations.pydantic_ai.PydanticAIIntegrationTypical interaction with the library: 1.
method
sentry_sdk.integrations.pydantic_ai.PydanticAIIntegration.setup_once() -> NoneSet up the pydantic-ai integration.
func
sentry_sdk.integrations.pydantic_ai.spans.invoke_agent.update_invoke_agent_span(span:'Union[sentry_sdk.tracing.Span, StreamedSpan]', result:'Any') -> NoneUpdate and close the invoke agent span.
func
sentry_sdk.integrations.pydantic_ai.utils.get_current_agent() -> 'Any'Get the current agent from the contextvar stack.
func
sentry_sdk.integrations.pydantic_ai.utils.pop_agent() -> NonePop an agent context from the stack.
func
sentry_sdk.integrations.starlette.patch_authentication_middleware(middleware_class:'Any') -> NoneAdd user information to Sentry scope.
func
sentry_sdk.integrations.wsgi.get_client_ip(environ:'Dict[str, str]') -> 'Optional[Any]'Infer the user IP address from various headers.
method
sentry_sdk.profiler.transaction_profiler.Scheduler.ensure_running() -> NoneEnsure the scheduler is running.
method
sentry_sdk.scope.Scope.add_breadcrumb(crumb:'Optional[Breadcrumb]'=None, hint:'Optional[BreadcrumbHint]'=None, **kwargs:'Any') -> NoneAdds a breadcrumb.
method
sentry_sdk.scope.Scope.add_error_processor(func:'ErrorProcessor', cls:'Optional[Type[BaseException]]'=None) -> NoneRegister a scope local error processor on the scope.
method
sentry_sdk.scope.Scope.add_event_processor(func:'EventProcessor') -> NoneRegister a scope local event processor on the scope.
method
sentry_sdk.scope.Scope.capture_event(event:'Event', hint:'Optional[Hint]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'Captures an event.
method
sentry_sdk.scope.Scope.capture_exception(error:'Optional[Union[BaseException, ExcInfo]]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'Captures an exception.
method
sentry_sdk.scope.Scope.capture_message(message:str, level:'Optional[LogLevelStr]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'Captures a message.
method
sentry_sdk.scope.Scope.clear() -> NoneClears the entire scope.
method
sentry_sdk.scope.Scope.clear_breadcrumbs() -> NoneClears breadcrumb buffer.
method
sentry_sdk.scope.Scope.end_session(*args:'Any', **kwargs:'Any') -> NoneEnds the current session if there is one.
method
sentry_sdk.scope.Scope.fingerprint(value:'Optional[List[str]]') -> NoneWhen set this overrides the default fingerprint.
method
sentry_sdk.scope.Scope.fork() -> 'Scope'..
method
sentry_sdk.scope.Scope.generate_propagation_context(incoming_data:'Optional[Dict[str, str]]'=None) -> NoneMakes sure the propagation context is set on the scope.
method
sentry_sdk.scope.Scope.get_client() -> 'sentry_sdk.client.BaseClient'..
method
sentry_sdk.scope.Scope.get_conversation_id() -> 'Optional[str]'Gets the conversation ID for gen_ai spans.
method
sentry_sdk.scope.Scope.get_current_scope() -> 'Scope'..
method
sentry_sdk.scope.Scope.get_global_scope() -> 'Scope'..
method
sentry_sdk.scope.Scope.get_isolation_scope() -> 'Scope'..
method
sentry_sdk.scope.Scope.last_event_id() -> 'Optional[str]'..
method
sentry_sdk.scope.Scope.level(value:'LogLevelStr') -> NoneWhen set this overrides the level.
method
sentry_sdk.scope.Scope.remove_attribute(attribute:str) -> NoneRemove an attribute if set on the scope.
method
sentry_sdk.scope.Scope.remove_context(key:str) -> NoneRemoves a context.
method
sentry_sdk.scope.Scope.remove_conversation_id() -> NoneRemoves the conversation ID.
method
sentry_sdk.scope.Scope.remove_extra(key:str) -> NoneRemoves a specific extra key.
method
sentry_sdk.scope.Scope.remove_tag(key:str) -> NoneRemoves a specific tag.
method
sentry_sdk.scope.Scope.set_attribute(attribute:str, value:'AttributeValue') -> NoneSet an attribute on the scope.
method
sentry_sdk.scope.Scope.set_attributes(attributes:'dict[str, AttributeValue]') -> NoneSet multiple attributes on the scope.
method
sentry_sdk.scope.Scope.set_client(client:'Optional[sentry_sdk.client.BaseClient]'=None) -> None..
method
sentry_sdk.scope.Scope.set_context(key:str, value:'Dict[str, Any]') -> NoneBinds a context at a certain key to a specific value.
method
sentry_sdk.scope.Scope.set_conversation_id(conversation_id:str) -> NoneSets the conversation ID for gen_ai spans.
method
sentry_sdk.scope.Scope.set_current_scope(new_current_scope:'Scope') -> None..
method
sentry_sdk.scope.Scope.set_extra(key:str, value:'Any') -> NoneSets an extra key to a specific value.
method
sentry_sdk.scope.Scope.set_isolation_scope(new_isolation_scope:'Scope') -> None..
method
sentry_sdk.scope.Scope.set_level(value:'LogLevelStr') -> NoneSets the level for the scope.
method
sentry_sdk.scope.Scope.set_tag(key:str, value:'Any') -> NoneSets a tag for a key to a specific value.
method
sentry_sdk.scope.Scope.set_tags(tags:'Mapping[str, object]') -> NoneSets multiple tags at once.
method
sentry_sdk.scope.Scope.set_user(value:'Optional[Dict[str, Any]]') -> NoneSets a user for the scope.
method
sentry_sdk.scope.Scope.span() -> 'Optional[Span]'Get/set current tracing span or transaction.
method
sentry_sdk.scope.Scope.start_session(*args:'Any', **kwargs:'Any') -> NoneStarts a new session.
method
sentry_sdk.scope.Scope.stop_auto_session_tracking(*args:'Any', **kwargs:'Any') -> NoneStops automatic session tracking.
method
sentry_sdk.scope.Scope.streamed_span() -> 'Optional[StreamedSpan]'Get/set current tracing span.
method
sentry_sdk.scope.Scope.transaction() -> 'Any'Return the transaction (root span) in the scope, if any.
method
sentry_sdk.scope.Scope.update_from_scope(scope:'Scope') -> NoneUpdate the scope with another scope's data.
method
sentry_sdk.scope.Scope.user(value:'Optional[Dict[str, Any]]') -> NoneWhen set a specific user is bound to the scope.
func
sentry_sdk.scope.isolation_scope() -> 'Generator[Scope, None, None]'..
func
sentry_sdk.scope.new_scope() -> 'Generator[Scope, None, None]'..
func
sentry_sdk.scope.use_isolation_scope(isolation_scope:'Scope') -> 'Generator[Scope, None, None]'..
func
sentry_sdk.scope.use_scope(scope:'Scope') -> 'Generator[Scope, None, None]'..
class
sentry_sdk.spotlight.SpotlightClientA client for sending envelopes to Sentry Spotlight.
class
sentry_sdk.traces.StreamedSpanA span holds timing information of a block of code.
method
sentry_sdk.traces.StreamedSpan.end(end_timestamp:'Optional[Union[float, datetime]]'=None) -> NoneFinish this span and queue it for sending.
func
sentry_sdk.traces.continue_trace(incoming:'dict[str, Any]') -> NoneContinue a trace from headers or environment variables.
func
sentry_sdk.traces.new_trace() -> NoneResets the propagation context, forcing a new trace.
func
sentry_sdk.traces.start_span(name:str, attributes:'Optional[Attributes]'=None, parent_span:'Optional[StreamedSpan]'=_DEFAULT_PARENT_SPAN, active:bool=True) -> 'StreamedSpan'Start a span.
method
sentry_sdk.tracing.NoOpSpan.finish(scope:'Optional[sentry_sdk.Scope]'=None, end_timestamp:'Optional[Union[float, datetime]]'=None, *hub:'Optional[sentry_sdk.Hub]'=None) -> 'Optional[str]'The `hub` parameter is deprecated.
class
sentry_sdk.tracing.SpanA span holds timing information of a block of code.
method
sentry_sdk.tracing.Span.containing_transaction() -> 'Optional[Transaction]'The ``Transaction`` that this span belongs to.
method
sentry_sdk.tracing.Span.continue_from_environ(environ:'Mapping[str, str]', **kwargs:'Any') -> 'Transaction'DEPRECATED: Use :py:meth:`sentry_sdk.continue_trace`.
method
sentry_sdk.tracing.Span.finish(scope:'Optional[sentry_sdk.Scope]'=None, end_timestamp:'Optional[Union[float, datetime]]'=None) -> 'Optional[str]'Sets the end timestamp of the span.
method
sentry_sdk.tracing.Span.from_traceparent(traceparent:'Optional[str]', **kwargs:'Any') -> 'Optional[Transaction]'DEPRECATED: Use :py:meth:`sentry_sdk.continue_trace`.
method
sentry_sdk.tracing.Span.set_measurement(name:str, value:float, unit:'MeasurementUnit'='') -> None..
method
sentry_sdk.tracing.Span.start_child(instrumenter:str=INSTRUMENTER.SENTRY, **kwargs:'Any') -> 'Span'Start a sub-span from the current span or transaction.
method
sentry_sdk.tracing.Span.to_json() -> 'Dict[str, Any]'Returns a JSON-compatible representation of the span.
method
sentry_sdk.tracing.Transaction.containing_transaction() -> 'Transaction'The root element of the span tree.
method
sentry_sdk.tracing.Transaction.set_context(key:str, value:'dict[str, Any]') -> NoneSets a context.
method
sentry_sdk.tracing.Transaction.set_measurement(name:str, value:float, unit:'MeasurementUnit'='') -> None..
func
sentry_sdk.tracing_utils.add_sentry_baggage_to_headers(headers:'MutableMapping[str, str]', sentry_baggage:str) -> NoneAdd the Sentry baggage to the headers.
func
sentry_sdk.tracing_utils.is_ignored_span(name:str, attributes:'Optional[Attributes]') -> boolDetermine if a span fits one of the rules in ignore_spans.
func
sentry_sdk.tracing_utils.span_decorator(f:'Any') -> 'Any'Decorator to create a span for the given function.
class
sentry_sdk.transport.BaseHttpTransportThe base HTTP transport (synchronous).
class
sentry_sdk.transport.HttpTransportCoreShared base class for sync and async transports.
class
sentry_sdk.transport.TransportBaseclass for all transports.
method
sentry_sdk.transport.Transport.capture_envelope(envelope:'Envelope') -> NoneSend an envelope to Sentry.
method
sentry_sdk.transport.Transport.capture_event(event:'Event') -> NoneDEPRECATED: Please use capture_envelope instead.
method
sentry_sdk.transport.Transport.kill() -> NoneForcefully kills the transport.
class
sentry_sdk.utils.AuthHelper object that represents the auth info.
method
sentry_sdk.utils.Auth.get_api_url(type:'EndpointType'=EndpointType.ENVELOPE) -> strReturns the API url for storing events.
method
sentry_sdk.utils.Auth.to_header() -> strReturns the auth header a string.
class
sentry_sdk.utils.BadDsnRaised on invalid DSNs.
class
sentry_sdk.utils.DsnRepresents a DSN.
method
sentry_sdk.utils.Dsn.netloc() -> strThe netloc part of a DSN.
method
sentry_sdk.utils.Dsn.to_auth(client:'Optional[Any]'=None) -> 'Auth'Returns the auth info object for this dsn.
func
sentry_sdk.utils.event_hint_with_exc_info(exc_info:'Optional[ExcInfo]'=None) -> 'Dict[str, Optional[ExcInfo]]'Creates a hint with the exc info filled in.
func
sentry_sdk.utils.format_attribute(val:'Any') -> 'AttributeValue'Turn unsupported attribute value types into an AttributeValue.
func
sentry_sdk.utils.format_timestamp(value:'datetime') -> strFormats a timestamp in RFC 3339 format.
func
sentry_sdk.utils.from_base64(base64_string:str) -> 'Optional[str]'Convert a string from base64, via UTF-8.
func
sentry_sdk.utils.get_default_release() -> 'Optional[str]'Try to guess a default release.
func
sentry_sdk.utils.is_sentry_url(client:'sentry_sdk.client.BaseClient', url:str) -> boolDetermines whether the given URL matches the Sentry DSN.
func
sentry_sdk.utils.json_dumps(data:'Any') -> bytesSerialize data into a compact JSON representation encoded as UTF-8.
func
sentry_sdk.utils.parse_url(url:str, sanitize:bool=True) -> 'ParsedUrl'Splits a URL into a url (including path), query and fragment.
func
sentry_sdk.utils.parse_version(version:str) -> 'Optional[Tuple[int, ...]]'Parses a version string into a tuple of integers.
func
sentry_sdk.utils.qualname_from_function(func:'Callable[..., Any]') -> 'Optional[str]'Return the qualified name of func.
func
sentry_sdk.utils.safe_serialize(data:'Any') -> strSafely serialize to a readable string.
func
sentry_sdk.utils.serialize_attribute(val:'AttributeValue') -> 'SerializedAttributeValue'Serialize attribute value to the transport format.
func
sentry_sdk.utils.to_base64(original:str) -> 'Optional[str]'Convert a string to base64, via UTF-8.
class
sentry_sdk.worker.WorkerBase class for all workers.
method
sentry_sdk.worker.Worker.full() -> boolWhether the worker's queue is full.
method
sentry_sdk.worker.Worker.is_alive() -> boolWhether the worker is alive and running.
method
sentry_sdk.worker.Worker.kill() -> NoneKill the worker.
method
sentry_sdk.worker.Worker.submit(callback:'Callable[[], Any]') -> boolSchedule a callback.
About this data
These signatures were extracted from the public source of getsentry/sentry-python
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.