sdkagent

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

KindCount
Classes32
Functions45
Methods104

API list

classsentry_sdk._queue.EmptyError
Exception raised by Queue.get(block=0)/get_nowait().
classsentry_sdk._queue.FullError
Exception raised by Queue.put(block=0)/put_nowait().
classsentry_sdk._queue.Queue
Create a queue object with a given maximum size.
methodsentry_sdk._queue.Queue.put(item, block=True, timeout=None)
Put an item into the queue.
classsentry_sdk._types.AnnotatedValue
Meta information for a data field in the event payload.
funcsentry_sdk._werkzeug.get_host(environ:'Dict[str, str]', use_x_forwarded_for:bool=False) -> str
Return the host for the given WSGI environment.
funcsentry_sdk.ai.utils.get_modality_from_mime_type(mime_type:str) -> str
Infer the content modality from a MIME type string.
funcsentry_sdk.ai.utils.parse_data_uri(url:str) -> 'Tuple[str, str]'
Parse a data URI and return (mime_type, content).
funcsentry_sdk.ai.utils.set_conversation_id(conversation_id:str) -> None
Set the conversation_id in the scope.
funcsentry_sdk.api.is_initialized() -> bool
..
funcsentry_sdk.api.remove_attribute(attribute:str) -> None
Remove an attribute.
funcsentry_sdk.api.set_attribute(attribute:str, value:'Any') -> None
Set an attribute.
funcsentry_sdk.api.set_attributes(attributes:'dict[str, Any]') -> None
Set multiple attributes.
funcsentry_sdk.api.set_measurement(name:str, value:float, unit:'MeasurementUnit'='') -> None
..
classsentry_sdk.attachments.Attachment
Additional files/data to send along with an event.
methodsentry_sdk.attachments.Attachment.to_envelope_item() -> 'Item'
Returns an envelope item for this attachment.
classsentry_sdk.client.BaseClient
..
methodsentry_sdk.client.BaseClient.is_active() -> bool
..
classsentry_sdk.client.NonRecordingClient
..
classsentry_sdk.consts.EndpointType
The type of an endpoint.
classsentry_sdk.consts.SPANDATA
Additional information describing the type of the span.
classsentry_sdk.consts.SPANSTATUS
The status of a Sentry span.
classsentry_sdk.envelope.Envelope
Represents a Sentry Envelope.
methodsentry_sdk.envelope.Item.get_event() -> 'Optional[Event]'
Returns an error event if there is one.
classsentry_sdk.hub.Hub
..
methodsentry_sdk.hub.Hub.add_breadcrumb(crumb:'Optional[Breadcrumb]'=None, hint:'Optional[BreadcrumbHint]'=None, **kwargs:'Any') -> None
..
methodsentry_sdk.hub.Hub.bind_client(new:'Optional[BaseClient]') -> None
..
methodsentry_sdk.hub.Hub.capture_event(event:'Event', hint:'Optional[Hint]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'
..
methodsentry_sdk.hub.Hub.capture_exception(error:'Optional[Union[BaseException, ExcInfo]]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'
..
methodsentry_sdk.hub.Hub.capture_message(message:str, level:'Optional[LogLevelStr]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'
..
methodsentry_sdk.hub.Hub.client() -> 'Optional[BaseClient]'
..
methodsentry_sdk.hub.Hub.continue_trace(environ_or_headers:'Dict[str, Any]', op:'Optional[str]'=None, name:'Optional[str]'=None, source:'Optional[str]'=None) -> 'Transaction'
..
methodsentry_sdk.hub.Hub.end_session() -> None
..
methodsentry_sdk.hub.Hub.flush(timeout:'Optional[float]'=None, callback:'Optional[Callable[[int, float], None]]'=None) -> None
..
methodsentry_sdk.hub.Hub.get_baggage() -> 'Optional[str]'
..
methodsentry_sdk.hub.Hub.get_integration(name_or_class:'Union[str, Type[Integration]]') -> 'Any'
..
methodsentry_sdk.hub.Hub.get_traceparent() -> 'Optional[str]'
..
methodsentry_sdk.hub.Hub.iter_trace_propagation_headers(span:'Optional[Span]'=None) -> 'Generator[Tuple[str, str], None, None]'
..
methodsentry_sdk.hub.Hub.last_event_id() -> 'Optional[str]'
Returns the last event ID.
methodsentry_sdk.hub.Hub.pop_scope_unsafe() -> 'Tuple[Optional[Client], Scope]'
..
methodsentry_sdk.hub.Hub.resume_auto_session_tracking() -> None
..
methodsentry_sdk.hub.Hub.run(callback:'Callable[[], T]') -> 'T'
..
methodsentry_sdk.hub.Hub.scope() -> 'Scope'
..
methodsentry_sdk.hub.Hub.start_session(session_mode:str='application') -> None
..
methodsentry_sdk.hub.Hub.start_span(instrumenter:str=INSTRUMENTER.SENTRY, **kwargs:'Any') -> 'Span'
..
methodsentry_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]'
..
methodsentry_sdk.hub.Hub.stop_auto_session_tracking() -> None
..
methodsentry_sdk.hub.Hub.trace_propagation_meta(span:'Optional[Span]'=None) -> str
..
classsentry_sdk.integrations.Integration
Baseclass for all integrations.
methodsentry_sdk.integrations.Integration.setup_once() -> None
Initialize the integration.
classsentry_sdk.integrations._wsgi_common.RequestExtractor
Base class for request extraction.
funcsentry_sdk.integrations.asyncio.enable_asyncio_integration(*args:'Any', **kwargs:'Any') -> None
Enable AsyncioIntegration with the provided options.
funcsentry_sdk.integrations.beam.raise_exception() -> None
Raise an exception.
classsentry_sdk.integrations.cloud_resource_context.CLOUD_PLATFORM
The cloud platform.
classsentry_sdk.integrations.cloud_resource_context.CLOUD_PROVIDER
Name of the cloud provider.
classsentry_sdk.integrations.django.DjangoIntegration
Auto instrument a Django application.
funcsentry_sdk.integrations.django.signals_handlers.patch_signals() -> None
Patch django signal receivers to create a span.
classsentry_sdk.integrations.google_genai.utils.UsageData
Structure for token usage data.
funcsentry_sdk.integrations.google_genai.utils.extract_finish_reasons(response:'GenerateContentResponse') -> 'Optional[List[str]]'
Extract finish reasons from response candidates.
funcsentry_sdk.integrations.google_genai.utils.get_model_name(model:'Union[str, Model]') -> str
Extract model name from model parameter.
funcsentry_sdk.integrations.google_genai.utils.set_span_data_for_request(span:'Union[Span, StreamedSpan]', integration:'Any', model:str, contents:'ContentListUnion', kwargs:'dict[str, Any]') -> None
Set span data for the request.
funcsentry_sdk.integrations.google_genai.utils.set_span_data_for_response(span:'Union[Span, StreamedSpan]', integration:'Any', response:'GenerateContentResponse') -> None
Set span data for the response.
funcsentry_sdk.integrations.google_genai.utils.wrapped_tool(tool:'Tool | Callable[..., Any]') -> 'Tool | Callable[..., Any]'
Wrap a tool to emit execute_tool spans when called.
classsentry_sdk.integrations.langchain.SentryLangchainCallback
Callback handler that creates Sentry spans.
methodsentry_sdk.integrations.langchain.SentryLangchainCallback.on_chat_model_end(response:'LLMResult', *run_id:'UUID', **kwargs:'Any') -> 'Any'
Run when Chat Model ends running.
methodsentry_sdk.integrations.langchain.SentryLangchainCallback.on_chat_model_error(error:'Union[Exception, KeyboardInterrupt]', *run_id:'UUID', **kwargs:'Any') -> 'Any'
Run when Chat Model errors.
methodsentry_sdk.integrations.langchain.SentryLangchainCallback.on_llm_end(response:'LLMResult', *run_id:'UUID', **kwargs:'Any') -> 'Any'
Run when LLM ends running.
methodsentry_sdk.integrations.langchain.SentryLangchainCallback.on_llm_error(error:'BaseException', *run_id:'UUID', **kwargs:'Any') -> 'Any'
Run when LLM errors.
methodsentry_sdk.integrations.langchain.SentryLangchainCallback.on_tool_end(output:str, *run_id:'UUID', **kwargs:'Any') -> 'Any'
Run when tool ends running.
methodsentry_sdk.integrations.langchain.SentryLangchainCallback.on_tool_error(error:'BaseException', *run_id:'UUID', **kwargs:'Any') -> 'Any'
Run when tool errors.
methodsentry_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.
classsentry_sdk.integrations.litellm.LiteLLMIntegration
LiteLLM integration for Sentry.
methodsentry_sdk.integrations.litellm.LiteLLMIntegration.setup_once() -> None
Set up LiteLLM callbacks for monitoring.
classsentry_sdk.integrations.otlp.OTLPIntegration
Automatically setup OTLP ingestion from the DSN.
classsentry_sdk.integrations.pydantic_ai.PydanticAIIntegration
Typical interaction with the library: 1.
methodsentry_sdk.integrations.pydantic_ai.PydanticAIIntegration.setup_once() -> None
Set up the pydantic-ai integration.
funcsentry_sdk.integrations.pydantic_ai.spans.invoke_agent.update_invoke_agent_span(span:'Union[sentry_sdk.tracing.Span, StreamedSpan]', result:'Any') -> None
Update and close the invoke agent span.
funcsentry_sdk.integrations.pydantic_ai.utils.get_current_agent() -> 'Any'
Get the current agent from the contextvar stack.
funcsentry_sdk.integrations.pydantic_ai.utils.pop_agent() -> None
Pop an agent context from the stack.
funcsentry_sdk.integrations.starlette.patch_authentication_middleware(middleware_class:'Any') -> None
Add user information to Sentry scope.
funcsentry_sdk.integrations.wsgi.get_client_ip(environ:'Dict[str, str]') -> 'Optional[Any]'
Infer the user IP address from various headers.
methodsentry_sdk.profiler.transaction_profiler.Scheduler.ensure_running() -> None
Ensure the scheduler is running.
methodsentry_sdk.scope.Scope.add_breadcrumb(crumb:'Optional[Breadcrumb]'=None, hint:'Optional[BreadcrumbHint]'=None, **kwargs:'Any') -> None
Adds a breadcrumb.
methodsentry_sdk.scope.Scope.add_error_processor(func:'ErrorProcessor', cls:'Optional[Type[BaseException]]'=None) -> None
Register a scope local error processor on the scope.
methodsentry_sdk.scope.Scope.add_event_processor(func:'EventProcessor') -> None
Register a scope local event processor on the scope.
methodsentry_sdk.scope.Scope.capture_event(event:'Event', hint:'Optional[Hint]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'
Captures an event.
methodsentry_sdk.scope.Scope.capture_exception(error:'Optional[Union[BaseException, ExcInfo]]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'
Captures an exception.
methodsentry_sdk.scope.Scope.capture_message(message:str, level:'Optional[LogLevelStr]'=None, scope:'Optional[Scope]'=None, **scope_kwargs:'Any') -> 'Optional[str]'
Captures a message.
methodsentry_sdk.scope.Scope.clear() -> None
Clears the entire scope.
methodsentry_sdk.scope.Scope.clear_breadcrumbs() -> None
Clears breadcrumb buffer.
methodsentry_sdk.scope.Scope.end_session(*args:'Any', **kwargs:'Any') -> None
Ends the current session if there is one.
methodsentry_sdk.scope.Scope.fingerprint(value:'Optional[List[str]]') -> None
When set this overrides the default fingerprint.
methodsentry_sdk.scope.Scope.fork() -> 'Scope'
..
methodsentry_sdk.scope.Scope.generate_propagation_context(incoming_data:'Optional[Dict[str, str]]'=None) -> None
Makes sure the propagation context is set on the scope.
methodsentry_sdk.scope.Scope.get_client() -> 'sentry_sdk.client.BaseClient'
..
methodsentry_sdk.scope.Scope.get_conversation_id() -> 'Optional[str]'
Gets the conversation ID for gen_ai spans.
methodsentry_sdk.scope.Scope.get_current_scope() -> 'Scope'
..
methodsentry_sdk.scope.Scope.get_global_scope() -> 'Scope'
..
methodsentry_sdk.scope.Scope.get_isolation_scope() -> 'Scope'
..
methodsentry_sdk.scope.Scope.last_event_id() -> 'Optional[str]'
..
methodsentry_sdk.scope.Scope.level(value:'LogLevelStr') -> None
When set this overrides the level.
methodsentry_sdk.scope.Scope.remove_attribute(attribute:str) -> None
Remove an attribute if set on the scope.
methodsentry_sdk.scope.Scope.remove_context(key:str) -> None
Removes a context.
methodsentry_sdk.scope.Scope.remove_conversation_id() -> None
Removes the conversation ID.
methodsentry_sdk.scope.Scope.remove_extra(key:str) -> None
Removes a specific extra key.
methodsentry_sdk.scope.Scope.remove_tag(key:str) -> None
Removes a specific tag.
methodsentry_sdk.scope.Scope.set_attribute(attribute:str, value:'AttributeValue') -> None
Set an attribute on the scope.
methodsentry_sdk.scope.Scope.set_attributes(attributes:'dict[str, AttributeValue]') -> None
Set multiple attributes on the scope.
methodsentry_sdk.scope.Scope.set_client(client:'Optional[sentry_sdk.client.BaseClient]'=None) -> None
..
methodsentry_sdk.scope.Scope.set_context(key:str, value:'Dict[str, Any]') -> None
Binds a context at a certain key to a specific value.
methodsentry_sdk.scope.Scope.set_conversation_id(conversation_id:str) -> None
Sets the conversation ID for gen_ai spans.
methodsentry_sdk.scope.Scope.set_current_scope(new_current_scope:'Scope') -> None
..
methodsentry_sdk.scope.Scope.set_extra(key:str, value:'Any') -> None
Sets an extra key to a specific value.
methodsentry_sdk.scope.Scope.set_isolation_scope(new_isolation_scope:'Scope') -> None
..
methodsentry_sdk.scope.Scope.set_level(value:'LogLevelStr') -> None
Sets the level for the scope.
methodsentry_sdk.scope.Scope.set_tag(key:str, value:'Any') -> None
Sets a tag for a key to a specific value.
methodsentry_sdk.scope.Scope.set_tags(tags:'Mapping[str, object]') -> None
Sets multiple tags at once.
methodsentry_sdk.scope.Scope.set_user(value:'Optional[Dict[str, Any]]') -> None
Sets a user for the scope.
methodsentry_sdk.scope.Scope.span() -> 'Optional[Span]'
Get/set current tracing span or transaction.
methodsentry_sdk.scope.Scope.start_session(*args:'Any', **kwargs:'Any') -> None
Starts a new session.
methodsentry_sdk.scope.Scope.stop_auto_session_tracking(*args:'Any', **kwargs:'Any') -> None
Stops automatic session tracking.
methodsentry_sdk.scope.Scope.streamed_span() -> 'Optional[StreamedSpan]'
Get/set current tracing span.
methodsentry_sdk.scope.Scope.transaction() -> 'Any'
Return the transaction (root span) in the scope, if any.
methodsentry_sdk.scope.Scope.update_from_scope(scope:'Scope') -> None
Update the scope with another scope's data.
methodsentry_sdk.scope.Scope.user(value:'Optional[Dict[str, Any]]') -> None
When set a specific user is bound to the scope.
funcsentry_sdk.scope.isolation_scope() -> 'Generator[Scope, None, None]'
..
funcsentry_sdk.scope.new_scope() -> 'Generator[Scope, None, None]'
..
funcsentry_sdk.scope.use_isolation_scope(isolation_scope:'Scope') -> 'Generator[Scope, None, None]'
..
funcsentry_sdk.scope.use_scope(scope:'Scope') -> 'Generator[Scope, None, None]'
..
classsentry_sdk.spotlight.SpotlightClient
A client for sending envelopes to Sentry Spotlight.
classsentry_sdk.traces.StreamedSpan
A span holds timing information of a block of code.
methodsentry_sdk.traces.StreamedSpan.end(end_timestamp:'Optional[Union[float, datetime]]'=None) -> None
Finish this span and queue it for sending.
funcsentry_sdk.traces.continue_trace(incoming:'dict[str, Any]') -> None
Continue a trace from headers or environment variables.
funcsentry_sdk.traces.new_trace() -> None
Resets the propagation context, forcing a new trace.
funcsentry_sdk.traces.start_span(name:str, attributes:'Optional[Attributes]'=None, parent_span:'Optional[StreamedSpan]'=_DEFAULT_PARENT_SPAN, active:bool=True) -> 'StreamedSpan'
Start a span.
methodsentry_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.
classsentry_sdk.tracing.Span
A span holds timing information of a block of code.
methodsentry_sdk.tracing.Span.containing_transaction() -> 'Optional[Transaction]'
The ``Transaction`` that this span belongs to.
methodsentry_sdk.tracing.Span.continue_from_environ(environ:'Mapping[str, str]', **kwargs:'Any') -> 'Transaction'
DEPRECATED: Use :py:meth:`sentry_sdk.continue_trace`.
methodsentry_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.
methodsentry_sdk.tracing.Span.from_traceparent(traceparent:'Optional[str]', **kwargs:'Any') -> 'Optional[Transaction]'
DEPRECATED: Use :py:meth:`sentry_sdk.continue_trace`.
methodsentry_sdk.tracing.Span.set_measurement(name:str, value:float, unit:'MeasurementUnit'='') -> None
..
methodsentry_sdk.tracing.Span.start_child(instrumenter:str=INSTRUMENTER.SENTRY, **kwargs:'Any') -> 'Span'
Start a sub-span from the current span or transaction.
methodsentry_sdk.tracing.Span.to_json() -> 'Dict[str, Any]'
Returns a JSON-compatible representation of the span.
methodsentry_sdk.tracing.Transaction.containing_transaction() -> 'Transaction'
The root element of the span tree.
methodsentry_sdk.tracing.Transaction.set_context(key:str, value:'dict[str, Any]') -> None
Sets a context.
methodsentry_sdk.tracing.Transaction.set_measurement(name:str, value:float, unit:'MeasurementUnit'='') -> None
..
funcsentry_sdk.tracing_utils.add_sentry_baggage_to_headers(headers:'MutableMapping[str, str]', sentry_baggage:str) -> None
Add the Sentry baggage to the headers.
funcsentry_sdk.tracing_utils.is_ignored_span(name:str, attributes:'Optional[Attributes]') -> bool
Determine if a span fits one of the rules in ignore_spans.
funcsentry_sdk.tracing_utils.span_decorator(f:'Any') -> 'Any'
Decorator to create a span for the given function.
classsentry_sdk.transport.BaseHttpTransport
The base HTTP transport (synchronous).
classsentry_sdk.transport.HttpTransportCore
Shared base class for sync and async transports.
classsentry_sdk.transport.Transport
Baseclass for all transports.
methodsentry_sdk.transport.Transport.capture_envelope(envelope:'Envelope') -> None
Send an envelope to Sentry.
methodsentry_sdk.transport.Transport.capture_event(event:'Event') -> None
DEPRECATED: Please use capture_envelope instead.
methodsentry_sdk.transport.Transport.kill() -> None
Forcefully kills the transport.
classsentry_sdk.utils.Auth
Helper object that represents the auth info.
methodsentry_sdk.utils.Auth.get_api_url(type:'EndpointType'=EndpointType.ENVELOPE) -> str
Returns the API url for storing events.
methodsentry_sdk.utils.Auth.to_header() -> str
Returns the auth header a string.
classsentry_sdk.utils.BadDsn
Raised on invalid DSNs.
classsentry_sdk.utils.Dsn
Represents a DSN.
methodsentry_sdk.utils.Dsn.netloc() -> str
The netloc part of a DSN.
methodsentry_sdk.utils.Dsn.to_auth(client:'Optional[Any]'=None) -> 'Auth'
Returns the auth info object for this dsn.
funcsentry_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.
funcsentry_sdk.utils.format_attribute(val:'Any') -> 'AttributeValue'
Turn unsupported attribute value types into an AttributeValue.
funcsentry_sdk.utils.format_timestamp(value:'datetime') -> str
Formats a timestamp in RFC 3339 format.
funcsentry_sdk.utils.from_base64(base64_string:str) -> 'Optional[str]'
Convert a string from base64, via UTF-8.
funcsentry_sdk.utils.get_default_release() -> 'Optional[str]'
Try to guess a default release.
funcsentry_sdk.utils.is_sentry_url(client:'sentry_sdk.client.BaseClient', url:str) -> bool
Determines whether the given URL matches the Sentry DSN.
funcsentry_sdk.utils.json_dumps(data:'Any') -> bytes
Serialize data into a compact JSON representation encoded as UTF-8.
funcsentry_sdk.utils.parse_url(url:str, sanitize:bool=True) -> 'ParsedUrl'
Splits a URL into a url (including path), query and fragment.
funcsentry_sdk.utils.parse_version(version:str) -> 'Optional[Tuple[int, ...]]'
Parses a version string into a tuple of integers.
funcsentry_sdk.utils.qualname_from_function(func:'Callable[..., Any]') -> 'Optional[str]'
Return the qualified name of func.
funcsentry_sdk.utils.safe_serialize(data:'Any') -> str
Safely serialize to a readable string.
funcsentry_sdk.utils.serialize_attribute(val:'AttributeValue') -> 'SerializedAttributeValue'
Serialize attribute value to the transport format.
funcsentry_sdk.utils.to_base64(original:str) -> 'Optional[str]'
Convert a string to base64, via UTF-8.
classsentry_sdk.worker.Worker
Base class for all workers.
methodsentry_sdk.worker.Worker.full() -> bool
Whether the worker's queue is full.
methodsentry_sdk.worker.Worker.is_alive() -> bool
Whether the worker is alive and running.
methodsentry_sdk.worker.Worker.kill() -> None
Kill the worker.
methodsentry_sdk.worker.Worker.submit(callback:'Callable[[], Any]') -> bool
Schedule 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.

Back to all 805 libraries