API Docs¶
- sentry_sdk.Scope¶
alias of
PotelScope
- class sentry_sdk.Client(dsn=None, *, max_breadcrumbs=100, release=None, environment=None, server_name=None, shutdown_timeout=2, integrations=[], in_app_include=[], in_app_exclude=[], default_integrations=True, dist=None, transport=None, transport_queue_size=100, sample_rate=1.0, send_default_pii=None, http_proxy=None, https_proxy=None, ignore_errors=[], max_request_body_size='medium', socket_options=None, keep_alive=None, before_send=None, before_breadcrumb=None, debug=None, attach_stacktrace=False, ca_certs=None, traces_sample_rate=None, traces_sampler=None, profiles_sample_rate=None, profiles_sampler=None, profiler_mode=None, profile_lifecycle='manual', profile_session_sample_rate=None, auto_enabling_integrations=True, disabled_integrations=None, auto_session_tracking=True, send_client_reports=True, _experiments={}, proxy_headers=None, before_send_transaction=None, project_root=None, include_local_variables=True, include_source_context=True, trace_propagation_targets=['.*'], functions_to_trace=[], event_scrubber=None, max_value_length=1024, enable_backpressure_handling=True, error_sampler=None, enable_db_query_source=True, db_query_source_threshold_ms=100, spotlight=None, cert_file=None, key_file=None, custom_repr=None, add_full_stack=False, max_stack_frames=100)[source]¶
- class sentry_sdk.client.BaseClient(options=None)[source]¶
Added in version 2.0.0.
The basic definition of a client that is used for sending data to Sentry.
- class sentry_sdk.client.NonRecordingClient(options=None)[source]¶
Added in version 2.0.0.
A client that does not send any events to Sentry. This is used as a fallback when the Sentry SDK is not yet initialized.
- class sentry_sdk.client._Client(*args, **kwargs)[source]¶
The client is internally responsible for capturing the events and forwarding them to sentry through the configured transport. It takes the client options as keyword arguments and optionally the DSN as first argument.
Alias of
sentry_sdk.Client
. (Was created for better intelisense support)- capture_event(event, hint=None, scope=None)[source]¶
Captures an event.
- Parameters:
event (
Event
) – A ready-made event that can be directly sent to Sentry.hint (
Optional
[Dict
[str
,Any
]]) – Contains metadata about the event that can be read from before_send, such as the original exception object or a HTTP request object.scope (
Optional
[Scope
]) – An optionalsentry_sdk.Scope
to apply to events.
- Return type:
- Returns:
An event ID. May be None if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting debug=True on init() may help.
- close(timeout=None, callback=None)[source]¶
Close the client and shut down the transport. Arguments have the same semantics as
Client.flush()
.- Return type:
- get_integration(name_or_class)[source]¶
Returns the integration for this client by name or class. If the client does not have that integration then None is returned.
- Return type:
Optional
[Integration
]
- class sentry_sdk.Transport(options=None)[source]¶
Baseclass for all transports.
A transport is used to send an event to sentry.
- abstract capture_envelope(envelope)[source]¶
Send an envelope to Sentry.
Envelopes are a data container format that can hold any type of data submitted to Sentry. We use it to send all event data (including errors, transactions, crons check-ins, etc.) to Sentry.
- Return type:
- flush(timeout, callback=None)[source]¶
Wait timeout seconds for the current events to be sent out.
The default implementation is a no-op, since this method may only be relevant to some transports. Subclasses should override this method if necessary.
- Return type:
- kill()[source]¶
Forcefully kills the transport.
The default implementation is a no-op, since this method may only be relevant to some transports. Subclasses should override this method if necessary.
- Return type:
- record_lost_event(reason, data_category=None, item=None, *, quantity=1)[source]¶
This increments a counter for event loss by reason and data category by the given positive-int quantity (default 1).
If an item is provided, the data category and quantity are extracted from the item, and the values passed for data_category and quantity are ignored.
When recording a lost transaction via data_category=”transaction”, the calling code should also record the lost spans via this method. When recording lost spans, quantity should be set to the number of contained spans, plus one for the transaction itself. When passing an Item containing a transaction via the item parameter, this method automatically records the lost spans.
- Return type:
- class sentry_sdk.tracing.Span(*, op=None, description=None, status=None, sampled=None, start_timestamp=None, origin=None, name=None, source=TransactionSource.CUSTOM, attributes=None, only_if_parent=False, parent_span=None, otel_span=None, span=None)[source]¶
OTel span wrapper providing compatibility with the old span interface.
- class sentry_sdk.session.Session(sid=None, did=None, timestamp=None, started=None, duration=None, status=None, release=None, environment=None, user_agent=None, ip_address=None, errors=None, user=None, session_mode='application')[source]¶
- class sentry_sdk.attachments.Attachment(bytes=None, filename=None, path=None, content_type=None, add_to_transactions=False)[source]¶
Additional files/data to send along with an event.
This class stores attachments that can be sent along with an event. Attachments are files or other data, e.g. config or log files, that are relevant to an event. Attachments are set on the
Scope
, and are sent along with all non-transaction events (or all events including transactions ifadd_to_transactions
isTrue
) that are captured within theScope
.To add an attachment to a
Scope
, usesentry_sdk.Scope.add_attachment()
. The parameters foradd_attachment
are the same as the parameters for this class’s constructor.- Parameters:
bytes (
Union
[None
,bytes
,Callable
[[],bytes
]]) – Raw bytes of the attachment, or a function that returns the raw bytes. Must be provided unlesspath
is provided.filename (
Optional
[str
]) – The filename of the attachment. Must be provided unlesspath
is provided.path (
Optional
[str
]) – Path to a file to attach. Must be provided unlessbytes
is provided.content_type (
Optional
[str
]) – The content type of the attachment. If not provided, it will be guessed from thefilename
parameter, if available, or thepath
parameter iffilename
isNone
.add_to_transactions (
bool
) – Whether to add this attachment to transactions. Defaults toFalse
.
- class sentry_sdk.scrubber.EventScrubber(denylist=None, recursive=False, send_default_pii=False, pii_denylist=None)[source]¶
- scrub_dict(d)[source]¶
If a dictionary is passed to this method, the method scrubs the dictionary of any sensitive data. The method calls itself recursively on any nested dictionaries ( including dictionaries nested in lists) if self.recursive is True. This method does nothing if the parameter passed to it is not a dictionary.
- Return type:
- class sentry_sdk.monitor.Monitor(transport, interval=10)[source]¶
Performs health checks in a separate thread once every interval seconds and updates the internal state. Other parts of the SDK only read this state and act accordingly.
- class sentry_sdk.envelope.Envelope(headers=None, items=None)[source]¶
Represents a Sentry Envelope. The calling code is responsible for adhering to the constraints documented in the Sentry docs: https://develop.sentry.dev/sdk/envelopes/#data-model. In particular, each envelope may have at most one Item with type “event” or “transaction” (but not both).