Documentation
¶
Overview ¶
Package logbrew provides a small public client for building, validating, previewing, and flushing LogBrew event batches from Go applications.
Index ¶
- Constants
- func AsTransportError(err error, target **TransportError) bool
- func CacheOperationWithLogBrewSpan[T any](ctx context.Context, client *Client, operationName string, ...) (T, error)
- func ContextWithLogBrewTrace(parent context.Context, trace TraceContext) context.Context
- func CreateTraceparent(traceID, spanID, traceFlags string) (string, error)
- func DatabaseOperationWithLogBrewSpan[T any](ctx context.Context, client *Client, operationName string, ...) (T, error)
- func GenerateSpanID() (string, error)
- func GenerateTraceID() (string, error)
- func IssueExceptionType(value any) string
- func NewHTTPClientTransport(config HTTPClientTransportConfig) (http.RoundTripper, error)
- func NewHTTPHandler(next http.Handler, config HTTPHandlerConfig) (http.Handler, error)
- func NewHTTPHandlerFunc(next http.HandlerFunc, config HTTPHandlerConfig) (http.Handler, error)
- func NewHTTPHandlerFuncWithOptions(next http.HandlerFunc, config HTTPHandlerConfig, options ...HTTPHandlerOption) (http.Handler, error)
- func NewHTTPHandlerWithOptions(next http.Handler, config HTTPHandlerConfig, options ...HTTPHandlerOption) (http.Handler, error)
- func NewSlogHandler(config SlogHandlerConfig) (slog.Handler, error)
- func PurgePersistentDelivery(config PersistentDeliveryConfig) error
- func QueueOperationWithLogBrewSpan[T any](ctx context.Context, client *Client, operationName string, ...) (T, error)
- func SQLExecContextWithLogBrewSpan(ctx context.Context, client *Client, execer any, operationName string, ...) (sql.Result, error)
- func SQLQueryContextWithLogBrewSpan(ctx context.Context, client *Client, queryer any, operationName string, ...) (*sql.Rows, error)
- func SQLTransactionWithLogBrewSpan[T any](ctx context.Context, client *Client, beginner SQLBeginTxRunner, ...) (T, error)
- func TraceMetadataFromContext(ctx context.Context) map[string]any
- type ActionAttributes
- type AutomaticDeliveryConfig
- type CacheOperationConfig
- type Client
- func (c *Client) Action(id, timestamp string, attributes ActionAttributes) error
- func (c *Client) DeliveryHealth() DeliveryHealth
- func (c *Client) DroppedEvents() int
- func (c *Client) Environment(id, timestamp string, attributes EnvironmentAttributes) error
- func (c *Client) Flush(transport Transport) (*TransportResponse, error)
- func (c *Client) Issue(id, timestamp string, attributes IssueAttributes) error
- func (c *Client) Log(id, timestamp string, attributes LogAttributes) error
- func (c *Client) Metric(id, timestamp string, attributes MetricAttributes) error
- func (c *Client) PendingEvents() int
- func (c *Client) PreviewJSON() (string, error)
- func (c *Client) Release(id, timestamp string, attributes ReleaseAttributes) error
- func (c *Client) ResumeDelivery() error
- func (c *Client) Shutdown(transport Transport) (*TransportResponse, error)
- func (c *Client) Span(id, timestamp string, attributes SpanAttributes) error
- type Config
- type DatabaseOperationConfig
- type DeliveryHealth
- type EnvironmentAttributes
- type Event
- type EventDrop
- type HTTPClientTransportConfig
- type HTTPHandlerConfig
- type HTTPHandlerOption
- type HTTPTransport
- type HTTPTransportConfig
- type IssueAttributes
- type IssueBreadcrumb
- type IssueDiagnosticEvidence
- type IssueException
- type IssueExceptionChain
- type IssueExceptionChainEntry
- type IssueExceptionChainInput
- type IssueExceptionMechanism
- type IssueExceptionMessageState
- type IssueExceptionRelationship
- type IssueExceptionStackFramesState
- type IssueImpactEvidence
- type IssueLikelyFixArea
- type IssueStackFrame
- type LogAttributes
- type MetricAttributes
- type NetworkMilestoneInput
- type PersistentDeliveryConfig
- type ProductActionInput
- type QueueOperationConfig
- type RecordingTransport
- type ReleaseAttributes
- type SQLBeginTxRunner
- type SQLExecContextRunner
- type SQLQueryContextRunner
- type SQLStatementExecContextRunner
- type SQLStatementQueryContextRunner
- type SdkError
- type SlogHandlerConfig
- type SpanAttributes
- type SpanLinkSummary
- type SupportTicketDraft
- type SupportTicketDraftInput
- type TelemetryApplication
- type TelemetryContext
- type TelemetryDeployment
- type TelemetryDevice
- type TelemetryNamedVersion
- type TelemetryOperatingSystem
- type TelemetryResource
- type TelemetrySessionContext
- type TelemetrySubjectContext
- type TelemetryTraceContext
- type TraceContext
- type TraceContextInput
- type TraceContextSpanInput
- type TraceparentContext
- type TraceparentSpanInput
- type Transport
- type TransportError
- type TransportResponse
Constants ¶
const ( DeliveryStateManual = "manual" DeliveryStateRunning = "running" DeliveryStatePaused = "paused" DeliveryStateShuttingDown = "shutting_down" DeliveryStateShutdownFailed = "shutdown_failed" DeliveryStateShutdown = "shutdown" )
const ( DeliveryOutcomeNone = "none" DeliveryOutcomeAccepted = "accepted" DeliveryOutcomeRetryableFailure = "retryable_failure" DeliveryOutcomeAuthenticationPause = "authentication_paused" DeliveryOutcomeQuotaPause = "quota_paused" DeliveryOutcomeNonRetryablePause = "nonretryable_paused" DeliveryOutcomePersistencePause = "persistence_paused" DeliveryOutcomeShutdownFailed = "shutdown_failed" )
const ( DeliveryBackoffSourceNone = "none" DeliveryBackoffSourceClient = "client" DeliveryBackoffSourceServer = "server" )
const ( DeliveryBackoffOutcomeNone = "none" DeliveryBackoffOutcomeScheduled = "scheduled" DeliveryBackoffOutcomeHonored = "honored" DeliveryBackoffOutcomeClamped = "clamped" DeliveryBackoffOutcomeFallback = "fallback" )
const ( // DefaultHTTPEndpoint is the production LogBrew event intake URL used by // NewHTTPTransport when no endpoint is supplied. DefaultHTTPEndpoint = "https://api.logbrew.co/v1/events" )
Variables ¶
This section is empty.
Functions ¶
func AsTransportError ¶
func AsTransportError(err error, target **TransportError) bool
AsTransportError extracts a public transport failure for retry-aware callers.
func CacheOperationWithLogBrewSpan ¶ added in v0.1.2
func CacheOperationWithLogBrewSpan[T any]( ctx context.Context, client *Client, operationName string, operation func(context.Context) (T, error), config CacheOperationConfig, ) (T, error)
CacheOperationWithLogBrewSpan runs operation under a child trace context and queues one privacy-bounded cache span.
func ContextWithLogBrewTrace ¶ added in v0.1.2
func ContextWithLogBrewTrace(parent context.Context, trace TraceContext) context.Context
ContextWithLogBrewTrace attaches trace context to a Go context.
func CreateTraceparent ¶
CreateTraceparent creates a normalized W3C traceparent header from explicit trace, span, and flags values. Empty traceFlags defaults to sampled "01".
func DatabaseOperationWithLogBrewSpan ¶ added in v0.1.2
func DatabaseOperationWithLogBrewSpan[T any]( ctx context.Context, client *Client, operationName string, operation func(context.Context) (T, error), config DatabaseOperationConfig, ) (T, error)
DatabaseOperationWithLogBrewSpan runs operation under a child trace context and queues one privacy-bounded database span.
func GenerateSpanID ¶ added in v0.1.2
GenerateSpanID returns a fresh non-zero W3C-compatible span ID.
func GenerateTraceID ¶ added in v0.1.2
GenerateTraceID returns a fresh non-zero W3C-compatible trace ID.
func IssueExceptionType ¶ added in v0.1.7
IssueExceptionType returns a bounded type identity for an error or recovered panic value without formatting or reading that value.
func NewHTTPClientTransport ¶ added in v0.1.2
func NewHTTPClientTransport(config HTTPClientTransportConfig) (http.RoundTripper, error)
NewHTTPClientTransport wraps an app-owned RoundTripper with privacy-safe outbound spans.
func NewHTTPHandler ¶ added in v0.1.2
NewHTTPHandler wraps an app-owned net/http handler with privacy-safe request span telemetry and request-local trace context.
func NewHTTPHandlerFunc ¶ added in v0.1.2
func NewHTTPHandlerFunc(next http.HandlerFunc, config HTTPHandlerConfig) (http.Handler, error)
NewHTTPHandlerFunc wraps an app-owned net/http handler function.
func NewHTTPHandlerFuncWithOptions ¶ added in v0.1.4
func NewHTTPHandlerFuncWithOptions( next http.HandlerFunc, config HTTPHandlerConfig, options ...HTTPHandlerOption, ) (http.Handler, error)
NewHTTPHandlerFuncWithOptions wraps an app-owned handler function with explicit additive behavior.
func NewHTTPHandlerWithOptions ¶ added in v0.1.4
func NewHTTPHandlerWithOptions( next http.Handler, config HTTPHandlerConfig, options ...HTTPHandlerOption, ) (http.Handler, error)
NewHTTPHandlerWithOptions wraps an app-owned handler with explicit additive behavior while preserving the stable HTTPHandlerConfig layout.
func NewSlogHandler ¶ added in v0.1.2
func NewSlogHandler(config SlogHandlerConfig) (slog.Handler, error)
NewSlogHandler wraps an app-owned slog.Handler and correlates logs with the LogBrew trace context stored on the provided context.
func PurgePersistentDelivery ¶ added in v0.1.4
func PurgePersistentDelivery(config PersistentDeliveryConfig) error
PurgePersistentDelivery removes only recognized LogBrew persistence files while holding exclusive ownership. It intentionally does not require the previous encryption key, allowing recovery from a lost caller-owned key.
func QueueOperationWithLogBrewSpan ¶ added in v0.1.2
func QueueOperationWithLogBrewSpan[T any]( ctx context.Context, client *Client, operationName string, operation func(context.Context) (T, error), config QueueOperationConfig, ) (T, error)
QueueOperationWithLogBrewSpan runs operation under a child trace context and queues one privacy-bounded queue span.
func SQLExecContextWithLogBrewSpan ¶ added in v0.1.3
func SQLExecContextWithLogBrewSpan( ctx context.Context, client *Client, execer any, operationName string, query string, config DatabaseOperationConfig, args ...any, ) (sql.Result, error)
SQLExecContextWithLogBrewSpan runs an app-owned database/sql ExecContext call under a child trace and queues one privacy-bounded database span. Query-text runners receive query text and args; prepared statement runners receive args only. Neither query text nor args are copied into telemetry by this helper.
func SQLQueryContextWithLogBrewSpan ¶ added in v0.1.3
func SQLQueryContextWithLogBrewSpan( ctx context.Context, client *Client, queryer any, operationName string, query string, config DatabaseOperationConfig, args ...any, ) (*sql.Rows, error)
SQLQueryContextWithLogBrewSpan runs an app-owned database/sql QueryContext call under a child trace and queues one privacy-bounded database span. Query-text runners receive query text and args; prepared statement runners receive args only. Neither query text nor args are copied into telemetry by this helper.
func SQLTransactionWithLogBrewSpan ¶ added in v0.1.3
func SQLTransactionWithLogBrewSpan[T any]( ctx context.Context, client *Client, beginner SQLBeginTxRunner, operationName string, opts *sql.TxOptions, operation func(context.Context, *sql.Tx) (T, error), config DatabaseOperationConfig, ) (T, error)
SQLTransactionWithLogBrewSpan runs an app-owned database/sql transaction callback under a child transaction span. LogBrew starts the transaction through the app-owned runner, passes the active transaction context to the callback, commits on callback success, and rolls back on callback error. Query and exec helpers called with the callback context become children of this transaction span. SQL text, args, connection details, and rollback error messages are not copied into telemetry.
Types ¶
type ActionAttributes ¶
type ActionAttributes struct {
Name string `json:"name"`
Status string `json:"status"`
Metadata map[string]any `json:"metadata,omitempty"`
Context *TelemetryContext `json:"context,omitempty"`
}
ActionAttributes describes the public payload fields for an action event.
func ActionAttributesWithTrace ¶ added in v0.1.6
func ActionAttributesWithTrace(ctx context.Context, attributes ActionAttributes) ActionAttributes
ActionAttributesWithTrace adds exact active trace/span context while keeping legacy primitive metadata for compatible readers.
func CreateNetworkMilestoneAttributes ¶ added in v0.1.1
func CreateNetworkMilestoneAttributes(input NetworkMilestoneInput) (ActionAttributes, error)
CreateNetworkMilestoneAttributes builds privacy-safe action attributes for an API milestone without patching HTTP clients or capturing payloads/headers.
func CreateProductActionAttributes ¶ added in v0.1.1
func CreateProductActionAttributes(input ProductActionInput) (ActionAttributes, error)
CreateProductActionAttributes builds privacy-safe action attributes for a product milestone without automatic click capture or global app mutation.
type AutomaticDeliveryConfig ¶ added in v0.1.4
type AutomaticDeliveryConfig struct {
Transport Transport
FlushInterval time.Duration
FlushThreshold int
RetryBaseDelay time.Duration
RetryMaxDelay time.Duration
}
AutomaticDeliveryConfig configures client-owned delivery through one transport. NewClient remains fully manual; NewAutomaticClient opts in.
type CacheOperationConfig ¶ added in v0.1.2
type CacheOperationConfig struct {
System string
OperationKind string
CacheName string
Hit *bool
ItemSizeBytes *int
ItemCount *int
EventIDPrefix string
Metadata map[string]any
SpanIDFactory func() string
Now func() time.Time
OnError func(error)
}
CacheOperationConfig configures an explicit app-owned cache span.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client buffers validated LogBrew events until they are previewed, flushed, or shut down through a transport.
func NewAutomaticClient ¶ added in v0.1.4
func NewAutomaticClient(config Config, delivery AutomaticDeliveryConfig) (*Client, error)
NewAutomaticClient creates a client that owns interval and threshold delivery through the supplied app-scoped transport.
func NewClient ¶
NewClient creates a public LogBrew client from user-supplied SDK identity and API key configuration.
func NewPersistentAutomaticClient ¶ added in v0.1.4
func NewPersistentAutomaticClient( config Config, delivery AutomaticDeliveryConfig, persistence PersistentDeliveryConfig, ) (*Client, error)
NewPersistentAutomaticClient creates an owned automatic client whose one delivery queue is durably encrypted before capture returns.
func (*Client) Action ¶
func (c *Client) Action(id, timestamp string, attributes ActionAttributes) error
func (*Client) DeliveryHealth ¶ added in v0.1.4
func (c *Client) DeliveryHealth() DeliveryHealth
DeliveryHealth returns a fixed local snapshot with no event content, identifiers, keys, endpoint data, headers, or raw transport errors.
func (*Client) DroppedEvents ¶ added in v0.1.3
DroppedEvents returns the number of locally dropped events since the client was created. Flush does not reset this diagnostic counter.
func (*Client) Environment ¶
func (c *Client) Environment(id, timestamp string, attributes EnvironmentAttributes) error
func (*Client) Flush ¶
func (c *Client) Flush(transport Transport) (*TransportResponse, error)
Flush sends queued events through a transport while preserving retry semantics. It freezes one snapshot, and a nil transport uses an owned automatic transport when configured.
func (*Client) Issue ¶
func (c *Client) Issue(id, timestamp string, attributes IssueAttributes) error
func (*Client) Metric ¶ added in v0.1.1
func (c *Client) Metric(id, timestamp string, attributes MetricAttributes) error
Metric queues an explicit, application-owned metric event after validating name, optional description, kind, value, unit, temporality, and optional metadata.
func (*Client) PendingEvents ¶
PendingEvents returns the number of validated events currently buffered in memory.
func (*Client) PreviewJSON ¶
PreviewJSON returns the queued event batch as stable, pretty-printed JSON.
func (*Client) Release ¶
func (c *Client) Release(id, timestamp string, attributes ReleaseAttributes) error
func (*Client) ResumeDelivery ¶ added in v0.1.4
ResumeDelivery resumes an automatically managed client after a terminal authentication, quota, or non-retryable pause.
type Config ¶
type Config struct {
// APIKey is the public LogBrew API key sent to the transport.
APIKey string
// SDKName identifies the calling SDK or application in emitted payloads.
SDKName string
// SDKVersion identifies the calling SDK or application version.
SDKVersion string
// Context is explicit privacy-bounded resource, correlation, session,
// subject, and tag context merged into every event.
Context *TelemetryContext
// DisableRuntimeContext turns off the default Go version, OS family, and
// architecture context without changing explicit Context.
DisableRuntimeContext bool
// MaxRetries sets the retry budget for retryable transport failures.
MaxRetries int
// MaxQueueSize bounds the in-memory event queue. Zero defaults to 1000.
MaxQueueSize int
// OnEventDropped is an advisory callback for local queue overflow. It must
// not be used for critical app control flow because panics are recovered.
OnEventDropped func(EventDrop)
}
Config describes the public SDK identity, API key, and retry behavior for a Go LogBrew client.
type DatabaseOperationConfig ¶ added in v0.1.2
type DatabaseOperationConfig struct {
System string
OperationKind string
DatabaseName string
StatementTemplate string
RowCount *int
EventIDPrefix string
Metadata map[string]any
SpanIDFactory func() string
Now func() time.Time
OnError func(error)
}
DatabaseOperationConfig configures an explicit app-owned database span.
type DeliveryHealth ¶ added in v0.1.4
type DeliveryHealth struct {
State string `json:"state"`
PendingEvents int `json:"pendingEvents"`
DroppedEvents int `json:"droppedEvents"`
InFlight bool `json:"inFlight"`
WakePending bool `json:"wakePending"`
LastOutcome string `json:"lastOutcome"`
Flushes uint64 `json:"flushes"`
Attempts uint64 `json:"attempts"`
AcceptedEvents uint64 `json:"acceptedEvents"`
FailedFlushes uint64 `json:"failedFlushes"`
RetrySchedules uint64 `json:"retrySchedules"`
// BackoffSource and BackoffOutcome use the fixed DeliveryBackoff vocabulary.
BackoffSource string `json:"backoffSource"`
BackoffOutcome string `json:"backoffOutcome"`
// BackoffDelayMillis is the bounded delay selected for the latest retry.
BackoffDelayMillis uint64 `json:"backoffDelayMillis"`
ServerBackoffs uint64 `json:"serverBackoffs"`
ClientBackoffs uint64 `json:"clientBackoffs"`
InvalidServerBackoffs uint64 `json:"invalidServerBackoffs"`
}
DeliveryHealth is a fixed, content-free snapshot of local delivery state.
type EnvironmentAttributes ¶
type EnvironmentAttributes struct {
Name string `json:"name"`
Region string `json:"region,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Context *TelemetryContext `json:"context,omitempty"`
}
EnvironmentAttributes describes the public payload fields for an environment event.
type Event ¶
type Event struct {
// Type is the stable LogBrew event type such as release or span.
Type string `json:"type"`
// Timestamp is the RFC 3339 event timestamp with timezone information.
Timestamp string `json:"timestamp"`
// ID is the caller-supplied stable identifier for the event.
ID string `json:"id"`
// Attributes contains the event payload fields for the given event type.
Attributes map[string]any `json:"attributes"`
}
Event is the public event shape buffered, previewed, and flushed by the client.
type EventDrop ¶ added in v0.1.3
type EventDrop struct {
EventID string `json:"eventId"`
EventType string `json:"eventType"`
Reason string `json:"reason"`
DroppedEvents int `json:"droppedEvents"`
}
EventDrop is a privacy-bounded advisory emitted when the client drops a local event before transport. It never includes event attributes, payloads, or keys.
type HTTPClientTransportConfig ¶ added in v0.1.2
type HTTPClientTransportConfig struct {
Client *Client
Base http.RoundTripper
// RouteTemplate is retained for source compatibility. Outbound tracing does not capture routes.
RouteTemplate string
// EventIDPrefix is a bounded local label used only to identify queued span events.
EventIDPrefix string
// Metadata is retained for source compatibility. Outbound tracing emits a fixed metadata allowlist.
Metadata map[string]any
// CapturePhaseTimings is retained for source compatibility. Transport internals are not captured.
CapturePhaseTimings bool
// FinishSpanOnResponseBodyClose defers span capture until the response body is read to EOF or closed.
FinishSpanOnResponseBodyClose bool
SpanIDFactory func() string
Now func() time.Time
OnError func(error)
}
HTTPClientTransportConfig configures dependency-free outbound net/http client spans.
type HTTPHandlerConfig ¶ added in v0.1.2
type HTTPHandlerConfig struct {
Client *Client
RouteTemplate string
CaptureRequestMetric bool
EventIDPrefix string
Metadata map[string]any
SpanIDFactory func() string
Now func() time.Time
OnError func(error)
}
HTTPHandlerConfig configures dependency-free net/http request telemetry.
type HTTPHandlerOption ¶ added in v0.1.4
type HTTPHandlerOption interface {
// contains filtered or unexported methods
}
HTTPHandlerOption adds explicit behavior without changing the stable HTTPHandlerConfig layout.
func WithHTTPServerErrorIssues ¶ added in v0.1.4
func WithHTTPServerErrorIssues() HTTPHandlerOption
WithHTTPServerErrorIssues adds one generic correlated issue for ordinary 5xx responses. Panics always add a generic issue before being re-panicked.
type HTTPTransport ¶
type HTTPTransport struct {
// Endpoint is the URL that receives serialized LogBrew event batches.
Endpoint string
// Headers are added to every HTTP delivery request after default headers.
Headers map[string]string
// Client sends requests. When nil, a shared default client is used.
Client *http.Client
}
HTTPTransport sends queued batches through Go's standard net/http client.
func NewHTTPTransport ¶
func NewHTTPTransport(config HTTPTransportConfig) (*HTTPTransport, error)
NewHTTPTransport creates a dependency-free HTTP transport with safe defaults.
func (*HTTPTransport) Send ¶
func (t *HTTPTransport) Send(apiKey string, body []byte) (*TransportResponse, error)
Send posts one serialized event batch and returns the HTTP status.
type HTTPTransportConfig ¶
type HTTPTransportConfig struct {
// Endpoint is the URL that receives serialized LogBrew event batches.
Endpoint string
// Headers are added to every HTTP delivery request after default headers.
Headers map[string]string
// Client sends requests. When nil, Send uses a shared default client unless
// Timeout asks NewHTTPTransport to create one.
Client *http.Client
// Timeout is used for the default HTTP client when Client is nil.
Timeout time.Duration
}
HTTPTransportConfig configures the dependency-free HTTP transport.
type IssueAttributes ¶
type IssueAttributes struct {
Title string `json:"title"`
Level string `json:"level"`
Message string `json:"message,omitempty"`
Exception *IssueException `json:"exception,omitempty"`
ExceptionChain *IssueExceptionChain `json:"exceptionChain,omitempty"`
StackFrames []IssueStackFrame `json:"stackFrames,omitempty"`
Breadcrumbs []IssueBreadcrumb `json:"breadcrumbs,omitempty"`
BreadcrumbsTruncated bool `json:"breadcrumbsTruncated,omitempty"`
Evidence *IssueDiagnosticEvidence `json:"evidence,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Context *TelemetryContext `json:"context,omitempty"`
}
IssueAttributes describes the public payload fields for an issue event.
func IssueAttributesFromError ¶ added in v0.1.7
func IssueAttributesFromError(err error, title string, mechanismType string, handled bool) (IssueAttributes, error)
IssueAttributesFromError creates error-level issue attributes from a Go error. The root capture stack is bounded; unwrap nodes explicitly report that Go did not provide a separate stack. Error text is redacted by default.
func IssueAttributesWithTrace ¶ added in v0.1.2
func IssueAttributesWithTrace(ctx context.Context, attributes IssueAttributes) IssueAttributes
IssueAttributesWithTrace merges active trace metadata into issue attributes.
type IssueBreadcrumb ¶ added in v0.1.6
type IssueBreadcrumb struct {
Timestamp string `json:"timestamp"`
Type string `json:"type,omitempty"`
Category string `json:"category"`
Level string `json:"level,omitempty"`
Message string `json:"message,omitempty"`
Data map[string]any `json:"data,omitempty"`
}
IssueBreadcrumb is one application-supplied, privacy-bounded step that happened before an issue. Data accepts at most eight flat finite primitive values.
type IssueDiagnosticEvidence ¶ added in v0.1.8
type IssueDiagnosticEvidence struct {
LikelyRootCause string `json:"likelyRootCause,omitempty"`
LikelyFixArea *IssueLikelyFixArea `json:"likelyFixArea,omitempty"`
Impact *IssueImpactEvidence `json:"impact,omitempty"`
CapturedFields []string `json:"capturedFields,omitempty"`
MissingFields []string `json:"missingFields,omitempty"`
RedactedFields []string `json:"redactedFields,omitempty"`
TruncatedFields []string `json:"truncatedFields,omitempty"`
}
IssueDiagnosticEvidence contains bounded application-reported cause, fix area, impact, and explicit field-state receipts.
type IssueException ¶ added in v0.1.6
type IssueException struct {
Type string `json:"type"`
Mechanism *IssueExceptionMechanism `json:"mechanism,omitempty"`
}
IssueException is a privacy-bounded exception identity. It intentionally excludes the exception value; applications keep control of the issue Message field when a display-safe description is appropriate.
type IssueExceptionChain ¶ added in v0.1.7
type IssueExceptionChain struct {
Entries []IssueExceptionChainEntry `json:"entries"`
Truncated bool `json:"truncated"`
}
IssueExceptionChain contains at most eight parent-first runtime exceptions.
func CreateIssueExceptionChain ¶ added in v0.1.7
func CreateIssueExceptionChain(input IssueExceptionChainInput) (*IssueExceptionChain, error)
CreateIssueExceptionChain builds a bounded parent-first chain from a Go error or recovered panic value without reading or serializing its text.
type IssueExceptionChainEntry ¶ added in v0.1.7
type IssueExceptionChainEntry struct {
ID int `json:"id"`
ParentID *int `json:"parentId,omitempty"`
Relationship IssueExceptionRelationship `json:"relationship"`
Type string `json:"type"`
Message string `json:"message,omitempty"`
MessageState IssueExceptionMessageState `json:"messageState"`
Module string `json:"module,omitempty"`
Mechanism *IssueExceptionMechanism `json:"mechanism,omitempty"`
StackFrames []IssueStackFrame `json:"stackFrames,omitempty"`
StackFramesState IssueExceptionStackFramesState `json:"stackFramesState"`
}
IssueExceptionChainEntry is one parent-first runtime exception with its own bounded evidence states.
type IssueExceptionChainInput ¶ added in v0.1.7
type IssueExceptionChainInput struct {
Value any
Exception *IssueException
StackFrames []IssueStackFrame
StackFramesTruncated bool
}
IssueExceptionChainInput provides a runtime value and the matching legacy exception fields used to create one bounded chain.
type IssueExceptionMechanism ¶ added in v0.1.6
IssueExceptionMechanism identifies the runtime path that observed an exception and whether the exception escaped that path.
type IssueExceptionMessageState ¶ added in v0.1.7
type IssueExceptionMessageState string
IssueExceptionMessageState reports whether one exception message was captured, truncated, redacted, or unavailable.
const ( IssueExceptionMessageCaptured IssueExceptionMessageState = "captured" IssueExceptionMessageTruncated IssueExceptionMessageState = "truncated" IssueExceptionMessageRedacted IssueExceptionMessageState = "redacted" IssueExceptionMessageNotCaptured IssueExceptionMessageState = "not_captured" )
type IssueExceptionRelationship ¶ added in v0.1.7
type IssueExceptionRelationship string
IssueExceptionRelationship describes how a runtime exception relates to an earlier parent node.
const ( IssueExceptionReported IssueExceptionRelationship = "reported" IssueExceptionCause IssueExceptionRelationship = "cause" IssueExceptionContext IssueExceptionRelationship = "context" IssueExceptionAggregateMember IssueExceptionRelationship = "aggregate_member" IssueExceptionSuppressed IssueExceptionRelationship = "suppressed" )
type IssueExceptionStackFramesState ¶ added in v0.1.7
type IssueExceptionStackFramesState string
IssueExceptionStackFramesState reports whether one exception stack was captured, truncated, or unavailable.
const ( IssueExceptionStackFramesCaptured IssueExceptionStackFramesState = "captured" IssueExceptionStackFramesTruncated IssueExceptionStackFramesState = "truncated" IssueExceptionStackFramesNotCaptured IssueExceptionStackFramesState = "not_captured" )
type IssueImpactEvidence ¶ added in v0.1.8
type IssueImpactEvidence struct {
AffectedUserSegment string `json:"affectedUserSegment,omitempty"`
FailedAction string `json:"failedAction,omitempty"`
UserVisibleOutcome string `json:"userVisibleOutcome,omitempty"`
}
IssueImpactEvidence describes application-reported user-visible impact without carrying user identities.
type IssueLikelyFixArea ¶ added in v0.1.8
type IssueLikelyFixArea struct {
Component string `json:"component,omitempty"`
Module string `json:"module,omitempty"`
Function string `json:"function,omitempty"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
InApp *bool `json:"inApp,omitempty"`
}
IssueLikelyFixArea is an application-reported code location that may contain the fix. File paths are repository-relative.
type IssueStackFrame ¶ added in v0.1.6
type IssueStackFrame struct {
Filename string `json:"filename"`
Line int `json:"line"`
Column int `json:"column"`
Function string `json:"function,omitempty"`
Module string `json:"module,omitempty"`
InApp *bool `json:"inApp,omitempty"`
DebugID string `json:"debugId,omitempty"`
}
IssueStackFrame is one structured code location. CaptureIssueStackFrames emits basename-only generated filenames and never includes source text, locals, or raw stack strings.
func CaptureIssueStackFrames ¶ added in v0.1.6
func CaptureIssueStackFrames() []IssueStackFrame
CaptureIssueStackFrames snapshots the current goroutine's call frames in newest-first order. It returns at most 32 validated frames with basename-only filenames and bounded function/module identities. It never captures source lines, local variables, raw stack text, or panic values.
type LogAttributes ¶
type LogAttributes struct {
Message string `json:"message"`
Level string `json:"level"`
Logger string `json:"logger,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Context *TelemetryContext `json:"context,omitempty"`
}
LogAttributes describes the public payload fields for a log event.
func LogAttributesWithTrace ¶ added in v0.1.2
func LogAttributesWithTrace(ctx context.Context, attributes LogAttributes) LogAttributes
LogAttributesWithTrace merges active trace metadata into log attributes.
type MetricAttributes ¶ added in v0.1.1
type MetricAttributes struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Kind string `json:"kind"`
Value float64 `json:"value"`
Unit string `json:"unit"`
Temporality string `json:"temporality"`
Metadata map[string]any `json:"metadata,omitempty"`
Context *TelemetryContext `json:"context,omitempty"`
}
MetricAttributes describes the public payload fields for an explicit metric event.
func MetricAttributesWithTrace ¶ added in v0.1.6
func MetricAttributesWithTrace(ctx context.Context, attributes MetricAttributes) MetricAttributes
MetricAttributesWithTrace adds exact active trace/span context while keeping legacy primitive metadata for compatible readers.
type NetworkMilestoneInput ¶ added in v0.1.1
type NetworkMilestoneInput struct {
Name string
RouteTemplate string
Method string
Status string
StatusCode *int
DurationMs *float64
SessionID string
TraceID string
Metadata map[string]any
}
NetworkMilestoneInput describes an app-owned API milestone that should be captured as an agent-readable action event.
type PersistentDeliveryConfig ¶ added in v0.1.4
type PersistentDeliveryConfig struct {
// Directory is the dedicated owner-only storage leaf.
Directory string
// EncryptionKey is a stable caller-owned 32-byte AES-256 key.
EncryptionKey []byte
// MaxStoredBytes bounds canonical serialized event bytes. Zero uses 4 MiB.
MaxStoredBytes int
}
PersistentDeliveryConfig opts an owned automatic client into encrypted restart persistence. EncryptionKey must contain exactly 32 caller-owned bytes and is never written to storage.
type ProductActionInput ¶ added in v0.1.1
type ProductActionInput struct {
Name string
Status string
RouteTemplate string
SessionID string
TraceID string
Screen string
Funnel string
Step string
Metadata map[string]any
}
ProductActionInput describes an app-owned product step that should be captured as an agent-readable action event.
type QueueOperationConfig ¶ added in v0.1.2
type QueueOperationConfig struct {
System string
OperationKind string
QueueName string
TaskName string
MessageCount *int
EventIDPrefix string
Metadata map[string]any
TraceparentSetter func(string) error
IncomingTraceparent string
LinkedTraceparents []string
Links []SpanLinkSummary
LinkMetadata map[string]any
SpanIDFactory func() string
Now func() time.Time
OnError func(error)
}
QueueOperationConfig configures an explicit app-owned queue span.
type RecordingTransport ¶
type RecordingTransport struct {
// SentBodies records every request body sent through this transport.
SentBodies [][]byte
// contains filtered or unexported fields
}
RecordingTransport scripts transport outcomes for previewing, accepting, or failing queued event flushes in tests and local runs.
func AlwaysAcceptTransport ¶
func AlwaysAcceptTransport() *RecordingTransport
AlwaysAcceptTransport creates a transport that accepts every queued flush request with a 202 response.
func NewRecordingTransport ¶
func NewRecordingTransport(scripted []any) *RecordingTransport
NewRecordingTransport creates a scripted transport from public status codes or transport errors.
func (*RecordingTransport) LastBody ¶
func (t *RecordingTransport) LastBody() []byte
LastBody returns the most recent request body sent through this transport.
func (*RecordingTransport) Send ¶
func (t *RecordingTransport) Send(apiKey string, body []byte) (*TransportResponse, error)
type ReleaseAttributes ¶
type ReleaseAttributes struct {
Version string `json:"version"`
Commit string `json:"commit,omitempty"`
Notes string `json:"notes,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Context *TelemetryContext `json:"context,omitempty"`
}
ReleaseAttributes describes the public payload fields for a release event.
type SQLBeginTxRunner ¶ added in v0.1.3
type SQLBeginTxRunner interface {
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}
SQLBeginTxRunner is implemented by app-owned *sql.DB and *sql.Conn values that can start database/sql transactions.
type SQLExecContextRunner ¶ added in v0.1.3
type SQLExecContextRunner interface {
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
SQLExecContextRunner is implemented by app-owned *sql.DB, *sql.Tx, and *sql.Conn values that can run exec operations from query text.
type SQLQueryContextRunner ¶ added in v0.1.3
type SQLQueryContextRunner interface {
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}
SQLQueryContextRunner is implemented by app-owned *sql.DB, *sql.Tx, and *sql.Conn values that can run query operations from query text.
type SQLStatementExecContextRunner ¶ added in v0.1.3
type SQLStatementExecContextRunner interface {
ExecContext(ctx context.Context, args ...any) (sql.Result, error)
}
SQLStatementExecContextRunner is implemented by app-owned *sql.Stmt values that can run prepared exec operations from args only.
type SQLStatementQueryContextRunner ¶ added in v0.1.3
type SQLStatementQueryContextRunner interface {
QueryContext(ctx context.Context, args ...any) (*sql.Rows, error)
}
SQLStatementQueryContextRunner is implemented by app-owned *sql.Stmt values that can run prepared query operations from args only.
type SdkError ¶
SdkError describes a stable public SDK failure with parseable code and message fields.
type SlogHandlerConfig ¶ added in v0.1.2
type SlogHandlerConfig struct {
Client *Client
Wrapped slog.Handler
Logger string
EventIDPrefix string
Metadata map[string]any
Now func() time.Time
OnError func(error)
}
SlogHandlerConfig configures a slog handler that preserves app-owned logging while also queueing LogBrew log events.
type SpanAttributes ¶
type SpanAttributes struct {
Name string `json:"name"`
TraceID string `json:"traceId"`
SpanID string `json:"spanId"`
ParentSpanID string `json:"parentSpanId,omitempty"`
Status string `json:"status"`
DurationMs *float64 `json:"durationMs,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Links []SpanLinkSummary `json:"links,omitempty"`
Context *TelemetryContext `json:"context,omitempty"`
}
SpanAttributes describes the public payload fields for a span event.
func SpanAttributesFromTraceContext ¶ added in v0.1.2
func SpanAttributesFromTraceContext(input TraceContextSpanInput) (SpanAttributes, error)
SpanAttributesFromTraceContext returns LogBrew span attributes from request-local trace context.
func SpanAttributesFromTraceparent ¶
func SpanAttributesFromTraceparent(input TraceparentSpanInput) (SpanAttributes, error)
SpanAttributesFromTraceparent returns LogBrew span attributes that continue an incoming W3C traceparent as a child span.
type SpanLinkSummary ¶ added in v0.1.3
type SpanLinkSummary struct {
TraceID string `json:"traceId"`
SpanID string `json:"spanId"`
Sampled bool `json:"sampled"`
Metadata map[string]any `json:"metadata,omitempty"`
}
SpanLinkSummary is a privacy-bounded link from one span to another W3C trace context, useful for queue batch/fan-in relationships.
func NewSpanLinkSummary ¶ added in v0.1.3
func NewSpanLinkSummary(traceID, spanID string, sampled bool) (SpanLinkSummary, error)
NewSpanLinkSummary validates explicit W3C trace and span IDs and returns a safe span-link summary.
func SpanLinkSummaryFromTraceparent ¶ added in v0.1.3
func SpanLinkSummaryFromTraceparent(traceparent string) (SpanLinkSummary, error)
SpanLinkSummaryFromTraceparent validates a W3C traceparent value and returns a safe span-link summary without retaining the raw propagation string.
type SupportTicketDraft ¶ added in v0.1.2
type SupportTicketDraft struct {
ProjectID string `json:"project_id,omitempty"`
Source string `json:"source"`
Category string `json:"category"`
Title string `json:"title"`
Description string `json:"description"`
Environment string `json:"environment,omitempty"`
Runtime string `json:"runtime,omitempty"`
Framework string `json:"framework,omitempty"`
SDKPackage string `json:"sdk_package,omitempty"`
SDKVersion string `json:"sdk_version,omitempty"`
Release string `json:"release,omitempty"`
TraceID string `json:"trace_id,omitempty"`
EventID string `json:"event_id,omitempty"`
Diagnostics map[string]any `json:"diagnostics,omitempty"`
}
SupportTicketDraft is the planned support-ticket create payload after local validation and diagnostics redaction.
func CreateSupportTicketDraft ¶ added in v0.1.2
func CreateSupportTicketDraft(input SupportTicketDraftInput) (SupportTicketDraft, error)
CreateSupportTicketDraft builds a local-only, token-free support-ticket create payload draft without calling backend support routes.
type SupportTicketDraftInput ¶ added in v0.1.2
type SupportTicketDraftInput struct {
ProjectID string
Source string
Category string
Title string
Description string
Environment string
Runtime string
Framework string
SDKPackage string
SDKVersion string
Release string
TraceID string
EventID string
Diagnostics map[string]any
}
SupportTicketDraftInput describes an explicit local-only draft for planned backend support-ticket routes. It does not open a ticket or send telemetry.
type TelemetryApplication ¶ added in v0.1.6
type TelemetryApplication struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
Build string `json:"build,omitempty"`
}
TelemetryApplication identifies the instrumented application and build.
type TelemetryContext ¶ added in v0.1.6
type TelemetryContext struct {
SchemaVersion int `json:"schemaVersion"`
Resource *TelemetryResource `json:"resource,omitempty"`
Trace *TelemetryTraceContext `json:"trace,omitempty"`
Session *TelemetrySessionContext `json:"session,omitempty"`
Subject *TelemetrySubjectContext `json:"subject,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
}
TelemetryContext is the versioned privacy-bounded context available on every LogBrew event type. Tags are limited to low-cardinality string dimensions.
func MergeTelemetryContexts ¶ added in v0.1.6
func MergeTelemetryContexts(base, override *TelemetryContext) (*TelemetryContext, error)
MergeTelemetryContexts applies the same client-base and event-override rules used by Client event capture and returns a detached result.
func ValidateTelemetryContext ¶ added in v0.1.6
func ValidateTelemetryContext(context *TelemetryContext) (*TelemetryContext, error)
ValidateTelemetryContext validates, normalizes, and detaches one shared context without queueing an event.
type TelemetryDeployment ¶ added in v0.1.6
type TelemetryDeployment struct {
Environment string `json:"environment,omitempty"`
Release string `json:"release,omitempty"`
}
TelemetryDeployment identifies an application deployment without host data.
type TelemetryDevice ¶ added in v0.1.6
type TelemetryDevice struct {
Family string `json:"family,omitempty"`
Model string `json:"model,omitempty"`
Architecture string `json:"architecture,omitempty"`
}
TelemetryDevice describes a broad device or runtime host class. Do not put unique device identifiers, machine names, network addresses, or local account names here.
type TelemetryNamedVersion ¶ added in v0.1.6
type TelemetryNamedVersion struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
}
TelemetryNamedVersion is a bounded service, runtime, or framework identity.
type TelemetryOperatingSystem ¶ added in v0.1.6
type TelemetryOperatingSystem struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
Build string `json:"build,omitempty"`
}
TelemetryOperatingSystem identifies an OS family and optional safe version.
type TelemetryResource ¶ added in v0.1.6
type TelemetryResource struct {
Service *TelemetryNamedVersion `json:"service,omitempty"`
Deployment *TelemetryDeployment `json:"deployment,omitempty"`
Runtime *TelemetryNamedVersion `json:"runtime,omitempty"`
Framework *TelemetryNamedVersion `json:"framework,omitempty"`
OperatingSystem *TelemetryOperatingSystem `json:"operatingSystem,omitempty"`
Device *TelemetryDevice `json:"device,omitempty"`
Application *TelemetryApplication `json:"application,omitempty"`
}
TelemetryResource is the shared service, deployment, runtime, framework, OS, device, and application identity attached to telemetry signals.
type TelemetrySessionContext ¶ added in v0.1.6
type TelemetrySessionContext struct {
ID string `json:"id"`
PreviousID string `json:"previousId,omitempty"`
}
TelemetrySessionContext is an opaque application-owned session identity. It must not contain an email address, authentication material, or other direct PII.
type TelemetrySubjectContext ¶ added in v0.1.6
TelemetrySubjectContext is an explicit opaque user or anonymous identity. Applications should use their own irreversible or otherwise non-PII ID.
type TelemetryTraceContext ¶ added in v0.1.6
type TelemetryTraceContext struct {
TraceID string `json:"traceId"`
SpanID string `json:"spanId,omitempty"`
ParentSpanID string `json:"parentSpanId,omitempty"`
Sampled *bool `json:"sampled,omitempty"`
}
TelemetryTraceContext is exact W3C-compatible trace and span correlation for any telemetry signal.
type TraceContext ¶ added in v0.1.2
type TraceContext struct {
TraceID string
SpanID string
ParentSpanID string
TraceFlags string
Sampled bool
}
TraceContext is the request-local LogBrew trace state safe to attach to logs, spans, issues, and callbacks.
func LogBrewTraceFromContext ¶ added in v0.1.2
func LogBrewTraceFromContext(ctx context.Context) (TraceContext, bool)
LogBrewTraceFromContext returns the active LogBrew trace context, when one is attached to ctx.
func NewTraceContext ¶ added in v0.1.2
func NewTraceContext(input TraceContextInput) (TraceContext, error)
NewTraceContext creates a request-local trace context. When Traceparent is empty it starts a fresh W3C-shaped local trace; malformed traceparent values are returned as validation errors so framework helpers can choose whether to fall back non-fatally.
func (TraceContext) Metadata ¶ added in v0.1.2
func (trace TraceContext) Metadata() map[string]any
Metadata returns primitive-only trace metadata for logs, issues, and metrics.
func (TraceContext) TelemetryContext ¶ added in v0.1.6
func (trace TraceContext) TelemetryContext() *TelemetryContext
TelemetryContext returns first-class W3C trace and exact span correlation suitable for an issue, log, action, or metric Context field.
type TraceContextInput ¶ added in v0.1.2
TraceContextInput creates request-local trace context from an optional W3C traceparent header and optional explicit child span ID.
type TraceContextSpanInput ¶ added in v0.1.2
type TraceContextSpanInput struct {
Trace TraceContext
Name string
Status string
DurationMs *float64
Metadata map[string]any
Links []SpanLinkSummary
}
TraceContextSpanInput describes a LogBrew span derived from a request-local TraceContext.
type TraceparentContext ¶
type TraceparentContext struct {
// Version is the two-character W3C traceparent version.
Version string
// TraceID is the normalized 32-character trace identifier.
TraceID string
// ParentSpanID is the normalized 16-character upstream span identifier.
ParentSpanID string
// TraceFlags is the normalized two-character trace flags value.
TraceFlags string
// Sampled reports whether the W3C sampled flag is set.
Sampled bool
}
TraceparentContext describes an incoming W3C traceparent header after validation and normalization.
func ParseTraceparent ¶
func ParseTraceparent(traceparent string) (TraceparentContext, error)
ParseTraceparent validates and normalizes a W3C traceparent header.
type TraceparentSpanInput ¶
type TraceparentSpanInput struct {
// Traceparent is the incoming W3C traceparent header value.
Traceparent string
// Name is the LogBrew span name.
Name string
// SpanID is the fresh child span identifier created by this service.
SpanID string
// Status is the LogBrew span status, usually ok or error.
Status string
// DurationMs is the optional span duration in milliseconds.
DurationMs *float64
// Metadata is copied with primitive values only.
Metadata map[string]any
}
TraceparentSpanInput describes a LogBrew span derived from an incoming W3C traceparent header.
type Transport ¶
type Transport interface {
Send(apiKey string, body []byte) (*TransportResponse, error)
}
Transport is the public interface used by Flush and Shutdown transport calls.
type TransportError ¶
TransportError describes a transport-layer failure with a stable public code and retry hint.
func NetworkError ¶
func NetworkError(message string) *TransportError
NetworkError creates a retryable network failure that preserves queued events.
func (*TransportError) Error ¶
func (e *TransportError) Error() string
type TransportResponse ¶
type TransportResponse struct {
// StatusCode is the final HTTP-like status returned by the transport.
StatusCode int `json:"status"`
// Attempts is the number of transport attempts used for the flush.
Attempts int `json:"attempts"`
}
TransportResponse is returned after a transport accepts or skips a queued flush.
Source Files
¶
- delivery.go
- http_client_trace.go
- http_response_writer.go
- http_trace.go
- issue_diagnostics.go
- logbrew.go
- operation_trace.go
- persistence.go
- persistence_files.go
- persistence_files_unix.go
- persistence_transaction_unix.go
- retry_after.go
- slog.go
- support_ticket.go
- telemetry_context.go
- telemetry_context_encoding.go
- telemetry_context_merge.go
- telemetry_context_runtime.go
- telemetry_context_types.go
- timeline.go
- trace_context.go
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
agent_timeline
command
|
|
|
first_useful_telemetry
command
|
|
|
http_client_trace
command
|
|
|
http_trace_correlation
command
|
|
|
readme_example
command
|
|
|
real_user_smoke
command
|
|
|
gin
module
|
|
|
otel
module
|