Documentation
¶
Overview ¶
Copyright 2026 Agentrail. Licensed under the Apache License, Version 2.0.
Package agentrail records privacy-filtered backend evidence for Agentrail. It uses explicit request contexts and never installs global OTel providers.
Copyright 2026 Agentrail. Licensed under the Apache License, Version 2.0.
Copyright 2026 Agentrail. Licensed under the Apache License, Version 2.0.
Index ¶
- Constants
- Variables
- type AuthorizedOperation
- type CaptureError
- type Client
- func (c *Client) Diagnostics() Diagnostics
- func (c *Client) Flush(ctx context.Context) error
- func (c *Client) Identify(ctx context.Context, id VerifiedIdentity) error
- func (c *Client) Log(ctx context.Context, input StructuredLog)
- func (c *Client) Middleware(next http.Handler) http.Handler
- func (c *Client) Milestone(ctx context.Context, name string, d MilestoneContext)
- func (c *Client) Shutdown(ctx context.Context) error
- func (c *Client) StartMilestone(ctx context.Context, name string, d MilestoneContext) (context.Context, func(error))
- func (c *Client) Transport(base *http.Transport) http.RoundTripper
- func (c *Client) WithMilestone(ctx context.Context, name string, d MilestoneContext, ...) (err error)
- type CollectorOptions
- type ConfigurationError
- type Diagnostics
- type IPLocation
- type LocationSource
- type LogsOptions
- type MCPContext
- type MCPOptions
- type MCPPayload
- type MilestoneContext
- type Options
- type PerformanceContext
- type PerformanceEnvironment
- type PluginInvocation
- type PrincipalKind
- type QueueOptions
- type StructuredLog
- type Surface
- type VerifiedIdentity
- type WorkflowRole
Constants ¶
const Version = "0.5.1"
Variables ¶
var ErrClosed = errors.New("Agentrail capture is shut down")
Functions ¶
This section is empty.
Types ¶
type AuthorizedOperation ¶
type AuthorizedOperation struct {
NamespaceID, InstanceRef string
Role WorkflowRole
}
AuthorizedOperation names a business attempt the application has already authorized. InstanceRef is hashed locally and never exported.
type CaptureError ¶
CaptureError describes loss or refused context without including customer data.
func (CaptureError) Error ¶
func (e CaptureError) Error() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
New starts capture with tracer and logger providers of its own. It registers no OpenTelemetry global and replaces nothing the application set up, so it runs beside Sentry, Datadog or the application's own OpenTelemetry, before or after them.
func (*Client) Diagnostics ¶
func (c *Client) Diagnostics() Diagnostics
func (*Client) Flush ¶
Flush waits for delivery attempts, not guaranteed delivery. Inspect Diagnostics and OnError for records lost to refusal, timeout or queue overflow.
func (*Client) Identify ¶
func (c *Client) Identify(ctx context.Context, id VerifiedIdentity) error
Identify asserts identity the application has already authenticated. Headers, generic OTel user attributes and self-reported MCP metadata are never trusted.
func (*Client) Log ¶
func (c *Client) Log(ctx context.Context, input StructuredLog)
Log records structured fields only. Message text requires Logs.IncludeFields.
func (*Client) Middleware ¶
Middleware records each request it admits. Install it once. Other tracing middleware, such as otelhttp, Sentry's or Datadog's, can wrap it: their span stays current in the request's context, and ours is never its parent nor its child.
func (*Client) Milestone ¶
func (c *Client) Milestone(ctx context.Context, name string, d MilestoneContext)
func (*Client) StartMilestone ¶
func (c *Client) StartMilestone(ctx context.Context, name string, d MilestoneContext) (context.Context, func(error))
StartMilestone starts a scoped operation. Call the returned end function once with the application error. Use WithMilestone to preserve panics automatically.
func (*Client) Transport ¶
func (c *Client) Transport(base *http.Transport) http.RoundTripper
Transport instruments a network transport. Inside a managed request, a call keeps the application's trace headers, such as those otelhttp, Sentry or Datadog set in a transport installed outside this one, and loses Agentrail's own. A call to an exact allowed origin gets our signed traceparent and handoff in place of the application's traceparent and tracestate. A concrete *http.Transport keeps that adjacent to the network: a nested tracing RoundTripper could otherwise overwrite the signed traceparent after signing. A nil base uses a private standard network transport. Client redirects pass through this wrapper again, so each actual destination is admitted independently.
type CollectorOptions ¶
type ConfigurationError ¶
type ConfigurationError struct{ Problem string }
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
type IPLocation ¶
type IPLocation struct {
Country, Region, City string
Source LocationSource
}
IPLocation describes a network exit, not a person's verified location. Country is an uppercase two-letter code. Empty place fields mean unknown. Values are copied at request admission; raw addresses are never included.
type LocationSource ¶
type LocationSource string
LocationSource identifies the trusted provider of an approximate IP location.
const ( LocationDBIP LocationSource = "dbip" LocationCloudflare LocationSource = "cloudflare" LocationVercel LocationSource = "vercel" LocationConfigured LocationSource = "source" )
type LogsOptions ¶
type LogsOptions struct {
IncludeFields []string
}
type MCPContext ¶
type MCPContext struct{ Method, Client, ClientVersion, Protocol, Name string }
MCPContext describes an MCP call. Name is the tool, resource or prompt's registered name, never a value from its arguments.
type MCPOptions ¶ added in v0.3.0
type MCPOptions struct {
// CapturePayloads sends each request's params and its result as JSON text.
// Off by default: without it no argument, result or resource content is sent.
// It requires Redact.
CapturePayloads bool
// Redact, required with CapturePayloads, runs on every payload before it
// is queued, on the goroutine that wrote the response. Return the payload to send, which must stay valid JSON,
// or false to send none. It receives copies it may change. A panic, or JSON
// that is not valid, drops the payload and is reported to OnError; the MCP
// call is never affected.
Redact func(MCPPayload) (MCPPayload, bool)
}
MCPOptions configures capture by the mcp package's transport wrappers.
type MCPPayload ¶ added in v0.3.0
type MCPPayload struct {
Method, Name string
Request, Response json.RawMessage
}
MCPPayload is one MCP message the server received and its answer, as the MCP SDK encoded them. Request is the request's params; Response is the result, or the JSON-RPC error object. Name is the tool or prompt name, or the resource URI, where the method has one.
type MilestoneContext ¶
type MilestoneContext struct {
Surface Surface
Kind string
MCP *MCPContext
// Performance is explicit evidence supplied after application authorization;
// it is never inferred from tool inputs or results, and applies only to this
// milestone's own span.
Performance *PerformanceContext
}
type Options ¶
type Options struct {
Collector CollectorOptions
HashKey, ServiceName, ServiceInstanceID string
OutboundOrigins []string
IgnoreIncomingRequest func(*http.Request) bool
// IncomingLocation uses trusted platform metadata or a preloaded local database.
// Return a zero value for unknown locations. Errors are reported without failing the request.
IncomingLocation func(*http.Request) (IPLocation, error)
Logs LogsOptions
Queue QueueOptions
MCP MCPOptions
OnError func(context.Context, CaptureError)
// contains filtered or unexported fields
}
Options configures backend capture. Secrets are supplied by the application; this package never reads environment variables implicitly.
type PerformanceContext ¶
type PerformanceContext struct {
Environment PerformanceEnvironment
Operation *AuthorizedOperation
EventName string
Plugin *PluginInvocation
}
PerformanceContext is explicit workflow or plugin evidence for one milestone. Supply an Operation with an EventName, a Plugin, or both; or a Plugin alone, without an EventName, for activity that earns no workflow-outcome credit.
type PerformanceEnvironment ¶
type PerformanceEnvironment string
PerformanceEnvironment separates production evidence from test evidence.
const ( EnvironmentProduction PerformanceEnvironment = "production" EnvironmentTest PerformanceEnvironment = "test" )
type PluginInvocation ¶
type PluginInvocation struct{ BindingID, InvocationID string }
PluginInvocation names an authenticated plugin deployment and an opaque invocation ID, never tool arguments or a customer identifier.
type PrincipalKind ¶
type PrincipalKind string
const ( PrincipalAgentRegistration PrincipalKind = "agent_registration" PrincipalUser PrincipalKind = "user" PrincipalAPIKey PrincipalKind = "api_key" PrincipalAgentInstance PrincipalKind = "agent_instance" PrincipalOAuthClient PrincipalKind = "oauth_client" )
type QueueOptions ¶
type StructuredLog ¶
type Surface ¶
type Surface string
const ( SurfaceHTTP Surface = "http" SurfaceMCP Surface = "mcp" SurfaceAuth Surface = "auth" SurfaceCustom Surface = "custom" SurfaceA2A Surface = "a2a" SurfaceGenAI Surface = "genai" SurfacePayment Surface = "payment" SurfaceEdge Surface = "edge" SurfaceFirewall Surface = "firewall" SurfaceBrowser Surface = "browser" )
type VerifiedIdentity ¶
type VerifiedIdentity struct {
Kind PrincipalKind
ID, ActingUserID string
}
type WorkflowRole ¶
type WorkflowRole string
WorkflowRole is where a milestone sits in one business attempt.
const ( RoleStart WorkflowRole = "start" RoleProgress WorkflowRole = "progress" RoleTerminal WorkflowRole = "terminal" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
http
command
|
|
|
mcp
command
|
|
|
integration
|
|
|
capture
command
Command capture produces synthetic OTLP bytes through the public Go SDK.
|
Command capture produces synthetic OTLP bytes through the public Go SDK. |
|
internal
|
|
|
delivery
Package delivery provides bounded, best-effort asynchronous batch delivery.
|
Package delivery provides bounded, best-effort asynchronous batch delivery. |
|
handoff
Package handoff implements the authenticated Agentrail trace handoff protocol.
|
Package handoff implements the authenticated Agentrail trace handoff protocol. |
|
mcpspan
Package mcpspan connects the MCP adapter to the client's private span recording.
|
Package mcpspan connects the MCP adapter to the client's private span recording. |
|
Package mcp records MCP traffic of official MCP Go SDK servers as Agentrail evidence.
|
Package mcp records MCP traffic of official MCP Go SDK servers as Agentrail evidence. |
|
Package slog adds opt-in Agentrail capture to an application's log/slog handler.
|
Package slog adds opt-in Agentrail capture to an application's log/slog handler. |