observer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 14 Imported by: 3

Documentation

Overview

Package observer centralizes the adapter's OpenTelemetry instrumentation: ACP request spans and metrics, prompt-turn GenAI metrics, permission and elicitation dialogs, session store operations, and native process exits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstrumentationName

func InstrumentationName(vendor string) string

InstrumentationName returns a sibling's OpenTelemetry scope.

Types

type Config

type Config struct {
	Vendor         string
	NativeClient   string
	MeterProvider  metric.MeterProvider
	Propagator     propagation.TextMapPropagator
	TracerProvider trace.TracerProvider
	Version        string
}

Config wires optional OpenTelemetry providers into an Observer.

type ElicitationResult

type ElicitationResult struct {
	Accepted bool
	Err      error
}

ElicitationResult finishes one elicitation-request observation.

type Observer

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

Observer records adapter spans and metrics; nil providers degrade to no-ops.

func New

func New(config Config) *Observer

New constructs an Observer; nil providers degrade to no-ops.

func (*Observer) AddActiveSession

func (o *Observer) AddActiveSession(ctx context.Context, delta int64)

AddActiveSession adjusts the active-session gauge.

func (*Observer) RecordProcessExit

func (o *Observer) RecordProcessExit(ctx context.Context, outcome string, err error)

RecordProcessExit counts one native process exit.

func (*Observer) RecordRawMessageEmitFailure

func (o *Observer) RecordRawMessageEmitFailure(ctx context.Context, err error)

RecordRawMessageEmitFailure counts one raw-event notification failure.

func (*Observer) StartACP

func (o *Observer) StartACP(ctx context.Context, meta map[string]any, method string, attrs ...attribute.KeyValue) (context.Context, func(error))

StartACP begins one ACP request observation.

func (*Observer) StartElicitation

func (o *Observer) StartElicitation(ctx context.Context) (context.Context, func(ElicitationResult))

StartElicitation begins one elicitation-request observation.

func (*Observer) StartPermission

func (o *Observer) StartPermission(ctx context.Context, toolName string, mode string) (context.Context, func(PermissionResult))

StartPermission begins one permission-request observation.

func (*Observer) StartPrompt

func (o *Observer) StartPrompt(ctx context.Context, meta map[string]any, model string) (context.Context, func(PromptResult))

StartPrompt begins one prompt-turn observation.

func (*Observer) StartSessionStore

func (o *Observer) StartSessionStore(ctx context.Context, operation SessionStoreOperation) (context.Context, func(error))

StartSessionStore begins one session store operation observation.

type PermissionResult

type PermissionResult struct {
	Behavior string
	Err      error
	Mode     string
	ToolName string
}

PermissionResult finishes one permission-request observation.

type PromptResult

type PromptResult struct {
	CachedReadTokens  int
	CachedWriteTokens int
	Err               error
	Model             string
	Provider          string
	InputTokens       int
	OutputTokens      int
	StopReason        string
	TotalTokens       int
}

PromptResult finishes one prompt-turn observation.

func PromptResultFrom

func PromptResultFrom(resp acp.PromptResponse, err error, model, provider string) PromptResult

PromptResultFrom records the response usage and resolves a provider from a qualified model when the caller does not supply one.

type SessionStoreOperation

type SessionStoreOperation string

SessionStoreOperation names one observed session store operation.

const (
	SessionStoreCommit     SessionStoreOperation = "commit"
	SessionStoreLoad       SessionStoreOperation = "load"
	SessionStoreLoadRecord SessionStoreOperation = "load_record"
	SessionStoreList       SessionStoreOperation = "list"
)

The session store operations a sibling observes: a mirror commit, a full load, a configuration-only load, and a listing.

Directories

Path Synopsis
Package exporters wires the OTEL_* exporter, propagator, and log-bridge configuration a sibling's command binary hands to its Agent.
Package exporters wires the OTEL_* exporter, propagator, and log-bridge configuration a sibling's command binary hands to its Agent.

Jump to

Keyboard shortcuts

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