sentry

package
v2.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// SourceFetchPrivate fetches only from loopback and private addresses
	// (127.0.0.0/8, ::1, 10/8, 172.16/12, 192.168/16, fc00::/7): the dev
	// server, a docker service, ddev. The default.
	SourceFetchPrivate = "private"
	// SourceFetchAny fetches from any host.
	SourceFetchAny = "any"
	// SourceFetchOff never fetches.
	SourceFetchOff = "off"
)

Source fetch modes, config sentry.source_fetch.

View Source
const StoredEvent = "sentry.stored"

StoredEvent is the WebSocket notice that structured rows were stored: logs, metrics or traces, which create no feed card and so no "event.received". Its payload names the project and the kinds - "log", "metric", "trace" -, never the rows, so the Sentry tabs know which list to fetch again.

Variables

This section is empty.

Functions

This section is empty.

Types

type Breadcrumb struct {
	Type      string          `json:"type"`
	Category  string          `json:"category"`
	Level     string          `json:"level"`
	Message   string          `json:"message"`
	Timestamp FlexibleTS      `json:"timestamp"`
	Data      json.RawMessage `json:"data"`
}
type BreadcrumbList struct {
	Values []Breadcrumb `json:"values"`
}
func (b *BreadcrumbList) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both shapes Sentry SDKs emit for breadcrumbs: the "interface" object form {"values": [...]} (Python/PHP) and the bare-array form [...] (sentry.javascript / SvelteKit). Without this, a JS error event fails to parse and never lands in the sentry tables.

type Contexts

type Contexts struct {
	Trace *TraceContext `json:"trace"`
}

type EnvelopeHeader

type EnvelopeHeader struct {
	EventID string `json:"event_id"`
	SentAt  string `json:"sent_at"`
	DSN     string `json:"dsn"`
}

EnvelopeHeader is the first line of a Sentry envelope.

type EnvelopeItem

type EnvelopeItem struct {
	Type    string          // "event", "transaction", "spans", "log", "session", etc.
	Header  json.RawMessage // raw item header JSON
	Payload json.RawMessage // raw item body JSON
}

EnvelopeItem represents a single parsed item from a Sentry envelope.

type ErrorEvent

type ErrorEvent struct {
	EventID     string          `json:"event_id"`
	Timestamp   FlexibleTS      `json:"timestamp"`
	Platform    string          `json:"platform"`
	Level       string          `json:"level"`
	Logger      string          `json:"logger"`
	Transaction string          `json:"transaction"`
	ServerName  string          `json:"server_name"`
	Environment string          `json:"environment"`
	Release     string          `json:"release"`
	Message     FlexibleMessage `json:"message"`
	LogEntry    *LogEntry       `json:"logentry"`
	Exception   *ExceptionList  `json:"exception"`
	Breadcrumbs *BreadcrumbList `json:"breadcrumbs"`
	Contexts    *Contexts       `json:"contexts"`
	SDK         *SDK            `json:"sdk"`
	Request     json.RawMessage `json:"request"`
	Modules     json.RawMessage `json:"modules"`
	Extra       json.RawMessage `json:"extra"`
	Tags        json.RawMessage `json:"tags"`
}

ErrorEvent represents a parsed Sentry error event.

type ExceptionList

type ExceptionList struct {
	Values []ExceptionValue `json:"values"`
}

func (*ExceptionList) UnmarshalJSON

func (e *ExceptionList) UnmarshalJSON(data []byte) error

UnmarshalJSON also accepts a bare array of exceptions (sentry-go).

type ExceptionValue

type ExceptionValue struct {
	Type       string          `json:"type"`
	Value      string          `json:"value"`
	Mechanism  *Mechanism      `json:"mechanism"`
	Stacktrace json.RawMessage `json:"stacktrace"`
}

type FlexibleMessage

type FlexibleMessage struct {
	Text     string   // plain message or the "formatted" / "message" fallback
	Template string   // the original template (message field from object form)
	Params   []string // interpolation parameters
}

FlexibleMessage handles Sentry "message" which can be a plain string or an object {"message":"...", "params":[...], "formatted":"..."}.

func (FlexibleMessage) String

func (m FlexibleMessage) String() string

String returns the display text.

func (*FlexibleMessage) UnmarshalJSON

func (m *FlexibleMessage) UnmarshalJSON(data []byte) error

type FlexibleTS

type FlexibleTS struct {
	// contains filtered or unexported fields
}

FlexibleTS handles Sentry timestamps which can be either a numeric epoch (float64, used by SDK v3/v4) or an ISO 8601 string (used by SDK v2).

func (FlexibleTS) Number

func (t FlexibleTS) Number() json.Number

Number returns the underlying json.Number for use with parseTimestamp.

func (*FlexibleTS) UnmarshalJSON

func (t *FlexibleTS) UnmarshalJSON(data []byte) error

type ItemHeader

type ItemHeader struct {
	Type   string `json:"type"`
	Length int    `json:"length"`
}

ItemHeader is the header line before each item body.

type LogEntry

type LogEntry struct {
	Message string `json:"message"`
}

type LogEnvelope

type LogEnvelope struct {
	Items []LogRecord `json:"items"`
}

LogEnvelope represents a Sentry log envelope item body.

type LogRecord

type LogRecord struct {
	TraceID        string         `json:"trace_id"`
	SpanID         string         `json:"span_id"`
	Level          string         `json:"level"`
	SeverityNumber int            `json:"severity_number"`
	Body           string         `json:"body"`
	Timestamp      FlexibleTS     `json:"timestamp"`
	Attributes     map[string]any `json:"attributes"`
}

LogRecord represents a single Sentry native log entry.

type Mechanism

type Mechanism struct {
	Type    string `json:"type"`
	Handled *bool  `json:"handled"`
}

type MetricEnvelope

type MetricEnvelope struct {
	Items []MetricRecord `json:"items"`
}

MetricEnvelope represents a Sentry "trace_metric" envelope item body.

type MetricRecord

type MetricRecord struct {
	TraceID    string         `json:"trace_id"`
	SpanID     string         `json:"span_id"`
	Name       string         `json:"name"`
	Type       string         `json:"type"`
	Value      float64        `json:"value"`
	Unit       string         `json:"unit"`
	Timestamp  FlexibleTS     `json:"timestamp"` // epoch seconds, or RFC 3339 from sentry-go (time.Time)
	Attributes map[string]any `json:"attributes"`
}

MetricRecord represents a single Sentry trace metric: a counter, gauge or distribution value, linked to the trace and span it was recorded in.

type Module

type Module struct {
	module.BaseModule
	// contains filtered or unexported fields
}

func New

func New() *Module

func (*Module) HTTPHandler

func (m *Module) HTTPHandler() module.HTTPIngestionHandler

func (*Module) Name

func (m *Module) Name() string

func (*Module) OnEventsDeleted added in v2.11.0

func (m *Module) OnEventsDeleted(uuids []string)

OnEventsDeleted removes the structured copy of deleted error events.

func (*Module) OnInit

func (m *Module) OnInit(db *sql.DB) error

func (*Module) PreviewMapper

func (m *Module) PreviewMapper() event.PreviewMapper

func (*Module) PruneBefore added in v2.11.0

func (m *Module) PruneBefore(ctx context.Context, cutoff time.Time) (int, error)

PruneBefore deletes Sentry rows older than cutoff that no event card keeps: logs and metrics by received_at, transactions and spans by start_ts (or, without one, by their trace's last_seen), and structured errors whose card is already gone. Errors of a kept (pinned) card stay. It implements module.AgePruner for retention.max_age.

func (*Module) RegisterMigrations

func (m *Module) RegisterMigrations(migrator *storage.Migrator) error

func (*Module) RegisterProtectedRoutes

func (m *Module) RegisterProtectedRoutes(mux *http.ServeMux, protect func(http.Handler) http.Handler)

RegisterProtectedRoutes adds the Sentry UI API behind the API auth. SDK ingestion (envelope/store) goes through the HTTP handler and stays open.

func (*Module) SetBroadcaster

func (m *Module) SetBroadcaster(b module.Broadcaster)

SetBroadcaster implements module.Broadcasting.

func (*Module) SetSourceFetch added in v2.11.0

func (m *Module) SetSourceFetch(mode string)

SetSourceFetch sets where source code of JS frames may be fetched from: SourceFetchPrivate (default), SourceFetchAny or SourceFetchOff.

func (*Module) Type

func (m *Module) Type() string

type RawSpan

type RawSpan struct {
	SpanID         string     `json:"span_id"`
	ParentSpanID   string     `json:"parent_span_id"`
	TraceID        string     `json:"trace_id"`
	Op             string     `json:"op"`
	Description    string     `json:"description"`
	Status         string     `json:"status"`
	StartTimestamp FlexibleTS `json:"start_timestamp"`
	Timestamp      FlexibleTS `json:"timestamp"`
	IsSegment      bool       `json:"is_segment"`
	Data           SpanData   `json:"data"`
}

RawSpan represents a span within a transaction or spans envelope item.

func (*RawSpan) UnmarshalJSON

func (s *RawSpan) UnmarshalJSON(data []byte) error

UnmarshalJSON also accepts the Span v2 format (SDK v4 "span" items): name, end_timestamp and typed attributes {"key":{"type":"string","value":...}}.

type SDK

type SDK struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type SpanData

type SpanData map[string]string

SpanData holds span attributes. SDKs put more than strings in there: numbers and booleans as well (http.response.status_code: 200, http.request.redirect: false). With the declared map[string]string a single numeric attribute made the whole envelope item fail to unmarshal, so the transaction and all of its spans were dropped. Values are normalized to strings, which keeps existing consumers (classifySpan, extractServiceName, the spans table) unchanged.

func (*SpanData) UnmarshalJSON

func (d *SpanData) UnmarshalJSON(data []byte) error

type SpansEnvelope

type SpansEnvelope struct {
	Items []RawSpan `json:"items"`
}

SpansEnvelope represents a Sentry spans (v2) envelope item body.

type TraceContext

type TraceContext struct {
	TraceID string `json:"trace_id"`
	SpanID  string `json:"span_id"`
	Op      string `json:"op"`
	Status  string `json:"status"`
}

type Transaction

type Transaction struct {
	EventID      string          `json:"event_id"`
	Type         string          `json:"type"`
	Transaction  string          `json:"transaction"`
	Timestamp    FlexibleTS      `json:"timestamp"`
	StartTime    FlexibleTS      `json:"start_timestamp"`
	Platform     string          `json:"platform"`
	Environment  string          `json:"environment"`
	Release      string          `json:"release"`
	Contexts     *Contexts       `json:"contexts"`
	Spans        []RawSpan       `json:"spans"`
	Measurements json.RawMessage `json:"measurements"`
	SDK          *SDK            `json:"sdk"`

	// Root span fields
	Op     string `json:"op,omitempty"`
	Status string `json:"status,omitempty"`
}

Transaction represents a Sentry transaction envelope item.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL