xeprovider

package
v0.1.112 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 2 modules, 1 package

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 SQLXEventProviderType = "sqlserver-xevent"

SQLXEventProviderType names the Extended Events provider in a profile's `provider.type`. A profile naming it must also declare `trace:` — the capture has no single-shot form, so Execute refuses.

Variables

This section is empty.

Functions

func OpenSQLServer

func OpenSQLServer(ctx context.Context, reference string) (*sql.DB, func(), error)

OpenSQLServer leases the SQL Server connection named reference and opens a client on it for an Extended Events capture; release closes the client and gives the lease back. A connection of any other type is refused.

Types

type XEventCaptureOptions

type XEventCaptureOptions struct {
	// SessionName names the Extended Events session on the server. Required:
	// the session is visible in sys.dm_xe_sessions to everyone on the instance,
	// so what it is called is the profile author's to say, not this package's.
	// A unique suffix is appended so concurrent captures of one profile do not
	// collide on the server.
	SessionName string `json:"sessionName"`

	// Databases scopes the session by database name; empty uses the
	// connection's own, and "*" captures the whole instance.
	Databases []string `json:"databases,omitempty"`

	Users []string `json:"users,omitempty"`
	Apps  []string `json:"apps,omitempty"`
	Hosts []string `json:"hosts,omitempty"`

	// Events selects the Extended Events to capture; empty uses xetrace's
	// defaults. Add sp_statement_completed to see statements inside procedures.
	Events []string `json:"events,omitempty"`

	// Types narrows to statement types (SELECT/INSERT/UPDATE/DELETE/MERGE/EXEC/DML).
	Types []string `json:"types,omitempty"`
	// Tables narrows to referenced tables, or a procedure name for an EXEC.
	Tables []string `json:"tables,omitempty"`

	// MinDuration drops statements faster than this threshold, e.g. "10ms".
	MinDuration string `json:"minDuration,omitempty"`
	// Poll is the ring-buffer poll cadence, e.g. "1s". Empty uses xetrace's.
	Poll string `json:"poll,omitempty"`

	// MaxEvents caps the ring buffer's event count; MaxMemoryKB its size.
	MaxEvents   int `json:"maxEvents,omitempty"`
	MaxMemoryKB int `json:"maxMemoryKb,omitempty"`
}

XEventCaptureOptions are the capture knobs a profile sets under `provider.options`. Databases/Users/Apps/Hosts are pushed into the Extended Events predicate so they filter inside SQL Server; Types/Tables are applied to the parsed events, because the predicate has no structured statement type or referenced-object to match on. All of them take collections.MatchItem patterns (exact, prefix/suffix `*` wildcard, `!` exclusion).

The sizing and poll knobs are zero by default so an unset one means "take the documented default" rather than a number this struct has to keep in step with xetrace.

func (XEventCaptureOptions) CaptureOptions

CaptureOptions projects the decoded options onto the two xetrace option sets, rejecting any value the session could not honour.

It is separate from Stream so a bad profile fails at decode with the option named, rather than as an opaque SQL Server syntax error once a session is half-created.

Jump to

Keyboard shortcuts

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