Documentation
¶
Index ¶
- Constants
- type Dsn
- func (dsn Dsn) GetAPIURL() *url.URL
- func (dsn Dsn) GetHost() string
- func (dsn Dsn) GetPath() string
- func (dsn Dsn) GetPort() int
- func (dsn Dsn) GetProjectID() string
- func (dsn Dsn) GetPublicKey() string
- func (dsn Dsn) GetScheme() string
- func (dsn Dsn) GetSecretKey() string
- func (dsn Dsn) MarshalJSON() ([]byte, error)
- func (dsn Dsn) RequestHeaders(sdkVersion string) map[string]stringdeprecated
- func (dsn Dsn) String() string
- func (dsn *Dsn) UnmarshalJSON(data []byte) error
- type DsnParseError
- type Envelope
- type EnvelopeConvertible
- type EnvelopeHeader
- type EnvelopeItem
- type EnvelopeItemHeader
- type EnvelopeItemType
- type SdkInfo
- type SdkPackage
- type TelemetryTransport
Constants ¶
const ( SchemeHTTP scheme = "http" SchemeHTTPS scheme = "https" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dsn ¶
type Dsn struct {
// contains filtered or unexported fields
}
Dsn is used as the remote address source to client transport.
func NewDsn ¶
NewDsn creates a Dsn by parsing rawURL. Most users will never call this function directly. It is provided for use in custom Transport implementations.
func (Dsn) GetAPIURL ¶
GetAPIURL returns the URL of the envelope endpoint of the project associated with the DSN.
func (Dsn) MarshalJSON ¶
MarshalJSON converts the Dsn struct to JSON.
func (Dsn) RequestHeaders
deprecated
RequestHeaders returns all the necessary headers that have to be used in the transport when sending events to the /store endpoint.
Deprecated: This method shall only be used if you want to implement your own transport that sends events to the /store endpoint. If you're using the transport provided by the SDK, all necessary headers to authenticate against the /envelope endpoint are added automatically.
func (*Dsn) UnmarshalJSON ¶
UnmarshalJSON converts JSON data to the Dsn struct.
type DsnParseError ¶
type DsnParseError struct {
Message string
}
DsnParseError represents an error that occurs if a Sentry DSN cannot be parsed.
func (DsnParseError) Error ¶
func (e DsnParseError) Error() string
type Envelope ¶
type Envelope struct {
Header *EnvelopeHeader `json:"-"`
Items []*EnvelopeItem `json:"-"`
}
Envelope represents a Sentry envelope containing headers and items.
func NewEnvelope ¶
func NewEnvelope(header *EnvelopeHeader) *Envelope
NewEnvelope creates a new envelope with the given header.
func (*Envelope) AddItem ¶
func (e *Envelope) AddItem(item *EnvelopeItem)
AddItem adds an item to the envelope.
func (*Envelope) Serialize ¶
Serialize serializes the envelope to the Sentry envelope format.
Format: Headers "\n" { Item } [ "\n" ] Item: Headers "\n" Payload "\n".
type EnvelopeConvertible ¶
type EnvelopeConvertible interface {
// ToEnvelope converts the item to a Sentry envelope.
ToEnvelope(dsn *Dsn) (*Envelope, error)
}
EnvelopeConvertible represents any type that can be converted to a Sentry envelope. This interface allows the telemetry buffers to be generic while still working with concrete types like Event.
type EnvelopeHeader ¶
type EnvelopeHeader struct {
// EventID is the unique identifier for this event
EventID string `json:"event_id"`
// SentAt is the timestamp when the event was sent from the SDK as string in RFC 3339 format.
// Used for clock drift correction of the event timestamp. The time zone must be UTC.
SentAt time.Time `json:"sent_at,omitempty"`
// Dsn can be used for self-authenticated envelopes.
// This means that the envelope has all the information necessary to be sent to sentry.
// In this case the full DSN must be stored in this key.
Dsn string `json:"dsn,omitempty"`
// Sdk carries the same payload as the sdk interface in the event payload but can be carried for all events.
// This means that SDK information can be carried for minidumps, session data and other submissions.
Sdk *SdkInfo `json:"sdk,omitempty"`
// Trace contains the [Dynamic Sampling Context](https://develop.sentry.dev/sdk/telemetry/traces/dynamic-sampling-context/)
Trace map[string]string `json:"trace,omitempty"`
}
EnvelopeHeader represents the header of a Sentry envelope.
func (*EnvelopeHeader) MarshalJSON ¶
func (h *EnvelopeHeader) MarshalJSON() ([]byte, error)
MarshalJSON converts the EnvelopeHeader to JSON.
type EnvelopeItem ¶
type EnvelopeItem struct {
Header *EnvelopeItemHeader `json:"-"`
Payload []byte `json:"-"`
}
EnvelopeItem represents a single item within an envelope.
func NewAttachmentItem ¶
func NewAttachmentItem(filename, contentType string, payload []byte) *EnvelopeItem
NewAttachmentItem creates a new envelope item for an attachment. Parameters: filename, contentType, payload.
func NewEnvelopeItem ¶
func NewEnvelopeItem(itemType EnvelopeItemType, payload []byte) *EnvelopeItem
NewEnvelopeItem creates a new envelope item with the specified type and payload.
func NewLogItem ¶
func NewLogItem(itemCount int, payload []byte) *EnvelopeItem
NewLogItem creates a new envelope item for logs.
type EnvelopeItemHeader ¶
type EnvelopeItemHeader struct {
// Type specifies the type of this Item and its contents.
// Based on the Item type, more headers may be required.
Type EnvelopeItemType `json:"type"`
// Length is the length of the payload in bytes.
// If no length is specified, the payload implicitly goes to the next newline.
// For payloads containing newline characters, the length must be specified.
Length *int `json:"length,omitempty"`
// Filename is the name of the attachment file (used for attachments)
Filename string `json:"filename,omitempty"`
// ContentType is the MIME type of the item payload (used for attachments and some other item types)
ContentType string `json:"content_type,omitempty"`
// ItemCount is the number of items in a batch (used for logs)
ItemCount *int `json:"item_count,omitempty"`
}
EnvelopeItemHeader represents the header of an envelope item.
type EnvelopeItemType ¶
type EnvelopeItemType string
EnvelopeItemType represents the type of envelope item.
const ( EnvelopeItemTypeEvent EnvelopeItemType = "event" EnvelopeItemTypeTransaction EnvelopeItemType = "transaction" EnvelopeItemTypeCheckIn EnvelopeItemType = "check_in" EnvelopeItemTypeAttachment EnvelopeItemType = "attachment" EnvelopeItemTypeLog EnvelopeItemType = "log" )
Constants for envelope item types as defined in the Sentry documentation.
type SdkInfo ¶
type SdkInfo struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
Integrations []string `json:"integrations,omitempty"`
Packages []SdkPackage `json:"packages,omitempty"`
}
SdkInfo contains SDK metadata.
type SdkPackage ¶
type SdkPackage struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
}
SdkPackage describes a package that was installed.
type TelemetryTransport ¶
type TelemetryTransport interface {
// SendEnvelope sends an envelope to Sentry. Returns immediately with
// backpressure error if the queue is full.
SendEnvelope(envelope *Envelope) error
// SendEvent sends an event to Sentry.
SendEvent(event EnvelopeConvertible)
// IsRateLimited checks if a specific category is currently rate limited
IsRateLimited(category ratelimit.Category) bool
// Flush waits for all pending envelopes to be sent, with timeout
Flush(timeout time.Duration) bool
// FlushWithContext waits for all pending envelopes to be sent
FlushWithContext(ctx context.Context) bool
// Close shuts down the transport gracefully
Close()
}
TelemetryTransport represents the envelope-first transport interface. This interface is designed for the telemetry buffer system and provides non-blocking sends with backpressure signals.